• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Switches and Gates Problem

Status
Not open for further replies.
Level 4
Joined
Sep 11, 2018
Messages
74
The gate opens several times after closing. Sometimes it works sometimes don't. Any idea?
  • Switches
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (switches[(Integer A)] is dead) Equal to True
            • Then - Actions
              • Destructible - Kill blocker[(Integer A)]
              • Destructible - Open gates[(Integer A)]
              • Trigger - Turn off (This trigger)
              • Wait 5.00 seconds
              • Destructible - Resurrect blocker[(Integer A)] with (Max life of blocker[(Integer A)]) life and Show birth animation
              • Destructible - Resurrect switches[(Integer A)] with (Max life of switches[(Integer A)]) life and Show birth animation
              • Destructible - Close gates[(Integer A)]
              • Trigger - Turn on (This trigger)
            • Else - Actions
 
Level 13
Joined
May 10, 2009
Messages
868
Well, using (Integer A / B) for multiples triggers plus waits is not a good idea because they are global variables. Also, you'll probably have to use 2 loops for that trigger:

Loop
-> Open gates

Wait

Loop again.
-> Close gates
 
Level 4
Joined
Sep 11, 2018
Messages
74
Can you give me an example of the trigger? Won't the 'every 1 second' thing interfere with the wait?
 
Last edited:
Level 6
Joined
Aug 28, 2015
Messages
213
I have Written a small system for you so you can just enter the levers and door you need it's a bit more complex but I commented as much as a think is needed and you can always ask here for help ;)

Waits are evil!!!:mad: not really but try to avoid them:D
  • Initialization
    • Events
      • Time - Elapsed game time is 0.30 seconds
    • Conditions
    • Actions
      • -------- set the intervall the levers should be checked if they are reset --------
      • -------- in my case its 6 times a second increasing this number makes it more precise but cost more reccourses --------
      • Set Lever_TimeInterval = (1.00 / 6.00)
      • -------- set the duration after how many seconds the door should be closed again --------
      • Set Lever_ResetDuration = 5.00
      • -------- set all lever and doors that should be opend as the same array index --------
      • Set Lever_Levers[1] = Lever 0000 <gen>
      • Set Lever_Doors[1] = Elven Gate (Horizontal) 0003 <gen>
      • Set Lever_Levers[2] = Lever 0001 <gen>
      • Set Lever_Doors[2] = Elven Gate (Horizontal) 0004 <gen>
      • Set Lever_Levers[3] = Lever 0002 <gen>
      • Set Lever_Doors[3] = Elven Gate (Horizontal) 0005 <gen>
      • -------- sets the max Lever amount and register the kill event to the kill trigger to open the doors. You don't need to do enything here anymore --------
      • For each (Integer Lever_Index) from 0 to Lever_LeverAmount, do (Actions)
        • Loop - Actions
          • -------- check if there will be more Levers --------
          • Custom script: if ( not(udg_Lever_Levers[udg_Lever_LeverAmount + 1 ] == null)) then
          • Set Lever_LeverAmount = (Lever_LeverAmount + 1)
          • -------- Lever to kill Lever Trigger --------
          • Trigger - Add to Kill Lever <gen> the event (Destructible - Lever_Levers[Lever_LeverAmount] dies)
          • Custom script: endif
  • Kill Lever
    • Events
    • Conditions
    • Actions
      • -------- Check which lever is killed --------
      • For each (Integer Lever_Index) from 1 to Lever_LeverAmount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Dying destructible) Equal to Lever_Levers[Lever_Index]
            • Then - Actions
              • -------- add the killed lever to the is killed lever list and run the timer that checks if it should be reset --------
              • Set Lever_DeadAmount = (Lever_DeadAmount + 1)
              • Set Lever_DeadLeversIndexes[Lever_DeadAmount] = Lever_Index
              • Set Lever_DeadLeversDuration[Lever_DeadAmount] = Lever_ResetDuration
              • -------- check if it is the first lever in that list --------
              • -------- if so we have to start the timer --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Lever_DeadAmount Equal to 1
                • Then - Actions
                  • Countdown Timer - Start Lever_Timer as a One-shot timer that will expire in Lever_TimeInterval seconds
                • Else - Actions
              • -------- open the right door --------
              • Destructible - Open Lever_Doors[Lever_Index]
            • Else - Actions
  • Close Door
    • Events
      • Time - Lever_Timer expires
    • Conditions
    • Actions
      • -------- Check if there is a lever in the dead list --------
      • -------- if not don't run this trigger again --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Lever_DeadAmount Less than or equal to 0
        • Then - Actions
          • Set Lever_DeadAmount = 0
          • Skip remaining actions
        • Else - Actions
      • -------- subtract the intervall amount from the duration and check if the duration is zero --------
      • For each (Integer Lever_DeadIndex) from 1 to Lever_DeadAmount, do (Actions)
        • Loop - Actions
          • Set Lever_DeadLeversDuration[Lever_DeadIndex] = (Lever_DeadLeversDuration[Lever_DeadIndex] - Lever_TimeInterval)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Lever_DeadLeversDuration[Lever_DeadIndex] Less than or equal to 0.00
            • Then - Actions
              • -------- Restore door and lever --------
              • Destructible - Close Lever_Doors[Lever_DeadLeversIndexes[Lever_DeadIndex]]
              • Destructible - Resurrect Lever_Levers[Lever_DeadLeversIndexes[Lever_DeadIndex]] with (Max life of Lever_Levers[Lever_DeadLeversIndexes[Lever_DeadIndex]]) life and Hide birth animation
              • -------- check if the list wasn't finished yet to move the last index to the current --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Lever_DeadIndex Less than Lever_DeadAmount
                • Then - Actions
                  • Set Lever_DeadLeversDuration[Lever_DeadIndex] = Lever_DeadLeversDuration[Lever_DeadAmount]
                  • Set Lever_DeadLeversIndexes[Lever_DeadIndex] = Lever_DeadLeversIndexes[Lever_DeadAmount]
                • Else - Actions
              • -------- remove the last item from the list and set amount as well as index -1 --------
              • Set Lever_DeadLeversDuration[Lever_DeadAmount] = 0.00
              • Set Lever_DeadLeversIndexes[Lever_DeadAmount] = 0
              • Set Lever_DeadAmount = (Lever_DeadAmount - 1)
              • Set Lever_DeadIndex = (Lever_DeadIndex - 1)
            • Else - Actions
      • Countdown Timer - Start Lever_Timer as a One-shot timer that will expire in Lever_TimeInterval seconds
and the Map:


Happy Hollidays!
 

Attachments

  • Lever System.w3x
    20.6 KB · Views: 19
Last edited:
Level 4
Joined
Sep 11, 2018
Messages
74
Instead of Integer A (global variable), I use another integer variable it works. Thanks for your system btw.
 
Last edited:
Status
Not open for further replies.
Top