1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Spell] Make Devour restore 50% Max HP

Discussion in 'World Editor Help Zone' started by Warseeker, Aug 22, 2020.

Tags:
  1. Warseeker

    Warseeker

    Joined:
    Feb 18, 2014
    Messages:
    3,154
    Resources:
    2
    Maps:
    2
    Resources:
    2
    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.
     
  2. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,201
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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.
     
  3. DoomBlade

    DoomBlade

    Joined:
    Feb 5, 2018
    Messages:
    380
    Resources:
    0
    Resources:
    0
    • 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.
     
  4. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,201
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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.
     
  5. DoomBlade

    DoomBlade

    Joined:
    Feb 5, 2018
    Messages:
    380
    Resources:
    0
    Resources:
    0
    Yes, forgot to put that in. Pretty sure Warseeker knew this thought :D
     
  6. Warseeker

    Warseeker

    Joined:
    Feb 18, 2014
    Messages:
    3,154
    Resources:
    2
    Maps:
    2
    Resources:
    2
    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.
     
  7. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,201
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Since most people do not know it, I do have to mention it a lot.
    Why the separate trigger to null the unit? Also I thought GUI lets you set unit variables to "no unit" which is null.
     
  8. Warseeker

    Warseeker

    Joined:
    Feb 18, 2014
    Messages:
    3,154
    Resources:
    2
    Maps:
    2
    Resources:
    2
    In case the hero dies while still devouring.
     
  9. Map Designer

    Map Designer

    Joined:
    May 2, 2011
    Messages:
    1,255
    Resources:
    2
    Maps:
    1
    Spells:
    1
    Resources:
    2
    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)
     
  10. Warseeker

    Warseeker

    Joined:
    Feb 18, 2014
    Messages:
    3,154
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Like I told @DoomBlade, this ability will be used by a single hero only, so using unit groups may not be necessary.