Author Topic: Question about the armour-damage formula  (Read 744 times)

Richter09

  • Guest
Question about the armour-damage formula
« on: 20 January 2013, 16:11:54 »
Hi, this is my first post on these forums so sorry if I posted this in the wrong section. I am trying to mod mega-glest and found this formula on the wiki:



As I see it this formula can't be right. Surely if you subtract the armor on the bottom of the equation then the higher the amount of armor the more damage the unit receives which doesn't make sense.

Also, if you have a damage multiplier, does it apply only to the armor or also to the HP?

Thank you in advance to anyone who can help me, Richter09

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Question about the armour-damage formula
« Reply #1 on: 21 January 2013, 02:03:18 »
I'm interested in this as well. As mentioned in this topic, the damage formula is normally floor((attack_strength - armor) * damage_multiplier). The formula you posted is related to splash damage, but its misplaced (future note to self, location is XML/Unit) and may not necessarily be accurate (I should have cited the source).

In the previously linked topic, Softcoder's posted code basically says the damage from splash is (damage / (distance + 1) - armour) * damage multiplier. The actual code says:
Code: [Select]
damage += random.randRange(-var, var);
damage /= distance+1;
damage -= armor;
damage *= damageMultiplier;
Damage is the value of the attack strength, plus or minus a random variance. It's then divided by distance plus one and subtracted by armour before being multiplied by the damage multiplier. This means the LaTeX code on the wiki is slightly incorrect. The armour shouldn't be subtracted from the distance + 1, but rather it should be subtracted from the divisor of the attack strength over distance plus one.

If I can get confirmation as to these two formulas as being correct, I'll update the wiki's formulas (and make them easier to find, they're way too buried).
« Last Edit: 18 June 2016, 14:56:25 by filux »
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

Richter09

  • Guest
Re: Question about the armour-damage formula
« Reply #2 on: 21 January 2013, 06:30:15 »
Thanks for the help. I did actually read that thread but since it said something different to the wiki I didn't know which one was correct. You also answered my other question since from the code I take it that even if the armor is 0 the damage multiplier still takes effect.

I think I'll just use this formula:
Code: [Select]
floor((attack_strength - armor) * damage_multiplier) as what I am doing doesn't really require a greater degree of accuracy than that. Thanks again, Richter09

 

anything