[Spell] For each missing health/mana

Status
Not open for further replies.

sentrywiz

S

sentrywiz

Hi all.

I've been pondering on this for a while. But I can't figure out a valid math.
I must be looking at from the wrong angle. I am thinking Max HP / Something = What I'm looking for. Idk maybe I'm just blind.

So how do you make out the math for spells that say:

Example:

"For each 1% missing health, gain +1 damage"

Or:

"For each 2% missing mana, deal +2 damage"

Something along those lines.
 

sentrywiz

S

sentrywiz

Basically, use the percentage comparison, I guess it's a little complicated though.

Okay, say its the first example "For each 1% of max health missing, gain +1 damage" how do I calculate that?

I need the formula obviously. And an explanation wouldn't hurt.
 

Deleted member 219079

D

Deleted member 219079

1 - hp/max hp = missing hp %
round(1 / missing hp %) = how many missing hp % you have
as a one liner:
round(1 / (1 - hp/max hp))

Edit: Proof:

max 130
hp 100

1 - 100/130 = 0.23077...
round(1/0.23077) = 4


Edit2: Nvm that, the correct one is:
round(100*(1. - hp/max hp)), in JASS2 R2I(100*(1. - GetUnitState(u,UNIT_STATE_LIFE)/GetUnitState(u,UNIT_STATE_MAX_LIFE)))

Edit3: Proof again:

max 130
hp 100

1. - 100/130 = 0.23...
100*ans = 23...
round(23...) = 23

So you will have 23 missing hp percentages when your max life is 130 and your current life is 100.
 

sentrywiz

S

sentrywiz

1 - hp/max hp = missing hp %
round(1 / missing hp %) = how many missing hp % you have
as a one liner:
round(1 / (1 - hp/max hp))

Edit: Proof:

max 130
hp 100

1 - 100/130 = 0.23077...
round(1/0.23077) = 4


Edit2: Nvm that, the correct one is:
round(100*(1. - hp/max hp)), in JASS2 R2I(100*(1. - GetUnitState(u,UNIT_STATE_LIFE)/GetUnitState(u,UNIT_STATE_MAX_LIFE)))

Edit3: Proof again:

max 130
hp 100

1. - 100/130 = 0.23...
100*ans = 23...
round(23...) = 23

So you will have 23 missing hp percentages when your max life is 130 and your current life is 100.

Great. +rep

But any chance to give me this in GUI?
 

Deleted member 219079

D

Deleted member 219079

I believe this the GUI form:
  • Set integer_result = (Integer((100.00 x (1.00 - ((Life of unit_u) / (Max life of unit_u))))))
 
Level 14
Joined
Oct 18, 2013
Messages
723
I did something along these lines. The I did it like this:
Set Bonus = (11 - ((Integer((Percentage life of Jinchuriki 0052 <gen>))) / 9))

My abil. was a bonus for every 9% of life missing, hence the 9. The 11 comes from 100/9=11. So idk if that is a good way to do it, but it works for me ^^
 

sentrywiz

S

sentrywiz

I believe this the GUI form:
  • Set integer_result = (Integer((100.00 x (1.00 - ((Life of unit_u) / (Max life of unit_u))))))

Thanks. I still don't get it, but I'll analyze it.

I did something along these lines. The I did it like this:
Set Bonus = (11 - ((Integer((Percentage life of Jinchuriki 0052 <gen>))) / 9))

My abil. was a bonus for every 9% of life missing, hence the 9. The 11 comes from 100/9=11. So idk if that is a good way to do it, but it works for me ^^

Thanks for your second example. I'll also analyze this, maybe I'll understand it better from your example. +rep
 

sentrywiz

S

sentrywiz

100 - current hp (%) = missing hp

if you want add let's say 1 str for each missing percent you'd do:
current str + 1 * missing hp

Omg so simple. Didn't think of this..
So blind..finally got it
+rep
 
Level 14
Joined
Oct 18, 2013
Messages
723
I've been checking back here every now and then to see if you solved your issue ^^ glad to hear you did.
 
Status
Not open for further replies.
Top