TriggerHappy
...
- Reaction score
- 341
This is my first vJASS System.
What this system does is it removes the need for creating
Reigons in order to make gates open and close when a unit
Comes near the gate. This will automaticly do that for you
Reigons in order to make gates open and close when a unit
Comes near the gate. This will automaticly do that for you
JASS:
//+-------------------------------------------------------------+
// +--------------------------------+ \\
// | AGS - Automatic Gate System | \\
// | TriggerHapppy187 | \\
// +--------------------------------+ \\
// ClanMapz.com \\
//+-------------------------------------------------------------+
// What this system does is it removes the need for creating \\
// Reigons in order to make gates open and close when a unit \\
// Comes near the gate. This will automaticly do that for you \\
//+-------------------------------------------------------------+
// =How To Intsall= \\
// Simple copy the code into your map and place your gates \\
// then the system will do the rest. If you have custom gates \\
// then you will need to specify them by adding their "raw Id" \\
// In the code Below. \\
//+-------------------------------------------------------------+
// =Changelog= \\
// --=Version 1.00=-- - Release \\
// --=Version 1.01=-- \\
//- Fixed location leak \\
//- Registered Gates Doesn't Loop \\
//- Fixed group loop \\
//+-------------------------------------------------------------+
scope AGS initializer AgsEvents
globals
private constant real refresh = 0.50 // How Fast the triggers are ran periodicly
private constant real dist = 300 // How far from the gate that it detects the unit
private constant integer NoG = 31 // Number of gate types
integer array gType[NoG]
endglobals
private function openClose takes nothing returns nothing
local integer i = 0
local location leak = GetDestructableLoc(GetEnumDestructable())
local group l = GetUnitsInRangeOfLocAll(dist, leak)
if FirstOfGroup(l) != null then
loop
exitwhen i > NoG
if GetDestructableTypeId(GetEnumDestructable()) == gType<i> then
call ModifyGateBJ( bj_GATEOPERATION_OPEN, GetEnumDestructable() )
endif
set i = i + 1
endloop
else
call ModifyGateBJ( bj_GATEOPERATION_CLOSE, GetEnumDestructable() )
endif
call DestroyGroup(l)
call RemoveLocation(leak)
set leak = null
set l = null
endfunction
private function AgsActions takes nothing returns nothing
call EnumDestructablesInRectAll( GetPlayableMapRect(), function openClose )
endfunction
private function AgsEvents takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEventPeriodic( t, refresh )
call TriggerAddAction( t, function AgsActions )
set t = null
endfunction
endscope
scope gateReg initializer regGatesEve
private function regGates takes nothing returns nothing
set gType[1] = 039;ATg2039;
set gType[2] = 039;ATg4039;
set gType[3] = 039;ATg1039;
set gType[4] = 039;ATg3039;
set gType[5] = 039;DTg1039;
set gType[6] = 039;DTg2039;
set gType[7] = 039;DTg3039;
set gType[8] = 039;DTg4039;
set gType[9] = 039;LTg1039;
set gType[10] = 039;LTg2039;
set gType[11] = 039;LTg3039;
set gType[12] = 039;LTg4039;
set gType[13] = 039;LTe1039;
set gType[14] = 039;LTe2039;
set gType[15] = 039;LTe3039;
set gType[16] = 039;LTe4039;
set gType[17] = 039;ITx1039;
set gType[18] = 039;ITx2039;
set gType[19] = 039;ITx3039;
set gType[20] = 039;ITx4039;
set gType[21] = 039;ITg1039;
set gType[22] = 039;ITg2039;
set gType[23] = 039;ITg3039;
set gType[24] = 039;ITg4039;
set gType[25] = 039;DTg5039;
set gType[26] = 039;DTg6039;
set gType[27] = 039;DTg7039;
set gType[28] = 039;DTg8039;
set gType[29] = 039;DTg7039;
set gType[30] = 039;ZTsx039;
set gType[31] = 039;ZTsg039;
endfunction
private function regGatesEve takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEventSingle( t, 0.00 )
call TriggerAddAction(t, function regGates)
set t = null
endfunction
endscope
</i>
Note : I am probly missing a few gates. COMMENTS / CODE FIXES PLEASE. MY FIRST VJASS SYSTEM