• 🏆 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] Random Lever Action

Status
Not open for further replies.
Level 17
Joined
Jun 12, 2007
Messages
1,261
I'm in need of some help here.
I am making a map for the paired mapmaking contest and I took upon the role to make the puzzles.
Well one of the puzzles is a room with 6 levers (it's a destructable lolz).
One of these levers will open the gate to the next room. The other 5 will spawn monsters.

How do I randomize this at the start of the game. And don't say stuf like, use booleans and integers, I get that part. I just forgot how to do this. xD


As a final motivation I'll rep people that help. *sighs*
 
Level 6
Joined
Sep 13, 2008
Messages
261
I would roll a random integer and if integer equals x disable that levers trigger and enable alternate trigger. To clarify Have a unit array set up in advance for the levers.

lever[1]-[6]

or disable that trigger and set that lever to a unit variable for the already enabled open trigger.

I'd make the triggers for you, but I lost my copy of warcraft and I reinstalled windows today.
 
Last edited:
Level 6
Joined
Sep 13, 2008
Messages
261
I'll try to make the triggers without my editor.

  • Events
  • time elapsed .04 secs
  • Conditions
  • Actions
  • Set Unit[1] = Unit Lever1
  • Set Unit[2] = Unit Lever2
  • Set Unit[3] = Unit Lever3
  • Set Unit[4] = Unit Lever4
  • Set Unit[5] = Unit Lever5
  • Set Unit[6] = Unit Lever6
  • Events
  • time elapsed .30 secs
  • Conditions
  • Actions
  • Set Integer = Random number between 1 and 6
  • Set Unit2 = Unit[Integer]
  • Turn Off Trigger (string (Lever + Integer))

to spawn unit use
  • Events
  • Unit is attacked
  • Conditions
  • Attacked Unit = Lever1
  • Action
  • Unit - Create Unit(Killer of World Editor)
Thats all typed so it may not be exact. Each lever may or may not need its own trigger depending on your triggering skills.
 
Level 9
Joined
May 30, 2008
Messages
430
i have idea how to make it will post it after a while

Edit: this must work
  • Chance to open the gate
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal to lever
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by Player 1 (Red) of type lever)) Equal to 1
        • Then - Actions
          • Set random = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • random Greater than or equal to 0
            • Then - Actions
              • Destructible - Open Elven Gate (Diagonal 1) 0000 <gen>
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by Player 1 (Red) of type lever)) Equal to 2
        • Then - Actions
          • Set random = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • random Greater than 80
            • Then - Actions
              • Destructible - Open Elven Gate (Diagonal 1) 0000 <gen>
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by Player 1 (Red) of type lever)) Equal to 3
        • Then - Actions
          • Set random = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • random Greater than 80
            • Then - Actions
              • Destructible - Open Elven Gate (Diagonal 1) 0000 <gen>
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by Player 1 (Red) of type lever)) Equal to 4
        • Then - Actions
          • Set random = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • random Greater than 80
            • Then - Actions
              • Destructible - Open Elven Gate (Diagonal 1) 0000 <gen>
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by Player 1 (Red) of type lever)) Equal to 5
        • Then - Actions
          • Set random = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • random Greater than 80
            • Then - Actions
              • Destructible - Open Elven Gate (Diagonal 1) 0000 <gen>
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by Player 1 (Red) of type lever)) Equal to 6
        • Then - Actions
          • Set random = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • random Greater than 80
            • Then - Actions
              • Destructible - Open Elven Gate (Diagonal 1) 0000 <gen>
            • Else - Actions
        • Else - Actions
you can change the chance to open the gate. You can add your monsters at else actions
 
Level 9
Joined
May 27, 2006
Messages
498
First off: the lever is a destructible, not a unit.
Second off: the Destructible - (destructible) dies event would be much more efficient here, trigging when the lever is actually hit and switched.
Third off: no need to set the random integer to a number. Just roll Lever[(Random number between 1 and 6)] and do something.
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
onix_noob has provided me with a good solution, while combining it with some bug fixes (because u used unit not destructable like raft_pl said).
I didn't test it yet but for now it looks like this:

  • Room1 Levers
    • Events
      • Destructible - Lever 4155 <gen> dies
      • Destructible - Lever 4153 <gen> dies
      • Destructible - Lever 4154 <gen> dies
      • Destructible - Lever 4142 <gen> dies
      • Destructible - Lever 4141 <gen> dies
      • Destructible - Lever 4143 <gen> dies
    • Conditions
    • Actions
      • Set RoomLevers = (RoomLevers + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RoomLevers Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random real number between 0.00 and 100.00) Greater than or equal to 95.00
            • Then - Actions
              • Destructible - Kill Dungeon Gate (Vertical) 0523 <gen>
              • Trigger - Turn off (This trigger)
              • Trigger - Turn on Room1 Levers Solved <gen>
            • Else - Actions
              • Set PuzzleSpawnLever[1] = (Center of Puzzle1 <gen>)
              • Unit - Create 1 Ghoul for Neutral Hostile at PuzzleSpawnLever[1] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_PuzzleSpawnLever[1])
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RoomLevers Equal to 2
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random real number between 0.00 and 100.00) Greater than or equal to 80.00
            • Then - Actions
              • Destructible - Kill Dungeon Gate (Vertical) 0523 <gen>
              • Trigger - Turn off (This trigger)
              • Trigger - Turn on Room1 Levers Solved <gen>
            • Else - Actions
              • Set PuzzleSpawnLever[1] = (Center of Puzzle1 <gen>)
              • Unit - Create 2 Ghoul for Neutral Hostile at PuzzleSpawnLever[1] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_PuzzleSpawnLever[1])
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RoomLevers Equal to 3
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random real number between 0.00 and 100.00) Greater than or equal to 65.00
            • Then - Actions
              • Destructible - Kill Dungeon Gate (Vertical) 0523 <gen>
              • Trigger - Turn off (This trigger)
              • Trigger - Turn on Room1 Levers Solved <gen>
            • Else - Actions
              • Set PuzzleSpawnLever[1] = (Center of Puzzle1 <gen>)
              • Unit - Create 3 Ghoul for Neutral Hostile at PuzzleSpawnLever[1] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_PuzzleSpawnLever[1])
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RoomLevers Equal to 4
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random real number between 0.00 and 100.00) Greater than or equal to 45.00
            • Then - Actions
              • Destructible - Kill Dungeon Gate (Vertical) 0523 <gen>
              • Trigger - Turn off (This trigger)
              • Trigger - Turn on Room1 Levers Solved <gen>
            • Else - Actions
              • Set PuzzleSpawnLever[1] = (Center of Puzzle1 <gen>)
              • Unit - Create 4 Ghoul for Neutral Hostile at PuzzleSpawnLever[1] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_PuzzleSpawnLever[1])
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RoomLevers Equal to 5
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random real number between 0.00 and 100.00) Greater than or equal to 20.00
            • Then - Actions
              • Destructible - Kill Dungeon Gate (Vertical) 0523 <gen>
              • Trigger - Turn off (This trigger)
              • Trigger - Turn on Room1 Levers Solved <gen>
            • Else - Actions
              • Set PuzzleSpawnLever[1] = (Center of Puzzle1 <gen>)
              • Unit - Create 5 Ghoul for Neutral Hostile at PuzzleSpawnLever[1] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_PuzzleSpawnLever[1])
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RoomLevers Equal to 6
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random real number between 0.00 and 100.00) Greater than or equal to 0.00
            • Then - Actions
              • Destructible - Kill Dungeon Gate (Vertical) 0523 <gen>
              • Trigger - Turn off (This trigger)
              • Trigger - Turn on Room1 Levers Solved <gen>
            • Else - Actions
        • Else - Actions
  • Room1 Levers Solved
    • Events
      • Destructible - Lever 4155 <gen> dies
      • Destructible - Lever 4153 <gen> dies
      • Destructible - Lever 4154 <gen> dies
      • Destructible - Lever 4142 <gen> dies
      • Destructible - Lever 4141 <gen> dies
      • Destructible - Lever 4143 <gen> dies
    • Conditions
    • Actions
      • Set PuzzleSpawnLever[1] = (Center of Puzzle1 <gen>)
      • Unit - Create 5 Ghoul for Neutral Hostile at PuzzleSpawnLever[1] facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_PuzzleSpawnLever[1])
I didn't test it yet but it should work, if not I can fix it myself xD. Thanks alot people. (I still have problems with an other trigger but I made a sepperate post for that. (It's about dialogs not working one way ven though it's the same way but without a cinematic, please check it out if u have any idea's)).

Dialog Problem
 
Status
Not open for further replies.
Top