function PreventFallDamage(_,activator) activator:AddCallback(ON_DAMAGE_RECEIVED_PRE, function(_, damageInfo) -- just in case if not activator:IsAlive() then return end --If the incoming damage is fall damage, run some checks. if (damageInfo.DamageType & DMG_FALL > 0) then util.PrintToChatAll("Fall damage taken!") local CustomTraceInfo = { start = activator, endpos = nil, distance = 272, -- 2x the viewheight angles = Vector(90,0,0), -- Used if endpos is nil mask = MASK_PLAYERSOLID, collisiongroup = COLLISION_GROUP_PLAYER, mins = Vector(-96,-96,0), maxs = Vector(100,100,0), filter = nil } local traceResult = util.Trace(CustomTraceInfo) util.PrintToChatAll("Hit position: "..tostring(traceResult.HitPos)) --3 cases: --The entity we hit doesn't exist or we didn't hit one. Take no fall damage. --The entity we hit is a real player. Take fall damage. --The entity we hit is not a real player. Take no fall damage. if not IsValid(traceResult.Entity) then util.PrintToChatAll("No entity hit...") ents.FindByName('insurrectionist_stomp_relay'):AcceptInput("Trigger") damageInfo.Damage = 0 damageInfo.DamageType = DMG_GENERIC elseif traceResult.Entity:IsRealPlayer() then util.PrintToChatAll("Get STOMPED!!!") ents.FindByName('insurrectionist_stomp_relay'):AcceptInput("Trigger") return true else util.PrintToChatAll("We hit an entity, but it wasn't a real player...") ents.FindByName('insurrectionist_stomp_relay'):AcceptInput("Trigger") damageInfo.Damage = 0 damageInfo.DamageType = DMG_GENERIC end -- local zeroDmgInfo = { -- Attacker = damageInfo.Attacker, -- Inflictor = damageInfo.Inflictor, -- Weapon = damageInfo.Weapon, -- Damage = 0, -- CritType = 0, -- DamageType = damageInfo.DamageType, -- DamageCustom = damageInfo.DamageCustom, -- DamagePosition = damageInfo.DamagePosition, -- DamageForce = damageInfo.DamageForce, -- ReportedPosition = damageInfo.ReportedPosition, -- } -- activator:TakeDamage(zeroDmgInfo) --alternate method: return false return true end --If we didn't take fall damage, just take the damage. return true end) end