Now I am trying to understand that huge code... I can't use handlers!! I don't know how xD
Can you give me an example of how to store a local unit? The function SetHandleBoolean takes a handle, a string and a value. What shoul I put as the handle?
to store a unit, or any other HANDLE (anything thats not an int, real, boolean, code, or string), use SetHandleHandle, but you have to individually get them (eg. GetHandleUnit, GetHandleGroup)
Should this work? It's supposed to create a kind of Wisp (a counter) at the position of the KillingUnit and store the group of Wisps as a handle attached to Kinara (the hero's name), but not if the number of Counters in the group is greater or equal to the level of the ability x2.
It seems to only create the unit... (cut a lot of the code, but I think it's not important)
function CounterUp takes nothing returns nothing
local unit Kinara = GetKillingUnit()
local unit Kill = GetDyingUnit()
local group G = GetHandleGroup(Kinara, "Counters")
local integer Level = GetUnitAbilityLevelSwapped( 'A019', Kinara )
local integer Counters = CountUnitsInGroup(G)
if (Counters < Level * 2) and (IsUnitEnemy(Kill, GetOwningPlayer(Kinara)) == true) and (IsUnitType(Kill, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(Kill, UNIT_TYPE_ANCIENT) == false) and GetUnitTypeId(Kinara) == 'N002' then
set Counters = Counters + 1
set Ang = I2R(360 / Counters)
call CreateUnit(GetOwningPlayer(Kinara), 'u00C', GetLocationX(GetUnitLoc(Kinara)), GetLocationY(GetUnitLoc(Kinara)), Ang)
call GroupAddUnitSimple(GetLastCreatedUnit(), G)
call SetHandleHandle( Kinara, "Counters", G )
endif
set G = null
set Kinara = null
set Kill = null
endfunction
Am I deluded or Handle Vars are like Attached Variables?
Anyways, you have to have stored the group at some point, so the first time it will return null, which is not good
About attachable vars, they were BASED off the handle vars.
and, here we go, a few code review thingees
GetDyingUnit = bleh. Use GetTriggerUnit
and that abominably long condition can be shortened to this
if Counters < Level * 2 and IsUnitEnemy(Kill, GetOwningPlayer(Kinara)) and GetUnitTypeId(Kinara) == 'N002' and not (IsUnitType(Kill, UNIT_TYPE_STRUCTURE) or IsUnitType(Kill, UNIT_TYPE_ANCIENT))
A. Create the group, you mean, CreateGroup()? (ohh ignorance) B. Fixed C. Fixed D. Read and fixed E. Fixed F. In fact, it was, but I cut it by accident xD
Now I wrote an If that Set G = CreateGroup() if G == null, as there was in KaTTaNa's example...
It still doesn't work, but I'll try more tomorrow morning 'cause now I need to sleep... That's what night serves for...
Oh sorry, there's some time I don't enter here due to a lack of time ^^'
function CounterUp takes nothing returns nothing local unit Kinara = GetKillingUnit()
local unit Kill = GetTriggerUnit()
local unit u
local group G = GetHandleGroup(Kinara, "Counters")
local integer Level = GetUnitAbilityLevel( Kinara, 'A019' )
local integer Counters = CountUnitsInGroup(G)
local real Ang = 0
if (Counters < Level * 2) and (IsUnitEnemy(Kill, GetOwningPlayer(Kinara)) == true) and GetUnitTypeId(Kinara) == 'N002' and not (IsUnitType(Kill, UNIT_TYPE_STRUCTURE) == false) or (IsUnitType(Kill, UNIT_TYPE_ANCIENT) == false) then
if G == null then
set G = CreateGroup()
endif
set Counters = Counters + 1
set Ang = I2R(360 / Counters)
set u = CreateUnit(GetOwningPlayer(Kinara), 'u00C', GetLocationX(GetUnitLoc(Kinara)), GetLocationY(GetUnitLoc(Kinara)), Ang)
call GroupAddUnit(G, u)
call SetHandleHandle( Kinara, "Counters", G )
endif
set G = null
set Kinara = null
set Kill = null
endfunction
I think I fixed everything here. May I change CreateUnit to CreateNUnitsAtLoc? I saw somewhere that this was buggy..