• 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.

[Trigger] need help with some math please

Status
Not open for further replies.
Level 4
Joined
Jul 25, 2007
Messages
68
I'm trying to make a skill that lowers the targets hp by 20% thing is I have the function to lower their max hp, but it doesn't lower it in real number. and conversion doesnt work. so I only have adding subtracting multiply and divison with no decimal numbers to work with... is there some sort of formula using these to get a % out of a number?

thanks in advance
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
hmm... I don't understand what you mean. Does your function work in such a manner that you can add and substract as much life as you want (practically, modifying it to any value)? It is more than possible to make such a function if you haven't got it. Anyway... the problem is just like reducing a unit's current with 20%. Let's THINK it:

Unit has an amount of 'LX' life (variable amount). If we want to reduce 20%, it would look like this:
FX (final life after reduction) = LX-(LX*20/100)=LX-(LX*0.20)=LX*0.80

For a percentage PG, the formula looks like this:
FX=LX*(1-PG/100)

Now, let's get back to another problem. Let's say that you want to boost the unit's life back to the original LX. Hmm, we know that the reduction was 20%. We had this:

FX=LX(1-PG/100) => LX=FX/(1-PG/100)
Replacing with the percentage, we get this:
LX=FX/(1-0.20)=FX/(4/5)=FX*(5/4)=FX*1.25

Hope this whole stuff made sense. Good luck implementing it!

-Mihai
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Im sure they are meant to have taught this to you at school.

Well anyway, lets say CL = current life and RL = reduced life and we want to reduce current life by 20%.
RL = CL*0.8

Now to get from RL back to CL you preform the opposit opperation.
CL = RL/0.8

Also you talk about lowering MAX hp, WC3 has no native function to do that next the handicap one which effects all units owned by the player, thus you must be refering to a custom function. We can not help you unless you post the function you are trying to use.
 
Level 4
Joined
Jul 25, 2007
Messages
68
not when you go to a stupid special ed behavour school all your life until you got sick of it and droped out like I did.

But theres another problem the max hp is a real aswell and I wasn't aware of that so it's impossible to do what I asked.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
And so what, a real is purly a more advanced integer so there is nothing to worry about, you only have to run the conversion functions (actions) for real to intiger and intiger to real to make them useable. And anyway you can not change max HP unless you use jass or that set handicap action that effects all units, summons and buildings included.
 
Level 4
Joined
Jul 25, 2007
Messages
68
I can with weu, but it doesn't let you pick a real which is kind of dumb becuase the max hp is a real... and I already tried to convert. and it didnt work. but it only works with integers.
 
Status
Not open for further replies.
Top