• 🏆 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 open/close issue

Status
Not open for further replies.
Level 10
Joined
Mar 17, 2012
Messages
579
Hello everyone! I have a small issue with gates that I haven't seen before.
Whenever I open and close the gate via triggers, it stops blocking units, they can walk through it.
Maybe you could help me to find the solution.
Here are the triggers:

open
  • Gate Open Red
    • Events
      • Unit - A unit enters Farm Gate Red <gen>
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Owner of (Triggering unit)) Equal to Player 1 (Red)
                  • (Unit-type of (Triggering unit)) Equal to Peasant
              • (Unit-type of (Triggering unit)) Equal to Thief
          • (Current life of Gate[1]) Greater than 0.00
    • Actions
      • Set Gate_Health[1] = (Current life of Gate[1])
      • Destructible - Open Gate[1]
      • Destructible - Set life of Gate[1] to Gate_Health[1]
close
  • Gate Close Red
    • Events
      • Unit - A unit leaves Farm Gate Red <gen>
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
          • (Unit-type of (Triggering unit)) Equal to Peasant
          • (Current life of Gate[1]) Greater than 0.00
    • Actions
      • Set Gate_Red_Group = (Units in Farm Gate Red <gen> matching ((((Matching unit) is A structure) Not equal to True) and ((Owner of (Matching unit)) Equal to Player 1 (Red))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Gate_Red_Group) Equal to 0
        • Then - Actions
          • Set Gate_Health[1] = (Current life of Gate[1])
          • Destructible - Close Gate[1]
          • Destructible - Close Gate[1]
          • Destructible - Set life of Gate[1] to Gate_Health[1]
        • Else - Actions
      • Custom script: call DestroyGroup(udg_Gate_Red_Group)
off
  • Gate off Red
    • Events
      • Destructible - A destructible within Farm Gate Red <gen> dies
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Dying destructible) Equal to Gate[1]
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Killing unit)) Equal to Peasant
              • (Unit-type of (Killing unit)) Equal to Thief
    • Actions
      • Trigger - Turn off Gate Open Red <gen>
      • Trigger - Turn off Gate Close Red <gen>
Thanks in advance!
 
Level 9
Joined
Jul 30, 2018
Messages
445
It's most likely the setting of life. A gate that is opened has 0 life. If you change that and then the gate is attacked, it will appear as if it was closed, but it actually is not and will allow units move through it. I don't know how far this goes, but it might actually mess up the whole pathing system, as it is based on the life of the gate (0 meaning it's passable).

You might want to make the gate invulnerable when it's open.


Also, a side note: "and" condition is in most cases useless. If you just put multiple conditions under the conditions, the default is And. And is needed quite rarely, in fact you have one need for it on the first trigger:

  • Conditions
    • (Current life of Gate[1]) Greater than 0.00
    • Or - Any (Conditions) are true
      • Conditions
        • And - All (Conditions) are true
          • Conditions
            • (Owner of (Triggering unit)) Equal to Player 1 (Red)
            • (Unit-type of (Triggering unit)) Equal to Peasant
        • (Unit-type of (Triggering unit)) Equal to Thief
But the others don't need it at all. It will make the trigger a lot easier to read. :)
 
Level 10
Joined
Mar 17, 2012
Messages
579
It's most likely the setting of life. A gate that is opened has 0 life. If you change that and then the gate is attacked, it will appear as if it was closed, but it actually is not and will allow units move through it. I don't know how far this goes, but it might actually mess up the whole pathing system, as it is based on the life of the gate (0 meaning it's passable).

You might want to make the gate invulnerable when it's open.


Also, a side note: "and" condition is in most cases useless. If you just put multiple conditions under the conditions, the default is And. And is needed quite rarely, in fact you have one need for it on the first trigger:

  • Conditions
    • (Current life of Gate[1]) Greater than 0.00
    • Or - Any (Conditions) are true
      • Conditions
        • And - All (Conditions) are true
          • Conditions
            • (Owner of (Triggering unit)) Equal to Player 1 (Red)
            • (Unit-type of (Triggering unit)) Equal to Peasant
        • (Unit-type of (Triggering unit)) Equal to Thief
But the others don't need it at all. It will make the trigger a lot easier to read. :)

Thanks, I'm definitly going to try making gate invulnerable while open, it's a good idea.
As for "and"s, I've had a couple situations when "default and" didn't work out, so since then I've been using only "force and" :)
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
As for "and"s, I've had a couple situations when "default and" didn't work out
This is impossible; I guarantee you improperly formatted/grouped/wrote at least one of your conditions. If there was a situation in which TriggerConditions, the way If-blocks are formatted, or GetBooleanAnd() (what GUI uses instead of an AND operator) were improperly implemented and so would return false when true or true when false... then someone in the wc3 community would have noticed that in the 16 years since this game was released and we would all know not to do things that way.
 
Level 10
Joined
Mar 17, 2012
Messages
579
This is impossible; I guarantee you improperly formatted/grouped/wrote at least one of your conditions. If there was a situation in which TriggerConditions, the way If-blocks are formatted, or GetBooleanAnd() (what GUI uses instead of an AND operator) were improperly implemented and so would return false when true or true when false... then someone in the wc3 community would have noticed that in the 16 years since this game was released and we would all know not to do things that way.

You are probably right, but the fact is that using "default and condition" in a simple "if" did not work for me while "and multiple actions" did, without changing other trigger parts!
I assume that 2 coincidences are possible, but I have learned my lesson and use this kind of precautionary measure.

If I find this trigger, I'll share it so you could see it for yourself :)
 
Status
Not open for further replies.
Top