Trigger running too many times

TBear

New Member
Reaction score
3
(Okay, so I've been mapping for quite a while and have finally decided to come here, trying to be a little active. Hello everyone, I'm TBear and this is my first post)

I'm currently working on a "Tug-of-War"-like map:
Pitched:
2 teams, 4 players on each. Each team has it's own "Creep Pit", which spawns new units every 10th second, then sending them toward the other players' Creep Pit.
You and your three teammates control a hero each, while a bot for each team control the spawned units.
Victory can be achieved by destroying the other team's Creep-Pit. This might sound a bit like DotA, but believe me; it's not anywhere near ;)

This is my current code for ordering the spawned ones to move from center of map to post #1 in hostile area:

Trigger:
  • Post CENTER
    • Events
      • Unit - A unit enters REG_CENTER<gen>
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 250.00 of (Position of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to Player 9 (Gray) <<< Team West's bot
            • Then - Actions
              • Unit - Order (Picked unit) to Attack-Move To (Center of REG_E1 <gen>)
            • Else - Actions


So what this trigger actually does, is ordering a Unit-Group to move in formation toward the enemy creep-pit, instead of moving them one by one.

This is where my problem appears -


This trigger runs each time a unit enters the region. There are 7 regions like this, and 7 triggers for each team. By other means, a unit group will be given exactly the same order, each time a unit from the same group enters the region. Unnecessary, aye?

Can anyone think of a way(probably a condition), that prevents units from the already-ordered group to activate the trigger? (Action "Wait" won't work in this case)

Hope I didn't make this too complicated and boring :] Thanks
 

nabbig2

New Member
Reaction score
43
Try to make it so that the condition only works if the unit's Custom Value is 1, and whenever the unit enters the region, set the Custom Value to 0. That way it only works once for that unit.
 

ManyTimes

I'm so lonesome I could cry...
Reaction score
293
Code:
Untitled Trigger 002
    Events
        Unit - A unit enters Region 000 <gen>
    Conditions
        (Owner of (Triggering unit)) Equal to Player 12 (Brown)
    Actions
        Unit - Order (Triggering unit) to Move To (Center of (Playable map area))
I would have done something like this.

I would not do what you did, picking every units within range of triggering unit.
Specially not if it is supposed to be 250 range, or is this trigger you show us here just a sample? If so; show us the real trigger.

Also; your trigger leaks (so does the trigger above by me), search this very forum after a "Leak tutorial". ;)

Else, are all the units within 250 range? I suggest "Trigger - Turn off this trigger" and wait a bit, turn it on before the next wave spawns...

Edit: Custom Values + Point variables are often used to order units from one place to another...
To give you an idea:
Code:
map Init
    Events
        Map initialization
    Conditions
    Actions
        Set [COLOR="Red"]point[/COLOR][0] = (Center of 1 <gen>)
        Set [COLOR="Red"]point[/COLOR][1] = (Center of 2 <gen>)
        Set [COLOR="Red"]point[/COLOR][2] = (Center of 3 <gen>)

Code:
craete
    Events
        Time - Every 2.00 seconds of game time
    Conditions
    Actions
        Unit - Create 1 Footman for Player 10 (Light Blue) at point[0] facing Default building facing degrees
Code:
order move
    Events
        Unit - A unit enters 1 <gen>
        Unit - A unit enters 2 <gen>
        Unit - A unit enters 3 <gen>
    Conditions
        (Owner of (Triggering unit)) Equal to Player 10 (Light Blue)
    Actions
        Unit - Set the custom value of (Triggering unit) to ((Custom value of (Triggering unit)) + 1)
        Unit - Order (Triggering unit) to Attack-Move To [COLOR="Red"]point[/COLOR][(Custom value of (Triggering unit))]
 

TBear

New Member
Reaction score
3
Thanks for sudden response, and thanks for telling me about leaks, ManyTimes. It's all a bit complicated, but I'll try to explain the map a little further.

Here is my spawning-trigger:
Trigger:
  • Spawn
    • Events
    • Conditions
    • Actions
      • -------- Team West --------
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Unit - Create (2 - (Number of units in creepsCount[(Integer A)])) creepsType[(Integer A)] for Player 9 (Gray) at (Center of reg wBase &lt;gen&gt;) facing (Center of (Playable map area))
          • Unit Group - Add all units of (Last created unit group) to creepsCount[(Integer A)]
          • Unit Group - Pick every unit in (Last created unit group) and do (Unit - Change color of (Picked unit) to (Color of (Player((Integer A)))))
      • Unit Group - Order (Units within 250.00 of (Center of reg wBase &lt;gen&gt;) matching ((Owner of (Matching unit)) Equal to Player 9 (Gray))) to Attack-Move To (Center of reg w1 &lt;gen&gt;)
      • -------- Team East --------
      • For each (Integer A) from 5 to 8, do (Actions)
        • Loop - Actions
          • Unit - Create (2 - (Number of units in creepsCount[(Integer A)])) creepsType[(Integer A)] for Player 10 (Light Blue) at (Center of reg eBase &lt;gen&gt;) facing (Center of (Playable map area))
          • Unit Group - Add all units of (Last created unit group) to creepsCount[(Integer A)]
          • Unit Group - Pick every unit in (Last created unit group) and do (Unit - Change color of (Picked unit) to (Color of (Player((Integer A)))))
      • Unit Group - Order (Units within 250.00 of (Center of reg eBase &lt;gen&gt;) matching ((Owner of (Matching unit)) Equal to Player 10 (Light Blue))) to Attack-Move To (Center of reg w1 &lt;gen&gt;)


(Love them leaks! Will fix'em once I get this over with)

As you can see, the bots spawn 2 units for each player. When the timer reaches zero, the trigger will spawn 2 new units minus the ones currently in game(for each player). A player won't be able to control those units, but he will be able to upgrade the unit-type(creepsType[#] defines unit-type for player #'s creeps). So if one of my units are killed, a new one will appear, once the timer reaches zero and runs the trigger.

The reason I want them to move as a group, is so that they will move a bit more organized, and not queue up in the center of a region. (Sorry, I won't use Random Point in Region either ^^)

Though if there's no solution to this, I'll do as you suggested ManyTimes :]

Here's an overview of the map:


Any suggestions will be appreciated!
 

deebee

New Member
Reaction score
15
I would use two unit group variable for each region and use a condition to check.

Trigger:
  • Post CENTER
    • Set CenterGroup = (Units within 250.00 of (Position of (Triggering unit)) matching (((Owner of (Matching unit)) Equal to Player 9 (Gray)) and (((Matching unit) is in CenterOrderedGroup) Not equal to True)))
    • Unit Group - Pick every unit in CenterGroup and do (Actions)
      • Loop - Actions
        • Set NextPoint = (Center of NextPoint (region))
        • Unit - Order (Picked unit) to Attack-Move To NextPoint
        • Unit Group - Add (Picked unit) to CenterOrderedGroup
        • Custom script: call RemoveLocation (udg_NextPoint)
    • Custom script: call DestroyGroup (udg_CenterGroup)


But this will not solve the triggers from firing all the time anyway, you cant really avoid that.
 

TBear

New Member
Reaction score
3
Problem solved! The units now walk smoothly all the way :]

What I did, was removing the old within-range-triggers, and replacing them with booleans, like nabbig2 said. At spawn, every creep from Team West is added to unitgroup[1], while creeps from Team East are added to unitgroup[7].

If a creep from team west enters reg w1, every Player 9(Team West's bot) creep in unitgroup[1] will be sent to reg w2, removed from unitgroup[1], and added to unitgroup[2] etc.

This is what the triggers look like:

Trigger:
  • Spawn
    • Actions
      • -------- Team West --------
      • Set currentPoint = (Center of reg wBase &lt;gen&gt;)
      • Set nextPoint = (Center of reg w1 &lt;gen&gt;)
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Unit - Create (2 - (Number of units in creepsCount[(Integer A)])) creepsType[(Integer A)] for Player 9 (Gray) at currentPoint facing nextPoint
          • Set tempGroup = (Last created unit group)
          • Unit Group - Add all units of tempGroup to creepsCount[(Integer A)]
          • Unit Group - Pick every unit in tempGroup and do (Unit - Change color of (Picked unit) to (Color of (Player((Integer A)))))
          • Custom script: call DestroyGroup (udg_tempGroup)
      • Set tempGroup = (Units within 300.00 of currentPoint)
      • Unit Group - Add all units of tempGroup to postGroup[1]
      • Unit Group - Order tempGroup to Attack-Move To nextPoint
      • Custom script: call RemoveLocation (udg_currentPoint)
      • Custom script: call RemoveLocation (udg_nextPoint)
      • -------- Team East --------
      • Set currentPoint = (Center of reg eBase &lt;gen&gt;)
      • Set nextPoint = (Center of reg e1 &lt;gen&gt;)
      • For each (Integer A) from 5 to 8, do (Actions)
        • Loop - Actions
          • Unit - Create (2 - (Number of units in creepsCount[(Integer A)])) creepsType[(Integer A)] for Player 10 (Light Blue) at currentPoint facing nextPoint
          • Set tempGroup = (Last created unit group)
          • Unit Group - Add all units of tempGroup to creepsCount[(Integer A)]
          • Unit Group - Pick every unit in tempGroup and do (Unit - Change color of (Picked unit) to (Color of (Player((Integer A)))))
          • Custom script: call DestroyGroup (udg_tempGroup)
      • Set tempGroup = (Units within 300.00 of currentPoint)
      • Unit Group - Add all units of tempGroup to postGroup[7]
      • Unit Group - Order tempGroup to Attack-Move To nextPoint
      • Custom script: call RemoveLocation (udg_currentPoint)
      • Custom script: call RemoveLocation (udg_nextPoint)


Trigger:
  • Post w2
    • Events
      • Unit - A unit enters reg w2 &lt;gen&gt;
    • Conditions
      • ((Triggering unit) is in postGroup[2]) Equal to True
      • ((Owner of (Triggering unit)) Equal to Player 9 (Gray)) or ((Owner of (Triggering unit)) Equal to Player 10 (Light Blue))
    • Actions
      • -------- Team West --------
      • Set nextPoint = (Center of reg w3 &lt;gen&gt;)
      • Set tempGroup = (Units owned by Player 9 (Gray) matching (((Matching unit) is in postGroup[2]) Equal to True))
      • Unit Group - Remove all units of tempGroup from postGroup[2]
      • Unit Group - Add all units of tempGroup to postGroup[3]
      • Unit Group - Order tempGroup to Attack-Move To nextPoint
      • Custom script: call RemoveLocation (udg_currentPoint)
      • Custom script: call DestroyGroup (udg_tempGroup)
      • Custom script: call RemoveLocation (udg_nextPoint)
      • -------- Team East --------
      • Set nextPoint = (Center of reg w1 &lt;gen&gt;)
      • Set tempGroup = (Units owned by Player 10 (Light Blue) matching (((Matching unit) is in postGroup[2]) Equal to True))
      • Unit Group - Remove all units of tempGroup from postGroup[2]
      • Unit Group - Add all units of tempGroup to postGroup[1]
      • Unit Group - Order tempGroup to Attack-Move To nextPoint
      • Custom script: call RemoveLocation (udg_currentPoint)
      • Custom script: call DestroyGroup (udg_tempGroup)
      • Custom script: call RemoveLocation (udg_nextPoint)


Thanks guys, you really saved my day! ;D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top