ID:1906822
 
(See the best response by Kaiochao.)
Hey guys, simple question:

Let's say my player has Energy = 100 and I want his Fireball attack to drain a certain percentage from my Energy...Like 50% so that he isn't too OP with his magix.

How do I do that?
energy -= energy * 0.5
In response to Lugia319
Best response
In this case,
energy *= 0.5


For an arbitrary percentage,
energy *= (1 - P)
where P might be 0.25 to lose 25% of the current energy.

If you actually wanted a percentage of the maximum energy,
var cost = max_energy * P

Thank you very much to both of you.