- Joined
- Sep 19, 2006
- Messages
- 152
This trigger seems needlessly complex. Are there any ways to simple it but keep the functionality?
JASS:
function HubExit_Filter01 takes nothing returns boolean
local unit U = GetFilterUnit ()
local boolean B
//
if GetUnitTypeId (U) == 'hpea' then
set B = false
elseif IsUnitType (U, UNIT_TYPE_STRUCTURE) == true then
set B = false
else
set B = GetUnitState (U, UNIT_STATE_LIFE) > 0.00
endif
set U = null
return B
endfunction
function HubExit_Action01 takes nothing returns nothing
local unit u = GetLeavingUnit ()
local integer q = GetPlayerId (GetOwningPlayer (u))
local real uX = GetUnitX (u)
local real uY = GetUnitY (u)
local rect r = gg_rct_NeutralRegion
local boolean b = true
local group G
local group g
local unit f
//
if GetOwningPlayer (u) == Player (15) then
set b = false
elseif GetUnitTypeId (u) == 'hphx' then
set b = false
elseif GetRectMinX (r) < uX and GetRectMaxX (r) > uX and GetRectMinY (r) < uY and GetRectMaxY (r) > uY then
set b = false
endif
if b == true then
call SetUnitInvulnerable (u, false)
endif
if IsUnitType (u, UNIT_TYPE_HERO) == true then
set G = CreateGroup ()
set g = CreateGroup ()
call GroupEnumUnitsOfPlayer (G, Player (q), Filter (function HubExit_Filter01))
loop
set f = FirstOfGroup (G)
exitwhen f == null
call GroupRemoveUnit (G, f)
call GroupAddUnit (g, f)
call SetUnitPosition (f, uX, uY)
endloop
call DestroyGroup (G)
set G = null
call TriggerSleepAction (1.00)
loop
set f = FirstOfGroup (g)
exitwhen f == null
call GroupRemoveUnit (g, f)
call IssueTargetOrder (f, "smart", u)
endloop
call DestroyGroup (g)
set g = null
set f = null
endif
set u = null
endfunction
function InitTrig_HubExit takes nothing returns nothing
set gg_trg_HubExit = CreateTrigger ()
call TriggerRegisterLeaveRectSimple (gg_trg_HubExit, gg_rct_Hub)
call TriggerAddAction (gg_trg_HubExit, function HubExit_Action01)
endfunction