Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- autorun/server/qbox_rip.lua
- ----------------------------------------------------------------
- -- Maximum mass test
- -- Todo: Make it more sane
- ----------------------------------------------------------------
- local mass = 0
- local frozen = false
- local localent = NULL
- local function IncMass(Entities)
- if Entities != nil then
- local PhysObj = NULL
- for _,t in pairs(Entities) do
- local ent = t.Ent2 != localent and t.Ent2 or t.Ent1
- if ent and ent:IsValid() then
- PhysObj = ent:GetPhysicsObject()
- if PhysObj:IsValid() then
- if not PhysObj:IsMoveable() then
- --D("Pickup deny",ent)
- frozen = true
- return
- end
- --D(ent,"->",mass,"+",PhysObj:GetMass())
- mass = mass + PhysObj:GetMass()
- end
- end
- end
- end
- end
- ----------------------------------------------------------------
- ----------------------------------------------------------------
- -- Prevent lifting odd objects. Slightly more realism but lots of annoyage
- -- TODO
- ----------------------------------------------------------------
- hook.Add('GravGunPickupAllowed','QBox_Rip',function( pl, ent )
- if ( ent && ent:IsValid() and ent:GetPhysicsObject():IsValid() ) then
- frozen = false
- mass = ent:GetPhysicsObject():GetMass()
- localent = ent
- local maxmass = GetConVarNumber("physcannon_maxmass")
- local PhysObj = NULL
- local entz = constraint.FindConstraints(ent,"Weld")
- IncMass(entz)
- entz = constraint.FindConstraints(ent,"Hydraulic")
- IncMass(entz)
- entz = constraint.FindConstraints(ent,"Muscle")
- IncMass(entz)
- entz = constraint.FindConstraints(ent,"Pulley")
- IncMass(entz)
- -- TODO: Objects added to the ent count ConstraintsToTargetObject times. Fix
- if mass > maxmass || frozen then
- -- D("Pickup deny for",pl," frozen="..tostring(frozen).." | "..(maxmass).."(maxmass) < "..tostring(mass))
- return false
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment