mirror of
https://github.com/JonnyBro/beatrun.git
synced 2024-12-28 12:53:02 +05:00
parent
52c7eeea3a
commit
f8ab85a207
4 changed files with 61 additions and 24 deletions
|
@ -18,6 +18,21 @@ lockang = false
|
||||||
CamAddAng = false
|
CamAddAng = false
|
||||||
CamIgnoreAng = false
|
CamIgnoreAng = false
|
||||||
|
|
||||||
|
local tools = {["gmod_tool"] = true, ["weapon_physgun"] = true, ["gmod_camera"] = true}
|
||||||
|
has_tool_equipped = false
|
||||||
|
|
||||||
|
hook.Add("Think", "beatrun_detect_tool", function()
|
||||||
|
local lp = LocalPlayer()
|
||||||
|
if not IsValid(lp) then return end
|
||||||
|
|
||||||
|
local weapon = lp:GetActiveWeapon()
|
||||||
|
if not IsValid(weapon) then return end
|
||||||
|
|
||||||
|
local class = weapon:GetClass()
|
||||||
|
|
||||||
|
if tools[class] then has_tool_equipped = true else has_tool_equipped = false end
|
||||||
|
end)
|
||||||
|
|
||||||
-- local BodyAnimPos = Vector(0, 0, 0)
|
-- local BodyAnimPos = Vector(0, 0, 0)
|
||||||
-- local BodyAnimAngLerp = Angle(0, 0, 0)
|
-- local BodyAnimAngLerp = Angle(0, 0, 0)
|
||||||
-- local DidDraw = false
|
-- local DidDraw = false
|
||||||
|
@ -338,8 +353,6 @@ function StartBodyAnim(animtable)
|
||||||
BodyAnim:SetPos(ply:GetPos())
|
BodyAnim:SetPos(ply:GetPos())
|
||||||
BodyAnim:SetNoDraw(false)
|
BodyAnim:SetNoDraw(false)
|
||||||
|
|
||||||
BodyAnimStartPos:Set(BodyAnim:GetPos())
|
|
||||||
|
|
||||||
if not IsValid(ply:GetHands()) then return end
|
if not IsValid(ply:GetHands()) then return end
|
||||||
|
|
||||||
local plymodel = ply
|
local plymodel = ply
|
||||||
|
@ -480,6 +493,12 @@ function BodyAnimCalcView2(ply, pos, angles, fov)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if has_tool_equipped then
|
||||||
|
BodyAnim:SetNoDraw(true)
|
||||||
|
BodyAnim:SetRenderOrigin(pos * 1000)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if IsValid(BodyAnim) and pos:Distance(ply:EyePos()) > 20 then
|
if IsValid(BodyAnim) and pos:Distance(ply:EyePos()) > 20 then
|
||||||
if updatethirdperson then
|
if updatethirdperson then
|
||||||
ply:SetNoDraw(false)
|
ply:SetNoDraw(false)
|
||||||
|
@ -575,7 +594,7 @@ function BodyAnimCalcView2(ply, pos, angles, fov)
|
||||||
end
|
end
|
||||||
|
|
||||||
if attach ~= nil then
|
if attach ~= nil then
|
||||||
view.origin = attach.Pos
|
view.origin = has_tool_equipped and pos or attach.Pos
|
||||||
|
|
||||||
if savedeyeangb == Angle(0, 0, 0) then
|
if savedeyeangb == Angle(0, 0, 0) then
|
||||||
savedeyeangb = Angle(0, attach.Ang.y, 0)
|
savedeyeangb = Angle(0, attach.Ang.y, 0)
|
||||||
|
@ -583,10 +602,10 @@ function BodyAnimCalcView2(ply, pos, angles, fov)
|
||||||
|
|
||||||
view.angles = ply:EyeAngles()
|
view.angles = ply:EyeAngles()
|
||||||
|
|
||||||
if lockang2 then
|
if lockang2 and not has_tool_equipped then
|
||||||
view.angles = attach.Ang
|
view.angles = has_tool_equipped and angles or attach.Ang
|
||||||
view.angles.x = ply:EyeAngles().x
|
view.angles.x = ply:EyeAngles().x
|
||||||
view.origin = attach.Pos
|
view.origin = has_tool_equipped and pos or attach.Pos
|
||||||
end
|
end
|
||||||
|
|
||||||
allowedangchange = true
|
allowedangchange = true
|
||||||
|
@ -598,7 +617,7 @@ function BodyAnimCalcView2(ply, pos, angles, fov)
|
||||||
lastlockangstart:Set(lasteyeang)
|
lastlockangstart:Set(lasteyeang)
|
||||||
end
|
end
|
||||||
|
|
||||||
if ply:Alive() and lockang then
|
if ply:Alive() and (lockang and not has_tool_equipped) then
|
||||||
local attachId = BodyAnim:LookupAttachment(camjoint)
|
local attachId = BodyAnim:LookupAttachment(camjoint)
|
||||||
local attach = BodyAnim:GetAttachment(attachId) or attach
|
local attach = BodyAnim:GetAttachment(attachId) or attach
|
||||||
local ang = attach.Ang
|
local ang = attach.Ang
|
||||||
|
@ -608,7 +627,7 @@ function BodyAnimCalcView2(ply, pos, angles, fov)
|
||||||
lerplockang = math.Approach(lerplockang, 1, FrameTime() * 4.5)
|
lerplockang = math.Approach(lerplockang, 1, FrameTime() * 4.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
view.angles = ang
|
view.angles = has_tool_equipped and angles or ang
|
||||||
view.angles:Add(ViewTiltAngle)
|
view.angles:Add(ViewTiltAngle)
|
||||||
allowedangchange = false
|
allowedangchange = false
|
||||||
|
|
||||||
|
@ -672,8 +691,9 @@ function BodyAnimCalcView2(ply, pos, angles, fov)
|
||||||
hook.Run("BodyAnimCalcView", view)
|
hook.Run("BodyAnimCalcView", view)
|
||||||
|
|
||||||
pos:Set(view.origin)
|
pos:Set(view.origin)
|
||||||
angles:Set(view.angles)
|
if not has_tool_equipped then
|
||||||
|
angles:Set(view.angles)
|
||||||
|
end
|
||||||
if lerpchangeatt < 1 then
|
if lerpchangeatt < 1 then
|
||||||
pos:Set(lerpedpos)
|
pos:Set(lerpedpos)
|
||||||
end
|
end
|
||||||
|
@ -697,7 +717,7 @@ function BodyAnimCalcView2(ply, pos, angles, fov)
|
||||||
end
|
end
|
||||||
|
|
||||||
if attach == nil or CurTime() < (mantletimer or 0) then
|
if attach == nil or CurTime() < (mantletimer or 0) then
|
||||||
view.origin = lastattachpos
|
view.origin = has_tool_equipped and pos or lastattachpos
|
||||||
pos:Set(lastattachpos)
|
pos:Set(lastattachpos)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -745,8 +765,8 @@ hook.Add("CreateMove", "BodyAnim_Mouse", function(cmd)
|
||||||
local limitx = BodyLimitX or 30
|
local limitx = BodyLimitX or 30
|
||||||
local limity = BodyLimitY or 50
|
local limity = BodyLimitY or 50
|
||||||
|
|
||||||
pastlimitx = limitx < math.AngleDifference(nang.x, oang.x)
|
pastlimitx = limitx < math.AngleDifference(nang.x, oang.x) and not has_tool_equipped
|
||||||
pastlimity = limity < math.abs(math.AngleDifference(nang.y, oang.y))
|
pastlimity = limity < math.abs(math.AngleDifference(nang.y, oang.y)) and not has_tool_equipped
|
||||||
|
|
||||||
if limitx ~= lastlimitx and pastlimitx or limity ~= lastlimity and pastlimity then
|
if limitx ~= lastlimitx and pastlimitx or limity ~= lastlimity and pastlimity then
|
||||||
BodyAnimLimitEase = true
|
BodyAnimLimitEase = true
|
||||||
|
@ -796,7 +816,7 @@ end)
|
||||||
hook.Add("InputMouseApply", "BodyAnim_Mouse", function(cmd)
|
hook.Add("InputMouseApply", "BodyAnim_Mouse", function(cmd)
|
||||||
local newvalues = false
|
local newvalues = false
|
||||||
|
|
||||||
if lockang then
|
if lockang and not has_tool_equipped then
|
||||||
cmd:SetMouseX(0)
|
cmd:SetMouseX(0)
|
||||||
cmd:SetMouseY(0)
|
cmd:SetMouseY(0)
|
||||||
|
|
||||||
|
|
|
@ -1318,6 +1318,8 @@ hook.Add("PostDrawSkyBox", "JumpArm3DSky", function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
hook.Add("CalcViewModelView", "lol", function(wep, vm, oldpos, oldang, pos, ang)
|
hook.Add("CalcViewModelView", "lol", function(wep, vm, oldpos, oldang, pos, ang)
|
||||||
|
if has_tool_equipped then return end
|
||||||
|
|
||||||
pos:Sub(oldpos)
|
pos:Sub(oldpos)
|
||||||
pos:Add(campos)
|
pos:Add(campos)
|
||||||
ang:Sub(oldang)
|
ang:Sub(oldang)
|
||||||
|
|
|
@ -36,6 +36,8 @@ XP_floatingxp = {}
|
||||||
hook.Add("OnParkour", "ParkourXP", function(event)
|
hook.Add("OnParkour", "ParkourXP", function(event)
|
||||||
local ply = LocalPlayer()
|
local ply = LocalPlayer()
|
||||||
|
|
||||||
|
if not IsValid(ply) then return end
|
||||||
|
|
||||||
if ply.InReplay then return end
|
if ply.InReplay then return end
|
||||||
|
|
||||||
local pos = ply:GetPos()
|
local pos = ply:GetPos()
|
||||||
|
|
|
@ -301,9 +301,9 @@ end
|
||||||
local function CustomPropMat(prop)
|
local function CustomPropMat(prop)
|
||||||
if propmatsblacklist[buildmode_props_index[prop:GetModel()]] then return end
|
if propmatsblacklist[buildmode_props_index[prop:GetModel()]] then return end
|
||||||
|
|
||||||
if prop.hr then
|
if prop.hr == true then
|
||||||
prop:SetMaterial("medge/redplainplastervertex")
|
prop:SetMaterial("medge/redplainplastervertex")
|
||||||
else
|
elseif prop.hr == nil then
|
||||||
prop:SetMaterial("medge/plainplastervertex")
|
prop:SetMaterial("medge/plainplastervertex")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -604,7 +604,14 @@ if SERVER then
|
||||||
for _, v in pairs(props) do
|
for _, v in pairs(props) do
|
||||||
local a = ents.Create("prop_physics")
|
local a = ents.Create("prop_physics")
|
||||||
a.hr = v.hr
|
a.hr = v.hr
|
||||||
a:SetModel(buildmode_props[v.model])
|
|
||||||
|
local is_model_an_index = tonumber(v.model)
|
||||||
|
if is_model_an_index then
|
||||||
|
a:SetModel(buildmode_props[v.model])
|
||||||
|
else
|
||||||
|
a:SetModel(v.model)
|
||||||
|
end
|
||||||
|
|
||||||
CustomPropMat(a)
|
CustomPropMat(a)
|
||||||
|
|
||||||
a:SetPos(v.pos)
|
a:SetPos(v.pos)
|
||||||
|
@ -886,7 +893,7 @@ if CLIENT then
|
||||||
end
|
end
|
||||||
|
|
||||||
function CourseData(name)
|
function CourseData(name)
|
||||||
local save = {{}, {}, Course_StartPos, Course_StartAng, name or "Unnamed", {}}
|
local save = {{}, {}, Course_StartPos, Course_StartAng, name or os.date("%H:%M:%S - %d/%m/%Y", os.time()), {}}
|
||||||
|
|
||||||
for _, v in pairs(buildmode_placed) do
|
for _, v in pairs(buildmode_placed) do
|
||||||
if not IsValid(v) then -- Nothing
|
if not IsValid(v) then -- Nothing
|
||||||
|
@ -895,13 +902,13 @@ if CLIENT then
|
||||||
else
|
else
|
||||||
local class = v:GetClass()
|
local class = v:GetClass()
|
||||||
|
|
||||||
if class == "prop_physics" and not buildmode_props_index[v:GetModel():lower()] then
|
if class == "prop_physics" then
|
||||||
print("ignoring", v:GetModel():lower())
|
|
||||||
elseif class == "prop_physics" then
|
|
||||||
local hr = v:GetMaterial() == "medge/redplainplastervertex" and true or nil
|
local hr = v:GetMaterial() == "medge/redplainplastervertex" and true or nil
|
||||||
|
|
||||||
|
if v.buildmode_placed_manually then hr = false end
|
||||||
|
|
||||||
table.insert(save[1], {
|
table.insert(save[1], {
|
||||||
model = buildmode_props_index[v:GetModel():lower()],
|
model = v:GetModel():lower(),
|
||||||
pos = v:GetPos(),
|
pos = v:GetPos(),
|
||||||
ang = v:GetAngles(),
|
ang = v:GetAngles(),
|
||||||
hr = hr
|
hr = hr
|
||||||
|
@ -947,7 +954,7 @@ if CLIENT then
|
||||||
end
|
end
|
||||||
|
|
||||||
concommand.Add("Beatrun_SaveCourse", function(ply, cmd, args, argstr)
|
concommand.Add("Beatrun_SaveCourse", function(ply, cmd, args, argstr)
|
||||||
local name = args[1] or "Unnamed"
|
local name = args[1] or os.date("%H:%M:%S - %d/%m/%Y", os.time())
|
||||||
|
|
||||||
SaveCourse(name, args[2])
|
SaveCourse(name, args[2])
|
||||||
end)
|
end)
|
||||||
|
@ -970,7 +977,12 @@ if CLIENT then
|
||||||
end
|
end
|
||||||
|
|
||||||
concommand.Add("Beatrun_LoadCourse", function(ply, cmd, args, argstr)
|
concommand.Add("Beatrun_LoadCourse", function(ply, cmd, args, argstr)
|
||||||
local id = args[1] or "Unnamed"
|
local id = args[1]
|
||||||
|
|
||||||
|
if not id then
|
||||||
|
print("Supply the name.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
LoadCourse(id)
|
LoadCourse(id)
|
||||||
end)
|
end)
|
||||||
|
@ -1393,6 +1405,7 @@ if CLIENT then
|
||||||
|
|
||||||
hook.Add("OnEntityCreated", "BuildModeProps", function(ent)
|
hook.Add("OnEntityCreated", "BuildModeProps", function(ent)
|
||||||
if not ent:GetNW2Bool("BRProtected") and ent:GetClass() == "prop_physics" or buildmode_ents[ent:GetClass()] then
|
if not ent:GetNW2Bool("BRProtected") and ent:GetClass() == "prop_physics" or buildmode_ents[ent:GetClass()] then
|
||||||
|
if not BuildMode then ent.buildmode_placed_manually = true end
|
||||||
table.insert(buildmode_placed, ent)
|
table.insert(buildmode_placed, ent)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in a new issue