addHook("PlayerThink", function(player) -- runs once per player each frame if player.groundtimer == nil then player.groundtimer = 1*TICRATE/10 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 (P_IsObjectOnGround(player.mo) == true) then player.groundtimer = 1*TICRATE/10 end if (P_IsObjectOnGround(player.mo) == false) and player.groundtimer > 0 and not (player.pflags & PF_JUMPED) then player.airwalk = 1*TICRATE end if player.groundtimer > 0 then player.groundtimer = $ - 1 end if (P_IsObjectOnGround(player.mo) == true) then player.airwalk = 0*TICRATE player.airwalked = false player.shouldntairwalk = false player.falling = false end if (P_IsObjectOnGround(player.mo) == false) then player.airwalk = $ - 1 end if player.airwalk > 0 and player.mo.z/FRACUNIT - player.mo.floorz/FRACUNIT > 128 then player.airwalked = true player.mo.state = S_PLAY_RUN P_Thrust(player.mo, player.mo.angle, 1*FRACUNIT/2 + 1*FRACUNIT/8) player.mo.momz = 0 end if 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.shouldntairwalk = true player.airwalk = -1*TICRATE end if player.mo.z/FRACUNIT - player.mo.floorz/FRACUNIT < 128 and (player.pflags & PF_JUMPED) and (P_IsObjectOnGround(player.mo) == false) then player.mo.state = S_PLAY_JUMP 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 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 if player.playerstate == PST_DEAD then player.mo.state = S_PLAY_DEAD end end)