"Unit leaves region" problems

Kitt

New Member
Reaction score
5
Alright, what i'm making is a gate that opens itself when an allied unit comes close, and closes when it leaves. I have two triggers, one to detect when they're near and play an animation (opening animation) and one to detect when no allied unit is near, and play and animation (closing animation).

The open trigger works perfectly, however, the closing trigger never closes the gate.

Open trigger:
Code:
Open Gate
    Events
        Unit - A unit enters (Region centered at (Position of Orc Gate (north) 0005 <gen>) with size (400.00, 100.00))
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Owner of (Entering unit)) Equal to Player 1 (Red)
                (Owner of (Entering unit)) Equal to Player 4 (Purple)
                (Owner of (Entering unit)) Equal to Player 5 (Yellow)
                (Owner of (Entering unit)) Equal to Player 6 (Orange)
    Actions
        Animation - Play Orc Gate (north) 0005 <gen>'s Death Alternate animation

Close Trigger:
Code:
Close Gate
    Events
        Unit - A unit leaves (Region centered at (Position of Orc Gate (north) 0005 <gen>) with size (400.00, 100.00))
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Region centered at (Position of Orc Gate (north) 0005 <gen>) with size (400.00, 100.00))) and do (Actions)
            Loop - Actions
                -------- If any Unit is an Orc Unit --------
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Or - Any (Conditions) are true
                            Conditions
                                (Owner of (Picked unit)) Equal to Player 1 (Red)
                                (Owner of (Picked unit)) Equal to Player 4 (Purple)
                                (Owner of (Picked unit)) Equal to Player 5 (Yellow)
                                (Owner of (Picked unit)) Equal to Player 6 (Orange)
                    Then - Actions
                        Set Orc_KeepGateOpen = True
                    Else - Actions
                        Do nothing
        If (Orc_KeepGateOpen Equal to False) then do (Animation - Play Orc Gate (north) 0005 <gen>'s Stand animation) else do (Do nothing)
        Set Orc_KeepGateOpen = False

Any advice?

Mrow.
 
G

Ghoulfrenzy

Guest
Instead of playing animations use the actions "Destructible- Open Gate" and "Destructible- Close Gate"

-Ghoulfrenzy
 

Rad

...
Reaction score
228
Well first of all instead of playing the animation you can use Destructible Open/Close/Destroy gate, does just what it says.

Also, instead of checking the race of every unit near the gate to determine if there is ANY orc units, use integer - count units in <group>.

And isnt there a race condition instead of player conditions? Not sure if it would work though.
 
G

Ghoulfrenzy

Guest
Rad said:
Well first of all instead of playing the animation you can use Destructible Open/Close/Destroy gate, does just what it says.

What I said. :)

-Ghoulfrenzy
 

Rad

...
Reaction score
228
Yea well we must have clicked 'Post Reply' at the same time, yours was shorter so you got that part first :rolleyes:
 

Kitt

New Member
Reaction score
5
Yes, but the destructable trigger for opening/closing/destroying only works on a destructable. The gate i'm using i want to be an actual unit, owned by a player, not a destructable. That way it can do things such as be repaired, be built, share vision and etc. with the owning player, without having to make special triggers just for each of those things.

testing rad's suggestion for count untis in group. report shortly.

Mrow.
 

Kitt

New Member
Reaction score
5
Bingo, got it. The problem was that it was counting the gate as an owned unit aswell, and thus never closing. Here are my two (working) triggers, if anyone is curious.

Open Trigger:
Code:
Open Gate
    Events
        Unit - A unit enters (Region centered at (Position of Orc Gate (north) 0005 <gen>) with size (400.00, 100.00))
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Owner of (Entering unit)) Equal to Player 1 (Red)
                (Owner of (Entering unit)) Equal to Player 4 (Purple)
                (Owner of (Entering unit)) Equal to Player 5 (Yellow)
                (Owner of (Entering unit)) Equal to Player 6 (Orange)
    Actions
        Animation - Play Orc Gate (north) 0005 <gen>'s Death Alternate animation

Close Trigger
Code:
Close Gate
    Events
        Unit - A unit leaves (Region centered at (Position of Orc Gate (north) 0005 <gen>) with size (400.00, 100.00))
    Conditions
        (Number of units in (Units in (Region centered at (Position of Orc Gate (north) 0005 <gen>) with size (400.00, 100.00)) owned by Player 1 (Red))) Equal to 1
    Actions
        Animation - Play Orc Gate (north) 0005 <gen>'s stand animation

Meow!
 

Rad

...
Reaction score
228
Yay you solved it yourself...

Does the pathing and everything else work to?
 

DM Cross

You want to see a magic trick?
Reaction score
568
Code:
Conditions
                (Owner of (Entering unit)) Equal to Player 1 (Red)
                (Owner of (Entering unit)) Equal to Player 4 (Purple)
                (Owner of (Entering unit)) Equal to Player 5 (Yellow)
                (Owner of (Entering unit)) Equal to Player 6 (Orange)

Just a note:
You can use "Owner of Entering unit is an Ally of (whatever play owns the gate)" to make it a little bit neater.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top