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!
Okay. No unit is casting an ability so (Casting Unit) returns null. Change it to (Killing Unit) and it should work. =D
***BTW*** It would be a lot easier to read if you use the Trigger tags and not attach a picture. =D
The point is, I don't want it to trigger on Killing unit. I want to trigger it, every time a unid dies in the range of the hero. So also creeps killed by a fellow player f.e.
There are two problems:
Dying units don't have buffs, you can't check for them.
There is no event for AOE, how should it?
You'd have to pick all units in AOE around a dying one
and check if he has the aura.
Instead what I would do is setup your unit to trigger the "Unit takes damage" event. Now, when your unit takes damage you'll want to check if the damage dealt is greater than (or equal to) the unit's current life.
If this is the case, you will be able to detect whether or not the unit taking damage has the aura-buff.
What do you mean "bug-less", your code would display bugs if the units around the dying unit have the buff when the actual dying unit does not. That is a bug.
Justify said:
whenever damage is dealt that can still be healed at other triggers?
Um. What? What the hell does "healing" have to do with any of this, you're using the damage-detection trigger simply to reference the dying unit before he actually dies. What the hell does that have to do with other "healing triggers" or whatever you were talking about.
If the AOE range of the aura is 500, and a unit within
500 of the dying unit has the aura, then the dying
unit had the buff (the unit is in aura range...).
Also, I'm talking about damage prevention.
Most times it's used for shields.
A trigger that triggers on the damage event and uses
"SetUnitLife" to heal the unit.
I don't know in which order triggers are executed,
but if yours was the first, the trigger would detect a death,
while the shield trigger afterwards would heal the unit,
preventing death.
What if the unit is not an ally of the other unit? Or what if he's neutral hostile or magic immune or something. There are lots of reasons why a unit would not have a buff, even though the units around him do.
Justify said:
I don't know in which order triggers are executed,
but if yours was the first, the trigger would detect a death,
while the shield trigger afterwards would heal the unit,
preventing death.
Okay, so then if a unit takes lethal damage you'll want to use hashtables to store a boolean-value to the unit so that it can be referenced from another thread.
Now, have an event that detects when a unit dies. If the dying unit's stored value is true, then he had the buff before he died. If it is false, he did not. Better yet, only store a value to the unit if he does have the buff. This way, if the unit dies you can do:
JASS:
if HaveSavedBoolean( hash, GetHandleId( unit ), GetStringHash("SpecialAura") ) then
call RemoveSavedBoolean( hash, GetHandleId( unit ), StringHash("SpecialAura") )
// execute actions for a dying unit with aura buff
endif
So, if the boolean is not stored to the unit then he does not have the aura-buff, and thus you don't need to do anything. If there is a value there, then remove it from memory (not sure if this is absolutely necessary or not, better safe than sorry) and continue to execute the actions as if the unit had died with the buff.
The down-side of this is it only works when the unit is damaged. If the unit is suddenly killed (via triggers) then it will not work properly.
Auf deutsch wär es vllt einfach aber das ist ja ein englisches Forum =D
So if a unit with the aura buff dies, the killing unit should gains a gold bonus? hmm..
Anyway a dieing unit can't have a buff, because the unit is dead so you should do the following: ( I posted it already to another topic but who care )
You pick every 0.25 seconds each unit in the Playable MapArea who have the aura buff and add them into a group. ( Temp_UnitGroup )
Know if the unit dies and is in the unit group you add the amount of gold to the killing unit. ( If you only want give the bonus gold to the owner of the unit with the aura check this with conditions )
Now you create again a trigger that picks every 0.25 seconds all units in the "Temp_UnitGroup" and remove each unit without the buff ( you can check this with conditions to )
TestTrigger
Events
Time - Every 0.25 seconds of game time
Conditions
Actions
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) has buff Gold Aura [Buff] ) Equal to True)) and do (Actions)
Loop - Actions
Unit Group - Add (Picked unit) to Temp_UnitGroup
TestTrigger1
Events
Unit - A unit Dies
Conditions
((Dying unit) is in Temp_UnitGroup) Equal to True
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Gold Aura for (Killing unit)) Greater than 0
Then - Actions
Player - Add 25 to (Owner of (Killing unit)) Current gold
Else - Actions
TestTrigger2
Events
Time - Every 0.25 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in Temp_UnitGroup and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) has buff Gold Aura [Buff] ) Equal to False
Then - Actions
Unit Group - Remove (Picked unit) from Temp_UnitGroup
What if the unit is not an ally of the other unit? Or what if he's neutral hostile or magic immune or something. There are lots of reasons why a unit would not have a buff, even though the units around him do.
As opposed to a periodic timer. Those are rarely executed
But yes, your best option may be using periodically updated unit-group. I would suggest using something like 0.1 though instead of 0.25. You won't notice a difference but it will be a lot more accurate. You should also check IsUnitInRange so that the unit's collision is factored in.
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.