• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Get units gold cost (including upgrades)

Status
Not open for further replies.
Level 3
Joined
Aug 25, 2012
Messages
30
I think that the title says everything, but ill wite my question again.
Is there a way to get unit's cost (including upgrades in buildings)

For example if barracks cost 200 gold and upgraded barracks 150 gold, i need to get 350.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Not directly, but you can use unit point value for that. Unit point value has no meaning. Set it to the gold cost of the unit.

You can code upgrade cost into the point value.

Example base cost = 500, upgrade cost 150 -> Point value = 500+150*10000=1500500.
Example base cost = 100, upgrade cost 5 -> Point value = 100+5*10000=500100.
Example base cost = 900, no upgrade -> Point value = 900

if IntegertoReal(GetUnitPointValue(unit))/10000 > 1 then
--//It has upgrade cost
else
--//Has no upgrade cost

You can convert the cost to string and then get the last 4 characters to get the base cost and the rest is the upgrade cost. Then convert them to integers.
 
Status
Not open for further replies.
Top