• 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.

Trigger - get price of unit?

Status
Not open for further replies.
Level 3
Joined
Mar 5, 2015
Messages
21
Hey,
I need to get a unit price - but I don't think there is a way to do it?

What I need to do is I have many units (to send on enemy) and I want enemy hero to get just as many XP as the unit costs for killing it. So that I don't have to set every unit separately..

Thanks! :)
 
Level 25
Joined
May 11, 2007
Messages
4,650
Set the "Point Value" of the units to their gold cost, it's in the object editor.
  • Experience Gain
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Killing unit)) is an enemy of (Owner of (Triggering unit))) Equal to True
    • Actions
      • Set tempInt = (Point-value of (Triggering unit))
      • Hero - Add tempInt experience to (Killing unit), Hide level-up graphics
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
JASS:
native GetUnitGoldCost      takes integer unitid                        returns integer
native GetUnitWoodCost      takes integer unitid                        returns integer
native GetUnitBuildTime     takes integer unitid                        returns integer

From common.ai.

For this, however, you will need to declare these functions in custom script, and you MUST use JassHelper, so prefferably be working on JNGP.

Then you just call it as custom script like this:

  • Custom script: set udg_MyVariablesName = GetUnitGoldCost(udg_MyUnit).
  • LordDz's suggestion will work too, but it may screw up how the units are selected, as well as be a bit tiresome if you have couple hundred units
 
Level 3
Joined
Mar 5, 2015
Messages
21
Set the "Point Value" of the units to their gold cost, it's in the object editor.
  • Experience Gain
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Killing unit)) is an enemy of (Owner of (Triggering unit))) Equal to True
    • Actions
      • Set tempInt = (Point-value of (Triggering unit))
      • Hero - Add tempInt experience to (Killing unit), Hide level-up graphics

I chose to do this, works perfectly, thanks! :thumbs_up:
 
Status
Not open for further replies.
Top