EndoConvert
Warlord
- Joined
- Dec 17, 2010
- Messages
- 297
The formula for purchasing units and buildings is:
GoldCost = int( (30 * Cost * GameSpeedPercent)^0.75 * (1 + HurryCostModifier/100) / 10 ) * 10
Cost = The hammer cost on standard speed.
GameSpeedPercent = Modifier for game speed and starting era.
HurryCostModifier = A hidden rush-buy penalty.
I filled a large spreadsheet comparing the costs predicted by the above formula against actual costs generated in-game, and found that the original formula posted above gives correct results in most cases, but is off for a handful of units and buildings. The formula needs to be slightly tweaked, with a couple of additional integer flooring operations, to:
GoldCost = int( int{ [30 * int(Cost * GameSpeedPercent) ]^0.75 } * (1 + HurryCostModifier/100) / 10 ) * 10
which can also actually be simplified to:
GoldCost = int( int{ [30 * int(Cost * GameSpeedPercent) ]^0.75 } * (100 + HurryCostModifier) / 1000 ) * 10
(And BTW, much thanks to DaveMcW for discovering and posting the original formula! I was having trouble seeing how the purchase cost was calculated until I found this thread, so I'm grateful! )