Function that allows for a number to be checked, just "about" within a margin.
Franto
Member Posts: 779
Is there a function that say, instead of me checking for the number 5, I want to check for a number close to 5, by about 1, so it would be 4-6 then.
So that, if an actors self.integer is 19, then when the expression runs, it would check on another actor to see if their number is between 18 and 20? Basically within 1 unit of 19?
Comments
Can you not just take those values and evaluate them in a rule?
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
If A is => B-1 and <= B+1.
@Braydon_SFX Yes, but I wanted to know if it was possible within a single expression. Rather than having to type a Rule within another Rule. Since I need it in a rule that is already searching an entire table, so I wanted to cut down as much as possible on how many rules and conditions are needed.
@Socks Thanks, but what would be the most efficient to implement that if I am using it with another rule? I was hoping there was a function that say was called "'sup(n,d)", with "n" being the target number. and "d" being the deviation from it.
So if I put sup(self.integer, 2) = tablesearch(target.table), it would search that table for a number that is within 2 units of the self.integer.
I need it to be able to make a projectile attack identify who it is overlapping based on x,y's being tracked in another table. If the x,y of that projectile is within ~3 pixels of the target x,y, then the tablesearch will pinpoint the row, and subtract from a third value that shares the same row as the target x,y: hp.
The expression could be something like:
( self.myInteger >17)and( self.myInteger <21)
It would either "true" or "false" (or "1" or "0")
But how to put that into a table search? Thats the question!
@Rthurman True, lol. I'll guess I'll ponder it in the back of my head while I work on something else. Or experiment tomorrow morning if I can' think of anything. I appreciate the replies from all of you.
Something like this perhaps?
You'd achieve the exact same thing with three conditions and an any, though, as @Socks pointed out. Really no reason to avoid that as it does exactly what you asked for.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Nice one @Armelline !
Awesome example @Armelline , although, loop over table is a bit too slow for my game as it is.
I definitely appreciate the effort you put into the example though, and will try it out in a different game, and this will definitely benefit anybody that happens on this thread. This is definitely beneficial for an RPG damage system that requires a streamlined and organized damage system.
I do plan to build a slower-paced system in a future game, with less targets per level, that can take advantage of changing x,y values better. The second reason for the desire of a system like this is so I can get rid of the big "groups" inside every enemy actor, containing up to 30 different rules, that register a hit for each of the 30 attack actors in total for the players side. {And as I mentioned already, can't even register individual hits if they occur at the same time.}
IT would work wonders as well in a slower, physics-based game. (Since the other thing I'm trying to achieve is a moving projectile being able to identify the target it collides with/overlaps in a situation where there are multiple targets, multiple projectiles, all with their own x,y, and "hp" values(damage values for projectiles instead), stored in 2 tables(for projectiles and targets), and constantly generating and dissapearing from being "destroyed". The targets move in real time, thus the projectiles x,y has to match the x,y they have in order to identify who's hp value belongs to who and subtract from it.
The reason I want a moving projectile to identify the target it is hitting, is so that if there are multiples of this projectile, their damage will stack. The way things currently are, this can only be possible if your hp is a game.attribute, and the attack activates a self.integer to register that it has collided with the target, and then subtract from the game.attribute. This behavior must exist in the projectile itself. If the target has a similar projectile, it will not be able to register individual hits from copies of the same actor until they exit it's hitbox completely. Instead, it will register just one. My workaround was to do damage based on a timer, which is okay with "stream" style attacks like lasers or fire. But shell based projectiles like from a shotgun can't register individual projectiles shot at the same time seperately. Thus, these type of attacks act more like a single shot attack.
I don't know why I can't settle for a simpler system, I just feel eager to create a system that allows players who have chosen a weaker, but quick shooting attack to benefit from the concept of multiple projectiles on a big target doing more damage, while smaller targets will only be hit by a few of the shots in the spread range of the attack.
Same thing could be done with manual looping. If you're checking every table row, which you presumably have to do to search a table, the same logic can apply. If you can't check the table fast enough, then the whole issue is moot and you need to rethink the whole X/Y thing.
Why are you allowing the projectiles to pass through the targets though? Surely just destroying them on contact will solve a lot of your problems?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armelline Thanks again for your reply, too answer your question, it is primarily to make it easier to organize and edit the values of the damage system. I was hoping to achieve a single Rule, referring to table values, to determine damage registering, present in the actors and projectiles. It was mostly to clean up the many rules being used at present to calculate for each different type of attack, as well as be able to easily add "power-ups" into the equation, without having to copy and paste into all 30 different instances of attacks. Just a single rule in each character to determine damage calculation.
The attack doesn't pass through{except for lasers}, bullet projectile types destroy the "package" that traveled, upon impact, it spawns another actor, that would carry the rule to find the x,y and compare it to it's own. In the video with the gunslinger, the little "explosion" that occurs when a projectile hits, would be the actor containing x,y values that would go in a table. The enemies would have x,y values within their own table as well.
I forgot to ask, what is the name of the function you used in the expression in your example to determine if a number is within the range of another number by 1?
I see what you mean about the manual looping. I forgot to mention, since I use "add row" for the appearance of enmies, but no "remove row"(as it would get more complicated if the x,y values are constantly changing rows when others collapse via index removal), without remove row, the table would keep growing, eventually reaching over 200 rows if the player likes destroying tons of enemies instead of trying to complete a level.
Would even tablesearch falter if a table gets that big?
Here are some examples of the character in question. Two of his attacks involve spraying multiple projectiles in close proximity, gatling and shotgun style. As you will see an example, a weak enemy, the floating gargoyle statues, can take several volleys before going down. Their hp total is 10. Each shot of the shotgun type deals 7 damage per 0.06 intervals. The intended system was that they deal 4 damage per pellet. Thus, upon contact with just 3 of the 6 pellets, should deal a total of 12 damage instantly.
Right now, they have that system in place. Their attacks deal damage upon impact, rather than per time intervals, as the time interval method is the simplest way to deal damage at the moment to anybody, at the cost of damage stacking and instant registration. In this example the enemies are attacking the player, the players hp total is 100, each attack does about 2 damage, thus when the character is hit by a group of enemy projectiles, all their damage is registered, and they lose a chunk of life instantly. The player characters can't do this at the moment.
For comparison, two other characters in the game, like the knight in this next example, doesn't really need to stack damage since they attack with a single weapon at melee range.
The other ranged character, Pif, uses "stream" type attacks, like the two laser types in this vid, the current "time interval" style of damage calculation works fine for her. : )
Holy Kkrap, I figured it out. I don't even need "margin" of errors. If the enemy target spawns an invisible actor on impact, they will be able to triangulate their exact x,y!!! That actor alone could carry all the damage information!! Time to test this out! And combining it with some elements of the old method, I can still achieve an "organized" damage system, at least more organized than before. But this version should allow damage stacking!!
Thank you for all for having this discussion with me, otherwise I would have never reached this conclusion so quickly.
So close, but now my brain is having blue screens again. Here is what I have so far.
I'm at the part where the actor that spawns over the enemy gets their x,y info. For the "do" part, I want the change attribute to turn the self.integer of the actor, to the self.integer of the enemy row found to have the same x,y as that actor? As mentioned before, loop is the only way to do this?
Is there anyway to get the results of the tablesearch in the conditions into the right side of the change attribute?
Here's where I'm stuck at:
EDIT: Didn't somebody somewhere on the forums mention the result returned is the row# containing the data? Rather than the specific data itself? Perhaps run a rule for x and y seperately, then a third rule comparing if it's the same row number that each got? Then that row number would be tied to the actor, and then the actor will have access to the hp value within that row.
EDIT: IF I rewrote it as "enemy overlaps" Then do "change attribute, with the left self.integer storing the resulting data of the table search!
EDIT2: I'm about to test the actual thing now. Everything is set up, unless I wrote something wrong and it goes awry.
It works! Universal damage in a fast paced game with multiple actors!
Notice the numbers popping up, the white actor is able to read the x,y of the enemy, find them on a table, and calculate damage INSTANTLY! All with collision conditions, numeral comparison conditions, change attributes and change table value behaviors, no constrains or anything heavy on the processor!
It's a bit buggy, as you can see damage fails to register a few times. But it does work!
Now you can have enemies that act like their HP is a game attribute when it's really a table value! And it only needs to be changed when the damage calculation actor pops up!
I admit! I didn't think it would be possible without using loops or something else heavy, but another side of me was compelled to keep going, to TEST every avenue! The effort was well worth it! I blame my over-ambition for pushing me this far. Thank you to all those that offered advice, tips and feedback.
EDIT: The number over the enemy is their hp value. All this time it wasn't changing, until I finally used the current method.
The only part of the new method that didn't work, was the Xrow=Yrow determining what row the enemy was on. Instead, I relied solely on the X values of both actors matching, even though I fear it woudl have ill effects later, but then I realized the other condition, the collision, would prevent that from happening, so the Y becomes kind of moot. The yellow 0 you see popping up was suppose to be the "row" integer, which instead, /I replaced the row integer instance with the Xrow results, since Xrow is the row value of that actor anyway found from Table search. THUS, just that part alone is needed to triangulate on an enemy position.