• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Help Please, Movement Trigger will not Work.

Status
Not open for further replies.
Level 4
Joined
Mar 29, 2009
Messages
66
As you will be able to tell from the hidden trigger, I am a beginner to mapping. I am trying to condense all my "Unit - Move" triggers into one, though I am obviously doing something wrong. Half the time this works, the other half it does not. Anyways, any guidance will be helpful; is it possible to put multiple "Unit - Move" triggers in one at all?

  • Team One Creep
  • Events
    • Unit - A unit enters Team One 1 <gen>
    • Unit - A unit enters Team One 2 <gen>
    • Unit - A unit enters Team One 3 <gen>
    • Unit - A unit enters Team One Spec <gen>
  • Conditions
  • Actions
    • If ((Team One 1 <gen> contains (Triggering unit)) Equal to True) then do (Unit - Move (Triggering unit) instantly to (Center of Team One 1 Ent <gen>)) else do (Do nothing)
    • If ((Team One 2 <gen> contains (Triggering unit)) Equal to True) then do (Unit - Move (Triggering unit) instantly to (Center of Team One 2 Ent <gen>)) else do (Do nothing)
    • If ((Team One 3 <gen> contains (Triggering unit)) Equal to True) then do (Unit - Move (Triggering unit) instantly to (Center of Team One 3 Ent <gen>)) else do (Do nothing)
    • If ((Team One Spec <gen> contains (Triggering unit)) Equal to True) then do (Unit - Move (Triggering unit) instantly to (Center of Team One Spec Ent <gen>)) else do (Do nothing)
    • Camera - Pan camera for (Owner of (Triggering unit)) to (Position of (Triggering unit)) over 0.00 seconds
 
Level 11
Joined
Feb 11, 2010
Messages
199
As you will be able to tell from the hidden trigger, I am a beginner to mapping. I am trying to condense all my "Unit - Move" triggers into one, though I am obviously doing something wrong. Half the time this works, the other half it does not. Anyways, any guidance will be helpful; is it possible to put multiple "Unit - Move" triggers in one at all?

  • Team One Creep
  • Events
    • Unit - A unit enters Team One 1 <gen>
    • Unit - A unit enters Team One 2 <gen>
    • Unit - A unit enters Team One 3 <gen>
    • Unit - A unit enters Team One Spec <gen>
  • Conditions
  • Actions
    • If ((Team One 1 <gen> contains (Triggering unit)) Equal to True) then do (Unit - Move (Triggering unit) instantly to (Center of Team One 1 Ent <gen>)) else do (Do nothing)
    • If ((Team One 2 <gen> contains (Triggering unit)) Equal to True) then do (Unit - Move (Triggering unit) instantly to (Center of Team One 2 Ent <gen>)) else do (Do nothing)
    • If ((Team One 3 <gen> contains (Triggering unit)) Equal to True) then do (Unit - Move (Triggering unit) instantly to (Center of Team One 3 Ent <gen>)) else do (Do nothing)
    • If ((Team One Spec <gen> contains (Triggering unit)) Equal to True) then do (Unit - Move (Triggering unit) instantly to (Center of Team One Spec Ent <gen>)) else do (Do nothing)
    • Camera - Pan camera for (Owner of (Triggering unit)) to (Position of (Triggering unit)) over 0.00 seconds

Alright, first off, NEVER use "Do Nothing." It is bad in every way and good in absolutely no ways. Just use the if/then/else multiple conditions instead and leave a blank space after "else". It's more convenient to edit and better for you too! Everyone wins.

Second off, don't use "position of". Set the position to a variable and reference the variable, then, when you don't need that position anymore, use a custom script to remove the location. This will prevent memory leaks. You want to prevent memory leaks because they will slow down your game, and potentially cause problems that could disrupt online play. You don't want that, do you?

Third, yes, you can put them all in one trigger, but why would you want to? You have a string of useless checks there that just eats up efficiency for no reason (e.g. the game has to run through all of your functions regardless of which event is occurring). As far as I know, there's absolutely no reason you shouldn't just make those separate triggers like so:

  • Events
    • Unit - A unit enters Team One 1 <gen>
  • Conditions
  • Actions
    • Set TeamOne1Center = Center of Team One 1 Ent <gen>
    • Unit - Move (Triggering unit) instantly to TeamOne1Center
    • Camera - Pan camera for (Owner of (Triggering unit)) to TeamOne1Center over 0.00 seconds
    • Custom script: call RemoveLocation(udg_TeamOne1Center)
  • Events
    • Unit - A unit enters Team One 2 <gen>
  • Conditions
  • Actions
    • Set TeamOne2Center = Center of Team One 2 Ent <gen>
    • Unit - Move (Triggering unit) instantly to TeamOne2Center
    • Camera - Pan camera for (Owner of (Triggering unit)) to TeamOne2Center over 0.00 seconds
    • Custom script: call RemoveLocation(udg_TeamOne2Center)
  • Events
    • Unit - A unit enters Team One 3 <gen>
  • Conditions
  • Actions
    • Set TeamOne3Center = Center of Team One 3 Ent <gen>
    • Unit - Move (Triggering unit) instantly to TeamOne3Center
    • Camera - Pan camera for (Owner of (Triggering unit)) to TeamOne3Center over 0.00 seconds
    • Custom script: call RemoveLocation(udg_TeamOne3Center)
  • Events
    • Unit - A unit enters Team One Spec <gen>
  • Conditions
  • Actions
    • Set TeamOneSpecCenter = Center of Team One Spec Ent <gen>
    • Unit - Move (Triggering unit) instantly to TeamOneSpecCenter
    • Camera - Pan camera for (Owner of (Triggering unit)) to TeamOneSpecCenter over 0.00 seconds
    • Custom script: call RemoveLocation(udg_TeamOneSpecCenter)
These triggers avoid the memory leaks and useless wastes (like "Do Nothing") that were in your previous script, and should work just fine.
 
Last edited:
Level 4
Joined
Mar 29, 2009
Messages
66
Thanks!

EDIT:
Could I use the same variable for them all? Or should/do I need to make a variable for each instance?
 
Level 11
Joined
Feb 11, 2010
Messages
199
Thanks!

EDIT:
Could I use the same variable for them all? Or should/do I need to make a variable for each instance?

You could probably use the same variable for them all since it's instantaneous, though it would make little difference.

The important part is that Points (such as "position of") LEAK, which is bad, and to prevent the leak you set them to a variable, then destroy it with the custom script I gave you. For more information on leaks, see: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 
Status
Not open for further replies.
Top