YesNoOk
avatar

Lifeadd dilemma (Read 11318 times)

Started by WastedCoder, August 24, 2024, 03:45:53 pm
Share this topic:
Lifeadd dilemma
#1  August 24, 2024, 03:45:53 pm
  • **
    • Ukraine
Hi.
I am trying to make a character regain 1/3 of his max hp on transformation.
Transformation state lasts 500 ticks. I want him to slowly regain hp during [100,400] ticks
Yet I fail to do so.

It works fine when hp is at 1000, but if I change it to 1200 or use mugen's 120% hp increase from the options, the value doesn't scale properly. It stays 300. If I use ceil or floor I get either x2 the original value(600) or the same thing(300) even tho hp is 1200, and it should recover 400... How do I achieve it? It seems like Lifeadd is having troubles with integer. I tried using vars, fvars or making it ((lifemax/3.0)/300.0) and whatever. Is it possible, math wise?

I also tried using const(data.life), but nothing helps.

Looks like whenever lifeadd encounters an integer, like 1.5, it straight up ignores it and goes 1.

Code:
[State 800, LifeAdd]
type = LifeAdd
triggerall = var(29)>0 && life<lifemax
trigger1 = time = [100,400)
value = (lifemax/3)/300
absolute = 1
ignorehitpause = 1
Last Edit: August 24, 2024, 03:58:36 pm by WastedCoder
Re: Lifeadd dilemma
#2  August 24, 2024, 04:09:39 pm
  • ****
  • Formerly DeathScythe
    • Brazil
    • lyricasky.neocities.org
The thing is you're trying to divide 400/300, which is giving you a float value, and life is always integer. I don't think there is a way to make it EXACTLY 1/3 everytime.
Maybe you can use LifeSet instead of LifeAdd, together with a fvar and varadd.

value = var(0) + (floor(fvar(0)))

var(0) would be the life you had when you enter the state, you can store it in the beginning of the state.
and fvar(0) would be the amount of life to gain.

In a VarAdd:
fvar(0) = (lifemax/3.0)/300

Don't forget to reset your vars when leaving the state.

I have no idea if this will work but is worth to give it a try.
Re: Lifeadd dilemma
#3  August 24, 2024, 09:47:52 pm
  • **
    • Ukraine
The thing is you're trying to divide 400/300, which is giving you a float value, and life is always integer. I don't think there is a way to make it EXACTLY 1/3 everytime.
Maybe you can use LifeSet instead of LifeAdd, together with a fvar and varadd.

value = var(0) + (floor(fvar(0)))

var(0) would be the life you had when you enter the state, you can store it in the beginning of the state.
and fvar(0) would be the amount of life to gain.

In a VarAdd:
fvar(0) = (lifemax/3.0)/300

Don't forget to reset your vars when leaving the state.

I have no idea if this will work but is worth to give it a try.

I don't mean it to be exactly 1/3 every time, but when it gives 300 hp no matter if your max hp is 1000 or 1500, it's kinda sad :c
I kinda used the wrong word there, I did mean to say float.

But, the decision you came up with did work. Thank you so much ^-^
Yeah, it might not give me the exact value(gotta test more, so far it does), but it does scale, at the very least! :)
You saved me.