T
Tooters
Guest
I want some creeps to go attack the Castle after they enter a certain region. I have a loop that detects how many creeps are in the region, and when if that number should reach 0 then the gates close leading to the castle, but when they enter the area they attack the castle, and after I kill them all, the gates don't close. Here is my triggers:
Here is Loop_Function
Please help me figure this out.
Code:
Castle Area Copy
Events
Unit - A unit enters Human Encampment <gen>
Conditions
(Owner of (Entering unit)) Equal to Player 12 (Brown)
Actions
Destructible - Open Gate (Horizontal) 0000 <gen>
Destructible - Open Gate (Horizontal) 0001 <gen>
Destructible - Open Gate (Horizontal) 0002 <gen>
Destructible - Open Gate (Horizontal) 0003 <gen>
Destructible - Open Gate (Horizontal) 0004 <gen>
Trigger - Turn off Hero Death <gen>
Trigger - Turn on Hero Death2 <gen>
Custom script: call Loop_Function()
Set attackCastle = False
Here is Loop_Function
Code:
function Exit_When takes nothing returns boolean
return ( udg_attackCastle == true )
endfunction
function Units_In_attackGroup takes nothing returns boolean
if ( not ( CountUnitsInGroup(udg_attackGroup[0]) != 0 ) ) then
return false
endif
return true
endfunction
function If_Statement takes nothing returns nothing
if ( Units_In_attackGroup() ) then
else
set udg_attackCastle = true
call DisableTrigger( gg_trg_Hero_Death2 )
call EnableTrigger( gg_trg_Hero_Death )
call ModifyGateBJ( bj_GATEOPERATION_CLOSE, gg_dest_LTg1_0000 )
call ModifyGateBJ( bj_GATEOPERATION_CLOSE, gg_dest_LTg1_0001 )
call ModifyGateBJ( bj_GATEOPERATION_CLOSE, gg_dest_LTg1_0002 )
call ModifyGateBJ( bj_GATEOPERATION_CLOSE, gg_dest_LTg1_0003 )
call ModifyGateBJ( bj_GATEOPERATION_CLOSE, gg_dest_LTg1_0004 )
call SetDestructableInvulnerableBJ( gg_dest_LTg1_0000, true )
call SetDestructableInvulnerableBJ( gg_dest_LTg1_0001, true )
call SetDestructableInvulnerableBJ( gg_dest_LTg1_0002, true )
call SetDestructableInvulnerableBJ( gg_dest_LTg1_0003, true )
call SetDestructableInvulnerableBJ( gg_dest_LTg1_0004, true )
call PauseTimerBJ( false, udg_creepTimer )
call DestroyGroup(udg_attackGroup[0])
endif
endfunction
function Loop_Function takes nothing returns nothing
loop
call PolledWait( 1.00 )
set udg_attackGroup[0] = GetUnitsInRectOfPlayer(gg_rct_Human_Encampment, Player(11))
exitwhen(Exit_When())
call If_Statement()
endloop
endfunction
Please help me figure this out.