Need help with race triggers

Shadow

TH.net Regular
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

Ultra Cool Member
They are efficient enough. You have some leaks (effects), but they're too little to worry about.
 

Accname

2D-Graphics enthusiast
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
  • tom_mai78101 tom_mai78101:
    I need context.
    +1
  • The Helper The Helper:
    Back in the day conan was a young one and his mom was single and I used to tease him that I was going to date his mom and be his daddy - yeah sounds bad now but it was funny at the time
  • The Helper The Helper:
    his mom is my age
  • The Helper The Helper:
    i know right it was pretty funny
  • thewrongvine thewrongvine:
    its pretty funny
    +1
  • tom_mai78101 tom_mai78101:
    Thanks for the context.
    +1
  • The Helper The Helper:
    Happy Hump Day!!!
  • Blackveiled Blackveiled:
    TH old fart gotta have a beer with me one of these days
  • The Helper The Helper:
    I am down anytime Blackveiled
  • Blackveiled Blackveiled:
    count on it then cause you don't live that far from me hah
  • The Helper The Helper:
    really that is cool!
  • The Helper The Helper:
    Hey Tom I added a new Weird tag to the News Prefixes
  • The Helper The Helper:
    What is up Blackveiled?
  • Blackveiled Blackveiled:
    Chillin', lurkin'. :D
  • The Helper The Helper:
    I am working on a bunch of site projects right now doing a bunch of behind the scenes stuff and trying to clean up some stuff that I let slide when I got lazy with the site for a few years...
  • The Helper The Helper:
    Are you in Houston Blackveiled or just in Texas?
  • Blackveiled Blackveiled:
    Houston
  • Blackveiled Blackveiled:
    I've been living here since 2014.
  • The Helper The Helper:
    OK banlord we need to get together soon! The only other member of the site I know in Houston is XXX Conan
  • The Helper The Helper:
    and he does not want none lol
  • The Helper The Helper:
    he put up a picture of his mom one time and she was HOT!
  • The Helper The Helper:
    I wish we still had that
  • Blackveiled Blackveiled:
    Lmao you scared him off I see.
  • The Helper The Helper:
    he will be back

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top