• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Buildable Gate

Status
Not open for further replies.
Level 6
Joined
Jul 23, 2018
Messages
243
Follow this thread and this site to understand the topic, or you don't need to.
I decided to not use Unit - Replace or the variable, because they seem troublesome and cause leaks although that can be solved with custom script. So I used spell Bear Form instead, and I made several spells based on that. I have 8 units, 4 of them are horizontal and face either North or South, 2 of them has collision and another 2 has no collision. Another 4 of them are vertical and face either East or West, and the same thing with horizontal. Because of that, I made 4 spells based on the spell I mentioned. The problem is, the gate did not trigger Death Alternate animation, and turn into a close-looking but actually open since my unit can walk freely between it, after that I cannot change back to close gate and it keeps being an open gate. Anyone knows how to fix this? Thanks in advance and I appreciate all help.
 
Last edited:
Level 6
Joined
Jul 23, 2018
Messages
243
I have decided to use method from this thread since I was very rude and quick in the first post. And so I'm sorry for that
But this time, I asked you all to help me with this as I've been struggling a lot. These triggers move units every time it casts Close gate ability based on Channel. There are 6 regions, 3 for horizontal gate and 3 for vertical gate. 2 of the regions are for detecting units. The rest detect and decide whether to move units to the top or the bottom of the horizontal gate. Same thing with vertical, 2 regions decide whether moving units right or left of the gate. However, I have a problem with my triggers as I tried to make it MUI by using 1 point trigger along with other 2 integer variables, one is array. Units were not detected in Hori T <Rect> but in Hori B <Rect> instead and moved down.
  • Gate Close Hori South
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Close Gate
      • (Unit-type of (Casting unit)) Equal to Wooden Gate (Opened) (Hori) (Faces South)
    • Actions
      • Set CV = (Custom value of (Casting unit))
      • Set CV_Array[CV] = ((Custom value of (Casting unit)) x 3)
      • Set Loc_Gate[CV_Array[CV]] = (Position of (Casting unit))
      • Set Loc_Gate[CV_Array[CV_Array[CV]]] = (Loc_Gate[CV_Array[CV]] offset by (0.00, 120.00))
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV]]]] = (Loc_Gate[CV_Array[CV]] offset by (0.00, -120.00))
      • Region - Center Gate Hori Det <gen> on Loc_Gate[CV_Array[CV]]
      • Region - Center Gate Hori T <gen> on Loc_Gate[CV_Array[CV_Array[CV]]]
      • Region - Center Gate Hori B <gen> on Loc_Gate[CV_Array[CV_Array[CV_Array[CV]]]]
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]] = (Loc_Gate[CV_Array[CV]] offset by (0.00, 140.00))
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]] = (Loc_Gate[CV_Array[CV]] offset by (0.00, -140.00))
      • Wait 0.02 seconds
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Gate Hori Det <gen> matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is A ground unit) Equal to True))) and do (Actions)
        • Loop - Actions
          • If ((Gate Hori T <gen> contains (Picked unit)) Equal to True) then do (Unit - Move (Picked unit) instantly to Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]) else do (Do nothing)
          • If ((Gate Hori B <gen> contains (Picked unit)) Equal to True) then do (Unit - Move (Picked unit) instantly to Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]]) else do (Do nothing)
      • Wait 0.02 seconds
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]]]])
      • Unit - Replace (Casting unit) with a Wooden Gate (Closed) (Hori) (Faces South) using The old unit's relative life and mana
      • Animation - Play (Last replaced unit)'s stand animation
      • Selection - Select (Last replaced unit) for (Owner of (Casting unit))
  • Gate Close Hori North
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Close Gate
      • (Unit-type of (Casting unit)) Equal to Wooden Gate (Opened) (Hori) (Faces North)
    • Actions
      • Set CV = (Custom value of (Casting unit))
      • Set CV_Array[CV] = ((Custom value of (Casting unit)) x 3)
      • Set Loc_Gate[CV_Array[CV]] = (Position of (Casting unit))
      • Set Loc_Gate[CV_Array[CV_Array[CV]]] = (Loc_Gate[CV_Array[CV]] offset by (0.00, 120.00))
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV]]]] = (Loc_Gate[CV_Array[CV]] offset by (0.00, -120.00))
      • Region - Center Gate Hori Det <gen> on Loc_Gate[CV_Array[CV]]
      • Region - Center Gate Hori T <gen> on Loc_Gate[CV_Array[CV_Array[CV]]]
      • Region - Center Gate Hori B <gen> on Loc_Gate[CV_Array[CV_Array[CV_Array[CV]]]]
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]] = (Loc_Gate[CV_Array[CV]] offset by (0.00, 140.00))
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]] = (Loc_Gate[CV_Array[CV]] offset by (0.00, -140.00))
      • Wait 0.02 seconds
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Gate Hori Det <gen> matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is A ground unit) Equal to True))) and do (Actions)
        • Loop - Actions
          • If ((Gate Hori T <gen> contains (Picked unit)) Equal to True) then do (Unit - Move (Picked unit) instantly to Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]) else do (Do nothing)
          • If ((Gate Hori B <gen> contains (Picked unit)) Equal to True) then do (Unit - Move (Picked unit) instantly to Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]]) else do (Do nothing)
      • Wait 0.02 seconds
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]]]])
      • Unit - Replace (Casting unit) with a Wooden Gate (Closed) (Hori) (Faces North) using The old unit's relative life and mana
      • Animation - Play (Last replaced unit)'s stand animation
      • Selection - Select (Last replaced unit) for (Owner of (Casting unit))
  • Gate Close Vert West
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Close Gate
      • (Unit-type of (Casting unit)) Equal to Wooden Gate (Opened) (Vert) (Faces West)
    • Actions
      • Set CV = (Custom value of (Casting unit))
      • Set CV_Array[CV] = ((Custom value of (Casting unit)) x 3)
      • Set Loc_Gate[CV_Array[CV]] = (Position of (Casting unit))
      • Set Loc_Gate[CV_Array[CV_Array[CV]]] = (Loc_Gate[CV_Array[CV]] offset by (-120.00, 0.00))
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV]]]] = (Loc_Gate[CV_Array[CV]] offset by (120.00, 0.00))
      • Region - Center Gate Vert Det <gen> on Loc_Gate[CV_Array[CV]]
      • Region - Center Gate Vert R <gen> on Loc_Gate[CV_Array[CV_Array[CV]]]
      • Region - Center Gate Vert L <gen> on Loc_Gate[CV_Array[CV_Array[CV_Array[CV]]]]
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]] = (Loc_Gate[CV_Array[CV]] offset by (200.00, 0.00))
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]] = (Loc_Gate[CV_Array[CV]] offset by (-200.00, 0.00))
      • Wait 0.02 seconds
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Gate Vert Det <gen> matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is A ground unit) Equal to True))) and do (Actions)
        • Loop - Actions
          • If ((Gate Vert R <gen> contains (Picked unit)) Equal to True) then do (Unit - Move (Picked unit) instantly to Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]) else do (Do nothing)
          • If ((Gate Vert L <gen> contains (Picked unit)) Equal to True) then do (Unit - Move (Picked unit) instantly to Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]]) else do (Do nothing)
      • Wait 0.02 seconds
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]]]])
      • Unit - Replace (Casting unit) with a Wooden Gate (Closed) (Vert) (Faces West) using The old unit's relative life and mana
      • Animation - Play (Last replaced unit)'s stand animation
      • Selection - Select (Last replaced unit) for (Owner of (Casting unit))
  • Gate Close Vert East
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Close Gate
      • (Unit-type of (Casting unit)) Equal to Wooden Gate (Opened) (Vert) (Faces East)
    • Actions
      • Set CV = (Custom value of (Casting unit))
      • Set CV_Array[CV] = (Custom value of (Casting unit))
      • Set Loc_Gate[CV_Array[CV]] = (Position of (Casting unit))
      • Set Loc_Gate[CV_Array[CV_Array[CV]]] = (Loc_Gate[CV_Array[CV]] offset by (-120.00, 0.00))
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV]]]] = (Loc_Gate[CV_Array[CV]] offset by (120.00, 0.00))
      • Region - Center Gate Vert Det <gen> on Loc_Gate[CV_Array[CV]]
      • Region - Center Gate Vert R <gen> on Loc_Gate[CV_Array[CV_Array[CV]]]
      • Region - Center Gate Vert L <gen> on Loc_Gate[CV_Array[CV_Array[CV_Array[CV]]]]
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]] = (Loc_Gate[CV_Array[CV]] offset by (200.00, 0.00))
      • Set Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]] = (Loc_Gate[CV_Array[CV]] offset by (-200.00, 0.00))
      • Wait 0.02 seconds
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Gate Vert Det <gen> matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is A ground unit) Equal to True))) and do (Actions)
        • Loop - Actions
          • If ((Gate Vert R <gen> contains (Picked unit)) Equal to True) then do (Unit - Move (Picked unit) instantly to Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]) else do (Do nothing)
          • If ((Gate Vert L <gen> contains (Picked unit)) Equal to True) then do (Unit - Move (Picked unit) instantly to Loc_Gate[CV_Array[CV_Array[CV_Array[CV_Array[CV_Array[CV]]]]]]) else do (Do nothing)
      • Wait 0.02 seconds
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]]])
      • Custom script: call RemoveLocation(udg_Loc_Gate[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV_Array[udg_CV]]]]]])
      • Unit - Replace (Casting unit) with a Wooden Gate (Closed) (Vert) (Faces East) using The old unit's relative life and mana
      • Animation - Play (Last replaced unit)'s stand animation
      • Selection - Select (Last replaced unit) for (Owner of (Casting unit))
I only have 3 variables for all of the triggers
Loc_Gate = Point array
CV = Integer
CV_Array = Integer array
 
Last edited:
Level 9
Joined
Mar 26, 2017
Messages
376
You need no triggers for a gate model with a Morph Stand animation such as this one: Human Stonewalls

You will only have to do following set up:
-Create an open and closed for in the object editor, with the correct pathing map
-Give both units a bear form ability, making the closed gate the base unit and the open gate the alternate form


If you want to use a gate model with no such animation, you have to do a bit more:
-Create an open and closed for in the object editor, with the correct pathing map
-Give both forms a dummy 'Open/Close' ability

(the following is done instead of Replace, to prevent creating a new unit each time you case 'Open/Close')
-Make one trigger that fires on finish building the gate that does
> Create the 'Open' form, set its x, y and facing accordingly, and hide it
> Save the unit handle of the Open form in a hashtable with the Closed form as the key, and vice versa

-Make another trigger that fires on casting 'Open/Close'
> Show one for the forms and hide the other
> Set the life of the new form to the life of the old form
> If 'Close' was used, set the new form's X and Y coordinate to the X and Y of the other form (otherwise the Gate position might be displaced if it closes on top of a unit)
> Make the new form be selected for the casting player (for a seamless transition)

-Finally a trigger if one of the two forms die
>Remove the other form
 
Last edited:
Level 6
Joined
Jul 23, 2018
Messages
243
You need no triggers for a gate model with a Morph Stand animation such as this one: Human Stonewalls

You will only have to do following set up:
-Create an open and closed for in the object editor, with the correct pathing map
-Give both units a bear form ability, making the closed gate the base unit and the open gate the alternate form


If you want to use a gate model with no such animation, you have to do a bit more:
-Create an open and closed for in the object editor, with the correct pathing map
-Give both forms a dummy 'Open/Close' ability

(the following is done instead of Replace, to prevent creating a new unit each time you case 'Open/Close')
-Make one trigger that fires on finish building the gate that does
> Create the 'Open' form, set its x, y and facing accordingly, and hide it
> Save the unit handle of the Open form in a hashtable with the Closed form as the key, and vice versa

-Make another trigger that fires on casting 'Open/Close'
> Show one for the forms and hide the other
> Set the life of the new form to the life of the old form
> If 'Close' was used, set the new form's X and Y coordinate to the X and Y of the other form (otherwise the Gate position might be displaced if it closes on top of a unit)
> Make the new form be selected for the casting player (for a seamless transition)

-Finally a trigger if one of the two forms die
>Remove the other form
As I mentioned in the first post, I used Bear Form ability but what happened is that alternate unit did not change back to normal unit, even when there is no units between the gate.
As for hashtable, I'm still learning
 
Level 9
Joined
Mar 26, 2017
Messages
376
As I mentioned in the first post, I used Bear Form ability but what happened is that alternate unit did not change back to normal unit, even when there is no units between the gate.
As for hashtable, I'm still learning

Like I said a model needs to have Morph Stand animation for Bear Form to work. The gate model you are using is intended to open on death, and not for repeat opening/closing.

Otherwise, you can use the simpler Replace Unit approach you are currently using and skip hashtables.
Instead of the complicated method of displacing units on the closed gate, you could put the closing gate on the correct position. This can only be done with SetUnitX and SetUnitY as these do not check pathing. They are not available in GUI, so you will need to use a few custom script lines.

Place this at the top of Actions:
  • Custom script: local integer x = GetUnitX(GetTriggerUnit())
  • Custom script: local integer y = GetUnitY(GetTriggerUnit())
Place this below the Replace Unit line:
  • Custom script: call SetUnitX(bj_lastReplacedUnit, x)
  • Custom script: call SetUnitY(bj_lastReplacedUnit, y)
  • Custom script: set x = null
  • Custom script: set y = null
 
Level 6
Joined
Jul 23, 2018
Messages
243
Like I said a model needs to have Morph Stand animation for Bear Form to work. The gate model you are using is intended to open on death, and not for repeat opening/closing.

Otherwise, you can use the simpler Replace Unit approach you are currently using and skip hashtables.
Instead of the complicated method of displacing units on the closed gate, you could put the closing gate on the correct position. This can only be done with SetUnitX and SetUnitY as these do not check pathing. They are not available in GUI, so you will need to use a few custom script lines.

Place this at the top of Actions:
  • Custom script: local integer x = GetUnitX(GetTriggerUnit())
  • Custom script: local integer y = GetUnitY(GetTriggerUnit())
Place this below the Replace Unit line:
  • Custom script: call SetUnitX(bj_lastReplacedUnit, x)
  • Custom script: call SetUnitY(bj_lastReplacedUnit, y)
  • Custom script: set x = null
  • Custom script: set y = null
I'm actually using the model you mentioned.
And the instruction you tell me to do is to have opened and closed gates in the same place, one is hidden? When the event fires, hide one and show the other one?
 
Status
Not open for further replies.
Top