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!
Fairly new to the WC3 editor. I'm sure there's a simple solution to this, but I'm stumped.
I'm attempting to have a trigger go off whenever a player goes near a dummy. I'm able to select each individual dummy i've created, but I'm looking for a way to have more general code to avoid spaghetti & make spawning in future dummies easier.
Is there a way to recognize any currently existing instance of dummy1, instead of just dummy1 0005, 0010, etc?
No, that event only exists in the specific unit version; it can't be made general. If the units you need to do this for are static (don't get created/destroyed) throughout the map you can do something like:
-------- add event on map init --------
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units in playable map area matching (Unit-type of (Matching Unit) equal to dummy 1)) and do (Actions)
Loop - Actions
Trigger - Add to TRIGGER <gen> the event Unit - A unit comes within 256.00 of (Picked Unit)
Events
Unit - A unit enters (Playable map area)
Conditions
(Unit-type of (Triggering Unit) equal to dummy 1)
Actions
Trigger - Add to TRIGGER <gen> the event Unit - A unit comes within 256.00 of (Triggering Unit)
However, if the units are dynamically created your best option is to put them all into a unit group, then periodically (say every 0.2s) loop over all units in the group and search for units within 256 of them, then do whatever you want to do with any found units. The proper solution kind of depends what it is you want to do.
Awesome! The first solution worked perfectly, and changing it for future fires will be a walk in the park.
What I'm aiming to program right now is pretty simple; I have three dummy1's with fire particles attached to them. They die after the effect is put on, so it doesn't mess with the pathing of the player. Whenever a unit comes into range of a dummy1 (which is technically a fire, in this case), I'm trying to get a trigger to check if that unit has a specific item (a bucket of water), and if it does, to simply "put out the fire" by removing the particle, destroying the bucket, playing a sound effect, and updating a quest value.
The part I'm struggling with now is how to remove specific particle effects. So I have the player go into range of a dummy/fire; it removes the bucket, plays the sfx, and updates the quest. Great! But, there doesn't seem to be an easy way to delete the particle effect attached to that specific dummy. I'd imagine you could do something with Hashtables, like assigning the effect a number +1 in an array each time one is created, then checking that dummy's number when "putting out" the fire, but admittedly I'm a bit in over my head.
Here's what I have functioning so far.
For map initialization (just trying to get things working with some static fires first)
Code:
Unit Group - Pick every unit in (Units of type dummy1) and do (Actions)
Loop - Actions
Special Effect - Create a special effect attached to the overhead of (Picked unit) using Doodads\Cinematic\TownBurningFireEmitter\TownBurningFireEmitter.mdl
Hashtable - Save firenumber as (firenumber + 1) of 5 in (Last created hashtable)
Trigger - Add to TRIGGERfirecheck <gen> the event (Unit - A unit comes within 256.00 of (Picked unit))
Unit - Kill (Picked unit)
And then the trigger.
Code:
TRIGGERfirecheck
Events
Unit - A unit enters (Playable map area)
Conditions
((Triggering unit) has an item of type Full Bucket) Equal to True
(Unit-type of (Triggering unit)) Equal to Farmer
Actions
Special Effect - Destroy (Last created special effect)
Item - Remove (Item carried by (Triggering unit) of type Full Bucket)
Sound - Play Submerge1 <gen> at 100.00% volume, attached to Farmer 0013 <gen>
Unit Group - Pick every unit in (Units of type dummy1) and do (Actions)
Loop - Actions
Special Effect - Create a special effect attached to the overhead of (Picked unit) using Doodads\Cinematic\TownBurningFireEmitter\TownBurningFireEmitter.mdl
Hashtable - Save firenumber as (firenumber + 1) of 5 in (Last created hashtable)
Trigger - Add to TRIGGERfirecheck <gen> the event (Unit - A unit comes within 256.00 of (Picked unit))
Unit - Kill (Picked unit)
Events
Unit - A unit enters (Playable map area)
Conditions
((Triggering unit) has an item of type Full Bucket) Equal to True
(Unit-type of (Triggering unit)) Equal to Farmer
Actions
Special Effect - Destroy (Last created special effect)
Item - Remove (Item carried by (Triggering unit) of type Full Bucket)
Sound - Play Submerge1 <gen> at 100.00% volume, attached to Farmer 0013 <gen>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.