• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Trigger cleanup/rework

Status
Not open for further replies.
Level 4
Joined
Jan 23, 2009
Messages
74
hey guys its me again

the other day my friend gave me a "skeleton" of a map which hes to lazy to finish off, so while im doing the terrain (among some other tweaks) i was looking over the triggers.

The map itself was a brilliant concept but it was incomplete and i want to finish it, but to do that i need to find out a way to keep track of a winner of each round.

as they are some of the triggers look a bit "messy", to me at least i was wondering if i could get help cleaning them up. and then mabey if im lucky some help tips on keeping track of the players who win each round.

  • Initialize
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set Game = True
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 1 (Red) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[1] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 2 (Blue) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 2 (Blue) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[2] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 3 (Teal) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 3 (Teal) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[3] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 4 (Purple) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 4 (Purple) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[4] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 5 (Yellow) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 5 (Yellow) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[5] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 6 (Orange) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 6 (Orange) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[6] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 7 (Green) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 7 (Green) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[7] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 8 (Pink) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 8 (Pink) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[8] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 9 (Gray) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 9 (Gray) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[9] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 10 (Light Blue) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 10 (Light Blue) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[10] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 11 (Dark Green) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 11 (Dark Green) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[11] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 12 (Brown) slot status) Equal to Is playing
        • Then - Actions
          • Set Player_Count = (Player_Count + 1)
          • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for Player 12 (Brown) at (Random point in Arena <gen>) facing Default building facing degrees
          • Set Player_Unit[12] = (Last created unit)
        • Else - Actions
      • Wait 10.00 seconds
      • Trigger - Run Unit Change <gen> (checking conditions)
  • Unit Change
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[1] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[1] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[1] = (Last replaced unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[2] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[2] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[2] = (Last replaced unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[3] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[3] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[3] = (Last replaced unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[4] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[4] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[4] = (Last replaced unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[5] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[5] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[5] = (Last replaced unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[6] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[6] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[6] = (Last replaced unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[7] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[7] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[7] = (Last replaced unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[8] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[8] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[8] = (Last replaced unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[9] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[9] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[9] = (Last replaced unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[10] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[10] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[10] = (Last replaced unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[11] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[11] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[11] = (Last replaced unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_Unit[12] is alive) Equal to True
        • Then - Actions
          • Unit - Replace Player_Unit[12] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
          • Set Player_Unit[12] = (Last replaced unit)
        • Else - Actions
      • Wait 10.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Game Equal to True
        • Then - Actions
          • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
and this doesn't look to messy but i wouldn't want to leave it out b/c its an important part
  • Next round
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Dying unit) Equal to Player_Unit[1]
              • (Dying unit) Equal to Player_Unit[2]
              • (Dying unit) Equal to Player_Unit[3]
              • (Dying unit) Equal to Player_Unit[4]
              • (Dying unit) Equal to Player_Unit[5]
              • (Dying unit) Equal to Player_Unit[6]
              • (Dying unit) Equal to Player_Unit[7]
              • (Dying unit) Equal to Player_Unit[8]
              • (Dying unit) Equal to Player_Unit[9]
              • (Dying unit) Equal to Player_Unit[10]
              • (Dying unit) Equal to Player_Unit[11]
              • (Dying unit) Equal to Player_Unit[12]
        • Then - Actions
          • Set Player_Count = (Player_Count - 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Player_Count Equal to 1
        • Then - Actions
          • Set Game = False
          • Game - Display to (All players) for 11.00 seconds the text: Restarting game...
          • Wait 5.00 seconds
          • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Wait 6.00 seconds
          • Trigger - Run Initialize <gen> (checking conditions)
        • Else - Actions
(i left out 1 trigger, but that one was just a "list" of the units used in the "catalog" variable basically.)
 

ZIR

ZIR

Level 10
Joined
Jan 12, 2010
Messages
321
For the first trigger you could use a loop from 1 to 12 and use the convert integer to player number action, this should reduce the trigger length's really.
And for the second trigger make the same.
And Units in playable map area and random point in arena are leaks, the third doesn't look really messy, if you don't know what I eman just say I will give you an example.
 
Level 4
Joined
Jan 23, 2009
Messages
74
this is what you meant right?
although what suggestions do u have to fix the leaks, i have no idea what to use instead of "Units in playable map area and random point in arena"
  • Unit Change
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_Unit[(Integer A)] is alive) Equal to True
            • Then - Actions
              • Unit - Replace Player_Unit[(Integer A)] with a Catalog[(Random integer number between 1 and 67)] using The old unit's relative life and mana
              • Set Player_Unit[(Integer A)] = (Last replaced unit)
            • Else - Actions
      • Wait 10.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Game Equal to True
        • Then - Actions
          • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
  • Initialize
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set Game = True
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                • Then - Actions
                  • Set Player_Count = (Player_Count + 1)
                  • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for (Picked player) at (Random point in Arena <gen>) facing Default building facing degrees
                  • Set Player_Unit[(Integer A)] = (Last created unit)
                • Else - Actions
      • Wait 10.00 seconds
      • Trigger - Run Unit Change <gen> (checking conditions)
 
Level 4
Joined
Jan 23, 2009
Messages
74
i tried testing the trigger (as well as adding the new variable) and now a bug happens where a ton of units spawn for each player randomly on the map (instead of just one)

im pretty sure the problem rests the initialize trigger, can you see where i went wrong ;/

  • Initialize
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set Game = True
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                • Then - Actions
                  • Set Spawn = (Random point in Arena <gen>)
                  • Set Player_Count = (Player_Count + 1)
                  • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for (Picked player) at Spawn facing Default building facing degrees
                  • Set Player_Unit[(Integer A)] = (Last created unit)
                • Else - Actions
      • Wait 10.00 seconds
      • Trigger - Run Unit Change <gen> (checking conditions)
 
Level 4
Joined
Jan 23, 2009
Messages
74
  • Unit catalog
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
      • Set Catalog[1] = Peasant
      • Set Catalog[2] = Footman
      • Set Catalog[3] = Knight
      • Set Catalog[4] = Rifleman
      • Set Catalog[5] = Mortar Team
      • Set Catalog[6] = Flying Machine
      • Set Catalog[7] = Gryphon Rider
      • Set Catalog[8] = Priest
      • Set Catalog[9] = Sorceress
      • Set Catalog[10] = Siege Engine
      • Set Catalog[11] = Spell Breaker
      • Set Catalog[12] = Dragonhawk Rider
      • Set Catalog[13] = Guard Tower
      • Set Catalog[14] = Cannon Tower
      • Set Catalog[15] = Peon
      • Set Catalog[16] = Grunt
      • Set Catalog[17] = Raider
      • Set Catalog[18] = Tauren
      • Set Catalog[19] = Troll Headhunter
      • Set Catalog[20] = Demolisher
      • Set Catalog[21] = Kodo Beast
      • Set Catalog[22] = Wind Rider
      • Set Catalog[23] = Troll Batrider
      • Set Catalog[24] = Troll Witch Doctor
      • Set Catalog[25] = Shaman
      • Set Catalog[26] = Spirit Walker
      • Set Catalog[27] = Watch Tower
      • Set Catalog[28] = Troll Berserker
      • Set Catalog[29] = Serpent Ward (Level 3)
      • Set Catalog[30] = Water Elemental (Level 2)
      • Set Catalog[31] = Phoenix
      • Set Catalog[32] = Acolyte
      • Set Catalog[33] = Ghoul
      • Set Catalog[34] = Shade
      • Set Catalog[35] = Meat Wagon
      • Set Catalog[36] = Crypt Fiend
      • Set Catalog[37] = Banshee
      • Set Catalog[38] = Gargoyle
      • Set Catalog[39] = Necromancer
      • Set Catalog[40] = Obsidian Statue
      • Set Catalog[41] = Frost Wyrm
      • Set Catalog[42] = Destroyer
      • Set Catalog[43] = Skeleton Warrior
      • Set Catalog[44] = Carrion Beetle (Level 3)
      • Set Catalog[45] = Wisp
      • Set Catalog[46] = Archer
      • Set Catalog[47] = Huntress
      • Set Catalog[48] = Dryad
      • Set Catalog[49] = Glaive Thrower
      • Set Catalog[50] = Hippogryph
      • Set Catalog[51] = Hippogryph Rider
      • Set Catalog[52] = Chimaera
      • Set Catalog[53] = Druid of the Talon (Night Elf Form)
      • Set Catalog[54] = Druid of the Claw (Night Elf Form)
      • Set Catalog[55] = Mountain Giant
      • Set Catalog[56] = Faerie Dragon
      • Set Catalog[57] = Ancient Protector
      • Set Catalog[58] = Treant
      • Set Catalog[59] = Mur'gul Slave
      • Set Catalog[60] = Couatl
      • Set Catalog[61] = Mur'gul Reaver
      • Set Catalog[62] = Naga Siren
      • Set Catalog[63] = Snap Dragon
      • Set Catalog[64] = Naga Myrmidon
      • Set Catalog[65] = Naga Royal Guard
      • Set Catalog[66] = Dragon Turtle
      • Set Catalog[67] = Tidal Guardian
      • Set Catalog[68] = Abomination
As to the "P.S." that a very good question :hohum:

zomg i may have found the answer
trigger goes from this
  • Initialize
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set Game = True
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • Set Spawn = (Random point in Arena <gen>)
              • Set Player_Count = (Player_Count + 1)
              • Unit - Create 1 Catalog[(Random integer number between 1 and 67)] for (Picked player) at Spawn facing Default building facing degrees
              • Set Player_Unit[(Integer A)] = (Last created unit)
      • Wait 10.00 seconds
      • Trigger - Run Unit Change <gen> (checking conditions)
to this
  • Initialize
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set Game = True
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • Set Spawn = (Random point in Arena <gen>)
              • Set Player_Count = (Player_Count + 1)
              • Unit - Create 1 Catalog[(Random integer number between 1 and 68)] for (Picked player) at Spawn facing Default building facing degrees
              • Set Player_Unit[(Integer A)] = (Last created unit)
      • Wait 10.00 seconds
      • Trigger - Run Unit Change <gen> (checking conditions)
im an idiot for not realizing it, since there were 68 different units cataloged, i shoulda changed the integer

i hope this fixes it :)

EDIT: EPIC FAIL
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
Comment on your first post...
Never make so big,bad and boring triggers,you can always avoid it!

for example:
store all color codes in Array Variable Type String called "Color"

set Color[1] = red code
set Color[2] = blue code
......

than to show player name with his color use

Color[number of player] + Name of Player

also,you can use this to hide link or long triggers/descriptions (go to Quote to see)

anything you want here

TITLE of Link
 
Status
Not open for further replies.
Top