• 🏆 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] Make Devour restore 50% Max HP

Status
Not open for further replies.
Level 28
Joined
Feb 18, 2014
Messages
3,579
Simple question : How to make Devour ability restore 50% max HP of the devoured unit after it dies?

I'm trying to make the devour ability into a hero ability which will give him the ability to restore his HP after the devoured unit dies.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
A rough idea that might work.

First trigger detects when a unit is devoured. This is possibly a cast ability. Both devourer and devoured unit are tracked in variables.

Second trigger detects when a unit dies. This tests if the dying unit was the devoured unit. If it was, then restore the health of the devourer appropriately. I do not think killing unit may always be correct, as the devoured unit might die from other sources while being digested, hence the need for tracking the devourer.
 
Level 12
Joined
Feb 5, 2018
Messages
521
  • Devour
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Devour (Custom)
    • Actions
      • Unit Group - Add (Triggering unit) to DevourCaster_Group
      • Unit Group - Add (Target unit of ability being cast) to DevourTarget_Group
  • Devour Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in DevourTarget_Group.) Equal to True
      • ((Killing unit) is in DevourCaster_Group.) Equal to True
    • Actions
      • Unit - Set life of (Killing unit) to ((Life of (Killing unit)) + ((Max life of (Triggering unit)) x 0.50))
This is rough idea, we could also use custom values as index or hashtables. Might also be a good idea to add an Boolean "UnitIsDevoured".
Noticed that the devoured units have a buff by default on the ability, so that might also help with removing units from the group when needed.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
This is rough idea, we could also use custom values as index or hashtables. Might also be a good idea to add an Boolean "UnitIsDevoured".
Noticed that the devoured units have a buff by default on the ability, so that might also help with removing units from the group when needed.
You need to remove the unit from the group after it dies. Otherwise this causes a leak. Removed units are not automatically removed from groups.
 
Level 28
Joined
Feb 18, 2014
Messages
3,579
I think I got it.
  • Devour Init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Devour
    • Actions
      • Set Devoured_Unit = (Target unit of ability being cast)
  • Devour Hero Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Blood Death Knight
    • Actions
      • Custom script: set udg_Devoured_Unit = null
  • Devour Ends
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to Devoured_Unit
    • Actions
      • Unit - Set life of (Killing unit) to ((Life of (Killing unit)) + ((Max life of Devoured_Unit) / 2.00))
@DoomBlade, I'm using this ability for a single unit so I don't think unit groups or index are necessary but thanks anyway.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Yes, forgot to put that in. Pretty sure Warseeker knew this thought :D
Since most people do not know it, I do have to mention it a lot.
@DoomBlade, I'm using this ability for a single unit so I don't think unit groups or index are necessary but thanks anyway.
Why the separate trigger to null the unit? Also I thought GUI lets you set unit variables to "no unit" which is null.
 
Level 16
Joined
May 2, 2011
Messages
1,345
I think I got it.
  • Devour Init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Devour
    • Actions
      • Set Devoured_Unit = (Target unit of ability being cast)
  • Devour Hero Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Blood Death Knight
    • Actions
      • Custom script: set udg_Devoured_Unit = null
  • Devour Ends
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to Devoured_Unit
    • Actions
      • Unit - Set life of (Killing unit) to ((Life of (Killing unit)) + ((Max life of Devoured_Unit) / 2.00))
@DoomBlade, I'm using this ability for a single unit so I don't think unit groups or index are necessary but thanks anyway.
isn't it better to use it as groups? I mean like @DoomBlade has said.
to me, this seems to only work for one unit (not multi unit instance: i.e. not MUI)
 
Status
Not open for further replies.
Top