• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

GetUnitGoldCost()

Status
Not open for further replies.

Fordcz

F

Fordcz

Hello,

I'm experiencing some difficulties with GetUnitGoldCost() function. It's a tower sell system where the player is supposed to get back the tower's gold cost. I keep getting a compile error. Here's the suspicious line:

JASS:
call AdjustPlayerStateBJ( GetUnitGoldCost(GetHandleId(GetTriggerUnit())), GetOwningPlayer(GetTriggerUnit()), PLAYER_STATE_RESOURCE_GOLD )
 
Hello,

I'm experiencing some difficulties with GetUnitGoldCost() function. It's a tower sell system where the player is supposed to get back the tower's gold cost. I keep getting a compile error. Here's the suspicious line:

JASS:
call AdjustPlayerStateBJ( GetUnitGoldCost(GetHandleId(GetTriggerUnit())), GetOwningPlayer(GetTriggerUnit()), PLAYER_STATE_RESOURCE_GOLD )

what does the error say?

btw, where did you get GetUnitGoldCost? I cannot find it in the function list...
 
The error says: 1 compile error: Line 110: Expected a name

I found this function in JASS manual: http://jass.sourceforge.net/doc/api/common_ai-functions.shtml#section_G

I cant find it in the function list of TESH...

anyway, I think it shouldn't be GetHandleId, it should be GetUnitTypeId... because UnitTypeId is the one that returns the rawcode of the unit, HandleId changes for every unit instance even if they are from the same unit in the Object editor...

though this will only correct the way that it works, I'm not sure if this will solve the error...

maybe it was removed? Even in GUI I cannot find a line which says Unit - Gold Cost or the likes... and it is black colored inside the JASS tag which means its not a native...

you can try to add this line in the map header or in a library
JASS:
native GetUnitGoldCost         takes integer unitid                        returns integer

and use GetUnitTypeId...

anyway I think its because its in the common.ai and not in common.j that's why it wont work directly...
 
Yea you'll have to declare the native at the top of the script that uses it because it comes from the common.ai file I believe. It works like UnitAlive where you declare:

JASS:
native UnitAlive takes unit u returns boolean

Instead you would do as Adiktuz said, and define it as native GetUnitGoldCost takes integer id returns integer.
 
Status
Not open for further replies.
Back
Top