-- by lexidog :3 local CRUSH_RESISTANCE_LIMIT = 4 * TICRATE local DEATHPIT_LAUNCH_SPEED = 3 * FRACUNIT local DEATHPIT_LAUNCH_SPEED_MINIMUM = 16 * FRACUNIT local DEATHPIT_LAUNCH_COOLDOWN_LIMIT = 2 local crusherLeniencyEnabled = CV_RegisterVar( { name = "crusherleniency"; defaultvalue = "On"; flags = CV_NETVAR|CV_SHOWMODIF; PossibleValue = CV_OnOff; } ) local deathPitLeniencyEnabled = CV_RegisterVar( { name = "deathpitleniency"; defaultvalue = "On"; flags = CV_NETVAR|CV_SHOWMODIF; PossibleValue = CV_OnOff; } ) addHook("ShouldDamage", function(target, inflictor, source, damage, damagetype) if (damagetype == DMG_CRUSHED and crusherLeniencyEnabled.string == "On") or (damagetype == DMG_DEATHPIT and deathPitLeniencyEnabled.string == "On") then local player = target.player if damagetype == DMG_CRUSHED then player.crushresistance = $ - 3 if player.crushresistance <= 0 then return end end if damagetype == DMG_DEATHPIT and player.deathpitlaunchcooldown < DEATHPIT_LAUNCH_COOLDOWN_LIMIT then return end local storedMomZ = target.momz P_DamageMobj(target, inflictor, source) if damagetype == DMG_DEATHPIT and player.playerstate == PST_LIVE then target.state = S_PLAY_JUMP player.pflags = $ | PF_JUMPED player.pflags = $ & ~PF_THOKKED player.pflags = $ & ~PF_SHIELDABILITY target.momx = 0 target.momy = 0 local newMomZ = abs(storedMomZ) + DEATHPIT_LAUNCH_SPEED if newMomZ < DEATHPIT_LAUNCH_SPEED_MINIMUM then newMomZ = DEATHPIT_LAUNCH_SPEED_MINIMUM end P_SetObjectMomZ(target, newMomZ, false) player.deathpitlaunchcooldown = 0 S_StartSound(target, sfx_sprong) end return false end end, MT_PLAYER) addHook("PlayerSpawn", function(player) player.crushresistance = CRUSH_RESISTANCE_LIMIT player.deathpitlaunchcooldown = DEATHPIT_LAUNCH_COOLDOWN_LIMIT end) addHook("PlayerThink", function(player) if player.crushresistance == nil then player.crushresistance = CRUSH_RESISTANCE_LIMIT end if player.deathpitlaunchcooldown == nil then player.deathpitlaunchcooldown = DEATHPIT_LAUNCH_COOLDOWN_LIMIT end if player.crushresistance < CRUSH_RESISTANCE_LIMIT then player.crushresistance = $ + 1 end if P_IsObjectOnGround(player.mo) and player.deathpitlaunchcooldown < DEATHPIT_LAUNCH_COOLDOWN_LIMIT then player.deathpitlaunchcooldown = $ + 1 end end)