System AGS - Automatic Gate System

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​

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;ATg2&#039;
    set gType[2] = &#039;ATg4&#039;
    set gType[3] = &#039;ATg1&#039;
    set gType[4] = &#039;ATg3&#039;
    set gType[5] = &#039;DTg1&#039;
    set gType[6] = &#039;DTg2&#039;
    set gType[7] = &#039;DTg3&#039;
    set gType[8] = &#039;DTg4&#039;
    set gType[9] = &#039;LTg1&#039;
    set gType[10] = &#039;LTg2&#039;
    set gType[11] = &#039;LTg3&#039;
    set gType[12] = &#039;LTg4&#039;
    set gType[13] = &#039;LTe1&#039;
    set gType[14] = &#039;LTe2&#039;
    set gType[15] = &#039;LTe3&#039;
    set gType[16] = &#039;LTe4&#039;
    set gType[17] = &#039;ITx1&#039;
    set gType[18] = &#039;ITx2&#039;
    set gType[19] = &#039;ITx3&#039;
    set gType[20] = &#039;ITx4&#039;
    set gType[21] = &#039;ITg1&#039;
    set gType[22] = &#039;ITg2&#039;
    set gType[23] = &#039;ITg3&#039;
    set gType[24] = &#039;ITg4&#039;
    set gType[25] = &#039;DTg5&#039;
    set gType[26] = &#039;DTg6&#039;
    set gType[27] = &#039;DTg7&#039;
    set gType[28] = &#039;DTg8&#039;
    set gType[29] = &#039;DTg7&#039;
    set gType[30] = &#039;ZTsx&#039;
    set gType[31] = &#039;ZTsg&#039;
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
 

Attachments

  • AGS - Automatic Gate System.w3x
    19.3 KB · Views: 258

Tyman2007

Ya Rly >.
Reaction score
74
Did you honestly need to make this in vJass? seems like a waste of time if you ask me..

It's a neat system though! Nicely coded and i can't find any leaks.. well probably because i suck at vJass.

The Good:
-Leakless

The Bad:
-No info on how to add gates to the list for those who don't know.
-Not many maps need this.
 

Trollvottel

never aging title
Reaction score
262
its bad coded and full of leaks.

for example:

JASS:


set gType[1] = &#039;ATg2&#039;
    set gType[2] = &#039;ATg4&#039;
    set gType[3] = &#039;ATg1&#039;
    set gType[4] = &#039;ATg3&#039;
    set gType[5] = &#039;DTg1&#039;
    set gType[6] = &#039;DTg2&#039;
    set gType[7] = &#039;DTg3&#039;
.
.
.
.


why do you set this everytime and not once in the Init-function?

---------------------------

and leaks:



loc still leaks....

--------------------------------

this is bad too:

JASS:
 if CountUnitsInGroup(l) &gt; 0 then


if there are 10 units in this group it loops 10 times. so if you just would do

JASS:
 if FirstOfGroup(l) != null then


it would be much better.

-------------------------------------

also, set GetEnumDestructable and other often called functions to a variable.
and get rid of all these BJs.

-------------------------------------

Ah, and the system is useful.
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
Really, the only problem with this is that in most games that would use a gate, certain critera usually have to be reached before the gate can open(Complete this quest, find this item, etc.). This doesn't allow such critera.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
hm you could set the selection circle to -5 to make it look a little bit better. because you can see that the gate is being killed if you click it with the unit.
 

Tyman2007

Ya Rly >.
Reaction score
74
umm... this is becoming more of like an RPG system than just an "open a gate" system. how about you just explain how to add a condition so people could add their own conditions.
 
Reaction score
341
hm you could set the selection circle to -5 to make it look a little bit better. because you can see that the gate is being killed if you click it with the unit

Do it yourself , that is not part of the system

umm... this is becoming more of like an RPG system than just an "open a gate" system. how about you just explain how to add a condition so people could add their own conditions.


Um.... ill work on a condition snippet that lets you specify conditions
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
was just a little idea to make it look a little bit better in the test map...
 

Tyman2007

Ya Rly >.
Reaction score
74
Or somehow find a way to make a GUI action a condition for the gates that can only be used on map initialization.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top