Increase Max HP by %

ChaosWarlock

New Member
Reaction score
7
I am trying to increase, and then after time decrease a units Max HP by a % using GUI (I am new to triggers and don't know JASS). I found an action to set the Life of a unit but no action to set the MAX Life of a unit. Can someone please point me in the right direction to accomplish this?

Thank you!

EDIT: Updated with solution I found to work best.

Thank you very much for all who have put their comments here. I would not have gotten the solution if wasn't for everyone contributing.

This is where the I got the trigger for changing the Max HP.

You could alternatively use this but I did not try it because in the post it says it uses some JASS which I am not familiar with.

This explains a little more of why it works.

This technique is what I used to make the spell MUI.

The spell that I needed this for is called Last Stand. Many of you may know it from WoW. For those of you who are not familiar with it, it increases the casters hit points (max and current) by a percent for a short period of time. I have set the % to increase per level of the spell. If you would like the duration to increase per level of the spell all you would have to do is make the buff last longer. As always comments are welcome. Enjoy!

Trigger:
  • Last Stand Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Last Stand
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LastStandCV Less than 1000
        • Then - Actions
          • Set LastStandCV = (LastStandCV + 1)
        • Else - Actions
          • Set LastStandCV = 1
      • Set LastStandUnit[LastStandCV] = (Triggering unit)
      • Set LastStandPoint = (Position of (Triggering unit))
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at LastStandPoint facing Default building facing degrees
      • Unit - Set the custom value of (Last created unit) to LastStandCV
      • Set LastStandDummy[LastStandCV] = (Last created unit)
      • Unit - Add Last Stand (Buff) to (Last created unit)
      • Unit - Set level of Last Stand (Buff) for (Last created unit) to (Level of Last Stand for (Triggering unit))
      • Unit - Order (Last created unit) to Neutral Fire Lord - Soul Burn (Triggering unit)
      • Set LastStandGain[LastStandCV] = (Integer((((((Real((Level of Last Stand for (Triggering unit)))) x 5.00) + 10.00) / 100.00) x (Max life of (Triggering unit)))))
      • Game - Display to (All players) the text: (String(LastStandGain[LastStandCV]))
      • Set LastStandHP = LastStandGain[LastStandCV]
      • Trigger - Run Last Stand Health <gen> (ignoring conditions)
      • Unit - Set life of LastStandUnit[LastStandCV] to ((Life of LastStandUnit[LastStandCV]) + (Real(LastStandGain[LastStandCV])))
      • Custom script: call RemoveLocation(udg_LastStandPoint)
      • Wait 0.26 seconds
      • Unit Group - Add LastStandDummy[LastStandCV] to LastStandGroup


Trigger:
  • Last Stand Remove
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
      • (Number of units in LastStandGroup) Greater than 0
    • Actions
      • Unit Group - Pick every unit in LastStandGroup and do (Actions)
        • Loop - Actions
          • Set Temp_Integer = (Custom value of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (LastStandUnit[Temp_Integer] has buff Last Stand ) Equal to False
            • Then - Actions
              • Unit - Remove (Picked unit) from the game
              • Set LastStandHP = (0 - LastStandGain[Temp_Integer])
              • Set LastStandCV = Temp_Integer
              • Trigger - Run Last Stand Health <gen> (ignoring conditions)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Integer((Life of LastStandUnit[Temp_Integer]))) - LastStandGain[Temp_Integer]) Greater than 0
                • Then - Actions
                  • Unit - Set life of LastStandUnit[Temp_Integer] to ((Life of LastStandUnit[Temp_Integer]) - (Real(LastStandGain[Temp_Integer])))
                • Else - Actions
                  • Unit - Set life of LastStandUnit[Temp_Integer] to 1.00
            • Else - Actions


Trigger:
  • Last Stand Health
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LastStandHP Greater than 0
        • Then - Actions
          • Set LastStandLoop = ((LastStandHP - (LastStandHP mod 100)) / 100)
          • For each (Integer A) from 1 to LastStandLoop, do (Actions)
            • Loop - Actions
              • Unit - Add Last Stand (Health) to LastStandUnit[LastStandCV]
              • Unit - Set level of Last Stand (Health) for LastStandUnit[LastStandCV] to 4
              • Unit - Remove Last Stand (Health) from LastStandUnit[LastStandCV]
          • Set LastStandHP = (LastStandHP mod 100)
          • Set LastStandLoop = ((LastStandHP - (LastStandHP mod 10)) / 10)
          • For each (Integer A) from 1 to LastStandLoop, do (Actions)
            • Loop - Actions
              • Unit - Add Last Stand (Health) to LastStandUnit[LastStandCV]
              • Unit - Set level of Last Stand (Health) for LastStandUnit[LastStandCV] to 3
              • Unit - Remove Last Stand (Health) from LastStandUnit[LastStandCV]
          • Set LastStandHP = (LastStandHP mod 10)
          • For each (Integer A) from 1 to LastStandHP, do (Actions)
            • Loop - Actions
              • Unit - Add Last Stand (Health) to LastStandUnit[LastStandCV]
              • Unit - Set level of Last Stand (Health) for LastStandUnit[LastStandCV] to 2
              • Unit - Remove Last Stand (Health) from LastStandUnit[LastStandCV]
        • Else - Actions
          • Set LastStandHP = (0 - LastStandHP)
          • Set LastStandLoop = ((LastStandHP - (LastStandHP mod 100)) / 100)
          • For each (Integer A) from 1 to LastStandLoop, do (Actions)
            • Loop - Actions
              • Unit - Add Last Stand (Health) to LastStandUnit[LastStandCV]
              • Unit - Set level of Last Stand (Health) for LastStandUnit[LastStandCV] to 7
              • Unit - Remove Last Stand (Health) from LastStandUnit[LastStandCV]
          • Set LastStandHP = (LastStandHP mod 100)
          • Set LastStandLoop = ((LastStandHP - (LastStandHP mod 10)) / 10)
          • For each (Integer A) from 1 to LastStandLoop, do (Actions)
            • Loop - Actions
              • Unit - Add Last Stand (Health) to LastStandUnit[LastStandCV]
              • Unit - Set level of Last Stand (Health) for LastStandUnit[LastStandCV] to 6
              • Unit - Remove Last Stand (Health) from LastStandUnit[LastStandCV]
          • Set LastStandHP = (LastStandHP mod 10)
          • For each (Integer A) from 1 to LastStandHP, do (Actions)
            • Loop - Actions
              • Unit - Add Last Stand (Health) to LastStandUnit[LastStandCV]
              • Unit - Set level of Last Stand (Health) for LastStandUnit[LastStandCV] to 5
              • Unit - Remove Last Stand (Health) from LastStandUnit[LastStandCV]
 

Akolyt0r

New Member
Reaction score
33
only way to do this is to
- add a ability to the unit which increases max Hp (but there is none for percent i think only flat value)
and then after some time remove it again.
or
- use custom upgrades ...i think there is an option for maxhp (percent) there...
similar way to do it....create a custom upgrade with different levels
then set upgradelevel researched for player to X
after the time
set it back to 0
 

Igor_Z

You can change this now in User CP.
Reaction score
61
I don't know about a % increasement but i know how to increase by a number(1,2,3,4 etc...). You can't set life to more than the maximum. U can use an upgrade and level it up every time u want to increase your max life. U can add a spellbook with ability that increases maximum life. But increase by % i rly don't know
 

ChaosWarlock

New Member
Reaction score
7
Akolyt0r -

Is there a way with triggers to take an upgrade away? I only want the unit to have increased HP for a short period of time, like 20 seconds.


Igor_Z -

I can calculate the percentage in a trigger the problem is setting the new Max HP to what I have calculated.
 

DK's Pride

New Member
Reaction score
7
Cant you use an hp increasing spell like mountain kings avatar, its not in % but it increases HP :D
 

eXirrah

New Member
Reaction score
51
You can base your unit on some Hero unit, remove it's glow and stuff with no strength,agility,inteligence increace and calculate it's strength. set it's initial strength =1 caus I think you can't set it to 0. If it is a strenght hero then make the primary attibute something else than strength, like agility.

By default I think strength gives 25 hp to a hero. So the formula goes like this.

set strength = (MaxHP/25)*(PercInc/100)

MaxHP should be actually the base HP + 25 of the hero cause you set strenght to 1

PercInc is the percantage increace of health.(0-100)
(MaxHP/25) will tell you how much strength is needed to get the current HP of the unit
PercInc/100 will multiply that strenght by the percentage and you should get + PercInc HP on that unit.
If you want to set the life of the unit to normal again, just set strength of the unit to 1 again and done.

Check things I wrote again cause i'm very sleepy right now and I might have some mistakes but this is the base idea I got right now
-----------------------------------------------------
Ok I got something else. You can make custom spell based on Item Life Bonus.
The custom spell should have stats like this
Item Life Bonus x1
lvl 1 +1 HP
lvl 2 +2 HP
...
lvl 9 +9 HP
Then you make the same custom spell but with stats x 10
Item Life Bonus x 10
lvl 1 +10 HP
lvl 2 +20 HP
...
lvl 9 +100 HP
Then with starts x100 then 1000 as long as you see fit and the calculations goes that way
Code:
set real = (MaxHP*PercInc) - MaxHP
set int[0] = Integer(real/100)
set real = real - 100*int[0]
set int[1] = Integer(real/10)
set real = real - 10*int[0]
set int[2] = Ingeter(real)
add ability to unit (Item Life Bonus x 1)
set level of ability for unit (Item Life Bonus x 1) to int[2]
add ability to unit (Item Life Bonus x 10)
set level of ability for unit (Item Life Bonus x 10) to int[1]
add ability to unit (Item Life Bonus x 100)
set level of ability for unit (Item Life Bonus x 100) to int[0]
PercInc : the percent increace /100 + 1. example +20% PercInc = 1.2
If you want the unit to have normal HP again just remove the abilities from it.

The rest is an example if you got the idea do not read

Summerized HP should be equal to the percentage increace.
If you want a unit with 100 HP to have + 20% HP then
Code:
set real = (MaxHP*PercInc) - MaxHP = 100*1.2 - 100 = 120 - 100 = 20
set int[0] = Integer(real/100) = integer(20/100) = integer(0.2) = 0
set real = real - 100*int[0] = 20 - 100*0 = 20
set int[1] = Integer(real/10)= Int(20/10) = Int(2) = 2
set real = real - 10*int[0]= 20 - 2*10 = 0
set int[2] = Ingeter(real)=0

add ability to unit (Item Life Bonus x 1)
set level of ability for unit (Item Life Bonus x 1) to 0
add ability to unit (Item Life Bonus x 10)
set level of ability for unit (Item Life Bonus x 10) to 2
add ability to unit (Item Life Bonus x 100)
set level of ability for unit (Item Life Bonus x 100) to 0
Life Bonus x1     lvl 0 = 0
Life Bonus x10    lvl 2 = 20
Life Bonus x100  lvl 0 = 0
so the unit gets 20 HP.... which is +20% increace
 

ChaosWarlock

New Member
Reaction score
7
eXirrah -

Wow thanks for the Item Life Bonus idea. I'm pretty tired right now myself but I will try that out and post the results when I get a chance. I could just hide the spell in a spellbook or something so that I doesn't show.
 

warroom99

New Member
Reaction score
15
you could also use metamorphosis, i mean u create another hero same as the other one but give it an upgrade which increases HP and increase the level of the upgrade every time the hero learns the skill.
 

Cloak_Master

Active Member
Reaction score
41
you could also use metamorphosis, i mean u create another hero same as the other one but give it an upgrade which increases HP and increase the level of the upgrade every time the hero learns the skill.

That's terrible, just use the unit life bonus idea and corrupt the icon file.
 

eXirrah

New Member
Reaction score
51
If you check in the Object Editor .... this spell has no icon and doesn't appear on the unit as an actual spell.
 

eXirrah

New Member
Reaction score
51
This is the same as I proposed but made as a loop....
Item Life Bonus
lvl 1 = + 0 HP
lvl 2 = +1 HP
lvl 3 = +10 HP
lvl 4 = +100 HP
lvl 5 = -1 HP
lvl 6 = -10 HP
lvl 7 = -100 HP

Code:
if you want to add 1234 HP to the unit you do
for loop 1-12
    add ability to unit Item Life Bonus
    set ability Item Life Bonus to lvl 4
for loop 1-3
    add ability to unit Item Life Bonus
    set ability Item Life Bonus to lvl 3
for loop 1-4
    add ability to unit Item Life Bonus
    set ability Item Life Bonus to lvl 2
My method is a bit simplier in that if you want to remove the ability afterwards... Cause I use different abilities which are added once to a unit.
so after that you just need to remove 3-4 abilities from the unit. With this method you proposed you need to add like 10-20 abilities to the unit and then you need to remove them all.... which makes things more complicated.

EDIT: Hmmm... seems like he was talking about some bug with this ability that even when removed the bonus is still on. Check out what TriggerHappy proposed as well if the thing I proposed doesn't work as planned...
 

ChaosWarlock

New Member
Reaction score
7
Thank you all for contributing! + rep for the help!

I have updated the original post with the solution that worked and added the triggers of the spell which I have made using the Max HP change.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top