- Joined
- Jan 30, 2013
- Messages
- 12,762
Just a thought that hit my mind. Is there a way?
If not, would be nice to have access to a list of spells a unit have.
If not, would be nice to have access to a list of spells a unit have.
As in register all abilities and units who own them in a hash?Even it's not a good, there's still the way of binding abilities to the unit using hashtable in a setup trigger, and by hooking UnitAdd/RemoveAbility in case dynamics needs to be tracked.
function Setup takes nothing returns nothing
local integer parentKey = 'hfoo'
call SaveInteger(hash, parentKey, 0, 4) // store how many abilities
call SaveInteger(hash, parentKey, 1, 'A001') // store ability 1
call SaveInteger(hash, parentKey, 2, 'A001') // store ability 2
call SaveInteger(hash, parentKey, 3, 'A002') // store ability 3
call SaveInteger(hash, parentKey, 4, 'A004') // store ability 4
endfunction
function LoopThroughAbilities takes unit u returns nothing
local integer parentKey = GetUnitTypeId(u)
local integer abilitiesCount = LoadInteger(hash, parentKey, 0)
local integer abilityId
local integer i = 1
loop
exitwhen i > abilitiesCount
set abilityId = LoadInteger(hash, parentKey, i)
call BJDebugMsg("Unit Ability #" + I2S(i) + ": " + GetObjectName(abilityId) )
set i = i + 1
endloop
endfunction