addHook("PlayerThink", function(player) -- runs once per player each frame if player.shouldairwalk == nil then player.shouldairwalk = false end if player.airwalk == nil then player.airwalk = 0*TICRATE end if player.airwalked == nil then player.airwalked = false end if player.willtakedamage == nil then player.willtakedamage = false end if player.shouldntairwalk == nil then player.shouldntairwalk = false end if player.falling == nil then player.falling = false end if player.secondchance == nil then player.secondchance = 0*TICRATE end if player.stopaction == nil then player.stopaction = false end if (player.mo.eflags & MFE_UNDERWATER) or (player.mo.eflags & MFE_SPRUNG) or player.mo.state == S_PLAY_ROLL then player.falling = false player.willtakedamage = false player.shouldntairwalk = true end if (P_IsObjectOnGround(player.mo) == false) and player.shouldairwalk == true and not (player.pflags & PF_JUMPED) then player.airwalk = 1*TICRATE player.shouldairwalk = false end if (P_IsObjectOnGround(player.mo) == true) then player.shouldairwalk = true player.airwalk = 0*TICRATE player.airwalked = false player.shouldntairwalk = false player.falling = false player.secondchance = 0*TICRATE player.stopaction = false end if (P_IsObjectOnGround(player.mo) == false) and player.airwalk > -1 then player.airwalk = $ - 1 end if not P_IsObjectOnGround(player.mo) and player.secondchance > -1 then player.secondchance = $ - 1 end if player.airwalk > 0 and player.mo.z/FRACUNIT - player.mo.floorz/FRACUNIT > 128 and not (player.pflags & PF_JUMPED) and not (player.pflags & PF_THOKKED) and player.shouldntairwalk == false then player.airwalked = true player.mo.state = S_PLAY_RUN player.mo.momz = 0 end if player.airwalk > 0 and player.stopaction == false and player.mo.z/FRACUNIT - player.mo.floorz/FRACUNIT < 128 and not (player.pflags & PF_JUMPED) and not (player.pflags & PF_THOKKED) and player.airwalked == false and (P_IsObjectOnGround(player.mo) == false) then player.secondchance = 2 player.stopaction = true end if player.secondchance > 0 and player.mo.z/FRACUNIT - player.mo.floorz/FRACUNIT > 128 and not (player.pflags & PF_JUMPED) and not (player.pflags & PF_THOKKED) and player.shouldntairwalk == false then player.airwalk = 1*TICRATE end if player.airwalk < 0 and not (player.pflags & PF_JUMPED) and not (player.pflags & PF_THOKKED) and player.shouldntairwalk == false and player.falling == false then player.mo.momz = 10*FRACUNIT player.falling = true player.mo.state = S_PLAY_DEAD S_StartSound(player.mo, sfx_s3k51) end if player.falling == true then player.mo.momz = $ - 1*FRACUNIT/2 end if player.falling == true and player.mo.momz < -25*FRACUNIT then player.willtakedamage = true end if player.willtakedamage == true and player.mo.momz > 0 then player.willtakedamage = false player.falling = false player.shouldntairwalk = true end if player.willtakedamage == true and (P_IsObjectOnGround(player.mo) == true) then P_DamageMobj(player.mo) S_StartSound(player.mo, sfx_doord2) player.willtakedamage = false player.mo.momz = -1*FRACUNIT end end)