MasterRofl
New Member
- Reaction score
- 8
How do I make it so that I can use the struct in the callback function?
JASS:
library NetTrap initializer Init uses ABC
private struct Net
unit DyingUnit
group TrapGroup
location TrapLocation
method onDestroy takes nothing returns nothing
set.TrapGroup = null
set.TrapLocation = null
endmethod
endstruct
private function Callback takes nothing returns nothing
local unit NetDummy = CreateUnitAtLoc( GetOwningPlayer(n.DyingUnit), GetUnitLoc(GetEnumUnit()), 0 )
call UnitAddAbility( NetDummy, 039;A01V039; )
call SetUnitAbilityLevel( NetDummy, 039;A01V039;, GetUnitAbilityLevel( udg_JL_Caster, 039;A03O039; ))
call IssueTargetOrderById( NetDummy, 039;A01V039;, GetEnumUnit())
call RemoveUnit( NetDummy )
endfunction
private function Actions takes nothing returns nothing
local Net n = Net.create()
set n.TrapLocation = GetUnitLoc(GetDyingUnit())
set n.TrapGroup = GetUnitsInRangeOfLocMatching( 200., n.TrapLocation, null )
set n.DyingUnit = GetDyingUnit()
call ForGroup( n.TrapGroup, function Callback )
call n.destroy()
endfunction
private function Conds takes nothing returns boolean
return GetDyingUnit() == 039;n00T039;
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_UNIT_DEATH)
call TriggerAddCondition(t, Condition( function Conds ))
call TriggerAddAction(t, function Actions)
set t = null
endfunction
endlibrary