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.
 
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).
 
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.
 
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
 
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])
 
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?
 
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?
 
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)?
 
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 The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top