- Joined
- Aug 27, 2012
- Messages
- 362
EDIT: In case anyone in the future needs a Generic Unit Target Event here is the code:
JASS:
library SetPathing initializer OnInit
globals
public trigger AggroTrigger
public group PATHING_GROUP = CreateGroup()
private group PATHING_GROUP_SWAP=CreateGroup()
private group PATHING_GROUP_TEMP
endglobals
function SetPathing takes nothing returns boolean
local unit u = GetTriggerUnit()
local unit FoG
call SetUnitPathing(u,true)
call BJDebugMsg("Pathing set to true")
call DestroyTrigger(AggroTrigger)
call GroupRemoveUnit(PATHING_GROUP,u)
set AggroTrigger = CreateTrigger()
call TriggerAddCondition(AggroTrigger,function SetPathing)
loop
set FoG=FirstOfGroup(PATHING_GROUP)
exitwhen FoG==null
call TriggerRegisterUnitEvent(AggroTrigger,FoG,EVENT_UNIT_ACQUIRED_TARGET)
call GroupAddUnit(PATHING_GROUP_SWAP,FoG)
call GroupRemoveUnit(PATHING_GROUP,FoG)
endloop
set PATHING_GROUP_TEMP=PATHING_GROUP
set PATHING_GROUP=PATHING_GROUP_SWAP
set PATHING_GROUP_SWAP=PATHING_GROUP_TEMP
set u = null
return false
endfunction
function UnitCreation takes nothing returns nothing
local unit u = CreateUnit(Player(11),'hfoo',SpawnLocationX,SpawnLocationY,0.)
call SetUnitPathing(u,false)
call TriggerRegisterUnitEvent(AggroTrigger,u,EVENT_UNIT_ACQUIRED_TARGET)
call GroupAddUnit(PATHING_GROUP,u)
endfunction
private function OnInit takes nothing returns nothing
set AggroTrigger=CreateTrigger()
call TriggerAddCondition(AggroTrigger,function SetPathing)
endfunction
endlibrary
Last edited: