mirror of
https://github.com/Xerasin/Sit-Anywhere.git
synced 2025-03-04 03:13:07 -05:00
Cleanup
This commit is contained in:
parent
e78b614d06
commit
02c1261db1
@ -125,36 +125,4 @@ if CLIENT then
|
||||
|
||||
end
|
||||
end
|
||||
--easylua.EndEntity()
|
||||
|
||||
--[[if SERVER then
|
||||
if OldFollow then
|
||||
SafeRemoveEntity(OldFollow)
|
||||
SafeRemoveEntity(OldFollow.veh)
|
||||
return
|
||||
end
|
||||
|
||||
local tPos, tAng = me:GetShootPos() + Vector(0, 0, 4), me:EyeAngles()
|
||||
OldFollow = ents.Create("sit_holder")
|
||||
OldFollow:SetPos(tPos)
|
||||
OldFollow:SetAngles(tAng)
|
||||
OldFollow:Spawn()
|
||||
|
||||
local vehicle = ents.Create("prop_vehicle_prisoner_pod")
|
||||
vehicle:SetModel("models/nova/airboat_seat.mdl") -- DO NOT CHANGE OR CRASHES WILL HAPPEN
|
||||
|
||||
vehicle:SetKeyValue("vehiclescript", "scripts/vehicles/prisoner_pod.txt")
|
||||
vehicle:SetKeyValue("limitview","0")
|
||||
|
||||
vehicle:SetAngles(tAng)
|
||||
vehicle:SetPos(tPos)
|
||||
vehicle:Spawn()
|
||||
vehicle:Activate()
|
||||
|
||||
local phys = vehicle:GetPhysicsObject()
|
||||
vehicle:SetCollisionGroup(COLLISION_GROUP_WORLD)
|
||||
OldFollow.veh = vehicle
|
||||
vehicle:SetParent(OldFollow)
|
||||
OldFollow:SetTargetEnt(me, vehicle, tPos, tAng)
|
||||
end
|
||||
]]
|
||||
--easylua.EndEntity()
|
@ -1,10 +1,6 @@
|
||||
|
||||
local tag = "ground_sit"
|
||||
|
||||
local sitting = 0
|
||||
|
||||
|
||||
local time, speed = 1.5, 1.25
|
||||
hook.Add("SetupMove", tag, function(ply, mv)
|
||||
local butts = mv:GetButtons()
|
||||
|
||||
@ -12,27 +8,18 @@ hook.Add("SetupMove", tag, function(ply, mv)
|
||||
return
|
||||
end
|
||||
|
||||
if CLIENT then
|
||||
sitting = math.Clamp(sitting - FrameTime() * speed, 0, time)
|
||||
end
|
||||
|
||||
local getUp = bit.band(butts, IN_JUMP) == IN_JUMP or ply:GetMoveType() ~= MOVETYPE_WALK or ply:InVehicle() or not ply:Alive()
|
||||
|
||||
if getUp then
|
||||
ply:SetNWBool(tag, false)
|
||||
end
|
||||
|
||||
local move = bit.band(butts, IN_DUCK) == IN_DUCK -- do we want to move by ducking
|
||||
local move = bit.band(butts, IN_DUCK) == IN_DUCK
|
||||
|
||||
butts = bit.bor(butts, bit.bor(IN_JUMP, IN_DUCK)) -- enable ducking
|
||||
|
||||
butts = bit.bxor(butts, IN_JUMP) -- disable jumpng
|
||||
butts = bit.bxor(bit.bor(butts, bit.bor(IN_JUMP, IN_DUCK)), IN_JUMP)
|
||||
|
||||
if move then
|
||||
butts = bit.bor(butts, IN_WALK) -- enable walking
|
||||
|
||||
butts = bit.bor(butts, IN_SPEED)
|
||||
butts = bit.bxor(butts, IN_SPEED) -- disable sprinting
|
||||
butts = bit.bxor(bit.bor(bit.bor(butts, IN_WALK), IN_SPEED), IN_SPEED)
|
||||
|
||||
mv:SetButtons(butts)
|
||||
return
|
||||
@ -63,8 +50,9 @@ if SERVER then
|
||||
return
|
||||
end
|
||||
|
||||
if not ply:GetNWBool("ground_sit") then
|
||||
ply:ConCommand("ground_sit")
|
||||
if not ply:GetNWBool(tag) then
|
||||
ply:SetNWBool(tag, true)
|
||||
ply.LastSit = CurTime() + 1
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -72,7 +60,7 @@ if SERVER then
|
||||
|
||||
concommand.Add("ground_sit", function(ply)
|
||||
if AllowGroundSit:GetBool() and (not ply.LastSit or ply.LastSit < CurTime()) then
|
||||
ply:SetNWBool("ground_sit", not ply:GetNWBool("ground_sit"))
|
||||
ply:SetNWBool(tag, not ply:GetNWBool(tag))
|
||||
ply.LastSit = CurTime() + 1
|
||||
end
|
||||
end)
|
||||
|
@ -11,7 +11,6 @@ SitAnywhere.ModelBlacklist = {
|
||||
}
|
||||
|
||||
local EMETA = FindMetaTable"Entity"
|
||||
--local PMETA = FindMetaTable"Player"
|
||||
|
||||
function SitAnywhere.GetAreaProfile(pos, resolution, simple)
|
||||
local filter = player.GetAll()
|
||||
@ -106,3 +105,50 @@ function SitAnywhere.ValidSitTrace(ply, EyeTrace)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local seatClass = "prop_vehicle_prisoner_pod"
|
||||
local PMETA = FindMetaTable"Player"
|
||||
function PMETA:GetSitters()
|
||||
local seats, holders = {}, {}
|
||||
|
||||
local function processSeat(seat, depth)
|
||||
depth = (depth or 0) + 1
|
||||
if IsValid(seat:GetDriver()) then
|
||||
table.insert(seats, seat)
|
||||
end
|
||||
for _, v in pairs(seat:GetChildren()) do
|
||||
if IsValid(v) and v:GetClass() == seatClass and IsValid(v:GetDriver()) and #v:GetChildren() > 0 and depth <= 128 then
|
||||
processSeat(v, depth)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local plyVehicle = self:GetVehicle()
|
||||
if IsValid(plyVehicle) and plyVehicle:GetClass() == seatClass then
|
||||
processSeat(plyVehicle)
|
||||
end
|
||||
|
||||
for _, v in pairs(self:GetChildren()) do
|
||||
if IsValid(v) and v:GetClass() == seatClass then
|
||||
processSeat(v)
|
||||
end
|
||||
end
|
||||
|
||||
for _, v in pairs(ents.FindByClass(holderClass)) do
|
||||
if v.GetTargetPlayer and v:GetTargetPlayer() == self then
|
||||
table.insert(holders, v)
|
||||
if v.GetSeat and IsValid(v:GetSeat()) then
|
||||
processSeat(v:GetSeat())
|
||||
end
|
||||
end
|
||||
end
|
||||
return seats, holders
|
||||
end
|
||||
|
||||
function PMETA:IsPlayerSittingOn(ply)
|
||||
local seats = ply:GetSitters()
|
||||
for _,v in pairs(seats) do
|
||||
if IsValid(v:GetDriver()) and v:GetDriver() == self then return true end
|
||||
end
|
||||
return false
|
||||
end
|
@ -371,12 +371,12 @@ function META.Sit(ply, EyeTrace, ang, parent, parentbone, func, exit, wantedAng)
|
||||
local zadjust = math.abs( min.z ) + math.abs( max.z )
|
||||
local seatPos = ent:GetPos() + Vector( 0, 0, 10 + zadjust / 2)
|
||||
|
||||
do
|
||||
--[[do
|
||||
local bone = ent:LookupBone("ValveBiped.Bip01_Neck1")
|
||||
if bone then
|
||||
seatPos = ent:GetBonePosition(bone) - Vector(0, 0, 9)
|
||||
end
|
||||
end
|
||||
end]]
|
||||
|
||||
local vehicle = Sit(ply, seatPos, ply:GetAngles(), ent, EyeTrace.PhysicsBone or 0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user