- Joined
- Jul 26, 2008
- Messages
- 1,009
So using the SetUnitLifePercentBJ is really simple to use, but it's a BJ and it likely causes leaks from the natives I've been looking at.
However, just to set it to natives seems like a huge chore. I'm looking at the coding and my head hurts. First I need to turn it into a native, which requires turning RMaxBJ into a native, which requires an if, though since it uses reals it shouldn't leak and I might just be able to use it leak free.
Then I have to turn GetUnitLifePercent into a native because it's part of the percent I need to input for RJMaxBJ, which means turning GetUnitStatePercent into a native, which requires the use of some locals and ifs and whatnot, which is a lot of thinking and rearranging.
There's gotta be an easier way! I'm not a math buff, so maybe someone could tell me how you would decrease an enemies life by a percentage. Like -1%.
I got this far in before realizing how convoluted it would make my coding to do all this, and I knew I wasn't the only one who needed an easier way.
JASS:
call SetUnitLifePercentBJ( GetTriggerUnit(), ( GetUnitLifePercent(GetSpellTargetUnit()) - 1 ) )
However, just to set it to natives seems like a huge chore. I'm looking at the coding and my head hurts. First I need to turn it into a native, which requires turning RMaxBJ into a native, which requires an if, though since it uses reals it shouldn't leak and I might just be able to use it leak free.
Then I have to turn GetUnitLifePercent into a native because it's part of the percent I need to input for RJMaxBJ, which means turning GetUnitStatePercent into a native, which requires the use of some locals and ifs and whatnot, which is a lot of thinking and rearranging.
There's gotta be an easier way! I'm not a math buff, so maybe someone could tell me how you would decrease an enemies life by a percentage. Like -1%.
I got this far in before realizing how convoluted it would make my coding to do all this, and I knew I wasn't the only one who needed an easier way.
JASS:
SetUnitState(target, UNIT_STATE_LIFE, GetUnitState(target, UNIT_STATE_MAX_LIFE) * RMaxBJ(0,) * 0.01)