How is the damage determined?

General feedback and discussion of the game.

Moderators: Forum Moderators, Developers

User avatar
Dunno
Posts: 773
Joined: January 17th, 2010, 4:06 pm
Location: Behind you

How is the damage determined?

Post by Dunno » August 10th, 2011, 4:38 pm

It's one of those questions that's been bothering me for a while. I'm curious how does the damage equation look like-how damage bonuses (ToD and resistance) are added. Which leads me to another question - when and how does the rounding occur. We all know that fractions does not appear in game, so there must be a rounding process. Does it happen at the very end? Or after every step? And is it always rounded down, up, or something custom (like <.5 rounded down and >=.5 rounded up)?
I've came up with two possible equations, I hope they will clarify a bit what I mean:

Let x be the final damage, a the base damage, b the ToD bonus and c the resistance bonus.
x = a(1+b)(1+c)
x = a(1+b+c)

The difference may seem small, but we've all seen those lucky scouts with 1hp left who then retreat and heal.
Oh, I'm sorry, did I break your concentration?

Caphriel
Posts: 994
Joined: April 21st, 2008, 4:10 pm

Re: How is the damage determined?

Post by Caphriel » August 10th, 2011, 5:24 pm

It's the first formula. Modifiers are multiplied sequentially, not added and then multiplied. As for rounding, fractions greater than 1/2 round up, and fractions less than 1/2 round down, with exactly 1/2 being rounded toward the base damage.

For instance, a strong spearman at day with leadership:
Damage = base damage * leadership modifier * daytime modifier = 8 * 1.25 * 1.25 = 12.5 Since 12.5 is greater than base damage, it rounds down to 12.

User avatar
Dunno
Posts: 773
Joined: January 17th, 2010, 4:06 pm
Location: Behind you

Re: How is the damage determined?

Post by Dunno » August 10th, 2011, 7:20 pm

oh, thanks! I'm actually glad to hear that because that is exactly how I would do it :D
Now it will be much easier for me to plan my attacks! :twisted:
Oh, I'm sorry, did I break your concentration?

Caphriel
Posts: 994
Joined: April 21st, 2008, 4:10 pm

Re: How is the damage determined?

Post by Caphriel » August 10th, 2011, 7:59 pm

Well, it'd be easier to do the damage calculations mentally if it was addition of all modifiers, then multiplication, but this yields satisfactory results as well :lol2:

Ant
Posts: 21
Joined: January 29th, 2010, 4:21 am

Re: How is the damage determined?

Post by Ant » August 10th, 2011, 9:06 pm

Sorry Caphriel,

ist not the first but the second formula, which can easily be seen by using leadership on the unfavorable time of day. They cancel out since (1+0.25-0.25)=1 were as the first formula would suggest (1+0.25)(1-0.25)=(1-0.0625)=0.9375. Of course the difference between between these 2 formulas could only be seen for heavy hitters like Infantryman (11*1=11, 11*0.9375=10.3, Infantrymen does 11 supported with leadership at nightime)

Caphriel
Posts: 994
Joined: April 21st, 2008, 4:10 pm

Re: How is the damage determined?

Post by Caphriel » August 10th, 2011, 9:14 pm

Hmm. I asked this same question ages ago, and I'd swear one of the devs/mods/etc. told me it they were multiplied in sequence, not added and then multiplied. Well, if that's the case, then I guess I'll have to update my notes :hmm:

If that's the case, it's not only relevant with heavy hitters, but also in cases of high resistance/weakness to a damage type, because it also means that cumulative bonuses stack less than I thought.

uzy5o
Posts: 52
Joined: March 9th, 2008, 2:39 am

Re: How is the damage determined?

Post by uzy5o » August 11th, 2011, 3:28 am

I'm pretty sure that leadership and time of day are added together, and then multiplied by resistance.

Caphriel
Posts: 994
Joined: April 21st, 2008, 4:10 pm

Re: How is the damage determined?

Post by Caphriel » August 11th, 2011, 1:30 pm

Well, the game is open source, so anyone who wants to go poking through the code could go find out how it's calculated. I might do it later today after work if I have time.

Scatha
Posts: 111
Joined: March 29th, 2008, 2:55 pm

Re: How is the damage determined?

Post by Scatha » August 11th, 2011, 3:18 pm

I tested to work this out for myself a while back. It's not quite as definite as consulting the source code, but I'm also pretty confident that ToD and Leadership modifiers are added, then multiplied by resistances.

This makes leadership better than I'd expected at adverse times of day, and worse than expected at favourable times of day.

User avatar
powershot
Posts: 1193
Joined: May 7th, 2011, 3:03 am
Location: Central America
Contact:

Re: How is the damage determined?

Post by powershot » August 11th, 2011, 3:20 pm

Yup. It's a sad sad world.

Why not just look up the answer in the game files? :|
My new account is: Power_Pixel_Wannabe. Yea. Yea.... Why are you still reading this? What the heck m8? You have some kind of problem? Yea. I draw. NO I'M NOT 5 ANYMORE!!! Little brats.
The heck m8? I thought you left... No seriously... go... serious...
ok bye m8. I'm serious.

Caphriel
Posts: 994
Joined: April 21st, 2008, 4:10 pm

Re: How is the damage determined?

Post by Caphriel » August 11th, 2011, 3:25 pm

Go ahead, and let us know what you find. Thanks!

User avatar
powershot
Posts: 1193
Joined: May 7th, 2011, 3:03 am
Location: Central America
Contact:

Re: How is the damage determined?

Post by powershot » August 11th, 2011, 3:28 pm

I'm not sure where to look? :|
My new account is: Power_Pixel_Wannabe. Yea. Yea.... Why are you still reading this? What the heck m8? You have some kind of problem? Yea. I draw. NO I'M NOT 5 ANYMORE!!! Little brats.
The heck m8? I thought you left... No seriously... go... serious...
ok bye m8. I'm serious.

User avatar
Dunno
Posts: 773
Joined: January 17th, 2010, 4:06 pm
Location: Behind you

Re: How is the damage determined?

Post by Dunno » August 11th, 2011, 3:39 pm

powershot wrote: Why not just look up the answer in the game files? :|
powershot wrote:I'm not sure where to look? :|
Bingo!
Oh, I'm sorry, did I break your concentration?

User avatar
powershot
Posts: 1193
Joined: May 7th, 2011, 3:03 am
Location: Central America
Contact:

Re: How is the damage determined?

Post by powershot » August 11th, 2011, 3:46 pm

Maybe there is no specifying file... :|
My new account is: Power_Pixel_Wannabe. Yea. Yea.... Why are you still reading this? What the heck m8? You have some kind of problem? Yea. I draw. NO I'M NOT 5 ANYMORE!!! Little brats.
The heck m8? I thought you left... No seriously... go... serious...
ok bye m8. I'm serious.

User avatar
Dunno
Posts: 773
Joined: January 17th, 2010, 4:06 pm
Location: Behind you

Re: How is the damage determined?

Post by Dunno » August 11th, 2011, 4:05 pm

...moving on- it seems like Ant is right. I checked it by modifying orcish archer file so it would have 10000-2 fire attack and attacked wose at night with elvish captain next to archer. Surprisingly enough, the archer had 15000-2 attack - the only possibility is formula Ant mentioned. So it looks like this:

x = b (1+l+t)(1+r) where b=base damage l=leadership bonus t=ToD bonus and r=resistance bonus

Mmm... math... yummy... :geek:
P.S:I also checked the result at night and conclusion was the same
Oh, I'm sorry, did I break your concentration?

Post Reply