Need some math help: Percentage of a unit's life

tommerbob

Minecraft. :D
Reaction score
110
Math is not my forte, so here I am requesting some (probably) very simple math help. I'm looking to reference the percentage of a unit's life. For each X percentage of life missing, the unit gains attack speed. For those who play Dota, its like Huskar's Berserker's Blood ability.

How do I calculate when the unit loses 5% of his life? (i.e. unit's life 95% = gains 10% attack speed, 90% life = 20% attack seed, 85% life = 30% attack speed, etc.)

FYI, I'm using GUI.
 

BAkil

New Member
Reaction score
9
So what it looks like to me is that every 5% of life missing, 10% attack speed is gained.
Trigger:
  • Set REAL = ((100.00 - (Percentage life of (Triggering unit))) x 2.00)

That's what you'll want, the 100 is for 100% and then you're removing the percentage of life from the Triggering Unit, giving you the X percentage of life missing.
Note that Triggering Unit might not be appropriate for your trigger, and you will have to change it accordingly.
In this case, if the unit has 90% life remaining, 100-90 = 10 which is then multipled by 2 to give 20.
That's what you wanted for your 20% attack speed when on 90% life, it might be the case that you want 20% to be 0.2 in the spell. To do that you simply divide the end result by 100.

REAL will be the value of attack speed that you want.
If any more clarification is required either PM me or just say something in this post and I'll do my best to get back to it.
 

tommerbob

Minecraft. :D
Reaction score
110
Ok, this is what I have:

Trigger:
  • Untitled Trigger 001
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set REAL = (100.00 - (Percentage life of Paladin 0000 <gen>))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Integer(REAL)) mod 5) Equal to 0
        • Then - Actions
          • Unit - Set level of Item Attack Speed Bonus (Gloves of Haste) for Paladin 0000 <gen> to (((Integer(REAL)) / 5) + 1)
        • Else - Actions


For each 5% life missing, it increases his attack speed ability by 1. Correct? I tested it, and it seems to work fine, but I'm just making sure.

Thanks for the help! +rep
 

BAkil

New Member
Reaction score
9
Haha looks like you know what you're doing, however I've got no idea what mod means in that condition =(
It also depends on what values you put in the ability that alters the movement speed, but I'm glad to know that I was able to help ya =P
 

tommerbob

Minecraft. :D
Reaction score
110
The mod condition is a modulo, determining the remainder after a division. If that remainder is 0, the condition returns true.
 
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