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

[Spell] Healing Nearby units Upon Death

Status
Not open for further replies.
Level 3
Joined
Jun 17, 2012
Messages
46
Hey I have a spell for my hero that basically goes like this:
When a friendly unit near to the hero dies, all units around the hero get healed.

I cannot figure out how to get it to work, any help would be appreciated.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
  • Death Heal
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set TempLoc = (Position of (Triggering unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 600.00 of TempLoc matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) belongs to an ally of (Triggering player)) Equal to True))) and do (Actions)
        • Loop - Actions
          • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 300.00)
      • Custom script: call RemoveLocation(udg_TempLoc)
This trigger will heal any allied units within 600 AOE around the dying Hero unit by 300.
TempLoc is Point variable
 
Level 3
Joined
Jun 17, 2012
Messages
46
That could work but I want the healing to happen whenever any unit dies who is near the hero, which is the main problem.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
  • Death Heal
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A structure) Equal to False
    • Actions
      • Set TempLoc = (Position of (Triggering unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 600.00 of TempLoc matching (((Matching unit) belongs to an ally of (Triggering player)) Equal to True)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 300.00)
            • Else - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 150.00)
      • Custom script: call RemoveLocation(udg_TempLoc)
Normal unit will get healed by 150 and Heroes unit will get healed by 300.
 
Level 3
Joined
Jun 17, 2012
Messages
46
It works ALMOST perfect. The problem is that the camera gets moved to the center of the map. Also the units near the hero get healed to full health, but units that aren't even near the hero get healed for the target amount. I can just post the map here if you think it'd help.
 
Level 3
Joined
Jun 17, 2012
Messages
46
Wow yea that's almost exactly what I want. However I only want units who die next to the hero with the spell to heal people.
 
Level 3
Joined
Jun 17, 2012
Messages
46
I thought it was pretty well explaned... "When a friendly unit near to the hero dies, all units around the hero get healed." But adding that still doesn't change the fact that ANYONE can be healed, they don't have to be near the hero.
 
Level 3
Joined
Jun 17, 2012
Messages
46
uhhh no i haven't actually... I'm not sure what's so hard to understand. Let me type the order of events.
1. Hero gets a spell
2. A friendly unit near the hero dies
3. All friendly units near the hero get healed
It's really not that complicated.
 
Level 3
Joined
Jun 17, 2012
Messages
46
Yea yea that's it defskull, sorry for taking forever to reply I was asleep. Here's a +rep in advance haha
WhiteDeath I'm not sure why I didn't think of that myself haha hurdur I'll try it out.


EDIT: WhiteDeath what you said worked except that the camera moved to the center of the map when the unit died, which doesn't make any sense, none of my triggers have anything to do with cameras.
 
Last edited:
Level 33
Joined
Mar 27, 2008
Messages
8,035
  • ((Dying unit) has buff BUFF) Equal to True
Dead unit can't have buffs, therefore it won't be detected.

EDIT: WhiteDeath what you said worked except that the camera moved to the center of the map when the unit died, which doesn't make any sense, none of my triggers have anything to do with cameras.
Makes no sense at all.
Do you got other triggers in your map except mine ?
I can assure you that the camera problem is not from my test map.
 
Level 3
Joined
Jun 17, 2012
Messages
46
Here's the map, I cannot figure out why the camera moves, the spell in question is called Martyr.
 

Attachments

  • New Human Race.w3x
    789.9 KB · Views: 30
Level 33
Joined
Mar 27, 2008
Messages
8,035
The problem lies within the condition you just made.
You should filter dead units, because when a dead unit is added his HP back, it will returns a null value thus, making the game becomes misinterpret...

I have fixed your map, take a look.

Also, added a nested if-else for more accurate handling of data per each level of buff.
 

Attachments

  • New Human Race.w3x
    789.6 KB · Views: 36
Status
Not open for further replies.
Top