local function Jump(p)
if p.mo.skin == "tails" and p.playerstate == PST_LIVE then
if p.secondjump == 1 and p.control then
p.mo.state = S_PLAY_FLY
p.pflags = $|PF_NOJUMPDAMAGE
if (p.mo.eflags & MFE_UNDERWATER) and not (p.mo.eflags & MFE_GOOWATER) then
P_SetObjectMomZ(p.mo,5*FRACUNIT)
elseif p.mo.eflags & MFE_GOOWATER then
P_SetObjectMomZ(p.mo,-5*FRACUNIT)
else
S_StartSound(p.mo, sfx_putput)
end
end

if(p.mo.state == S_PLAY_SPRING or p.mo.state == S_PLAY_FALL or p.mo.state == S_PLAY_SWIM)
p.pflags = $ & ~PF_THOKKED
p.pflags = $|PF_JUMPED
end

if p.mo.eflags & MFE_UNDERWATER and (p.mo.state == S_PLAY_SPRING or p.mo.state == S_PLAY_FALL) then
p.mo.state = S_PLAY_SWIM 
end

if not (p.mo.eflags & MFE_UNDERWATER) and (p.mo.state == S_PLAY_FLY) and (p.secondjump ~= 1) then
p.mo.state = S_PLAY_FALL 
end

end
end
addHook("PlayerThink", Jump)