1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Have i succesfully made this trigger not leak?

Discussion in 'Triggers & Scripts' started by vlekje5, Aug 11, 2020.

  1. vlekje5

    vlekje5

    Joined:
    Dec 1, 2010
    Messages:
    255
    Resources:
    0
    Resources:
    0
    hey,
    So i've recently started redoing alot of my maps triggers since they leak. i've read quite a bit about leaks, but would like a second opinion on whether i fixed the leak correctly.

    so original trigger:
    • select hero
      • Events
        • Player - Player 1 (Red) skips a cinematic sequence
        • Player - Player 2 (Blue) skips a cinematic sequence
        • Player - Player 3 (Teal) skips a cinematic sequence
        • Player - Player 4 (Purple) skips a cinematic sequence
        • Player - Player 5 (Yellow) skips a cinematic sequence
        • Player - Player 6 (Orange) skips a cinematic sequence
        • Player - Player 7 (Green) skips a cinematic sequence
        • Player - Player 8 (Pink) skips a cinematic sequence
        • Player - Player 9 (Gray) skips a cinematic sequence
        • Player - Player 10 (Light Blue) skips a cinematic sequence
        • Player - Player 11 (Dark Green) skips a cinematic sequence
        • Player - Player 12 (Brown) skips a cinematic sequence
        • Player - Player 13 (Maroon) skips a cinematic sequence
        • Player - Player 14 (Navy) skips a cinematic sequence
        • Player - Player 15 (Turquoise) skips a cinematic sequence
        • Player - Player 16 (Violet) skips a cinematic sequence
        • Player - Player 17 (Wheat) skips a cinematic sequence
        • Player - Player 18 (Peach) skips a cinematic sequence
        • Player - Player 19 (Mint) skips a cinematic sequence
        • Player - Player 20 (Lavender) skips a cinematic sequence
        • Player - Player 21 (Coal) skips a cinematic sequence
        • Player - Player 22 (Snow) skips a cinematic sequence
        • Player - Player 23 (Emerald) skips a cinematic sequence
        • Player - Player 24 (Peanut) skips a cinematic sequence
      • Conditions
      • Actions
        • Selection - Select (Random unit from (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).)) for (Triggering player)
        • Camera - Pan camera for (Triggering player) to (Position of (Random unit from (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).))) over 0.10 seconds

    new trigger:
    • pos locker
      • Events
        • Time - Every 0.05 seconds of game time
      • Conditions
      • Actions
        • For each (Integer A) from 1 to 24, do (Actions)
          • Loop - Actions
            • Custom script: call RemoveLocation( udg_positionofhero[bj_forLoopAIndex] )
            • Set VariableSet positionofhero[(Integer A)] = (Position of Hero[(Integer A)])

    the idea is that it removes the previous location on the next time it loops. since i need the location to stay stored untill the next loop.

    Second part:
    • select hero noleaks
      • Events
        • Player - Player 1 (Red) skips a cinematic sequence
        • Player - Player 2 (Blue) skips a cinematic sequence
        • Player - Player 3 (Teal) skips a cinematic sequence
        • Player - Player 4 (Purple) skips a cinematic sequence
        • Player - Player 5 (Yellow) skips a cinematic sequence
        • Player - Player 6 (Orange) skips a cinematic sequence
        • Player - Player 7 (Green) skips a cinematic sequence
        • Player - Player 8 (Pink) skips a cinematic sequence
        • Player - Player 9 (Gray) skips a cinematic sequence
        • Player - Player 10 (Light Blue) skips a cinematic sequence
        • Player - Player 11 (Dark Green) skips a cinematic sequence
        • Player - Player 12 (Brown) skips a cinematic sequence
        • Player - Player 13 (Maroon) skips a cinematic sequence
        • Player - Player 14 (Navy) skips a cinematic sequence
        • Player - Player 15 (Turquoise) skips a cinematic sequence
        • Player - Player 16 (Violet) skips a cinematic sequence
        • Player - Player 17 (Wheat) skips a cinematic sequence
        • Player - Player 18 (Peach) skips a cinematic sequence
        • Player - Player 19 (Mint) skips a cinematic sequence
        • Player - Player 20 (Lavender) skips a cinematic sequence
        • Player - Player 21 (Coal) skips a cinematic sequence
        • Player - Player 22 (Snow) skips a cinematic sequence
        • Player - Player 23 (Emerald) skips a cinematic sequence
        • Player - Player 24 (Peanut) skips a cinematic sequence
      • Conditions
      • Actions
        • Selection - Select Hero[(Player number of (Triggering player))] for (Triggering player)
        • Camera - Pan camera for (Triggering player) to positionofhero[(Player number of (Triggering player))] over 0.10 seconds
    i set the hero variable for each number individually in a one time map initialization event since its not a repeating loop i dont think it would cause a ton of memory problems

    the purpose of the trigger is to do a simple select and pan over when the player presses esc, it also makes the camera locked when esc is held down wich is pretty nice on it's own.

    a second question would be if a trigger like this would cause a substantial amount of lagg when implemented in a way that it doesn't leak. I don't seem to notice it in the map i'm working on but i might be intrested to try this in a moba style project where there really can"t be any lagg.
     
  2. MasterBlaster

    MasterBlaster

    Joined:
    Feb 23, 2014
    Messages:
    1,059
    Resources:
    0
    Resources:
    0
    I don't really get the logic behind the "pos locker" trigger - I mean, I get what you are trying to do, but I can't see why you're not just doing something like this:

    • select hero noleaks
      • Events
        • Player - Player 1 (Red) skips a cinematic sequence
        • (...)
        • Player - Player 24 (Peanut) skips a cinematic sequence
      • Conditions
      • Actions
        • Selection - Select Hero[(Player number of (Triggering player))] for (Triggering player)
        • Set TempPoint = (Position of Hero[(Player number of (Triggering player))])
        • Camera - Pan camera for (Triggering player) to TempPoint over 0.10 seconds
        • Custom script: call RemoveLocation( udg_TempPoint )

    And yes, the above includes removing the "post locker" trigger.
     
  3. vlekje5

    vlekje5

    Joined:
    Dec 1, 2010
    Messages:
    255
    Resources:
    0
    Resources:
    0
    that seems to work aswell, as for the reason i did it that way, i don't remember. i probably thought that i had to independently update the position of a variable for it to not leak.
    It's indeed simpler to do it that way since both triggers seem to do the exact same once you're ingame. and that's more accurate less demanding and less lines.

    However i would still like to ask if my version was leak proof, I have since made a prototype for a locked camera mode out of it. which could prove usefull in a moba type of game. it still uses the same location lock trigger but in that one you lock in or out of locked camera by pressing esc
     
  4. MasterBlaster

    MasterBlaster

    Joined:
    Feb 23, 2014
    Messages:
    1,059
    Resources:
    0
    Resources:
    0
    Yes, technically it doesn't leak, but it's an awkward and suboptimal way of preventing leaks.
     
    Last edited: Aug 11, 2020
  5. vlekje5

    vlekje5

    Joined:
    Dec 1, 2010
    Messages:
    255
    Resources:
    0
    Resources:
    0
    i get that, But since i took that trigger to make a locked camera trigger in the context of that trigger it is more optimal. I have since changed the original trigger to keep things from getting too messy.