diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/BodyAnim.lua b/beatrun/gamemodes/beatrun/gamemode/cl/BodyAnim.lua index 44d9422..7f6048e 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/BodyAnim.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/BodyAnim.lua @@ -18,6 +18,21 @@ lockang = false CamAddAng = 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 BodyAnimAngLerp = Angle(0, 0, 0) -- local DidDraw = false @@ -338,8 +353,6 @@ function StartBodyAnim(animtable) BodyAnim:SetPos(ply:GetPos()) BodyAnim:SetNoDraw(false) - BodyAnimStartPos:Set(BodyAnim:GetPos()) - if not IsValid(ply:GetHands()) then return end local plymodel = ply @@ -480,6 +493,12 @@ function BodyAnimCalcView2(ply, pos, angles, fov) return 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 updatethirdperson then ply:SetNoDraw(false) @@ -575,7 +594,7 @@ function BodyAnimCalcView2(ply, pos, angles, fov) end 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 savedeyeangb = Angle(0, attach.Ang.y, 0) @@ -583,10 +602,10 @@ function BodyAnimCalcView2(ply, pos, angles, fov) view.angles = ply:EyeAngles() - if lockang2 then - view.angles = attach.Ang + if lockang2 and not has_tool_equipped then + view.angles = has_tool_equipped and angles or attach.Ang view.angles.x = ply:EyeAngles().x - view.origin = attach.Pos + view.origin = has_tool_equipped and pos or attach.Pos end allowedangchange = true @@ -598,7 +617,7 @@ function BodyAnimCalcView2(ply, pos, angles, fov) lastlockangstart:Set(lasteyeang) end - if ply:Alive() and lockang then + if ply:Alive() and (lockang and not has_tool_equipped) then local attachId = BodyAnim:LookupAttachment(camjoint) local attach = BodyAnim:GetAttachment(attachId) or attach local ang = attach.Ang @@ -608,7 +627,7 @@ function BodyAnimCalcView2(ply, pos, angles, fov) lerplockang = math.Approach(lerplockang, 1, FrameTime() * 4.5) end - view.angles = ang + view.angles = has_tool_equipped and angles or ang view.angles:Add(ViewTiltAngle) allowedangchange = false @@ -672,8 +691,9 @@ function BodyAnimCalcView2(ply, pos, angles, fov) hook.Run("BodyAnimCalcView", view) pos:Set(view.origin) - angles:Set(view.angles) - + if not has_tool_equipped then + angles:Set(view.angles) + end if lerpchangeatt < 1 then pos:Set(lerpedpos) end @@ -697,7 +717,7 @@ function BodyAnimCalcView2(ply, pos, angles, fov) end if attach == nil or CurTime() < (mantletimer or 0) then - view.origin = lastattachpos + view.origin = has_tool_equipped and pos or lastattachpos pos:Set(lastattachpos) return @@ -745,8 +765,8 @@ hook.Add("CreateMove", "BodyAnim_Mouse", function(cmd) local limitx = BodyLimitX or 30 local limity = BodyLimitY or 50 - pastlimitx = limitx < math.AngleDifference(nang.x, oang.x) - pastlimity = limity < math.abs(math.AngleDifference(nang.y, oang.y)) + pastlimitx = limitx < math.AngleDifference(nang.x, oang.x) and not has_tool_equipped + 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 BodyAnimLimitEase = true @@ -796,7 +816,7 @@ end) hook.Add("InputMouseApply", "BodyAnim_Mouse", function(cmd) local newvalues = false - if lockang then + if lockang and not has_tool_equipped then cmd:SetMouseX(0) cmd:SetMouseY(0) diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua b/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua index 41b9c6c..68f721e 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua @@ -1318,6 +1318,8 @@ hook.Add("PostDrawSkyBox", "JumpArm3DSky", function() end) hook.Add("CalcViewModelView", "lol", function(wep, vm, oldpos, oldang, pos, ang) + if has_tool_equipped then return end + pos:Sub(oldpos) pos:Add(campos) ang:Sub(oldang) diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/XP.lua b/beatrun/gamemodes/beatrun/gamemode/cl/XP.lua index 9ce75c3..c051ab8 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/XP.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/XP.lua @@ -36,6 +36,8 @@ XP_floatingxp = {} hook.Add("OnParkour", "ParkourXP", function(event) local ply = LocalPlayer() + if not IsValid(ply) then return end + if ply.InReplay then return end local pos = ply:GetPos() diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua b/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua index edd8510..8170209 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua @@ -301,9 +301,9 @@ end local function CustomPropMat(prop) if propmatsblacklist[buildmode_props_index[prop:GetModel()]] then return end - if prop.hr then + if prop.hr == true then prop:SetMaterial("medge/redplainplastervertex") - else + elseif prop.hr == nil then prop:SetMaterial("medge/plainplastervertex") end end @@ -604,7 +604,14 @@ if SERVER then for _, v in pairs(props) do local a = ents.Create("prop_physics") 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) a:SetPos(v.pos) @@ -886,7 +893,7 @@ if CLIENT then end 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 if not IsValid(v) then -- Nothing @@ -895,13 +902,13 @@ if CLIENT then else local class = v:GetClass() - if class == "prop_physics" and not buildmode_props_index[v:GetModel():lower()] then - print("ignoring", v:GetModel():lower()) - elseif class == "prop_physics" then + if class == "prop_physics" then local hr = v:GetMaterial() == "medge/redplainplastervertex" and true or nil + if v.buildmode_placed_manually then hr = false end + table.insert(save[1], { - model = buildmode_props_index[v:GetModel():lower()], + model = v:GetModel():lower(), pos = v:GetPos(), ang = v:GetAngles(), hr = hr @@ -947,7 +954,7 @@ if CLIENT then end 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]) end) @@ -970,7 +977,12 @@ if CLIENT then end 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) end) @@ -1393,6 +1405,7 @@ if CLIENT then hook.Add("OnEntityCreated", "BuildModeProps", function(ent) 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) end end)