• 🏆 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!

Gates with levers

Status
Not open for further replies.
Level 1
Joined
Oct 4, 2013
Messages
4
Hello, Ive been working upon a map to have fun with my friends but Ive stumbled on the following problem. I want to create a room with 3 levers and 3 gates. Each lever opens a gate and closes the other two. Can anyone give me some advice on how to do that. Im still new to map editing. Thanks
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Store the doodads like:
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set LeversAndGates[0] = Lever 0001 <gen>
    • Set LeversAndGates[1] = Lever 0002 <gen>
    • Set LeversAndGates[2] = Lever 0003 <gen>
    • Set LeversAndGates[3] = Gate 0001 <gen>
    • Set LeversAndGates[4] = Gate 0002 <gen>
    • Set LeversAndGates[5] = Gate 0003<gen>
    • For each IndexInteger from 0 to 2
      • Loop - Actions
        • Trigger - Add to 2ndTrigger the event (Destructible - LeversAndGates[IndexInteger]dies)
Then you have the following trigger:
  • Events
  • Conditions
  • Actions
    • For each IntegerIndex from 0 to 2, do (Actions)
      • If (Dying destructible) equal to LeversAndGates[IntegerIndex]
        • Then
          • Destructible - Open LeversAndGates[IntegerIndex + 3]
        • Else
          • Desctuctible - Close LeversAndGates[integerIndex + 3]
          • You should revive LeversAndGates[IntegerIndex] here, don't remember the syntax
This should work.
Should warn you, that the syntax is probably wrong. If you don't understand what is happening or can't find the correct actions/events/conditions, feel free to ask for further help.


regards
-Ned
 
Level 1
Joined
Oct 4, 2013
Messages
4
Store the doodads like:
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set LeversAndGates[0] = Lever 0001 <gen>
    • Set LeversAndGates[1] = Lever 0002 <gen>
    • Set LeversAndGates[2] = Lever 0003 <gen>
    • Set LeversAndGates[3] = Gate 0001 <gen>
    • Set LeversAndGates[4] = Gate 0002 <gen>
    • Set LeversAndGates[5] = Gate 0003<gen>
    • For each IndexInteger from 0 to 2
      • Loop - Actions
        • Trigger - Add to 2ndTrigger the event (Destructible - LeversAndGates[IndexInteger]dies)
Then you have the following trigger:
  • Events
  • Conditions
  • Actions
    • For each IntegerIndex from 0 to 2, do (Actions)
      • If (Dying destructible) equal to LeversAndGates[IntegerIndex]
        • Then
          • Destructible - Open LeversAndGates[IntegerIndex + 3]
        • Else
          • Desctuctible - Close LeversAndGates[integerIndex + 3]
          • You should revive LeversAndGates[IntegerIndex] here, don't remember the syntax
This should work.
Should warn you, that the syntax is probably wrong. If you don't understand what is happening or can't find the correct actions/events/conditions, feel free to ask for further help.


regards
-Ned


Thanks a lot ill try it out later and tell if it works fine
 
Level 7
Joined
Dec 17, 2017
Messages
134
Also there is a longer way, but if you do not understand loop, it will be easy.
  • Lever 1
    • Events
      • Destructible - Lever 001 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 1
      • Set GateCheck1 = 1
      • If (If conditions) are true Then do (Then actions) else do (Else actions)
      • If - Conditions
        • (((GateCheck2) is equal to 1) and ((GateCheck3) is equal to 1))
      • Then - Actions
        • Destructible - Close Gate 2
        • Set GateCheck2 = 0
        • Destructible - Close Gate 3
        • Set GateCheck3 = 0
        • Else - Actions
          • If (If conditions are true) Then do (Then actions) else do (Else actions)
          • If - Conditions
            • (GateCheck2) is equal to 1
          • Then - Actions
            • Destructible - Close Gate 002
            • Set GateCheck2 = 0
          • Else - Actions
            • If (If conditions are true) Then do (Then actions) else do (Else actions)
            • If - Conditions
              • (GateCheck3) is equal to 1
            • Then - Conditions
              • Destructible - Close Gate 3
              • Set GateCheck3 = 0
            • Else - Conditions
              • Do nothing
Like this, change the other triggers too. This is for Lever 2
  • Lever 2
    • Events
      • Destructible - Lever 002 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 2
      • Set GateCheck2 = 1
      • If (If conditions) are true Then do (Then actions) else do (Else actions)
      • If - Conditions
        • (((GateCheck1) is equal to 1) and ((GateCheck3) is equal to 1)) Then (
      • Then - Actions
        • Destructible - Close Gate 1
        • Set GateCheck1 = 0
        • Destructible - Close Gate 3
        • Set GateCheck3 = 0
        • Else - Actions
          • If (If conditions are true) Then do (Then actions) else do (Else actions)
          • If - Conditions
            • (GateCheck1) is equal to 1
          • Then - Actions
            • Destructible - Close Gate 001
            • Set GateCheck1 = 0
          • Else - Actions
            • If (If conditions are true) Then do (Then actions) else do (Else actions)
            • If - Conditions
              • (GateCheck3) is equal to 1
            • Then - Conditions
              • Destructible - Close Gate 3
              • Set GateCheck3 = 0
            • Else - Conditions
              • Do nothing
Lever 3

  • Lever 3
    • Events
      • Destructible - Lever 003 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 3
      • Set GateCheck3 = 1
      • If (If conditions) are true Then do (Then actions) else do (Else actions)
      • If - Conditions
        • (((GateCheck1) is equal to 1) and ((GateCheck2) is equal to 1)) Then (
      • Then - Actions
        • Destructible - Close Gate 2
        • Set GateCheck2 = 0
        • Destructible - Close Gate 1
        • Set GateCheck1 = 0
        • Else - Actions
          • If (If conditions are true) Then do (Then actions) else do (Else actions)
          • If - Conditions
            • (GateCheck2) is equal to 1
          • Then - Actions
            • Destructible - Close Gate 002
            • Set GateCheck2 = 0
          • Else - Actions
            • If (If conditions are true) Then do (Then actions) else do (Else actions)
            • If - Conditions
              • (GateCheck1) is equal to 1
            • Then - Conditions
              • Destructible - Close Gate 1
              • Set GateCheck1 = 0
            • Else - Conditions
              • Do nothing
This is more simple if you find loop hard and do not know the basics of loop. But if you know, you can do the method stated by Ned
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Also there is a longer way, but if you do not understand loop, it will be easy.
  • Lever 1
    • Events
      • Destructible - Lever 001 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 1
      • Set GateCheck1 = 1
      • If (If conditions) are true Then do (Then actions) else do (Else actions)
      • If - Conditions
        • (((GateCheck2) is equal to 1) and ((GateCheck3) is equal to 1))
      • Then - Actions
        • Destructible - Close Gate 2
        • Set GateCheck2 = 0
        • Destructible - Close Gate 3
        • Set GateCheck3 = 0
        • Else - Actions
          • If (If conditions are true) Then do (Then actions) else do (Else actions)
          • If - Conditions
            • (GateCheck2) is equal to 1
          • Then - Actions
            • Destructible - Close Gate 002
            • Set GateCheck2 = 0
          • Else - Actions
            • If (If conditions are true) Then do (Then actions) else do (Else actions)
            • If - Conditions
              • (GateCheck3) is equal to 1
            • Then - Conditions
              • Destructible - Close Gate 3
              • Set GateCheck3 = 0
            • Else - Conditions
              • Do nothing
Like this, change the other triggers too. This is for Lever 2
  • Lever 2
    • Events
      • Destructible - Lever 002 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 2
      • Set GateCheck2 = 1
      • If (If conditions) are true Then do (Then actions) else do (Else actions)
      • If - Conditions
        • (((GateCheck1) is equal to 1) and ((GateCheck3) is equal to 1)) Then (
      • Then - Actions
        • Destructible - Close Gate 1
        • Set GateCheck1 = 0
        • Destructible - Close Gate 3
        • Set GateCheck3 = 0
        • Else - Actions
          • If (If conditions are true) Then do (Then actions) else do (Else actions)
          • If - Conditions
            • (GateCheck1) is equal to 1
          • Then - Actions
            • Destructible - Close Gate 001
            • Set GateCheck1 = 0
          • Else - Actions
            • If (If conditions are true) Then do (Then actions) else do (Else actions)
            • If - Conditions
              • (GateCheck3) is equal to 1
            • Then - Conditions
              • Destructible - Close Gate 3
              • Set GateCheck3 = 0
            • Else - Conditions
              • Do nothing
Lever 3

  • Lever 3
    • Events
      • Destructible - Lever 003 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 3
      • Set GateCheck3 = 1
      • If (If conditions) are true Then do (Then actions) else do (Else actions)
      • If - Conditions
        • (((GateCheck1) is equal to 1) and ((GateCheck2) is equal to 1)) Then (
      • Then - Actions
        • Destructible - Close Gate 2
        • Set GateCheck2 = 0
        • Destructible - Close Gate 1
        • Set GateCheck1 = 0
        • Else - Actions
          • If (If conditions are true) Then do (Then actions) else do (Else actions)
          • If - Conditions
            • (GateCheck2) is equal to 1
          • Then - Actions
            • Destructible - Close Gate 002
            • Set GateCheck2 = 0
          • Else - Actions
            • If (If conditions are true) Then do (Then actions) else do (Else actions)
            • If - Conditions
              • (GateCheck1) is equal to 1
            • Then - Conditions
              • Destructible - Close Gate 1
              • Set GateCheck1 = 0
            • Else - Conditions
              • Do nothing
This is more simple if you find loop hard and do not know the basics of loop. But if you know, you can do the method stated by Ned
Oh, haay. Amm this is needlessly complicated... it can be dumbed down to:


  • Lever 1
    • Events
      • Destructible - Lever 001 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 1
      • Destructible - Close Gate 2
      • Destructible - Close Gate 3
      • Revive Lever 2
      • Revive Lever 3
  • Lever 2
    • Events
      • Destructible - Lever 002 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 2
      • Destructible - Close Gate 1
      • Destructible - Close Gate 3
      • Revive Lever 1
      • Revive Lever 3
  • Lever 3
    • Events
      • Destructible - Lever 003 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 3
      • Destructible - Close Gate 1
      • Destructible - Close Gate 2
      • Revive Lever 1
      • Revive Lever 2
There is absolutely no need for all of the If - Then / Else

Also,
  • Do nothing
this is practically considered a leak.

My variant is a bit easier to configure, abishkar's is easier to understand.
I do have to agree that my is a bit of overkill if there are only 3 gates out there.

regards
-Ned
 
Level 7
Joined
Dec 17, 2017
Messages
134
Okay, I tried the above triggers with a little help from my brother, who is a really good leak detector and has been playing Warcraft for 25 years. Okay let us describe the draw backs of all the above triggers :
Drawbacks of Ned's first trigger code :
Store the doodads like:
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set LeversAndGates[0] = Lever 0001 <gen>
    • Set LeversAndGates[1] = Lever 0002 <gen>
    • Set LeversAndGates[2] = Lever 0003 <gen>
    • Set LeversAndGates[3] = Gate 0001 <gen>
    • Set LeversAndGates[4] = Gate 0002 <gen>
    • Set LeversAndGates[5] = Gate 0003<gen>
    • For each IndexInteger from 0 to 2
      • Loop - Actions
        • Trigger - Add to 2ndTrigger the event (Destructible - LeversAndGates[IndexInteger]dies)
Then you have the following trigger:
  • Events
  • Conditions
  • Actions
    • For each IntegerIndex from 0 to 2, do (Actions)
      • If (Dying destructible) equal to LeversAndGates[IntegerIndex]
        • Then
          • Destructible - Open LeversAndGates[IntegerIndex + 3]
        • Else
          • Desctuctible - Close LeversAndGates[integerIndex + 3]
          • You should revive LeversAndGates[IntegerIndex] here, don't remember the syntax
This should work.
Should warn you, that the syntax is probably wrong. If you don't understand what is happening or can't find the correct actions/events/conditions, feel free to ask for further help.


regards
-Ned
1. This trigger is too complicated for this, and maybe a little hard for beginners.

Drawbacks of my trigger:
Also there is a longer way, but if you do not understand loop, it will be easy.
  • Lever 1
    • Events
      • Destructible - Lever 001 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 1
      • Set GateCheck1 = 1
      • If (If conditions) are true Then do (Then actions) else do (Else actions)
      • If - Conditions
        • (((GateCheck2) is equal to 1) and ((GateCheck3) is equal to 1))
      • Then - Actions
        • Destructible - Close Gate 2
        • Set GateCheck2 = 0
        • Destructible - Close Gate 3
        • Set GateCheck3 = 0
        • Else - Actions
          • If (If conditions are true) Then do (Then actions) else do (Else actions)
          • If - Conditions
            • (GateCheck2) is equal to 1
          • Then - Actions
            • Destructible - Close Gate 002
            • Set GateCheck2 = 0
          • Else - Actions
            • If (If conditions are true) Then do (Then actions) else do (Else actions)
            • If - Conditions
              • (GateCheck3) is equal to 1
            • Then - Conditions
              • Destructible - Close Gate 3
              • Set GateCheck3 = 0
            • Else - Conditions
              • Do nothing
Like this, change the other triggers too. This is for Lever 2
  • Lever 2
    • Events
      • Destructible - Lever 002 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 2
      • Set GateCheck2 = 1
      • If (If conditions) are true Then do (Then actions) else do (Else actions)
      • If - Conditions
        • (((GateCheck1) is equal to 1) and ((GateCheck3) is equal to 1)) Then (
      • Then - Actions
        • Destructible - Close Gate 1
        • Set GateCheck1 = 0
        • Destructible - Close Gate 3
        • Set GateCheck3 = 0
        • Else - Actions
          • If (If conditions are true) Then do (Then actions) else do (Else actions)
          • If - Conditions
            • (GateCheck1) is equal to 1
          • Then - Actions
            • Destructible - Close Gate 001
            • Set GateCheck1 = 0
          • Else - Actions
            • If (If conditions are true) Then do (Then actions) else do (Else actions)
            • If - Conditions
              • (GateCheck3) is equal to 1
            • Then - Conditions
              • Destructible - Close Gate 3
              • Set GateCheck3 = 0
            • Else - Conditions
              • Do nothing
Lever 3

  • Lever 3
    • Events
      • Destructible - Lever 003 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 3
      • Set GateCheck3 = 1
      • If (If conditions) are true Then do (Then actions) else do (Else actions)
      • If - Conditions
        • (((GateCheck1) is equal to 1) and ((GateCheck2) is equal to 1)) Then (
      • Then - Actions
        • Destructible - Close Gate 2
        • Set GateCheck2 = 0
        • Destructible - Close Gate 1
        • Set GateCheck1 = 0
        • Else - Actions
          • If (If conditions are true) Then do (Then actions) else do (Else actions)
          • If - Conditions
            • (GateCheck2) is equal to 1
          • Then - Actions
            • Destructible - Close Gate 002
            • Set GateCheck2 = 0
          • Else - Actions
            • If (If conditions are true) Then do (Then actions) else do (Else actions)
            • If - Conditions
              • (GateCheck1) is equal to 1
            • Then - Conditions
              • Destructible - Close Gate 1
              • Set GateCheck1 = 0
            • Else - Conditions
              • Do nothing
This is more simple if you find loop hard and do not know the basics of loop. But if you know, you can do the method stated by Ned
1. I do not know what I was thinking. I made it really complicated with the nested loops. It can be done easily.

Drawbacks of Ned's Second trigger :
Oh, haay. Amm this is needlessly complicated... it can be dumbed down to:


  • Lever 1
    • Events
      • Destructible - Lever 001 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 1
      • Destructible - Close Gate 2
      • Destructible - Close Gate 3
      • Revive Lever 2
      • Revive Lever 3
  • Lever 2
    • Events
      • Destructible - Lever 002 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 2
      • Destructible - Close Gate 1
      • Destructible - Close Gate 3
      • Revive Lever 1
      • Revive Lever 3
  • Lever 3
    • Events
      • Destructible - Lever 003 dies
    • Conditions
    • Actions
      • Destructible - Open Gate 3
      • Destructible - Close Gate 1
      • Destructible - Close Gate 2
      • Revive Lever 1
      • Revive Lever 2
There is absolutely no need for all of the If - Then / Else

Also,
  • Do nothing
this is practically considered a leak.

My variant is a bit easier to configure, abishkar's is easier to understand.
I do have to agree that my is a bit of overkill if there are only 3 gates out there.

regards
-Ned
1. Well, I never knew about this leak, but I found out that if you order a gate to be closed if it is already closed, then it causes an overlapping memory leak.
2. Another leak, if you revive a lever, it causes a leak, because remember a lever doesn't have a death. It's switch is just shown to go to the other side. Though, it may not appear in game, but it causes a memory leak.

Concluding trigger :
The real leakless trigger would look something like the hybrid of some of Ned's and my triggers. But it also contains some more triggers. But, be assured it's leakfree and works, cause I have tried it.

1. Initialization Trigger
In your initialization trigger, add these actions woth your preexisting ones:
  • Actions
    • Set LeverPoint1 = Random point in Your_First_Lever_Region
    • Destructible - Create a Lever in LeverPoint1
    • Set Lever1Val = (Last created destructible)
    • Custom Script - call RemoveLocation (udg_LeverPoint1)
    • Set LeverPoint2 = Random point in Your_Second_Lever_Region
    • Destructible - Create a Lever in LeverPoint2
    • Set Lever2Val = (Last created destructible)
    • Custom Script - call RemoveLocation (udg_LeverPoint2)
    • Set LeverPoint3 = Random point in Your_Third_Lever_Region
    • Destructible - Create a Lever in LeverPoint3
    • Set Lever3Val = (Last created destructible)
    • Custom Script - call RemoveLocation (udg_LeverPoint3)
Explanation : We assume the destructibles to variables to make the variables change its value later.
Variables LeverPoint1, LeverPoint2 and LeverPoint3 are all region type variables while Lever1Val, Lever2Val and Lever3Val are of type Destructible.

2. Your trigger for Lever 1
  • Lever 1
    • Events
      • Destructible - Lever1Val dies
    • Conditions
    • Actions
      • Destructible - Open Gate 1
      • Set Gate1Open = 1
      • If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
        • If - Conditions
          • (Gate2Open) is equal to 1
        • Then - Actions
          • Destructible - Close Gate 2
          • Set Gate2Open = 0
        • Else - Actions
          • Do nothing
      • If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
        • If - Conditions
          • (Gate3Open) is equal to 1
        • Then - Actions
          • Destructible - Close Gate 3
          • Set Gate3Open = 0
        • Else - Actions
          • Do nothing
      • Destructible - Remove Lever 001 from the game
      • Set Lever1Death = Random point in Your_First_Lever_Region
      • Destructible - Create a Lever in Lever1Death
      • Set Lever1Val = (Last created Destructible)
      • Custom Script - call RemoveLocation (udg_Lever1Death)
Explanation:
First part is clear, I hope. After closing and opening the gates, we remove the lever from the game fully, and create another lever in that region, and assign Lever1Val to the last created destructible (The variable explained in Init Trigger, remember? ) So this will happen in kind of a loop, each time Lever1Val is destroyed.
Similarly the other two triggers:
3. The trigger for second lever
  • Lever 2
    • Events
      • Destructible - Lever2Val dies
    • Conditions
    • Actions
      • Destructible - Open Gate 2
      • Set Gate2Open = 1
      • If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
        • If - Conditions
          • (Gate1Open) is equal to 1
        • Then - Actions
          • Destructible - Close Gate 1
          • Set Gate1Open = 0
        • Else - Actions
          • Do nothing
      • If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
        • If - Conditions
          • (Gate3Open) is equal to 1
        • Then - Actions
          • Destructible - Close Gate 3
          • Set Gate3Open = 0
        • Else - Actions
          • Do nothing
      • Destructible - Remove Lever 002 from the game
      • Set Lever2Death = Random point in Your_Second_Lever_Region
      • Destructible - Create a Lever in Lever2Death
      • Set Lever2Val = (Last created Destructible)
      • Custom Script - call RemoveLocation (udg_Lever2Death)
4. Trigger for third lever :
  • Lever 3
    • Events
      • Destructible - Lever3Val dies
    • Conditions
    • Actions
      • Destructible - Open Gate 3
      • Set Gate3Open = 1
      • If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
        • If - Conditions
          • (Gate2Open) is equal to 1
        • Then - Actions
          • Destructible - Close Gate 2
          • Set Gate2Open = 0
        • Else - Actions
          • Do nothing
      • If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
        • If - Conditions
          • (Gate1Open) is equal to 1
        • Then - Actions
          • Destructible - Close Gate 1
          • Set Gate1Open = 0
        • Else - Actions
          • Do nothing
      • Destructible - Remove Lever 003 from the game
      • Set Lever3Death = Random point in Your_Third_Lever_Region
      • Destructible - Create a Lever in Lever3Death
      • Set Lever3Val = (Last created Destructible)
      • Custom Script - call RemoveLocation (udg_Lever3Death)
Hope I helped ! Also credit to Ned and my brother!
 
Last edited:
Level 12
Joined
Mar 24, 2011
Messages
1,082
1. Well, I never knew about this leak, but I found out that if you order a gate to be closed if it is already closed, then it causes an overlapping memory leak.
2. Another leak, if you revive a lever, it causes a leak, because remember a lever doesn't have a death. It's switch is just shown to go to the other side. Though, it may not appear in game, but it causes a memory leak.

Whooooah, hold on, what exactly leaks and how ???? :|

I demand an explanation on this! :D
I shall test this myself later, but as I am aware, there are no such leaks.

regards
-Ned
 
Last edited:
Status
Not open for further replies.
Top