Hi, how would I go about making a system where a damage calculation is played based on the users attack variable, the attack's own damage value as a modifier of the users attack variable, and the targets defense, all calculated universally by calling the calc when ever damage is done.
So that the only thing every hero or enemy object needs is an HP, ATT, and DEF variable in their instances?
This is for a sidescroller by the way, so theres collision detection.
Say for example, player uses fireball(Technique) on an enemy and it overlaps on them, then the damage calculation should be called: Players Attack*Techniques Power / Enemy Defense = Damage total, which is substract from the HP variable of the enemy.
I don't want to go and use a simple system where I just type "-5" for the damage of a fireball on an enemy, independent of the user of the fireball. I want the fireballs damage to be based on the user, while the fireball itself has an attack value, it is a multiplier of the users own attack power, instead of being independent damage. Like say, Fireball's value is always 1.25, so if the player's attack is 100, then the total damage is 125, if the players attack is 8, then the total damage is 10. Then the enemies defense comes into play, dividing the damage by the defense value.
How would I go about implementing this? What method is the most efficient?
To reiterate: Player and enemies have HP, ATT, and DEF as stats. Attack techniques have POWER as a stat{damage modifier}. And theres a calculation that is called everytime damage occurs to a target, based on these values and subtracting the results from the self HP attribute of target.