Trigger for opening and closing door with lever destructible.

Level 5
Joined
Sep 10, 2023
Messages
69
Hello im making a trigger for closing and opening a door with a single lever destructible. So far I can make it open only or close within a wait trigger. How can I make it work? Also it would be nice if the trigger had a condition that only players from force 1 (1 to 10) can open the gate with the lever and with force 2 attacking the lever wont do anything.

  • Gate
    • Events
      • Destructible - Lever 0005 <gen> dies
    • Conditions
    • Actions
      • Destructible - Open Dungeon Gate (Horizontal) 0006 <gen>
      • Destructible - Resurrect Lever 0005 <gen> with (Max life of (Last created destructible)) life and Show birth animation
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Dungeon Gate (Horizontal) 0006 <gen> is dead) Equal to True
        • Then - Actions
          • Destructible - Close Dungeon Gate (Horizontal) 0006 <gen>
          • Trigger - Add to (This trigger) the event (Destructible - Lever 0005 <gen> dies)
        • Else - Actions
  • /TRIGGER]
  • [/SPOILER]
 

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,634
I don't see a Wait there, what do you mean exactly? Is that trigger what you WANT to work?

Anyway, I would personally opt for a more elaborate system, give your desired units a hidden ability based on Channel, allow it to target Levers (destructibles), and catch when someone right clicks (smart order/attack order) a lever and issue an order to cast the Channel ability on that target instead. Once the ability begins casting you can alternate the state of the Lever. You may need to choose a different ability if Channel cannot be made to target destructibles.

Something like this for the ability trigger:
  • Events
    • Unit - A unit Begins casting an ability
  • Conditions
    • (Ability being cast) Equal to Interact
    • (Target destructible of ability being cast) Equal to Lever 0005 <gen>
    • ((Owner of (Triggering unit)) is in Team 0) Equal to True
  • Actions
    • Set Variable Lever_State = (Lever_State + 1)
    • If all conditions are true then do (Actions)
      • If - Conditions
        • (Lever_State mod 2) Equal to 0 // Modulo
      • Then - Actions
        • Destructible - Close Dungeon Gate (Horizontal) 0006 <gen>
        • Destructible - Play stand animation for Lever 0005 <gen>
      • Else - Actions
        • Destructible - Open Dungeon Gate (Horizontal) 0006 <gen>
        • Destructible - Play death animation for Lever 0005 <gen>
No killing required, simply play the death/stand animation to bounce between the two lever states. I ain't a math guy but the Modulo here basically says "If Lever State is a multiple of 2 (even number) then do these actions, otherwise do these other actions". On the first use Lever_State will be set to 1, which will run the Else - Actions. From there it will alternate infinitely, assuming I didn't screw something up.
 
Last edited:
Level 5
Joined
Sep 10, 2023
Messages
69
I don't see a Wait there, what do you mean exactly? Is that trigger what you WANT to work?
It was this one.
  • Door LB Open
    • Events
      • Destructible - Lever 22721 <gen> dies
    • Conditions
    • Actions
      • Wait 1.00 seconds
      • Destructible - Open Gate (Horizontal) 16498 <gen>
      • Wait 3.00 seconds
      • Destructible - Resurrect Lever 22721 <gen> with (Max life of (Last created destructible)) life and Show birth animation
      • Trigger - Add to (This trigger) the event (Destructible - Lever 22721 <gen> dies)
      • Wait 1.00 seconds
      • Destructible - Close Gate (Horizontal) 16498 <gen>
      • Wait 3.00 seconds
      • Destructible - Resurrect Lever 22721 <gen> with (Max life of (Last created destructible)) life and Show birth animation

Thanks, thats seems complicated I would never had it guess that it would take that to just open and close a door. I will try. I have many gates that need opening and closing it wouldnt be a problem right?
 

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,634
Unfortunately you cannot detect who killed a Destructible - as far as I know. Otherwise, you could likely stick with the simple approach. You'll want to use a unique variable for each Lever, an Integer array would be a good choice.

I'll mention some other things:

This seems unnecessary:
  • Trigger - Add to (This trigger) the event (Destructible - Lever 22721 <gen> dies)
Did it not work without that or something? Because it's identical to your original Event, which should remain working throughout the entire session.

These should reference the Destructible directly, not (Last created destructible). Or just set it to a specific value.
  • Destructible - Resurrect Lever 22721 <gen> with (Max life of (Last created destructible)) life and Show birth animation
  • Destructible - Resurrect Lever 22721 <gen> with (Max life of (Last created destructible)) life and Show birth animation
Remember that (Last created) anything literally means the last of that type of thing to be created, which could happen in other triggers, say if two Levers were to be destroyed around the same time. Waits complicate this since you create a period of time in which the "Last" thing can change to something else.
 
Level 5
Joined
Sep 10, 2023
Messages
69
Unfortunately you cannot detect who killed a Destructible - as far as I know. Otherwise, you could likely stick with the simple approach. You'll want to use a unique variable for each Lever, an Integer array would be a good choice.

I'll mention some other things:

This seems unnecessary:
  • Trigger - Add to (This trigger) the event (Destructible - Lever 22721 <gen> dies)
Did it not work without that or something? Because it's identical to your original Event, which should remain working throughout the entire session.

These should reference the Destructible directly, not (Last created destructible). Or just set it to a specific value.
  • Destructible - Resurrect Lever 22721 <gen> with (Max life of (Last created destructible)) life and Show birth animation
  • Destructible - Resurrect Lever 22721 <gen> with (Max life of (Last created destructible)) life and Show birth animation
Remember that (Last created) anything literally means the last of that type of thing to be created, which could happen in other triggers, say if two Levers were to be destroyed around the same time. Waits complicate this since you create a period of time in which the "Last" thing can change to something else.
If I remember correctly it only opened or just nothing happened if I didnt try the add event for some reason. I could be wrong tried many things. Thanks as always Uncle-
 
Level 29
Joined
Aug 29, 2012
Messages
1,324
You could turn the destructible into an unit instead, based on e.g. a chicken, change the model, set its movement to none, etc.

The main advantage is that units are much easier to work with than destructibles, you have a lot more functions related to them, and this way you could easily get who has killed the lever
 
Level 5
Joined
Sep 10, 2023
Messages
69
You could turn the destructible into an unit instead, based on e.g. a chicken, change the model, set its movement to none, etc.

The main advantage is that units are much easier to work with than destructibles, you have a lot more functions related to them, and this way you could easily get who has killed the lever
Will definetly look into it. I thought on using a unit at the beginning of this process but saw on other triggers that they used destructibles so I went with it
 
Top