- Joined
- Jul 10, 2007
- Messages
- 6,306
Updated GetUnitCost to use AI natives in the case of non-hero units =).
function IsHero takes integer rawcode returns boolean
return UnitId2String(rawcode) != null and IsHeroUnitId(rawcode)
endfunction
Yep, and the same for turns it an hero to an unit (first character anything else than an uppercase letter)So even with newgen just capitalizing the rawcode turns it into a hero?
If not, there's the native "IsUnitIdType(id, UNIT_TYPE_HERO)"
* function GetUnitTypeIdGoldCost takes integer unitTypeId returns integer
* function GetUnitTypeIdWoodCost takes integer unitTypeId returns integer
* function GetUnitTotalGoldCost takes unit whichUnit returns integer
* - Gets total unit gold cost including prior upgrades
* function GetUnitTotalWoodCost takes unit whichUnit returns integer
* - Gets total unit wood cost including prior upgrades
It will bug with Chaos when the unit transforms, it will display an incorrect gold cost.
You also missed the important correction I told you about in this post
I didn't mean with the debug statements actually, after talking with Troll-Brain about it I figured it should be up to the user to not be retarded. I meant you have an errro with this line:
set u = CreateUnit(p, UNITS_GET_COST, WorldBounds.maxX, WorldBounds.maxX, 0)
set u = CreateUnit(p, UNITS_GET_COST, WorldBounds.maxX, WorldBounds.maxX, 0)
RegisterPlayerUnitEvent as at least an optional requirement.
Using a null filter for the items, and doing everthing from the code, at the very least saves a handle and possibly saves efficiency.