Most efficient way to do this damage calculation?

FrantoFranto Member Posts: 779
edited July 2014 in Working with GS (Mac)

I'm still only familiar with the less advanced features of GS, and due to the Tizen crash due to the use of tables(tizen being a platform I'm aiming for) was unable to continue any learning on tables. And now that there are even newer features for GS with the latest releases, I wanted to know what is the most efficient way to implement this attack system:

Every character has a self.attack and self.defense stat. The range could be any number from 1 to 200 and anything in between or greater.

Every "attack" actor like a fireball, lightning bolt, Sword Slash, and so on, carries a self.damagemodifier attribute, that ranges from say 0.1 to 1.5, maybe even to 2.

Every player or enemy actor has an HP stat, a value of 100, to represent 100%.

Now heres the thing I want to do.

When an attack actor sprite overlaps its target, be it the player or enemy, it should run this calculation, heres the agenda for the calculation: Users self.attack = Att, self.defense = Def, self.damagemodifier = DM.

(Att*DM)/DEF = Total damage

Then the total damage is subtracted from HP of the target.

So I want this calc to run everytime a target interacts with an attack, but the attack has to have damage that is calculated from the user that is using it. Basically, if an small enemy with 10 attack, and big enemy with 50 attack use fireball, their damage would be different, and result in different damage when it hits the target, despite being the same actor, but two different spawning origins.

And in this way, if this calc always happens during actor interaction, then only thing to be done when making new actors is to add their self.attack and self.defense value, and that is it. No having to input different damage values for different actors, it's all done by a single calc that runs for all attack interactions. Perhaps the calc is stored in an offscreen actor, table, or some new feature? So which method would be best to implement this?

I would prefer to use this system for my game over the current use of timers as a way to deal damage and detect individual hits.

If you read this far, thank you.

Sign In or Register to comment.