Battle Calculator

With a view to being able to number crunch easily for balancing mods I've started to put together a battle calculator spreadsheet in excel using Derek's post here as a basis.

Trouble is, the numbers don't really stack up and I was hoping for a little guidance on what had been changed please.

My calculations are based along the following lines:

Unit stats:

  • str  = Strength
  • dex  = Dexterity
  • con  = Constitution
  • lvl  = Level

Weapon stats:

  • w_att = attack factor
  • w_hit = To hit bonus
  • w_ddg = Dodge bonus
  • w_def = Defense bonus

Armour stats:

  • a_att = attack factor
  • a_hit = To hit bonus
  • a_ddg = Dodge bonus
  • a_def = Defense bonus

Constants:

  • ba = Base accuracy                  = 15
  • al = Accuracy level multiplier      = 3
  • dd = Dodge dexterity divisor        = 2
  • sm = Attack strength subtraction    = 10
  • sf = Attack strength divisor        = 10
  • dm = Defense dexterity subtraction  = 10
  • df = Defense dexterity divisor      = 10
  • hb = Base hit points                = 10
  • hc = Hit point constitution divisor = 5
  • hl = Hit point level multiplier     = 2

Base Calculations:

  • acc = Accuracy   =  ba + (lvl * al) + w_hit + a_hit
  • ddg = Dodge      =  (dex / dd) + w_ddg + a_ddg
  • att = Attack     =  w_att + a_att + ((str - sm) / sf)
  • def = Defence    =  a_def + w_def + ((dex - dm) / df)
  • hp  = Hit Points =  hb + ((con / hc) * (lvl * hl))
  • rs  = Retaliation strikes = ???

Applied Calculations:

  • To Hit Percentage =  (acc1 / (acc1 + ddg2)) * 100
  • Minimum damage    =  ???
  • Maximum damage    =  ???
  • Average damage    =  ???

 


 

Ive tested this in-game and some of the results are a little off. Taking a spearman in enemy territory fighting against an enemy spearman the figures are as follows:

Spearman1:

  • str  = 10
  • dex  = 10
  • con  = 10
  • lvl  = 4

Weapon stats:

  • w_att = 9

Armour stats:

  • a_def = 2

Base Calculations:

  • acc = Accuracy   =  27 
  • ddg = Dodge      =  5
  • att = Attack     =  9
  • def = Defence    =  2 
  • hp  = Hit Points =  26 

Applied Calculations:

  • To Hit Percentage =  84% (actual 91%)
  • Minimum damage    =  ??? (actual 1)
  • Maximum damage    =  ??? (actual 8)
  • Average damage    =  ??? (actual 4.5?) 

 

 

EnemySpearman2:

  • str  = 10
  • dex  = 10
  • con  = 5
  • lvl  = 1

Weapon stats:

  • w_att = 10

Armour stats:

  • a_def = 5

Base Calculations:

  • acc = Accuracy   =  18 
  • ddg = Dodge      =  5
  • att = Attack     =  10
  • def = Defence    =  5
  • hp  = Hit Points =  12 

Applied Calculations:

  • To Hit Percentage =  78% (actual 86%)
  • Minimum damage    =  ??? (actual 6)
  • Maximum damage    =  ??? (actual 9)
  • Average damage    =  ??? (actual 7.5?)

 

So what I currently don't get is:

1. Why are the to-hit calculations not the same as in-game? I suspect mine are the accurate figures based on the amount of dodges in the battles.

2. How is damage calculated? I had assumed it was the same as the to-hit process but I can't be right based on the feedback in-game.

3. How are retaliation strikes calculated?

Where I want to end up is a calculator that tells you an average of how many turns it will take unit A to defeat unit B which would quickly allow modders to balance weapons and armour. In the above example my calculations would be as follows:

Each turn Spearman1 does an average of 4.5 points damage 84% of the time = 3.8 (kill enemy in 4 hits)

EnemySpearman2 does an average of 7.5 points damage 78% of the time = 5.9 (kill enemy in 5 hits)

So by the time Spearman1 dispatches the enemy he will only have an average of 2 hitpoints left. Very close battle. :)

 

(D4/N5)+D12+D19
10,131 views 11 replies
Reply #1 Top

Damage is calculated as follow:

roll between (N/2)^2 and N^2, take the square root. I don't know how the rounding is done.

Armor rolls between 1 and N^2 and takes the square root. No 1/2 hard cap here.

Reply #2 Top

That still doesn't correlate with the figures in-game. In the above example Spearman1 minimum attack should be:

√((att1 / 2)^2 - def2^2)  = √((9 / 2)^2 - 5^2) = √(20.25 - 25) = 0 (actual was 1)

and the maximum attack should be:

√(att1^2 - 1)  = √(9^2 - 1) = √(81 - 1) = 8 (this is correct)

and for the EnemySpearman2, minimum value should be:

√((att2 / 2)^2 - def1^2)  = √((10 / 2)^2 - 2^2) = √(24 - 4) = 4 (actual was 6)

and the maximum attack should be:

√(att2^2 - 1)  = √(10^2 - 1) = √(100 - 1) = 9 (this is correct)

 

If the formula for minimum is:

√((att1 / 1.5)^2 - def2^2)

... it then works as per the game.

Reply #3 Top



√((att1 / 2)^2 - def2^2)  = √((9 / 2)^2 - 5^2) = √(20.25 - 25) = 0 (actual was 1)

 

No, the subtraction is performed outside of the square root, not inside. So, the minimum is att1/2-def2. But yeah, that should still make 0. Odd: it seemed to work that way in my case.

Reply #4 Top

Do some tactical battles then check out debug.err they're outputting tactical battle info in 1.09p beta. You'll find very valuable info there.

Reply #5 Top

Thanks for the responses. Had a look in the debug.err file but all it is really doing is showing the same info as in-game. No real clues in there as to how the calculations are made.

Guess I'll need to wait until someone from Stardock reads this.

Reply #6 Top

The understanding I have for damage rolls is that you square the attack and defense values, roll Dsquaredvalue (with no results of less than half of the squared value), squareroot, and that's your damage.  Whether you compare before or after squareroot I'm not clear on, but it looks to me like defense roll is subtracted BEFORE squarerooting. 

I may be wrong, but the battle statistics I'm now seeing in combat (as of 1.09p, in the target window to the right) seem to agree with this formula.  As for the To Hit versus Dodge, I think that's linear, but don't really know.

It'd be nice to have an 'official' reply so we know how it now works, so we don't waste time on inaccurate calculations (for balancing purposes).

Reply #7 Top

That still doesn't give the correct result as per in-game:

Basically the minimum would be whichever is less of the following equations:

√(att1^2 - def2^2)

or:

√(att1^2 / 2) 

 

So applying that to the example:

√(att2^2 - def1^2)  = √((10^2 - 2^2) = √(100 - 4) = 9

or:

√(att2^2 / 2)  = √(100 / 2) = 7 (lower of the two but actual was 6)


Reply #8 Top

Is what I'm asking for too difficult for anyone at Stardock to answer?

I would have thought that anyone working on the mechanics of the game would know how damage is applied. Seems to me to be extremely important information for anyone looking at modding or balancing aspects of the game to understand. Otherwise we are just guessing as we go and hoping for the best.

Reply #9 Top

Apparently Stardock thinks mathematical formulas for game mechanics are a trade secret or something...

It's not like algebra and calculus haven't been around for thousands of years!

I think the dude's name was Aristotle, or Archimedes...

:banhammer:

Edit: Diophantus is sometimes called the 'Father of Algebra'. Democritus is the first person recorded to consider infinitesimals, with others such as Archimedes building on work by earlier Greek Mathemeticians.  Modern Calculus was pioneered in the 17th century.

Reply #10 Top

One, expecting a reply to a thread that's only been posted to at 2-5 AM is silly.

Two, Stardock isn't likely to be trolling the forums constantly.

Three, a lot of posts get posted.

So expecting a personal reply is just silly. You'd be better served PMing one of them and asking them directly rather than grumbling about it and expecting them to see every little post.

 

After all, if they spend 'just' 5 minutes to read and reply to 1 post... they'd only get to 96 posts in an 8 hour work day and not have any time for anything else.

Reply #11 Top

Yeah, I'll take that on the chin. When I wrote the grumble my head was saying 'Don't post it - its only been 24 hours' but I clicked 'Post Reply' anyway. After all, my posts are of vital importance! ;)