• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Math problems

Status
Not open for further replies.
Level 11
Joined
Apr 6, 2008
Messages
760
hi i have some math problems :/ i add hp to a unit with SetUnitMaxState system but i can figure how to remove the bonus hp xD i increse the hp with 10/20/30% (3 lvls reprecented as d.lvl)

well this is what i got so far

JASS:
call AddUnitMaxState(u,UNIT_STATE_MAX_LIFE,GetUnitState(u,UNIT_STATE_MAX_LIFE)/100*(d.lvl*10))

need a negative vaule here (- the added hp)

JASS:
call AddUnitMaxState(u,UNIT_STATE_MAX_LIFE,GetUnitState(u,UNIT_STATE_MAX_LIFE)/100+(d.lvl*10)*(100*-1))
 
JASS:
call AddUnitMaxState(u,UNIT_STATE_MAX_LIFE,GetUnitState(u,UNIT_STATE_MAX_LIFE)*(1+0.1*d.lvl))

JASS:
call 
AddUnitMaxState(u,UNIT_STATE_MAX_LIFE,GetUnitState(u,UNIT_STATE_MAX_LIFE)*(1/(1+d.lvl*0.1))
Like this?
 
nops thats not correct :/ it added hp instead of reducing it


i try to explain more i increase the hp with 10/20/30% depending on lvl.. but when the unit leave the radius of this aura it will get it old hp it had before it got the effect of this aura(more max hp)

JASS:
set life = GetUnitState(u,UNIT_STATE_MAX_LIFE)
call AddUnitMaxState(u,UNIT_STATE_MAX_LIFE,(life-(life/(100+(d.lvl*10))*100))*-1

this give the unit -1(449) hp then it had from the start:/ which is strange

450*1.10 = 495
(495-(495/(100+(1*10))*100))*-1 = -45

495+(-45) = 450
 
Last edited:
JASS:
call AddUnitMaxState(u,UNIT_STATE_MAX_LIFE,GetUnitState(u,UNIT_STATE_MAX_LIFE)*0.1*d.lvl)

JASS:
call 
AddUnitMaxState(u,UNIT_STATE_MAX_LIFE,GetUnitState(u,UNIT_STATE_MAX_LIFE)*(-1/(1 + d.lvl*0.1))

Lol.
Didn't see it was addunitmaxstate. Thought it was setunitmax state.
But go with Earth-Fury's suggestion.
 
Last edited:
Status
Not open for further replies.
Back
Top