• 🏆 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] Dynamic Units - Within Range of Unit Type

Status
Not open for further replies.
Level 3
Joined
Aug 17, 2009
Messages
33
Hello everyone!

My situation is as follows: Say I want to be able to place as many doors as I want on the map dynamically - meaning ingame and not placed before in the editor. Now I want a door to open as soon as there is a unit within range x of the door and close as soon as the unit leaves this range towards it.

I already figured out there is an event called "A Unit is within range of <Unit>". The problem would be solved if I could enter a Unit Type (meaning the door) to the <Unit> spot but it is impossible to add the specific door as they are placed dynamically.

Preferably I would use methods using the GUI of the trigger editor as I am not capable of writing JASS code.

I know it is possible - I saw it in Escape Builders 1.6 before. Any suggestions?

Sincerely,
Grekain1
 
You would have one trigger running on map initialization that groups all the units on the map of the type <your unit type>. Then you would add to the trigger that handles that sort of thing:
  • Trigger - Add to <Your Trigger> the event "A Unit is within range of (Picked unit)"
I don't have access to the editor at the moment, so I don't know the precise function. Next you would make a second trigger that has the event "Unit - A unit enters (playable map area)". You would add a condition to check "Unit-type of (Triggering unit) Equal to <Your Unit Type>". Then you would do the same line as above, but change (Picked Unit) to (Triggering Unit).

That should register it for all units of that type. Just note that there will be a unique event handle generated for each unit on the map, so if you think that you may have thousands of that unit-type coming in and out, then you will want to use a different method.
 
Level 3
Joined
Aug 17, 2009
Messages
33
Thank you! It works, that every door will now be registered, but say I want to open a door now if someone comes close. What Unit do I refer as the door then. In that Trigger where I add the events then, I put for example the triggers to turn collision off and play the Open Animation, but the door is not to be referred as "Triggering Unit". This is the unit coming in range.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Sadly, we can not access to that unit with triggers easily, there are 2 solutions.Lets say you used 500 range.

1)When trigger runs, you know (triggering unit) is near 500 range of the door.Pick every unit in 500 range(use 500 + 32) of triggering unit of type door.Unless door's are too close to each other, you will only find 1 door.

2)Use a jass system(mostly requires JNGP)
 
Status
Not open for further replies.
Top