• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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))
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
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?
 
Level 11
Joined
Apr 6, 2008
Messages
760
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:
Level 12
Joined
Apr 27, 2008
Messages
1,228
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.
Top