• 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.

Make units explode on death IF unit had specific buff before death

Status
Not open for further replies.
Level 4
Joined
Dec 25, 2012
Messages
66
Ability (named "Exploder") applies an AoE buff ("Exploder buff"), that lasts 5 sec. If an affected unit dies in any way during this time, it damages area of 200 around itself.

It would have been easy to make in GUI if not for one sore fact: Dying units are purged of all buffs, hence the condition "Dying unit has buff "Exploder buff" equals yes" will never be satisfied.

Currently i have a set of triggers to implement the ability:

First trigger writes all affected units to free space in a hashtable when ability is cast, along with integer 5

Second trigger checks hashtable every 1 second and decrements integers by 1. If value reaches zero, it is purged, along with the associated unit handle.

Third trigger has an Event "Unit dies". Then it checks if the dying unit was present in the aforementioned hash. If positive, then it creates an explosion effect and damage at the position of dying unit and clears its data (handle, integer) from the hash.


It goes without saying, that this is a very bulky method (especially the hashtable cleanup and management). Is there another way to detect if dying unit has (had) a specific buff? Preferably, without damage detection systems involvement...
 
Level 4
Joined
Dec 25, 2012
Messages
66
Method you've suggested was actually my first attempt at the skill.

Trigger 1:
Event: Unit Casts an ability
Condition: Ability being cast = Exploder
Actions: set explodingGroup = Pick every unit within 200 range of Target point of ability being cast

Trigger 2:
Event: Unit dies
Condition: Dying unit belongs to explodingGroup equals yes
Actions: Create special effect, area damage at position of dying unit
Remove dying unit from explodingGroup

This will not work correctly if another unit casts the same ability (Exploder) within 5 sec of original caster - new units will overwrite the original. Besides, units in that group will stay even after the buff duration expires.
Also, I forgot to mention in parent post, that the damage (done by trigger) must come from caster of Exploder.

If you know some way to create and manage local unitgroups between triggers, please suggest an example.
 

Rheiko

Spell Reviewer
Level 26
Joined
Aug 27, 2013
Messages
4,214
Well, You just did it wrong.
Besides, units in that group will stay even after the buff duration expires.
Use timer to count the duration. So when it expires, remove the unit from that unit group.

I would rather use Dynamic Indexing. Create the group, add the units into the group, use timer and check if the units in that group is dead. If the timer expires and no dead unit, do nothing but if the timer hasn't expired and the picked unit is dead then cause damage.
 
Level 4
Joined
Dec 25, 2012
Messages
66
I used the following trigger based on everyone's tips:

Every 1 sec: pick all units in exploderGroup and do: If (picked unit has buff Exploder buff = false) then Remove picked unit from unit group.

Works fine now, rep to all.
 
Status
Not open for further replies.
Top