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

Need help with a procentage healing spell

Status
Not open for further replies.
Level 2
Joined
Sep 15, 2022
Messages
5
Not so long ago I had an idea of a healing spell for my map. The format of the map implies the fight between two teams of players. Between battles, teams can buy various supplies, including scrolls. The ability I'm talking about is activated by one of these scrolls and, by killing the activating player, it gives the remaining team members the same percentage of health as he had at the time of death. As an example: a unit uses an ability when its health is 70%. So, if another unit has 10%, it restores its 80%. I've tried different methods, but it all comes down to summing up the percentages. Please, if you know how to solve this, help me out. 🙏
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
This will heal all of the enemy heroes by X% where X is the percentage life of the (Dying unit):
  • Method 1
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Variable HealPercentage = (Percentage life of (Dying unit))
      • Unit Group - Pick every unit in EnemyHeroes and do (Actions)
        • Loop - Actions
          • Unit - Set life of (Picked unit) to ((Percentage life of (Picked unit)) + HealPercentage)%
Or if you want to divide the % evenly among the enemy heroes:
  • Method 2
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Variable HealPercentage = ((Percentage life of (Dying unit)) / (Real((Number of units in EnemyHeroes))))
      • Unit Group - Pick every unit in EnemyHeroes and do (Actions)
        • Loop - Actions
          • Unit - Set life of (Picked unit) to ((Percentage life of (Picked unit)) + HealPercentage)%
Now the main issue I see with a spell like this is detecting that the Activating player is under the effects of the Scroll when it dies. The issue is that without something like a Damage Engine / Unit Group you cannot check for a Buff when a unit dies so you'd need to use some other method. But maybe you already have this part sorted out.
 
Level 2
Joined
Sep 15, 2022
Messages
5
This will heal all of the enemy heroes by X% where X is the percentage life of the (Dying unit):
  • Method 1
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Variable HealPercentage = (Percentage life of (Dying unit))
      • Unit Group - Pick every unit in EnemyHeroes and do (Actions)
        • Loop - Actions
          • Unit - Set life of (Picked unit) to ((Percentage life of (Picked unit)) + HealPercentage)%
Or if you want to divide the % evenly among the enemy heroes:
  • Method 2
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Variable HealPercentage = ((Percentage life of (Dying unit)) / (Real((Number of units in EnemyHeroes))))
      • Unit Group - Pick every unit in EnemyHeroes and do (Actions)
        • Loop - Actions
          • Unit - Set life of (Picked unit) to ((Percentage life of (Picked unit)) + HealPercentage)%
Now the main issue I see with a spell like this is detecting that the Activating player is under the effects of the Scroll when it dies. The issue is that without something like a Damage Engine / Unit Group you cannot check for a Buff when a unit dies so you'd need to use some other method. But maybe you already have this part sorted out.
Thank you very much! Not only for the first answer (that answering my question completely), but for the second one too. Recently I've been thinking about dividing procenteges and its formula too (for another spell), so your second answer would deal another huge impact on the map. Thank you agein! 😊🙏
 
Status
Not open for further replies.
Top