View Full Version : Where are the upgrade costs of units coded?


Bahmo
Mar 07, 2009, 06:58 PM
Just curious.

Edgecrusher
Mar 07, 2009, 07:46 PM
I believe its their "Cost" (which is in hammers). When upgrading, the game translates the difference in cost between the Upgrading Unit and the New Unit into Gold.

Shiggs713
Mar 07, 2009, 08:52 PM
well there is the BASE_UNIT_UPGRADE_COST and UNIT_UPGRADE_COST_PER_PRODUCTION defines in the globaldefines.xml

thats a good place to start

tsentom1
Mar 09, 2009, 02:32 PM
You can override in the the GameUtils python file (def getUpgradePriceOverride(self, argsList)):

iPrice = gc.getDefineINT("BASE_UNIT_UPGRADE_COST")
iPrice += (max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType( )))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"))

if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
iPrice = iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100
iPrice = iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100

iPrice = iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100)

Would be the python equivalent of the SDK upgrade price code.

phungus420
Mar 09, 2009, 03:01 PM
The above is how Tsentom made the Leonardo's Worksop World Wonder. Nice wonder by the way, thanks for making it available, it's made it's way into WolfRev :)

Bahmo
Mar 10, 2009, 07:13 PM
Thanks; I'll fiddle with it when I get the chance!