Best way to calculate unit deaths in browser game combat?
Posted
by
MikeCruz13
on Game Development
See other posts from Game Development
or by MikeCruz13
Published on 2012-05-28T01:36:26Z
Indexed on
2012/05/30
17:02 UTC
Read the original article
Hit count: 225
My browser game's combat system is written and mechanically functioning well. It's written in PHP and uses a SQL database. I'm happy with the unit balance in relation to one another. I am, however, a little worried about how I'm calculating unit deaths when one player attacks another because the deaths seem to pile up a little fast for my taste.
For this system, a battle doesn't just trigger, calculate winner, and end. Instead, it is allowed to go for several rounds (say one round every 15 mins.) until one side passes a threshold of being too strong for the other player and allows players to send reinforcements between rounds.
Each round, units pair up and attack each other. Essentially what I do is calculate the damage:
AP = Attack Points
HP = Hit Points
Units AP * Quantity * Random Factors * other factors (such as attrition)
I take that and divide by the defending unit's HP to find the number of casualties of defending units. So, for example (simplified to take out some factors), if I have: 500 attackers with 50 AP vs 1000 defenders with 100 HP = 250 deaths
. I wonder if that last step could be handled better to reduce the deaths piling up.
Some ideas:
- I just change all the units with more HP?
- I make sure to set the Attacking unit's AP to be a max of the defender's HP to make sure they only kill 1 unit. (is that fair if I have less huge units vs many small units?)
- I spread the damage around more by including the defending unit's quantity more? i.e. in that scenario some are dead and some are 50% damage. (How would I track this every round?)
- Other better mathematical approaches?
© Game Development or respective owner