How to clean up this trigger

Super.Gnome

New Member
Reaction score
0
I started my map when I was really bad at GUI. And I made this trigger:

Trigger:
  • Archer wave Light
    • Events
      • Unit - A unit enters Mainbase light <gen>
    • Conditions
      • (Unit-type of (Entering unit)) Equal to Hire Archer Reinforcement
    • Actions
      • Unit - Kill (Entering unit)
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Wait 5.00 seconds
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Wait 5.00 seconds
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Wait 5.00 seconds
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Wait 5.00 seconds
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Wait 5.00 seconds
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Wait 5.00 seconds
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))
      • Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing (Position of (Triggering unit))


As far as I know, at the moment, this is inefficient and leaks like mad. I should be able to accomplish the same effect, but without the waits. That way I can use a variable to clear the points I use.

Anyone know of a better way to trigger this? I'm tempted to set and clear my variables between waits, but I'm not even sure that would work.
 

kurtisebear

New Member
Reaction score
0
If you plan for no other reinforcements until all the archers are created, you could set a trigger with a one-shot timer to repeat itself until a counter reaches 5 (or whatever number).
 

Super.Gnome

New Member
Reaction score
0
What if I want it to be able to have more reinforcements to be able to be sent? They would be of a different unit type, but would be spawning from an identical trigger.

Does it hurt anything to just set and clear a "temppoint" variable between each wait? Because that seems like the easiest way to do it.
 

Icyculyr

I'm a Mac
Reaction score
68
I'd do:
Variables->
Point Array pPoints Index of 2

Trigger:
  • Unit - Kill (Triggering unit)
    • For Each Integer A From 0 To 6
      • Loop
        • Set pPoints[0] = Random point in Light Wave Spawn <gen>
        • Set pPoints[1] = Random point in Light Wave Spawn <gen>
        • Set pPoints[2] = Position of Triggering Unit
        • Unit - Create 3 Archer for Player 10 (Light Blue) at pPoints[0] facing pPoints[2])
        • Unit - Create 3 Archer for Player 10 (Light Blue) at pPoints[1] facing pPoints[2]
        • Custom Script - call RemoveLocation(udg_pPoints[0])
        • Custom Script - call RemoveLocation(udg_pPoints[1])
        • Custom Script - call RemoveLocation(udg_pPoints[2])
        • Wait 5.00 seconds


That looks good to me, careful with the custom script, it's CAPS sensitive, and one wrong character will stop the map from compiling.

The action is General - Custom Script
 

Executor

I see you
Reaction score
57
Trigger:
  • Actions:
    • Set pPoints[2] = Position of Triggering Unit
    • Unit - Kill (Triggering unit)
    • For Each Integer A From 0 To 6
      • Loop
        • Set pPoints[0] = Random point in Light Wave Spawn <gen>
        • Set pPoints[1] = Random point in Light Wave Spawn <gen>
        • Unit - Create 3 Archer for Player 10 (Light Blue) at pPoints[0] facing pPoints[2])
        • Unit - Create 3 Archer for Player 10 (Light Blue) at pPoints[1] facing pPoints[2]
        • Custom Script - call RemoveLocation(udg_pPoints[0])
        • Custom Script - call RemoveLocation(udg_pPoints[1])
        • Custom Script - call TriggerSleepAction( 5. )
    • Custom Script - call RemoveLocation(udg_pPoints[2])
 

Super.Gnome

New Member
Reaction score
0
Here is what I did:

Trigger:
  • Archer wave Light Copy
    • Events
      • Unit - A unit enters Mainbase light <gen>
    • Conditions
      • (Unit-type of (Entering unit)) Equal to Hire Archer Reinforcement
    • Actions
      • Set WPoints[0] = (Position of (Triggering unit))
      • Unit - Remove (Triggering unit) from the game
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set WPoints[1] = (Random point in Light Wave Spawn <gen>)
          • Set WPoints[2] = (Random point in Light Wave Spawn <gen>)
          • Unit - Create 3 Archer for Player 10 (Light Blue) at WPoints[1] facing WPoints[0]
          • Unit - Create 3 Archer for Player 10 (Light Blue) at WPoints[2] facing WPoints[0]
          • Custom script: call RemoveLocation (udg_WPoints[1])
          • Custom script: call RemoveLocation (udg_WPoints[2])
          • Custom script: call TriggerSleepAction( 5. )
      • Custom script: call RemoveLocation (udg_WPoints[0])


As I understand this. This will repeat 6 times, at 5 second intervals. And it's "MUI" so that if multiple waves are being sent at once, we wont have a bug.

Am I correct in my understanding?
 

Icyculyr

I'm a Mac
Reaction score
68
Yes that's what call TriggerSleepAction() does, what's the difference between Wait 5 seconds though?

Code:
Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing [COLOR="Red"](Position of (Triggering unit)[/COLOR])

You were accessing it in your code, that's why we set that variable.
pPoints[2] is set to the pos, and then it is changed to "facing pPoints[2]".

See?
 

Super.Gnome

New Member
Reaction score
0
Yes that's what call TriggerSleepAction() does, what's the difference between Wait 5 seconds though?

Code:
Unit - Create 3 Archer for Player 10 (Light Blue) at (Random point in Light Wave Spawn <gen>) facing [COLOR="Red"](Position of (Triggering unit)[/COLOR])

You were accessing it in your code, that's why we set that variable.
pPoints[2] is set to the pos, and then it is changed to "facing pPoints[2]".

See?

I edited my post above, after I realized what was happening but I forgot to check for replies -- oops. That's my question, isnt call TriggerSleepAction() the same as a Wait? In which case I have to use a new variable array for each separate trigger (I have 16 that do this same thing with different unit types)?
 

Icyculyr

I'm a Mac
Reaction score
68
Hey,
As I understand this. This will repeat 6 times, at 5 second intervals. And it's "MUI" so that if multiple waves are being sent at once, we wont have a bug.

Am I correct in my understanding?

I don't believe it's MUI, since there will be a wait involved, the points will be adjusted and different waves may end up appearing at the wrong locations.

Trigger:
  • Archer wave Light Copy
    • Events
    • Unit - A unit enters Mainbase light &lt;gen&gt;
    • Conditions
    • (Unit-type of (Entering unit)) Equal to Hire Archer Reinforcement
    • Actions
    • Set WPoints[iCounter] = (Position of (Triggering unit))
    • iCounter = iCounter + 1
    • Unit - Remove (Triggering unit) from the game
    • For each (Integer A) from 1 to 6, do (Actions)
    • Loop - Actions
    • Set WPoints[iCounter] = (Random point in Light Wave Spawn &lt;gen&gt;)
    • iCounter = iCounter + 1
    • Set WPoints[iCounter] = (Random point in Light Wave Spawn &lt;gen&gt;)
    • Unit - Create 3 Archer for Player 10 (Light Blue) at WPoints[iCounter-1] facing WPoints[iCounter-2]
    • Unit - Create 3 Archer for Player 10 (Light Blue) at WPoints[iCounter] facing WPoints[iCounter-2]
    • Custom script: call TriggerSleepAction( 5. )
    • iCounter = iCounter + 1



That should work just fine, however you need to clean those leaks, I can't think of an efficient way to clean the leaks, maybe you can?

Kind Regards
 
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