• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

a smart gate

Status
Not open for further replies.
Level 4
Joined
Oct 1, 2010
Messages
89
hello

i want to make gates that have 2 functions:

# 1 - open automatically when 'friendly' units come close
(so you don't have to manually open it every time)

# 2 - a lock/unlock function that disables and re-enables the open function (i.e. #1)
(e.g. when defending close to the gate, it should remain closed)


I have raided the tuts section, but couldn't turn anything up that suits this purpose... I'm assuming the auto open function works with a region/distance trigger and 2 models (open/closed) for the different pathing.

What I don't know is how to add the 'lock/unlock' function??!
 

dab

dab

Level 10
Joined
Oct 30, 2008
Messages
413
hello

i want to make gates that have 2 functions:

# 1 - open automatically when 'friendly' units come close
(so you don't have to manually open it every time)

# 2 - a lock/unlock function that disables and re-enables the open function (i.e. #1)
(e.g. when defending close to the gate, it should remain closed)


I have raided the tuts section, but couldn't turn anything up that suits this purpose... I'm assuming the auto open function works with a region/distance trigger and 2 models (open/closed) for the different pathing.

What I don't know is how to add the 'lock/unlock' function??!

Well, as you only asked for the "lock/unlock" function, that is what I'm going to give you. Simply create a spell and make that trigger an event which should check if to unlock or lock, then go into the other function and only make it work when its on. An example:

  • Events
  • An spell is triggered
  • Conditions
  • Actions
  • If (IsLocked is True) then (Set IsLocked = False) else (Set IsLocked = True)
And then in your other trigger which controls the automated opening:

  • Events
  • <Insert>
  • Conditions
  • If (IsLocked is False)
  • Actions
  • <Insert>
 
Level 4
Joined
Oct 1, 2010
Messages
89
okay, thanks! seems simple enough... do I just create an 'empty' spell in object editor (i.e. all values to 0) and use that? (don't want gates to to summon wolves or heal people, lol!)

Also, I just ran into a bit of a snag though with part 1... how do i get it to manually close again after the units leave the gate region? Do I set up a separate, 'unit leaves region' trigger? Or can it all be incorporated into the 'open gate' trigger.

(Just for interests sake. In general, which is better? having 1 or 2 separate triggers?)
 
Level 4
Joined
Oct 1, 2010
Messages
89
2 separate it is then! :p

I was thinking about just making a "gate lever" (or something - I'll have to see what model to use). so, just a 'building' close to the gate with the lock/unlock ability...

something that switches on/off, just can't think of one to use right now?
crow form or mount hippogryph maybe?

any suggestions?
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Uploaded a test map to get a better understanding
If you have any question regarding the test map, feel free to ask =D
Once you use -Lock command, you must enter/leave the region to see the effect
Because it uses the Event - Unit Enters/Leaves region
 

Attachments

  • Smart Gate.w3x
    14.1 KB · Views: 68
Level 4
Joined
Oct 1, 2010
Messages
89
Uploaded a test map to get a better understanding

thanks for the effort, really appreciate it! you people make mapping fun, coz getting stuck SUCKS!

Anyway, back to the point, I had a look at your triggers and they all seem fine It's just that the gate does not close when you leave the region??! :vw_wtf: am I doing something wrong here...?

also, as my map has about 9 different gates (Gondor Main & Level Gates), I think it would be easier to have a 'clickable' lock/unlock function as opposed to a command function as it could get a bit confusing... (_lockmain/-lock1r/-lock1l/-lock2r/-lock2l etc.)

I just don't know what ability to give the 'lever'?
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
The first part, there is a very easy way to do it.

As for the second, it's as simple as utilizing a boolean as stated above.

NOTE: The following assumes the gates are pre-placed on the map.

What you need:

  • Your Gate placed on the map in the Editor.
  • A region for each gate that extends on both sides. Name it for easy recognition if you wish.
  • 2 simple triggers.
This first one opens the gate upon a unit entering. This can be turned off if you want. Or you can use a boolean like above. "Gate MainEnter Open" is the name of my region.
  • OPEN MainEnter
    • Events
      • Unit - A unit enters Gate MainEnter Open <gen>
    • Conditions
    • Actions
      • Destructible - Open City Entrance 0000 <gen>
And this one will close it upon the unit(s) leaving the region.
  • Close MainEnter
    • Events
      • Unit - A unit leaves Gate MainEnter Open <gen>
    • Conditions
    • Actions
      • Destructible - Close City Entrance 0000 <gen>
It is as simple as that. If you want to use a lever, you're going to need:

  • A lever Destructible.
  • A Gate Destructable.
  • A Region for the Gate.
  • A Boolean Variable.
This is to set the Boolean initially.
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set GateLocked = True
This will unlock the gate when the Lever is killed.
  • Unlock Gate1
    • Events
      • Destructible - Lever 0001 <gen> dies
    • Conditions
      • (Dying destructible) Equal to (==) Lever 0001 <gen>
    • Actions
      • Animation - Play Lever 0001 <gen>'s death animation
      • Set GateLocked = False
      • Game - Display to (All players) the text: You hear a click.
This opens the gate.
  • Open Gate1
    • Events
      • Unit - A unit enters LockedGate <gen>
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GateLocked Equal to (==) False
        • Then - Actions
          • Destructible - Open Gate (Horizontal) 0000 <gen>
        • Else - Actions
          • Game - Display to (All players) the text: Gate is locked. You...
This closes the gate.
  • Close Gate1
    • Events
      • Unit - A unit leaves LockedGate <gen>
    • Conditions
      • GateLocked Equal to (==) False
    • Actions
      • Destructible - Close Gate (Horizontal) 0000 <gen>
If you wish, I have attached a testmap. I've tested it and it works. If you try to move to the gate prior to unlocking it, it gives you an error message. After unlocking it, you can come and go as you please. Good Luck, :D
 

Attachments

  • Gate test.w3x
    17.8 KB · Views: 72
Level 12
Joined
Jan 30, 2009
Messages
1,067
Oh, crap, I didn't even think about that...

Ramza is right, :eek:

PS: Gratz on blue, Ramza, :D
 
Level 4
Joined
Oct 1, 2010
Messages
89
this is a long one....

@ Vizel: thanks for the test map! I think I just learnt a bit about triggers there, hehe...

However, I want gates to be able to be locked and unlocked multiple times. (not just once)


okay here is the whole story

The city of Gondor has many levels and there are gates between all the levels of the city. (i.e. at the stairs going up).

However, there are also many different shops in the city, all on different levels. Thus, hero's must be able to run around the city to go to all the shops etc. Gates must open automatically when they (good units) come close and close automatically when they are gone.

Now, the lock unlock function is pretty much just for when the orcs are inside the city. If they are busy banging down the door, you obviously want to defend the narrowest point (which is at the gate). However if the trigger (open/close) is still active and you move your units there, the gate will open and let the orcs through without having to destroy the gate.

If you then manage to drive the orcs back somehow [not revealing all the tricks/secrets here ;) ] you want the gate to open close normally again. Then, whan they come close, you want to be able to lock it again.


Therefore: The default position is UNLOCKED, with the ability to LOCK.


I know now that this lockin/unlocking can be done with the "Locked" = true/false comparison, but I don't know how to set up that comparison.



Vizel's way works, but only once... I need the gates to be locked/unlocked multiple times. That is why I was looking for a permanent ability to give my "lever" (a 'gate keeper' if you will), so I can set the condition to that ability being active or not. I just cant think of an ability to use.....


EDIT: thus, if you are gonna use an lever, you must be able to hit again and again, each time locking/unlocking the gate
 
Level 22
Joined
Jan 10, 2005
Messages
3,426
When the lever dies, wait a couple of seconds, and ''Destructible - Resurrect'' it.

When you need the gate to be locked, just kill the lever with a trigger, so nobody can use it (and make sure another trigger won't resurrect it, of course).



Or what about creating a custom ability based on Immolation (or any spell you can turn on and off)?

When the ability is off, lock the gate. When it's on, open the gate. Something like that.
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Well, if you want it like that, it's quite simple.

Make the lever invulnerable, and instead of attacking it, have a region under it and have a "Unit - Unit Enters rect" event. Check the rect in conditions. Then in actions check if door is unlocked then to lock the door and change lever animation to "death"

Otherwise if door is locked, then Unlock, and change animation to "stand"

You only need to change the "Unlock Gate" trigger to something like this, then:

  • Unlock Gate1
    • Events
      • Unit - A unit enters Lever <gen>
    • Conditions
      • ((Owner of (Triggering unit)) is an ally of Player 1 (Red)) Equal to (==) True
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GateLocked Equal to (==) True
        • Then - Actions
          • Animation - Play Lever 0001 <gen>'s death animation
          • Set GateLocked = False
          • Game - Display to (All players) the text: Gate is now open.
        • Else - Actions
          • Animation - Play Lever 0001 <gen>'s stand animation
          • Set GateLocked = True
          • Game - Display to (All players) the text: Gate is now Locked.
I've tested and it works. If you want it to be open first, simple change the boolean at the start, and flip the actions here if necessary.

EDIT: If you want it so that all Gates are open to begin with, and you want the Levers to show that as well, add this to the init trigger:
  • Init
  • Destructible - Pick every destructible in (Playable map area) and do (Actions)
    • Loop - Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Destructible-type of (Picked destructible)) Equal to (==) Lever
        • Then - Actions
          • Animation - Play (Picked destructible)'s death animation
        • Else - Actions
And then change the Unlock trigger to:
  • Unlock Gate1
    • Events
      • Unit - A unit enters Lever <gen>
    • Conditions
      • ((Owner of (Triggering unit)) is an ally of Player 1 (Red)) Equal to (==) True
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GateLocked Equal to (==) False
        • Then - Actions
          • Animation - Play Lever 0001 <gen>'s stand animation
          • Set GateLocked = True
          • Game - Display to (All players) the text: Gate is now Locked.
        • Else - Actions
          • Animation - Play Lever 0001 <gen>'s death animation
          • Set GateLocked = False
          • Game - Display to (All players) the text: Gate is now open.
And it should look alright. Worked fine for me.
 
Level 4
Joined
Oct 1, 2010
Messages
89
Sick, thanks guys! All sorted! The city of Gondor has just installed smart gates! :)

+ rep to everyone


Now, finally I have one last question.
How do units know that they can go to the gate (i.e the region) and that it will then open? (for AI players (creeps) I'm guessing you just rally points). But if i'm in the one corner with Gandalf and click the second level he just runs to the wall and stands there...

This is obviously a pathing problem, as no 'open' path exists till the unit enters the gate region. Is there a wat to let him know that he must run to the gate first?
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Okay, I fixed everything, now, and updated the map. Here.

Features:

  • Gates initially unlocked.
  • Levers initially dead to show the gates are unlocked.
  • Levers play stand animation when doors are locked, dead animation when open.
  • Unit in door integer.
And I may have missed something. Oh well.

Hope you enjoy.
 

Attachments

  • Gate test.w3x
    18.4 KB · Views: 46
Status
Not open for further replies.
Top