MetalYpsilon
Member
Hello, i'm having trouble trying to limit z momentum of the character ability, its suppose to make the character bounce higher on each bounce but stop to certain height but keep going higher.
Is there a way to make it stop bouncing higher, I tried searching in the wiki but couldn't find anything useful.
Thanks in advance.
Here the code.
Is there a way to make it stop bouncing higher, I tried searching in the wiki but couldn't find anything useful.
Thanks in advance.
Here the code.
[CODE=lua]//power bounce
addHook("JumpSpinSpecial",function(player)
if player.mo.skin ~= "mk2sonic"//if not mecha sonic return false
return
end
local LIMIT = 17 // ground bounce height limit
local fixedz = FixedMul(FRACUNIT/2, player.mo.momz) // multiply z movement by 0.5(bounce momentum)
if player.bouncing == nil // if var nil
player.bouncing = 0 // make it
end
if player.bouncing == 1 //if bouncing 1
and not (player.pflags & PF_SPINDOWN) //and not holding spin
player.bouncing = 0 //make it 0
end
if (player.pflags & PF_JUMPED) // if player jumped
and (player.pflags & PF_SPINDOWN) // and holding spin
player.pflags = $1|PF_BOUNCING //player flag = bouncing
if not (player.panim == PA_ABILITY) //if animation not ca_ability(bounce)
player.state = S_PLAY_BOUNCE // force it to animation bounce
player.bouncing = 1 //bouncing is true(bad place to put but it works)
end
else // else return false
return
end
if (player.eflags & MFE_JUSTHITFLOOR) // if player just hit floor
and (player.pflags & PF_SPINDOWN) // and holding spin
player.state = S_PLAY_BOUNCE_LANDING // set player animation to bounce landing
if fixedz >= (LIMIT)
P_SetObjectMomZ(player, 17*FRACUNIT)
else
P_SetObjectMomZ(player, fixedz) //bounce up
print("bounceup")
end
end
end)
[/CODE]