[Spell] Open/Close Gate efficiently + ignore pathfinding for Gates

Status
Not open for further replies.
Level 12
Joined
May 16, 2020
Messages
660
Hi guys,

In my map I will have 6-8 different gates, which I want to open/close when specific units are nearby/are no longer nearby. The two triggers below work for what I want, but since I would need to create 2 triggers for every gate I end up with 12-16 triggers for just this function, which in my opinion is inefficient.

Also, when some of the gates are open and some closed, my hero takes an inefficient path to the gates which are open, instead of through the closest gates which would would open for him.

So 2 questions:
  1. Is it possible to condense these triggers for every door on the map?
  2. Is it possible for units to treat the gate as "open", even when it's closed?

  • Gate Enter
    • Events
      • Unit - A unit enters Gate North <gen>
    • Conditions
      • Gate_Boolean[1] Equal to False
      • Or - Any (Conditions) are true
        • Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
          • And - All (Conditions) are true
            • Conditions
              • ((Triggering unit) is A Hero) Equal to True
              • ((Triggering unit) belongs to an ally of Player 1 (Red).) Equal to True
    • Actions
      • Set VariableSet Gate_Boolean[1] = True
      • Destructible - Open Gate[1]
  • Gate Exit
    • Events
      • Unit - A unit leaves Gate North <gen>
    • Conditions
      • Gate_Boolean[1] Equal to True
      • (Number of units in (Units in Gate North <gen>)) Equal to 0
      • Or - Any (Conditions) are true
        • Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
          • And - All (Conditions) are true
            • Conditions
              • ((Triggering unit) is A Hero) Equal to True
              • ((Triggering unit) belongs to an ally of Player 1 (Red).) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • Set VariableSet Gate_Boolean[1] = False
          • Destructible - Close Gate[1]
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 69
Joined
Aug 10, 2018
Messages
7,166
To treat the gate as open, you would want to remove the pathing from the gate and trigger the pathing with a push effect. A unit enters Gate Region -> If Gate = Closed -> Push unit back.

And to make things more efficient you can store the gate Regions in an Array, and then use a For Loop to detect which Region your entering unit is in.

So you would create the Array:
  • Set GateRegion[1] = Gate North
  • Set GateRegion[2] = Gate South
Then you would add all of the enters Gate Events to a single trigger:
  • Unit - A unit enters Gate North
  • Unit - A unit enters Gate South
Then use a For Loop to detect if "GateRegion[X] contains triggering unit".

Also, Regions have sizing issues that will cause many problems. A solution can be found in my bottom post in this thread:
RectContainsUnit doesn't work
 
Status
Not open for further replies.
Top