• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Unit comes with "Unit-type" variable

Status
Not open for further replies.
Level 5
Joined
Jul 31, 2011
Messages
103
Hi HIVE!

i created this thread because i need help creating a unit comes trigger.

in my map i have a lot of unit called CHEST, and i want to create a trigger to show effect when you get closer to one of the chest.

I know how create a unit comes trigger but my question is:

Do i need create 30 trigger for 30 chest? or is a method to use a unit-type variable to save all the units?

Thanks For The Help!
 

EdgeOfChaos

E

EdgeOfChaos

You can always Add Events through a trigger. Maybe use a unit group, loop through all units of type chest, and add the event (Unit comes within ___) to a trigger, where you then do an action. This has the added effect of not requiring any more work for more chests you add.
 
Level 10
Joined
Sep 16, 2016
Messages
269
If the effects are all the same, then you can do it in one trigger. (actually two, 1st is to pick all unit and add event to trigger 2nd; the 2nd shows effects; or puts triggering unit into a group and create effect over time in a 3rd one)
 
Level 5
Joined
Jul 31, 2011
Messages
103
in the added trigger event , what is the type of the unit that comes to the chest?, trigger? matching? i tryed trigger but nothing happend
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
in the added trigger event , what is the type of the unit that comes to the chest?, trigger? matching? i tryed trigger but nothing happend
In response to a unit enters X range of unit event there is no way to get the unit who's range was entered, only the unit who entered the range.

The only solution I know to this problem is to create a unique trigger per unit. You can then use a hashtable to map the unit to the trigger. When the trigger fires you can then use the hashtable and the triggering trigger to get the unit who's range was entered.

Another less efficient and reliable approach would be to add all the possible units who's range was entered into a group. You then search through the group for the unit which is approximately the range distance away from the entering unit. Problem with this approach is scalability (complexity O(n)) and that the wrong unit may be returned in the case of entry at a point of intersection of entry ranges.

Be aware that attaching the event to a unit stops the unit from being able to use auras. It seems auras and the event use the same system in a mutually exclusive way. Not like you will be attaching auras to the chest though...
 
Level 5
Joined
Jul 31, 2011
Messages
103
i solve it jejeje :) the error was in the unit chest, i added locust xD, removed locust and work
 
Status
Not open for further replies.
Top