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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      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