Ideas for attack damage algorithm (language irrelevant)

Posted by Dillon on Game Development See other posts from Game Development or by Dillon
Published on 2012-12-20T04:09:09Z Indexed on 2012/12/20 5:14 UTC
Read the original article Hit count: 353

Filed under:
|

I am working on a game and I need ideas for the damage that will be done to the enemy when your player attacks. The total amount of health that the enemy has is called enemyHealth, and has a value of 1000. You start off with a weapon that does 40 points of damage (may be changed.) The player has an attack stat that you can increase, called playerAttack. This value starts off at 1, and has a possible max value of 100 after you level it up many times and make it farther into the game. The amount of damage that the weapon does is cut and dry, and subtracts 40 points from the total 1000 points of health every time the enemy is hit. But what the playerAttack does is add to that value with a percentage. Here is the algorithm I have now. (I've taken out all of the gui, classes, etc. and given the variables very forward names)

double totalDamage = weaponDamage + (weaponDamage*(playerAttack*.05))
enemyHealth -= (int)totalDamage;

This seemed to work great for the most part. So I statrted testing some values...

//enemyHealth ALWAYS starts at 1000
weaponDamage = 50;
playerAttack = 30;

If I set these values, the amount of damage done on the enemy is 125. Seemed like a good number, so I wanted to see what would happen if the players attack was maxed out, but with the weakest starting weapon.

weaponDamage = 50;
playerAttack = 100;

the totalDamage ends up being 300, which would kill an enemy in just a few hits. Even with your attack that high, I wouldn't want the weakest weapon to be able to kill the enemy that fast. I thought about adding defense, but I feel the game will lose consistency and become unbalanced in the long run. Possibly a well designed algorithm for a weapon decrease modifier would work for lower level weapons or something like that. Just need a break from trying to figure out the best way to go about this, and maybe someone that has experience with games and keeping the leveling consistent could give me some ideas/pointers.

© Game Development or respective owner

Related posts about game-design

Related posts about algorithm