HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

percents?

03-06-2005, 07:21 PM#1
Ponzini
Quote:
Set Damage = ((100 - (Integer((Life of (Attacked unit))))) x (Integer(0.30)))


I was trying to make a trigger to calculate a percentage of the damage so I can reduce the armor and health. I tested the whole trigger and this line is the one not working. I tried just Set Damage = (100 - (Integer((Life of (Attacked unit)))) and that worked but (Integer(0.30)) doesn't. Is there a way to multiply a variable by a percent?
03-06-2005, 07:25 PM#2
divine_peon
maybe use Set Damage = (100 - ((Percentage Life of (Attacked unit)))) ??
03-06-2005, 07:26 PM#3
Anitarf
Code:
Set Damage = ((100 - (Integer((Life of (Attacked unit)) x (0.30)))))
A very subtle change should make it all work like a charm.

Whenever you convert something to an integer, it looses everything after the decimal point, it is rounded down, because integers can only be whole numbers.
03-06-2005, 07:32 PM#4
Ponzini
The problem is that it wont let me put 0.30 into the editor. It only lets me put a percent when I use Convert Real to Integer. So thats what I used. Whenever I try to put a decimal into the value I want it to multiply by it doesnt do anything.
03-06-2005, 07:34 PM#5
Ponzini
Oh nm you still answered my question. My variable was set to Integer thats why it wouldnt let me. Thanks ^_^
03-06-2005, 07:35 PM#6
Anitarf
Of course it doesn't do anything. Read above, converting reals to integers rounds the reals down. It rounds any real that is less than 1, in your case 0.3, down to 0. Change the order already, multiply the life with 0.3 before converting it to integer.

Edit: Ah, I see you got it.