• 🏆 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] Passive AOE not working.

Status
Not open for further replies.
Level 2
Joined
Jan 18, 2010
Messages
16
I'm trying to make a passive aoe effect, that adds a bit of additional money everytime a creep is killed in the aoe.
My Code is in the attachment.

I suppose it's because a passive ability is nothing "casted"...

Could anyone help me?

Einheit = Unit
Stirbt = Dies
Grösser als = bigger than
Gleich = equals
Spieler = Player
Aktuelles Gold = actual gold
 

Attachments

  • CropperCapture[2].jpg
    CropperCapture[2].jpg
    72.6 KB · Views: 111
Last edited:
Level 6
Joined
Jul 24, 2008
Messages
180
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
 
Level 2
Joined
Jan 18, 2010
Messages
16
Yep sry I just learned that.

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.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Justify said:
You'd have to pick all units in AOE around a dying one
and check if he has the aura.

This isn't a very good solution to the problem.

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.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Justify said:
My solution isn't perfect, but at least it should be bugless.

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.
 
Level 13
Joined
Mar 16, 2008
Messages
941
Well, no.

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.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
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.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

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 :wsmile: )

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
            • Else - Actions
      • Custom script: call DestroyGroup(udg_Temp_UnitGroup)
Edit: I remind this way from Maker - so I think it will work :wwink:
 
Level 13
Joined
Mar 16, 2008
Messages
941
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.

Then only pick allies in an aoe of 500 of the dying unit?
I only like this solution, because damage events are
executed so often.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
As opposed to a periodic timer. Those are rarely executed :p

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.
 
Status
Not open for further replies.
Top