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
67
They are efficient enough. You have some leaks (effects), but they're too little to worry about.
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
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:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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