• 🏆 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!

[Spell] Damage Taken Trigger Does not Work

Status
Not open for further replies.
Level 5
Joined
Feb 18, 2016
Messages
96
I made this trigger that heal nearby units every time a specific unit (in this case a building) takes damage. The heal is a % of the damage taken for the building and increases by the level of the ability but it does not work

Events
Unit - Treenidad 0030 <gen> Takes damage
Conditions
Actions
Unit Group - Pick every unit in (Units in (Entire map)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) has buff Martir Tree ) Equal to True
Then - Actions
Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + ((0.02 + (0.04 x (Real((Level of (Ability) for (Building)))))) x (Damage taken)))
Else - Actions
Do nothing
 
Level 12
Joined
May 22, 2015
Messages
1,051
You're probably going to want to handle that memory leak. "takes damage" events can happen a lot, even for a single target.

I recommend using the trigger action to send a message to all players just to make sure the trigger is firing at all.

Then move the message action around to make sure all the code is being run.

"Do nothing" action is a trap. It actually uses some processing time, so running it for all the units in the map without the buff is just pointless processing (still, it most likely won't even be noticed - the memory leaks for the for the unit groups is a bigger issue).

I also recommend setting a variable to the amount of life to heal. The code will be cleaner this way and it does potentially save a lot of repeated calculations for the same number.

If the code is running and the units aren't getting healed, try just adding an action like this:
  • Unit - Kill (picked unit)
This is to just make sure the right units are being targeted by your code.
 
Status
Not open for further replies.
Top