Need help with race triggers

Shadow

TH.net Regular
Reaction score
23
Edit: I think im doing the WC3 tags wrong can anyone tell me how to make it indent and not be jumbled?

I'm making a mini game race where its elimination style (keep racing till your the last one standing). Each player has a certain amount of lives and the race will loop if either of these occur. (Unless there is one racer left standing that is.)

So I have 2 triggers.
- 1 If a player reaches the finish line.
-1 If all players die.

Both kinda do similar things they check to see if there is more then 1 player with at least 1 life.
The 2nd trigger check to see how many lives the

So I sorta got it to work but I am certain that they do leak, and are inefficient. I'll show you them anyways.
Code:
Variable Name                 Type                  
Racer                         Unit Array       
Stampeder                     Unit Array      
Randomizer                    Integer
Player                        String Array
ScoreBoard                    Multiboard
End                           Integer
LapsWon                       Integer Array
Users_Total                   Integer
Rank                          Integer Array
Place                         Integer Array
RacerGroup                    Unit Group
Users                         Integer
TeleportSFX                   Special Effect Array
Int                           Integer


Trigger:
  • Finish Line
    • Events
      • Unit - A unit enters FinishLine1 <gen>
      • Unit - A unit enters FinishLine2 <gen>
      • Unit - A unit enters FinishLine3 <gen>
      • Unit - A unit enters FinishLine4 <gen>
      • Unit - A unit enters FinishLine5 <gen>
      • Unit - A unit enters FinishLine6 <gen>
      • Unit - A unit enters FinishLine7 <gen>
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has buff Speed Bonus) Equal to True
        • Then - Actions
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • Unit - Remove Speed (Neutral Hostile) from Racer[(Integer A)]
          • For each (Integer A) from 0 to 3, do (Actions)
            • Loop - Actions
              • Unit - Remove Speed Stampeder (Neutral Hostile) from Stampeder[(Integer A)]
        • Else - Actions
      • Trigger - Turn off (This trigger)
      • Trigger - Turn off Rollers <gen>
      • Set Randomizer = (Random integer number between 1 and 10)
      • For each (Integer A) from 1 to 5, 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((Integer A)))
            • Then - Actions
              • Game - Display to (All players) for 30.00 seconds the text: (Player[(Integer A)] + ((Name of (Player((Integer A)))) + |r finished first!))
              • Set LapsWon[(Integer A)] = (LapsWon[(Integer A)] + 1)
              • Multiboard - Set the text for ScoreBoard item in column 3, row ((Integer A) + 1) to (String(LapsWon[(Integer A)]))
            • Else - Actions
      • Sound - Play GoodJob <gen>
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • End Greater than or equal to (Users_Total - 1)
        • Then - Actions
          • Set Rank[(Player number of (Owner of (Triggering unit)))] = 1
          • Set Place[1] = (Owner of (Triggering unit))
          • Unit - Remove (Triggering unit) from the game
          • Trigger - Run Winner <gen> (checking conditions)
        • Else - Actions
          • Trigger - Run NextLap <gen> (checking conditions)


Trigger:
  • NextLap
    • Events
    • Conditions
    • Actions
      • Wait 5.00 seconds
      • Set Int = (Random integer number between 1 and 5)
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Racer[(Integer A)] is alive) Equal to True
            • Then - Actions
              • Unit - Move Racer[(Integer A)] instantly to RacerLocs[Int], facing 45.00 degrees
              • Unit - Pause Racer[(Integer A)]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Int Equal to 5
                • Then - Actions
                  • Set Int = 1
                • Else - Actions
                  • Set Int = (Int + 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Lives[(Integer A)] Greater than 0
                  • ((Player((Integer A))) slot status) Equal to Is playing
                • Then - Actions
                  • Unit - Create 1 Racer for (Player((Integer A))) at RacerLocs[(Integer A)] facing 45.00 degrees
                  • Set Racer[(Integer A)] = (Last created unit)
                  • Camera - Lock camera target for (Player((Integer A))) to Racer[(Integer A)], offset by (0.00, 0.00) using Default rotation
                  • Unit Group - Add Racer[(Integer A)] to RacerGroup
                  • Unit - Pause Racer[(Integer A)]
                  • Set Lives[(Integer A)] = (Lives[(Integer A)] - 1)
                  • Multiboard - Set the text for ScoreBoard item in column 2, row ((Integer A) + 1) to (String(Lives[(Integer A)]))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Int Equal to 5
                    • Then - Actions
                      • Set Int = 1
                    • Else - Actions
                      • Set Int = (Int + 1)
                • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • Randomizer Equal to 1
              • Randomizer Equal to 5
              • Randomizer Equal to 10
        • Then - Actions
          • Trigger - Run Speed Round <gen> (checking conditions)
        • Else - Actions
      • Trigger - Add to Race Start <gen> the event (Time - Elapsed game time is 3.00 seconds)
      • Trigger - Turn on Rollers <gen>

Trigger:
  • All Racers Dead
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Racer
    • Actions
      • For each (Integer A) from 1 to 5, 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((Integer A)))
            • Then - Actions
              • Set Lives[(Integer A)] = (Lives[(Integer A)] - 1)
              • Multiboard - Set the text for ScoreBoard item in column 2, row ((Integer A) + 1) to (String(Lives[(Integer A)]))
            • Else - Actions
      • Camera - Lock camera target for (Owner of (Triggering unit)) to Stampede 0001 <gen>, offset by (0.00, 0.00) using The unit's rotation
      • For each (Integer A) from 1 to 5, 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((Integer A)))
              • Lives[(Integer A)] Equal to 0
            • Then - Actions
              • Set End = (End + 1)
              • Set Rank[(Integer A)] = Users
              • Set Users = (Users - 1)
              • Game - Display to (All players) the text: ((String(Rank[(Integer A)])) + Test message)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (All units of RacerGroup are dead) Equal to True
        • Then - Actions
          • Set Int = (Random integer number between 1 and 5)
          • For each (Integer A) from 0 to 3, do (Actions)
            • Loop - Actions
              • Unit - Remove Speed Stampeder (Neutral Hostile) from Stampeder[(Integer A)]
              • Special Effect - Create a special effect at (Position of Stampeder[(Integer A)]) using Abilities\Spells\Human\MassTeleport\MassTeleportCaster.mdl
              • Set TeleportSFX[(Integer A)] = (Last created special effect)
              • Unit - Move Stampeder[(Integer A)] instantly to Stampede[(Integer A)]
              • Unit - Hide Stampeder[(Integer A)]
              • Trigger - Turn off Rollers <gen>
          • Set Randomizer = (Random integer number between 1 and 10)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) has buff Speed Bonus) Equal to True
            • Then - Actions
              • For each (Integer A) from 1 to 5, do (Actions)
                • Loop - Actions
                  • Unit - Remove Speed (Neutral Hostile) from Racer[(Integer A)]
              • For each (Integer A) from 0 to 3, do (Actions)
                • Loop - Actions
                  • Unit - Remove Speed Stampeder (Neutral Hostile) from Stampeder[(Integer A)]
            • Else - Actions
          • Game - Display to (All players) for 3.00 seconds the text: |cffdc143cAll racer...
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Lives[(Integer A)] Greater than 0
                  • ((Player((Integer A))) slot status) Equal to Is playing
                • Then - Actions
                  • Unit Group - Remove Racer[(Integer A)] from RacerGroup
                  • Unit - Create 1 Racer for (Player((Integer A))) at RacerLocs[Int] facing 45.00 degrees
                  • Set Racer[(Integer A)] = (Last created unit)
                  • Camera - Lock camera target for (Player((Integer A))) to Racer[(Integer A)], offset by (0.00, 0.00) using Default rotation
                  • Special Effect - Create a special effect attached to the origin of Racer[(Integer A)] using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
                  • Set ReviveSFX[(Integer A)] = (Last created special effect)
                  • Unit Group - Add Racer[(Integer A)] to RacerGroup
                  • Unit - Pause Racer[(Integer A)]
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Int Equal to 5
                    • Then - Actions
                      • Set Int = 1
                    • Else - Actions
                      • Set Int = (Int + 1)
                • Else - Actions
                  • Unit Group - Remove Racer[(Integer A)] from RacerGroup
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • Randomizer Equal to 1
                  • Randomizer Equal to 5
                  • Randomizer Equal to 10
            • Then - Actions
              • Trigger - Run Speed Round <gen> (checking conditions)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • End Greater than or equal to (Users_Total - 1)
            • Then - Actions
              • Game - Display to (All players) the text: ((String(End)) + (>= + (String((Users_Total - 1)))))
              • Set Place[1] = (Owner of (Triggering unit))
              • Trigger - Run Winner <gen> (checking conditions)
            • Else - Actions
              • Trigger - Add to Race Start <gen> the event (Time - Elapsed game time is 3.00 seconds)
              • Trigger - Turn on Rollers <gen>
        • Else - Actions

So first, there must be a much more efficient way, I feel like i'm using a hammer to drive a tac. How would you approach this problem? Then I need help identifying leaks and such.
 
Last edited:

jonas

You can change this now in User CP.
Reaction score
66
They are efficient enough. You have some leaks (effects), but they're too little to worry about.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
There are a few location leaks in your "All Dead" trigger, I didnt notice any leaks in the others. What exactly is your question though?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top