--Sonic Heroes-style jumping animation by Zarosguth, --Reusable, please give proper credit. --Whitelist of skins that get the Heroes-style jumping animation: /*local whitelist = {"sonic","tails","knuckles","amy","fang","metalsonic"} local function onWhiteList(player, list) for _, skin in pairs(list) do if player.mo.skin == skin return true end end return false end*/ addHook("PlayerThink", function(p) local mo = p.mo if not (p and p.valid) return end --Check whether Player exists //if not onWhiteList(p, whitelist) return end --Check whether Player's skin is on the whitelist //if skins[mo.skin].flags & SF_NOJUMPSPIN return end --Check whether Player spins while jumping by default p.charflags = $|SF_NOJUMPSPIN --Disable vanilla jumpspin if p.pflags & PF_JUMPED and p.panim ~= PA_ABILITY and not (mo.state >= S_PLAY_SUPER_TRANS1 and mo.state <= S_PLAY_SUPER_TRANS6) and not (p.pflags & PF_THOKKED) and not (p.charability == CA_THOK and p.cmd.buttons & BT_SPIN and p.powers[pw_super]) local apex = FixedMul(4*mo.scale, min(skins[mo.skin].jumpfactor, FRACUNIT)) --Determine jump apex, if mo.eflags & MFE_UNDERWATER --Correct for being underwater, apex = 117*$/200 end if mo.momz > -apex and mo.momz < apex --while at apex of jump, if mo.state ~= S_PLAY_ROLL mo.state = S_PLAY_ROLL --Spinning animation end else if not (mo.eflags & MFE_VERTICALFLIP) and mo.momz > 0 --when going up, or mo.eflags & MFE_VERTICALFLIP and mo.momz < 0 --or down in reverse gravity, if mo.state ~= S_PLAY_JUMP and mo.state ~= S_PLAY_SPRING mo.state = S_PLAY_JUMP --Jumping animation end end if not (mo.eflags & MFE_VERTICALFLIP) and mo.momz < 0 --when going down, or mo.eflags & MFE_VERTICALFLIP and mo.momz > 0 --or up in reverse gravity, if mo.state ~= S_PLAY_FALL mo.state = S_PLAY_FALL --Falling animation end end end --Give smooth trail while being able to deal damage, based on smooth trail script by ffoxD if not (p.pflags & PF_NOJUMPDAMAGE) if not mo.prevz or not mo.prevleveltime or mo.prevleveltime ~= leveltime - 1 mo.prevz = mo.z end local rmomz = mo.z - mo.prevz mo.prevz = mo.z mo.prevleveltime = leveltime local mospeed = R_PointToDist2(0, 0, R_PointToDist2(0, 0, mo.momx, mo.momy), rmomz) local dist = max(mospeed / (4*FRACUNIT), 1) for i = dist, 1, -1 local trail = P_SpawnMobjFromMobj(mo, mo.momx/dist*i, mo.momy/dist*i, rmomz/dist*i, MT_THOK) trail.fuse = 3 trail.scale = 21*mo.scale/20 trail.color = mo.color trail.frame = FF_TRANS90|FF_ADD end end elseif p.pflags & PF_THOKKED --Set rolling animation when using a thok ability and not (p.prevpflags & PF_THOKKED) and p.panim ~= PA_ROLL if p.charability == CA_THOK or p.charability == CA_JUMPTHOK or p.charability == CA_HOMINGTHOK and p.homing mo.state = S_PLAY_ROLL end end p.prevpflags = p.pflags end)