1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Yet another question by me

Discussion in 'Triggers & Scripts' started by RollinDoubles, Aug 11, 2013.

  1. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    187
    Resources:
    0
    Resources:
    0
    Oh, ok thanks for that!

    So guys, back to my original question

    Is there a reason that my trigger slowly adds lag to the game, Im guessing it a leak of some kind, but I don't seen anymore?
     
  2. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,843
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Leaks.
     
  3. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    187
    Resources:
    0
    Resources:
    0
    i know cause of leaks, but what is leaking? I guess i shoulda asked that.
     
  4. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,843
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Post the triggers so that I can inspect it.

    Post it like :
    • Haha
      • Events
      • Conditions
      • Actions
     
  5. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    187
    Resources:
    0
    Resources:
    0
    • Change Defender Range
      • Events
        • Time - Every 0.15 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in baseDefenders and do (Actions)
          • Loop - Actions
            • Set tempUnit1 = (Picked unit)
            • Set tempPoint1 = (Position of tempUnit1)
            • Set tempGroup1 = (Units within 300.00 of tempPoint1 matching ((Unit-type of (Matching unit)) Equal to Tower))
            • Set tempUnit2 = (Random unit from tempGroup1)
            • Set tempPoint2 = (Position of tempUnit2)
            • Set tempPlayer1 = (Owner of tempUnit1)
            • Set tempGroup2 = (Units within 175.00 of tempPoint2 matching ((((Matching unit) is A structure) Equal to False) and (((Owner of (Matching unit)) Equal to tempPlayer1) and ((Matching unit) Not equal to tempUnit1))))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Distance between tempPoint1 and tempPoint2) Greater than or equal to 175.00
                • (Number of units in tempGroup2) Equal to 0
              • Then - Actions
                • -------- Move the defender back to the center of the CoP for his base, if he is the only unit around. --------
                • Unit - Move tempUnit1 instantly to tempPoint2
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Distance between tempPoint1 and tempPoint2) Greater than or equal to 175.00
                    • (Number of units in tempGroup2) Greater than or equal to 1
                  • Then - Actions
                    • -------- This will switch the defender is there is another in the range. --------
                    • Unit Group - Remove tempUnit1 from baseDefenders
                    • Set tempUnit3 = (Random unit from tempGroup2)
                    • Unit Group - Add tempUnit3 to baseDefenders
                  • Else - Actions
            • Custom script: set udg_tempUnit1 = null
            • Custom script: set udg_tempUnit2 = null
            • Custom script: set udg_tempUnit3 = null
            • Custom script: set udg_tempPlayer1 = null
            • Custom script: call DestroyGroup( udg_tempGroup1 )
            • Custom script: set udg_tempGroup1 = null
            • Custom script: call DestroyGroup( udg_tempGroup2 )
            • Custom script: set udg_tempGroup2 = null
            • Custom script: call RemoveLocation( udg_tempPoint1 )
            • Custom script: set udg_tempPoint1 = null
            • Custom script: call RemoveLocation( udg_tempPoint2 )
            • Custom script: set udg_tempPoint2 = null


    its also on the first post btw.
     
  6. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,843
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Hmmm, I can't spot it xD
     
  7. Daffa

    Daffa

    Joined:
    Jan 30, 2013
    Messages:
    7,820
    Resources:
    28
    Packs:
    1
    Maps:
    8
    Spells:
    17
    Tutorials:
    2
    Resources:
    28
    I don't think it's wise to dont remove the location and only null it.
     
  8. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,528
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    what are you talking about ?

    @rollindoubles
    The reason that spell doesn't work is that is based from an Aoe spell not based off of channel with a unit target.
    What that means is that target unit of ability being cast returns null.
    Which means it's not attacking any specific unit.
    Change to channel with target as unit target only if you want a one unit target.
    If you want it to be Aoe then you need a unit group to pick units in range and then add them to the other unit group so their health gets reduced every second.

    Please pay more attention to what you do rather than saying someone elses work doesn't work.
     
  9. Arhowk

    Arhowk

    Joined:
    Aug 8, 2007
    Messages:
    2,752
    Resources:
    0
    Resources:
    0
    again, you dont need to null them. theyre globals. you only need to null local handles

    if you want to make it more efficient, move the if in the "else" into the "then", remove the distance check on it, and put the current "then" actions in the "else" of the second if. (if you can follow that :p)

    you also dont need to set tempunit3, just use the (Random unit from blah)
     
  10. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    187
    Resources:
    0
    Resources:
    0
    @ Almia haha well thanks anyways
    @ deathismyfriend that was my first ever attempt at making a spell, i didnt know that about spells. and sorry didnt mean to offend you if i did.
    @ daffa i really have no idea what u mean
    @ arhowk 1. so the custom scripts where i nulled things like tempunit/points/groups are not needed?
    2. by local handles you mean when using jass and using locals right? as you can use locals in GUI correct?
    3. I thought that if i did not use tempunit3 and just used random unit from w/e it created a leak? Is that not the case?

    and when i have time in a little bit i will try that out (the moving around of conditions my blocks)

    After i do the suggested edits, I will edit this post and put the trigger in.
     
  11. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,528
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    Naa you didn't offend me i was just saying.

    1) you don't have to null things. Nulling variables just clears the variable so it doesn't point to anything. I null all variables that won't be used that often.

    2) Yes you can use locals in GUI look at my tutorial things a guier should know. It shows you local variables how to use them and it shows you how to shadow global variables.

    3) Unit variables do not create a leak.
     
  12. Arhowk

    Arhowk

    Joined:
    Aug 8, 2007
    Messages:
    2,752
    Resources:
    0
    Resources:
    0
    above is right. only groups, forces, timers, locations (mightve forgotten one) leak and have to be destroyed via Destroy#
     
  13. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    187
    Resources:
    0
    Resources:
    0
    Alright so i had some time to edit the trigger a little bit
    here it is
    new trig
    • Change Defender Range
      • Events
        • Time - Every 0.15 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in baseDefenders and do (Actions)
          • Loop - Actions
            • Set tempUnit1 = (Picked unit)
            • Set tempPoint1 = (Position of tempUnit1)
            • Set tempGroup1 = (Units within 300.00 of tempPoint1 matching ((Unit-type of (Matching unit)) Equal to Tower))
            • Set tempUnit2 = (Random unit from tempGroup1)
            • Set tempPoint2 = (Position of tempUnit2)
            • Set tempPlayer1 = (Owner of tempUnit1)
            • Set tempGroup2 = (Units within 175.00 of tempPoint2 matching ((((Matching unit) is A structure) Equal to False) and (((Owner of (Matching unit)) Equal to tempPlayer1) and ((Matching unit) Not equal to tempUnit1))))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Distance between tempPoint1 and tempPoint2) Greater than or equal to 175.00
                • (Number of units in tempGroup2) Equal to 0
              • Then - Actions
                • -------- Move the defender back to the center of the CoP for his base, if he is the only unit around. --------
                • Unit - Move tempUnit1 instantly to tempPoint2
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Number of units in tempGroup2) Greater than or equal to 1
                  • Then - Actions
                    • -------- This will switch the defender is there is another in the range. --------
                    • Unit Group - Remove tempUnit1 from baseDefenders
                    • Unit Group - Add (Random unit from tempGroup2) to baseDefenders
                  • Else - Actions
              • Else - Actions
            • Custom script: call DestroyGroup( udg_tempGroup1 )
            • Custom script: call DestroyGroup( udg_tempGroup2 )
            • Custom script: call RemoveLocation( udg_tempPoint1 )
            • Custom script: call RemoveLocation( udg_tempPoint2 )


    @death i just read your tutorial on using local calls in GUI, but i didnt see this answer in your tut.
    Is it faster to use local or global variables? I feel like locals would be, am i right?

    @arhowk So i did what u suggested with moving my blocks around, but this confused me a little: and put the current "then" actions in the "else" of the second if. by current then did u mean the then in the first ITE block? and if i that is what u meant, how would that work? (as in would the trigger work?) just for an example this is what im reading it as
    ITE blocks
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Distance between tempPoint1 and tempPoint2) Greater than or equal to 175.00
        • (Number of units in tempGroup2) Equal to 0
      • Then - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in tempGroup2) Greater than or equal to 1
          • Then - Actions
            • -------- This will switch the defender is there is another in the range. --------
            • Unit Group - Remove tempUnit1 from baseDefenders
            • Unit Group - Add (Random unit from baseDefenders) to baseDefenders
          • Else - Actions
            • -------- Move the defender back to the center of the CoP for his base, if he is the only unit around. --------
            • Unit - Move tempUnit1 instantly to tempPoint2
      • Else - Actions


    Now i have a question for you arhowk in your first post in this thread you said to do this:
    add a check to make sure that tempgroup1 isnt null, else you would
    threadcrash

    I just want to know why and what is a threadcrash.
    The reason i want to know why is because the way this trigger works is that since it loops through the defender and they are always kept within 175 distance of the base, should i still check to see if it is null? since it picks all units within 300 of the defender.

    Also i am trying to do this using a unit indexer, but im still a noob when it comes to indexing (ok ya im a noob at triggering period, thats besides the point :p ) So until i figure it out, whats a better way to do what this trigger does.
    Also, i been looking into jass a little. If i was to make a function that took an integer and a unit and return a boolean. could i make it work?
    my idea of the function would be to take the integer (distance between the unit and the base) and the unit (defender) and return true if it (the defender) is within the right range, and return false if it is not? (although i really note sure how i would write the function so that is not viable... yet)

    on a side note, from what i know the things that make a game lag is when a trigger leaks and after so much build of of those leaks u get noticeable lag.
    So when i disable this trigger i get no lag at all even after of sitting afk in the game for a few hours, when this trigger is enabled i start to see the lag after about 5 minutes.

    1.Why is it generating lag if there is no more leaks (as far as i know)
    2. Is it just bad coding?


    Had to edit what i did before, maybe i mis read what arhowk suggested, but when i had the trigger the way it is at the top of this post, it doesnt work correctly. When switching defenders the new defender would be able to leave the circle.
    here is what is it currently (working 100 percent, but causes lag)
    most updated
    • Change Defender Range
      • Events
        • Time - Every 0.15 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in baseDefenders and do (Actions)
          • Loop - Actions
            • Set tempUnit1 = (Picked unit)
            • Set tempPoint1 = (Position of tempUnit1)
            • Set tempGroup1 = (Units within 300.00 of tempPoint1 matching ((Unit-type of (Matching unit)) Equal to Tower))
            • Set tempUnit2 = (Random unit from tempGroup1)
            • Set tempPoint2 = (Position of tempUnit2)
            • Set tempPlayer1 = (Owner of tempUnit1)
            • Set tempGroup2 = (Units within 175.00 of tempPoint2 matching ((((Matching unit) is A structure) Equal to False) and (((Owner of (Matching unit)) Equal to tempPlayer1) and ((Matching unit) Not equal to tempUnit1))))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Distance between tempPoint1 and tempPoint2) Greater than or equal to 175.00
                • (Number of units in tempGroup2) Equal to 0
              • Then - Actions
                • -------- Move the defender back to the center of the CoP for his base, if he is the only unit around. --------
                • Unit - Move tempUnit1 instantly to tempPoint2
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Number of units in tempGroup2) Greater than or equal to 1
                  • Then - Actions
                    • -------- This will switch the defender is there is another in the range. --------
                    • Unit Group - Remove tempUnit1 from baseDefenders
                    • Unit Group - Add (Random unit from tempGroup2) to baseDefenders
                  • Else - Actions
            • Custom script: call DestroyGroup( udg_tempGroup1 )
            • Custom script: call DestroyGroup( udg_tempGroup2 )
            • Custom script: call RemoveLocation( udg_tempPoint1 )
            • Custom script: call RemoveLocation( udg_tempPoint2 )



    by the way guys, thanks ton for all the help, + rep for both of u
     
    Last edited: Aug 15, 2013
  14. Arhowk

    Arhowk

    Joined:
    Aug 8, 2007
    Messages:
    2,752
    Resources:
    0
    Resources:
    0
    im not going to quote that post because its long..

    ignore the group comment, im used to JASS where GroupEnumUnitsInRange doesn't create the group for you

    in ur "ITE Blocks" trigger, the issue is that the first "number of units in group" check shouldnt be there. it should be

    if distance > 175
    then (see how i left out the num units in group == 0)
    if num units in group == 0
    move unit back
    else
    set new unit as defender
    endif
    endif

    I'd still recommend setting the timer higher, to like 0.4 or 0.5. A unit can walk (movespeed) range every second, so a unit with capped movespeed (522) will be able to walk 261 in 0.5 seconds, 175+261=436, which means you increase the distance check for the initial defender to 436, or leave it at 300 and change time to 0.22 seconds (exact time is 0.239) which is the bare minimum if u want the range to be 300.

    Unit indexing is pretty simple, you can get an array-friendly integer based on the unit (after implementing the system), and every unit's integer is different with
    Custom value of (x)

    so if you would do

    set towers[custom value of guardian] = custom value of tower

    to get the tower that the unit is chained to

    UDexUnits[towers[custom value of guardian]] is your tower (UDexUnits is a variable generated by the unit indexer that is essentially the reverse of custom value, it takes the integer custom value of the unit and returns what unit has that custom value assigned)

    E/ just spent ten minutes staring at Almia and daffa's avatars
     
  15. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,843
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    @Arhowk
    You are amused to our avatars.
    Behold, Barry's Power!
     
  16. Arhowk

    Arhowk

    Joined:
    Aug 8, 2007
    Messages:
    2,752
    Resources:
    0
    Resources:
    0
    Who is barry... (assuming its the person in the ava)

    and no i was looking at synchronization :p
     
  17. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,843
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    I dunno. I just liked his groove
     
  18. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    187
    Resources:
    0
    Resources:
    0
    I been busy with other things lately. I just re organized the way you said it, I will try the custom value thing next, but ill have to redo most my other triggers to.

    So im watching my memory while letting the game run, it jumps up by around 20-100kb every second, (or less idk i cant tell) currently its at 180,000 kb
    Without the trigger, it sits around 165,000 kb total memory. moves up and down a lil bit.

    trig
    • Change Defender Range
      • Events
        • Time - Every 0.50 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in baseDefenders and do (Actions)
          • Loop - Actions
            • Set tempUnit1 = (Picked unit)
            • Set tempPoint1 = (Position of tempUnit1)
            • Set tempGroup1 = (Units within 436.00 of tempPoint1 matching ((Unit-type of (Matching unit)) Equal to Tower))
            • Set tempUnit2 = (Random unit from tempGroup1)
            • Set tempPoint2 = (Position of tempUnit2)
            • Set tempPlayer1 = (Owner of tempUnit1)
            • Set tempGroup2 = (Units within 175.00 of tempPoint2 matching ((((Matching unit) is A structure) Equal to False) and (((Owner of (Matching unit)) Equal to tempPlayer1) and ((Matching unit) Not equal to tempUnit1))))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Distance between tempPoint1 and tempPoint2) Greater than or equal to 175.00
              • Then - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Number of units in tempGroup2) Equal to 0
                  • Then - Actions
                    • Unit - Move tempUnit1 instantly to tempPoint2
                  • Else - Actions
                    • Unit Group - Remove tempUnit1 from baseDefenders
                    • Unit Group - Add (Random unit from tempGroup2) to baseDefenders
              • Else - Actions
            • Custom script: call DestroyGroup( udg_tempGroup1 )
            • Custom script: call DestroyGroup( udg_tempGroup2 )
            • Custom script: call RemoveLocation( udg_tempPoint1 )
            • Custom script: call RemoveLocation( udg_tempPoint2 )
     
  19. Arhowk

    Arhowk

    Joined:
    Aug 8, 2007
    Messages:
    2,752
    Resources:
    0
    Resources:
    0
    (Is it just me, or are
    • tags not working anymore? I can't collapse the windows on his tags)
    • I don't see a leak, but if I re-write the trigger in JASS would you implement it? (just so I'm not wasting my time)
     
  20. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    187
    Resources:
    0
    Resources:
    0