Warhammer Dark Omen Forum

Modifications => Troops => Topic started by: Darkmancer on September 13, 2010, 11:49:30 PM



Title: Troop replacement cost formulas
Post by: Darkmancer on September 13, 2010, 11:49:30 PM
Okay the troop replacement costs are worked out in DO by the following formula.

(point lvl + experiance lvl) * troop type) + (Compound Armour lvl * 10)

Note to modders the experiance level in the current version of WH32edit are wrong the levels are at 1k 3k and 6k for lvls 2,3 & 4 respectively.

Point Level - Is related to the point value of a unit.
Point value - Point LVL
0 -> 7 = 0
8 -> 15 = 1
16 -> 23 = 2
24+ = 3

NOTE Point + Experiance level is caped at 4 so a lvl 3 regiment with 3 armour only has a x4 not x6 multiplier

Troop Type
Infantry including ogres & artillery  - 10
Cavalry, wizards and fanatics- 25
Archer - 15
Chariot - Unkwown as it crashes the builder
Monster Inc Dread King - 40

Compound Armour  -  (Leaders armour lvl makes no difference)
Armour LvL - Price added
0 - 0
1 - +10
2 - +10 + 20 = 30
3 - +30 + 30 = 60
4 - +60 + 40 = 100
5 - +100 + 50 = 150

Misc  
Mounted / Normal - No difference in price
Wraiths - No Armour
Treeman - Lvl 2 Armour
Troll Lvl 3 Armour

Example
 lvl 2 Swordsman with lvl 2 armour and a point value of 10

= (2+1) * 10) + compound armour
= (3*10) + (1*10 + 2*10)
= 30 + 30
= 60gp for buying a new soldier


Title: Re: Troop replacement cost formulas
Post by: olly on September 13, 2010, 11:55:11 PM
Excellent Research and Results.

:)



Title: Re: Troop replacement cost formulas
Post by: Ghabry on September 14, 2010, 10:32:14 AM
And here some pseudo code for our programmers:

Formular to calculate Unit replacement costs:

int arrtype[] = { 10, 25, 15, 10, 25, 40 }

/*
Index in arrtype for every type (-> value for x):
Infantry:  0 -> 10
Cavalry:   1 -> 25
Archer:    2 -> 15
Artillery: 3 -> 10
Wizard:    4 -> 25
Monster:   5 -> 40
Chariot:   None!
*/
int x = arrtype[(regiment.unit.unittype/8 ) - 1];

int level;
if (regiment.exp >= 6000)
    level = 3;
else if (regiment.exp >= 3000)
    level = 2;
else if (regiment.exp >= 1000)
    level = 1;
else
    level = 0;

int tmp = regiment.unit.pointval + level*8

int y;
if (tmp <= 7)
    y = 1;
else if (tmp <= 15)
    y = 2;
else if (tmp <= 23)
    y = 3
else
    y = 4;

int arr[] = { 0, 1, 2, 3, 4, 0, 3, 2, 0, -1, -1, -1
             , -1, -1, -1, -1, 1, 2, 3, 4, 5, 5}
int arr2[] = { 0, 50, 150, 300, 500, 750 }

// Use the armor as index in arr and then
// value from arr as index in arr2
int z = arr2[arr[regiment.unit.armor]]

int costs = (int)(z/5) + x*y;


Calculate Armor costs:

// arr and arr2 are the same as above
int arr[] = { 0, 1, 2, 3, 4, 0, 3, 2, 0, -1, -1, -1
             , -1, -1, -1, -1, 1, 2, 3, 4, 5, 5 }
int arr2[] = { 0, 50, 150, 300, 500, 750 }
// Note that arr2index + 1 is used
// magicvalue is always 0? Read from 0xB4 in the regiment data but overwritten on runtime
int armorcosts = regiment.unit.maxtroops * arr2[arr[regiment.unit.armor + magicvalue] + 1] / 5;


Calculate Gold after battle:
This is actually done during the battle (no idea where) but the formula that displays the "You earned x gold coins" is:

int money = 0;
foreach (regiment_in_army r)
    money += r.experience_from_battle

money = money * 1.5;


Title: Re: Troop replacement cost formulas
Post by: Mikademus on September 16, 2010, 07:00:54 PM
Not really much pseudocode there is it? That basically could be used as it is...  ;)


Title: Re: Troop replacement cost formulas
Post by: Ghabry on September 16, 2010, 08:51:44 PM
Yes the "C-Style" Pseudocode fits in most parts quite well into the ArmParser class ;).


Title: Re: Troop replacement cost formulas
Post by: Ghabry on May 14, 2012, 11:52:03 PM
Here is the experience you get for killing units on the battlefield. Havnt verified this by playing some battles ^^
Not sure if this is all, so see this as a approximation (Per single unit kill, point value (pv) of the enemy):

Cannon: 12 * pv
Wizard: 8 * pv
Monster: 4 * pv
Misc (Fanatics): 4 * pv
Other: pv


Title: Re: Troop replacement cost formulas
Post by: olly on May 14, 2012, 11:59:14 PM
This is very interesting since we could only previously go by a brief mention in the Shadow of the Horned Rat Game Mechanics.

"Experience points are awarded after each battle to the participating regiments who actually scored kills. The amount of points awarded per kill is dependant on how powerful the enemy was. For example, 4 points are awarded for each Goblin Sticker killed, while 28 points are given for defeating a Giant".

http://forum.dark-omen.org/singleplayer/sothr-game-mechanics-stats-t273.0.html (http://forum.dark-omen.org/singleplayer/sothr-game-mechanics-stats-t273.0.html)

:)