From 9ff173ab3535fc9dbf75d2c8253831039544f4fb Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Sat, 30 Sep 2023 16:03:04 +0500 Subject: [PATCH] use meta function --- .../entities/weapons/runnerhands/shared.lua | 29 +++++++++---------- .../beatrun/gamemode/cl/BodyAnim.lua | 25 ++++++++-------- beatrun/gamemodes/beatrun/gamemode/cl/HUD.lua | 2 +- .../beatrun/gamemode/cl/JumpAnim.lua | 2 +- .../beatrun/gamemode/cl/off/blind.lua | 3 +- .../gamemode/player_class/player_beatrun.lua | 2 +- .../beatrun/gamemode/sh/0_Helpers.lua | 17 ++++++++++- .../gamemodes/beatrun/gamemode/sh/0_Misc.lua | 4 +-- .../gamemodes/beatrun/gamemode/sh/Climb.lua | 6 +--- .../beatrun/gamemode/sh/CrouchJump.lua | 21 ++++---------- .../beatrun/gamemode/sh/FreerunSysAll.lua | 10 +++---- .../gamemodes/beatrun/gamemode/sh/Grapple.lua | 8 ++--- .../gamemodes/beatrun/gamemode/sh/Melee.lua | 2 +- .../beatrun/gamemode/sh/Quickturn.lua | 24 ++++----------- .../beatrun/gamemode/sh/SafetyRoll.lua | 12 ++++---- .../beatrun/gamemode/sh/Vaulting.lua | 4 +-- .../gamemodes/beatrun/gamemode/sh/Wallrun.lua | 12 ++------ .../beatrun/gamemode/sh/WallrunME.lua | 12 ++------ 18 files changed, 76 insertions(+), 119 deletions(-) diff --git a/beatrun/gamemodes/beatrun/entities/weapons/runnerhands/shared.lua b/beatrun/gamemodes/beatrun/entities/weapons/runnerhands/shared.lua index 97cc632..0ebf6fc 100644 --- a/beatrun/gamemodes/beatrun/entities/weapons/runnerhands/shared.lua +++ b/beatrun/gamemodes/beatrun/entities/weapons/runnerhands/shared.lua @@ -10,7 +10,7 @@ if CLIENT then SWEP.DrawCrosshair = false hook.Add("VManipPrePlayAnim", "LOCNoVManip", function() - if LocalPlayer():GetActiveWeapon():GetClass() == "runnerhands" or blinded then return false end + if LocalPlayer():UsingRH() or blinded then return false end end) end @@ -148,32 +148,29 @@ function SWEP:Think() -- what a piece of shit, send help if vel:Length() == 0 and util.QuickTrace(ply:GetShootPos(), ply:GetAimVector() * 30, ply).Hit and ply:GetMoveType() ~= MOVETYPE_NOCLIP and not ply:Crouching() and ply:WaterLevel() == 0 and ply:GetWallrun() == 0 then - if (math.floor(ply:LocalEyeAngles().y) <= 35 and math.floor(ply:LocalEyeAngles().y) >= 5) or - (math.floor(ply:LocalEyeAngles().y) <= 125 and math.floor(ply:LocalEyeAngles().y) >= 95) or - (math.floor(ply:LocalEyeAngles().y) <= -55 and math.floor(ply:LocalEyeAngles().y) >= -85) or - (math.floor(ply:LocalEyeAngles().y) <= -145 and math.floor(ply:LocalEyeAngles().y) >= -175) then + if (math.floor(ply:LocalEyeAngles().y) <= 35 and math.floor(ply:LocalEyeAngles().y) >= 5) or (math.floor(ply:LocalEyeAngles().y) <= 125 and math.floor(ply:LocalEyeAngles().y) >= 95) or (math.floor(ply:LocalEyeAngles().y) <= -55 and math.floor(ply:LocalEyeAngles().y) >= -85) or (math.floor(ply:LocalEyeAngles().y) <= -145 and math.floor(ply:LocalEyeAngles().y) >= -175) then if CLIENT then + BodyLimitX = 20 + return ArmInterrupt("standhandwallright") elseif game.SinglePlayer() then - return ply:SendLua("ArmInterrupt('standhandwallright')") + return ply:SendLua("BodyLimitX = 20 ArmInterrupt('standhandwallright')") end - elseif (math.floor(ply:LocalEyeAngles().y) <= 5 and math.floor(ply:LocalEyeAngles().y) >= -5) or - (math.floor(ply:LocalEyeAngles().y) <= 95 and math.floor(ply:LocalEyeAngles().y) >= 85) or - (math.floor(ply:LocalEyeAngles().y) <= -85 and math.floor(ply:LocalEyeAngles().y) >= -95) or - (math.floor(ply:LocalEyeAngles().y) <= -175 or math.floor(ply:LocalEyeAngles().y) >= 175) then + elseif (math.floor(ply:LocalEyeAngles().y) <= 5 and math.floor(ply:LocalEyeAngles().y) >= -5) or (math.floor(ply:LocalEyeAngles().y) <= 95 and math.floor(ply:LocalEyeAngles().y) >= 85) or (math.floor(ply:LocalEyeAngles().y) <= -85 and math.floor(ply:LocalEyeAngles().y) >= -95) or (math.floor(ply:LocalEyeAngles().y) <= -175 or math.floor(ply:LocalEyeAngles().y) >= 175) then if CLIENT then + BodyLimitX = 20 + return ArmInterrupt("standhandwallboth") elseif game.SinglePlayer() then - return ply:SendLua("ArmInterrupt('standhandwallboth')") + return ply:SendLua("BodyLimitX = 20 ArmInterrupt('standhandwallboth')") end - elseif (math.floor(ply:LocalEyeAngles().y) <= 5 and math.floor(ply:LocalEyeAngles().y) >= -35) or - (math.floor(ply:LocalEyeAngles().y) <= 85 and math.floor(ply:LocalEyeAngles().y) >= 55) or - (math.floor(ply:LocalEyeAngles().y) <= -95 and math.floor(ply:LocalEyeAngles().y) >= -125) or - (math.floor(ply:LocalEyeAngles().y) <= 175 and math.floor(ply:LocalEyeAngles().y) >= 145) then + elseif (math.floor(ply:LocalEyeAngles().y) <= 5 and math.floor(ply:LocalEyeAngles().y) >= -35) or (math.floor(ply:LocalEyeAngles().y) <= 85 and math.floor(ply:LocalEyeAngles().y) >= 55) or (math.floor(ply:LocalEyeAngles().y) <= -95 and math.floor(ply:LocalEyeAngles().y) >= -125) or (math.floor(ply:LocalEyeAngles().y) <= 175 and math.floor(ply:LocalEyeAngles().y) >= 145) then if CLIENT then + BodyLimitX = 20 + return ArmInterrupt("standhandwallleft") elseif game.SinglePlayer() then - return ply:SendLua("ArmInterrupt('standhandwallleft')") + return ply:SendLua("BodyLimitX = 20 ArmInterrupt('standhandwallleft')") end end end diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/BodyAnim.lua b/beatrun/gamemodes/beatrun/gamemode/cl/BodyAnim.lua index b409ce3..44d9422 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/BodyAnim.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/BodyAnim.lua @@ -120,7 +120,7 @@ function RemoveBodyAnim(noang) local currentwep = ply:GetActiveWeapon() local vm = ply:GetViewModel() - if IsValid(currentwep) and currentwep:GetClass() ~= "runnerhands" then + if ply:notUsingRH() then if currentwep.PlayViewModelAnimation then currentwep:PlayViewModelAnimation("Draw") else @@ -222,13 +222,13 @@ function CacheLerpBodyAnim() local pos = LocalPlayer():GetPos() -- local posdelta = pos - matrixfrompos - local self = BodyAnim - self.m = self.m or Matrix() + local this = BodyAnim + this.m = this.m or Matrix() local from = matrixfrom local to = matrixto - for bone = 0, self:GetBoneCount() - 1 do + for bone = 0, this:GetBoneCount() - 1 do if not armbones[BodyAnim:GetBoneName(bone)] then if not to[bone] then to[bone] = {{}, {}, {}} @@ -240,7 +240,7 @@ function CacheLerpBodyAnim() from[bone] = cachebody[bone]:FastToTable(from[bone]) or from[bone] to[bone] = to[bone] or ModelBoneMatrix:FastToTable(to[bone]) - local bonematrix = self:GetBoneMatrix(bone) + local bonematrix = this:GetBoneMatrix(bone) bonematrix:SetTranslation(bonematrix:GetTranslation() - pos) to[bone] = bonematrix:FastToTable(to[bone]) @@ -255,8 +255,8 @@ function CacheLerpBodyAnim() v[4] = LerpL(transitionlerp, from[4], v[4]) end - if not self.m then - self.m = Matrix(to[bone]) + if not this.m then + this.m = Matrix(to[bone]) else local bt = to[bone] local bt1 = bt[1] @@ -264,12 +264,12 @@ function CacheLerpBodyAnim() local bt3 = bt[3] slot15 = bt[4] - self.m:SetUnpacked(bt1[1], bt1[2], bt1[3], bt1[4], bt2[1], bt2[2], bt2[3], bt2[4], bt3[1], bt3[2], bt3[3], bt3[4], 0, 0, 0, 1) + this.m:SetUnpacked(bt1[1], bt1[2], bt1[3], bt1[4], bt2[1], bt2[2], bt2[3], bt2[4], bt3[1], bt3[2], bt3[3], bt3[4], 0, 0, 0, 1) end - self.m:SetTranslation(self.m:GetTranslation() + pos) - self.m:SetScale(scalevec) - self:SetBoneMatrix(bone, self.m) + this.m:SetTranslation(this.m:GetTranslation() + pos) + this.m:SetScale(scalevec) + this:SetBoneMatrix(bone, this.m) end end @@ -505,9 +505,8 @@ function BodyAnimCalcView2(ply, pos, angles, fov) if ply:Crouching() then local from = BodyAnimCrouchLerpZ - local activewep = ply:GetActiveWeapon() - if IsValid(activewep) and activewep:GetClass() == "runnerhands" then + if ply:UsingRH() then from = ply:EyePos().z - 64 end diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/HUD.lua b/beatrun/gamemodes/beatrun/gamemode/cl/HUD.lua index a613443..ae0fe16 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/HUD.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/HUD.lua @@ -541,7 +541,7 @@ local function BeatrunReticle() local wep = LocalPlayer():GetActiveWeapon() - if not IsValid(wep) or wep:GetClass() ~= "runnerhands" then return end + if not IsValid(wep) or LocalPlayer():notUsingRH() then return end surface.SetDrawColor(255, 255, 255) surface.SetMaterial(crosshair_standard) diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua b/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua index 5c69c4a..f5b34d7 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua @@ -1233,7 +1233,7 @@ local function JumpArmDraw(a, b, c) local activewep = ply:GetActiveWeapon() - if IsValid(activewep) and activewep:GetClass() == "runnerhands" then + if ply:UsingRH() then if not worldarm[BodyAnimString] then cam.Start3D(pos, ang) cam.IgnoreZ(ignorezarm[BodyAnimString] or false) diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/off/blind.lua b/beatrun/gamemodes/beatrun/gamemode/cl/off/blind.lua index 63730e6..68ac2df 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/off/blind.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/off/blind.lua @@ -610,9 +610,8 @@ function ToggleBlindness(toggle) if blinded then local ply = LocalPlayer() local activewep = ply:GetActiveWeapon() - local usingrh = IsValid(activewep) and activewep:GetClass() == "runnerhands" - if usingrh and activewep.RunWind1 then + if ply:UsingRH() and activewep.RunWind1 then activewep.RunWind1:Stop() activewep.RunWind2:Stop() end diff --git a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua index 768de6f..d29f6b4 100644 --- a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua +++ b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua @@ -374,7 +374,7 @@ end hook.Add("FinishMove", "BeatrunRHVelocity", function(ply, mv) local activewep = ply:GetActiveWeapon() - if IsValid(activewep) and activewep:GetClass() == "runnerhands" and activewep.SetOwnerVelocity then + if ply:UsingRH() and activewep.SetOwnerVelocity then activewep:SetOwnerVelocity(math.Round(mv:GetVelocity():Length())) end end) diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/0_Helpers.lua b/beatrun/gamemodes/beatrun/gamemode/sh/0_Helpers.lua index d33bf4f..b23ee15 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/0_Helpers.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/0_Helpers.lua @@ -68,5 +68,20 @@ end function playermeta:UsingRH(wep) local activewep = wep or self:GetActiveWeapon() - if IsValid(activewep) then return activewep:GetClass() == "runnerhands" end + + if IsValid(activewep) and activewep:GetClass() == "runnerhands" then + return true + else + return false + end +end + +function playermeta:notUsingRH(wep) + local activewep = wep or self:GetActiveWeapon() + + if IsValid(activewep) and activewep:GetClass() ~= "runnerhands" then + return true + else + return false + end end \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/0_Misc.lua b/beatrun/gamemodes/beatrun/gamemode/sh/0_Misc.lua index c1b751b..ab94f74 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/0_Misc.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/0_Misc.lua @@ -70,9 +70,7 @@ hook.Add("SetupMove", "JumpDetect", function(ply, mv, cmd) end end - local activewep = ply:GetActiveWeapon() - - if IsValid(activewep) and activewep:GetClass() == "runnerhands" then + if ply:UsingRH() then ply:SetWasOnGround(ply:OnGround()) return diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Climb.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Climb.lua index e0a66f2..dfe7d3d 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Climb.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Climb.lua @@ -649,11 +649,7 @@ local function ClimbingCheck(ply, mv, cmd) local activewep = ply:GetActiveWeapon() - if IsValid(activewep) then - usingrh = activewep:GetClass() == "runnerhands" - end - - if usingrh and activewep.SendWeaponAnim then + if ply:UsingRH() and activewep.SendWeaponAnim then activewep:SendWeaponAnim(ACT_VM_HITCENTER) activewep:SetBlockAnims(false) end diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/CrouchJump.lua b/beatrun/gamemodes/beatrun/gamemode/sh/CrouchJump.lua index 8101005..fb5496b 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/CrouchJump.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/CrouchJump.lua @@ -1,4 +1,3 @@ -local usingrh = nil local punch = Angle(0.5, 0, 0) local punchland = Angle(10, 0, 0.5) local punchthink = Angle() @@ -30,13 +29,9 @@ hook.Add("SetupMove", "CrouchJump", function(ply, mv, cmd) ply:SetCrouchJumpBlocked(false) end + local activewep = ply:GetActiveWeapon() + if ply:Alive() and not ply:GetCrouchJumpBlocked() and not IsValid(ply:GetZipline()) and not IsValid(ply:GetLadder()) and ply:GetClimbing() == 0 and not ply:GetJumpTurn() and ply:GetMantle() == 0 and not ply:OnGround() and ply:GetVelocity().z > -350 and ply:GetCrouchJumpTime() < CurTime() and ply:GetWallrun() == 0 and mv:KeyPressed(IN_DUCK) then - local activewep = ply:GetActiveWeapon() - - if IsValid(activewep) then - usingrh = activewep:GetClass() == "runnerhands" - end - if CLIENT then local ang = ply:EyeAngles() ang.x = 0 @@ -47,7 +42,7 @@ hook.Add("SetupMove", "CrouchJump", function(ply, mv, cmd) BodyAnimCycle = 0 BodyAnimCrouchLerp = 0 - if usingrh then + if ply:UsingRH() then BodyAnimCrouchLerpZ = mv:GetOrigin().z - 32 else BodyAnimCrouchLerpZ = mv:GetOrigin().z @@ -70,16 +65,10 @@ hook.Add("SetupMove", "CrouchJump", function(ply, mv, cmd) ply:ViewPunch(punch) ply:SetViewOffsetDucked(Vector(0, 0, 28)) - if usingrh then + if ply:UsingRH() then activewep:SendWeaponAnim(ACT_VM_HOLSTER) end elseif (ply:OnGround() or ply:GetCrouchJumpTime() < CurTime() or not ply:Alive()) and ply:GetCrouchJump() then - local activewep = ply:GetActiveWeapon() - - if IsValid(activewep) then - usingrh = activewep:GetClass() == "runnerhands" - end - if game.SinglePlayer() then net.Start("CrouchJumpSP") net.WriteBool(false) @@ -88,7 +77,7 @@ hook.Add("SetupMove", "CrouchJump", function(ply, mv, cmd) ply:SetCrouchJump(false) - if usingrh and IsValid(activewep) then + if ply:UsingRH() then activewep:SendWeaponAnim(ACT_VM_DRAW) end diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/FreerunSysAll.lua b/beatrun/gamemodes/beatrun/gamemode/sh/FreerunSysAll.lua index cce3372..ab10f08 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/FreerunSysAll.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/FreerunSysAll.lua @@ -36,7 +36,6 @@ if game.SinglePlayer() and CLIENT then end hook.Add("PlayerStepSoundTime", "MEStepTime", function(ply, step, walking) - local activewep = ply:GetActiveWeapon() local sprint = ply:GetMEMoveLimit() < speed_limit:GetInt() - 25 local stepmod = ply:GetStepRight() and 1 or -1 local stepvel = 1.25 @@ -51,7 +50,7 @@ hook.Add("PlayerStepSoundTime", "MEStepTime", function(ply, step, walking) local stepmod2 = 1 local stepmod3 = 1 - if IsValid(activewep) and activewep:GetClass() ~= "runnerhands" then + if ply:notUsingRH() then stepmod2 = 0.25 if not ply:IsSprinting() then @@ -59,7 +58,7 @@ hook.Add("PlayerStepSoundTime", "MEStepTime", function(ply, step, walking) end end - if not ply:Crouching() and not ply:KeyDown(IN_WALK) then + if not ply:Crouching() and not walking then if game.SinglePlayer() then local intensity = ply:GetInfoNum("Beatrun_ViewbobIntensity", 20) / 20 @@ -212,8 +211,7 @@ hook.Add("OnPlayerHitGround", "MELandSound", function(ply, water, floater, speed end) hook.Add("SetupMove", "MESetupMove", function(ply, mv, cmd) - local activewep = ply:GetActiveWeapon() - local usingrh = IsValid(activewep) and activewep:GetClass() == "runnerhands" + local usingrh = ply:UsingRH() local ismoving = (mv:KeyDown(IN_FORWARD) or not ply:OnGround() or ply:Crouching()) and not mv:KeyDown(IN_BACK) and ply:Alive() and (mv:GetVelocity():Length() > 50 or ply:GetMantle() ~= 0 or ply:Crouching()) if (CLIENT or game.SinglePlayer()) and CurTime() > (ply:GetStepRelease() or 0) and ply.FootstepReleaseLand then @@ -261,7 +259,7 @@ hook.Add("SetupMove", "MESetupMove", function(ply, mv, cmd) local weaponspeed = 150 local activewep = ply:GetActiveWeapon() - if IsValid(activewep) and activewep:GetClass() ~= "runnerhands" then + if ply:notUsingRH() then weaponspeed = speed_limit:GetInt() end diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Grapple.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Grapple.lua index 81d8305..ff4dfc0 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Grapple.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Grapple.lua @@ -9,10 +9,7 @@ if CLIENT then if disable_grapple:GetBool() and Course_Name == "" then return end if ply:GetMantle() ~= 0 or ply:GetClimbing() ~= 0 then return end if not ply:Alive() or Course_Name ~= "" then return end - - local activewep = ply:GetActiveWeapon() - - if IsValid(activewep) and activewep:GetClass() ~= "runnerhands" then return end + if ply:notUsingRH() then return end if ply:GetMoveType() == MOVETYPE_NOCLIP then return end if GetGlobalBool("GM_INFECTION") or GetGlobalBool("GM_DATATHEFT") or GetGlobalBool("GM_DEATHMATCH") then return end @@ -60,8 +57,7 @@ hook.Add("SetupMove", "Grapple", function(ply, mv, cmd) if not ply:Alive() or Course_Name ~= "" and ply:GetNW2Int("CPNum", 1) ~= -1 and not ply:GetNW2Entity("Swingrope"):IsValid() then return end if GetGlobalBool("GM_INFECTION") or GetGlobalBool("GM_DATATHEFT") or GetGlobalBool("GM_DEATHMATCH") and not ply:GetNW2Entity("Swingrope"):IsValid() then return end - local activewep = ply:GetActiveWeapon() - local usingrh = IsValid(activewep) and activewep:GetClass() == "runnerhands" + local usingrh = ply:UsingRH() if not ply.Grapple_tr then ply.Grapple_tr = {} diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Melee.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Melee.lua index b80f65f..e304939 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Melee.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Melee.lua @@ -105,7 +105,7 @@ local doors = { } local function KeyMelee(ply, mv) - return mv:KeyPressed(IN_ALT2) or mv:KeyPressed(IN_ATTACK) and IsValid(ply:GetActiveWeapon()) and ply:GetActiveWeapon():GetClass() == "runnerhands" + return mv:KeyPressed(IN_ALT2) or mv:KeyPressed(IN_ATTACK) and ply:UsingRH() end local function MeleeType(ply, mv, cmd) diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Quickturn.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Quickturn.lua index 58cedb0..1215ad3 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Quickturn.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Quickturn.lua @@ -38,9 +38,7 @@ function DoJumpTurnStand() VMLegs:Remove() end - local activewep = LocalPlayer():GetActiveWeapon() - - if IsValid(activewep) and activewep:GetClass() ~= "runnerhands" then + if LocalPlayer():notUsingRH() then BodyAnim:SetSequence("jumpturnlandstandgun") else BodyAnim:SetSequence("jumpturnlandstand") @@ -56,7 +54,7 @@ end local standpunch = Angle(-5, 0, 0) local function Quickturn(ply, mv, cmd) - local keypressed = ply:Alive() and mv:KeyPressed(IN_ATTACK2) and (ply:GetInfoNum("Beatrun_QuickturnHandsOnly", 0) == 1 and ply:GetActiveWeapon():GetClass() == "runnerhands" or ply:GetInfoNum("Beatrun_QuickturnHandsOnly", 0) == 0) + local keypressed = ply:Alive() and mv:KeyPressed(IN_ATTACK2) and (ply:GetInfoNum("Beatrun_QuickturnHandsOnly", 0) == 1 and ply:UsingRH() or ply:GetInfoNum("Beatrun_QuickturnHandsOnly", 0) == 0) if ply:GetWallrun() ~= 0 then if mv:KeyDown(IN_BACK) and mv:KeyPressed(IN_JUMP) or ply:GetQuickturn() then @@ -118,14 +116,7 @@ local function Quickturn(ply, mv, cmd) end end - local usingrh = false - local activewep = ply:GetActiveWeapon() - - if IsValid(activewep) then - usingrh = activewep:GetClass() == "runnerhands" - end - - if not usingrh and ply:GetWallrun() >= 2 then return end + if not ply:UsingRH() and ply:GetWallrun() >= 2 then return end ply:SetQuickturn(true) ply:SetQuickturnTime(CurTime()) @@ -147,11 +138,7 @@ local function Quickturn(ply, mv, cmd) local activewep = ply:GetActiveWeapon() - if IsValid(activewep) then - usingrh = activewep:GetClass() == "runnerhands" - end - - if usingrh then + if ply:UsingRH() then activewep:SendWeaponAnim(ACT_VM_PRIMARYATTACK) activewep:SetBlockAnims(true) end @@ -204,9 +191,8 @@ local function Quickturn(ply, mv, cmd) end standpunch.x = -math.abs(math.min(CurTime() - ply:GetJumpTurnRecovery() + 0.5, 0)) - local activewep = ply:GetActiveWeapon() - if IsValid(activewep) and activewep:GetClass() ~= "runnerhands" then + if ply:notUsingRH() then standpunch.x = standpunch.x * 0.1 standpunch.z = standpunch.x * 10 else diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/SafetyRoll.lua b/beatrun/gamemodes/beatrun/gamemode/sh/SafetyRoll.lua index 8dcb0db..6fe9f29 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/SafetyRoll.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/SafetyRoll.lua @@ -68,10 +68,10 @@ net.Receive("RollAnimSP", function() roll.animmodelstring = "climbanim" roll.BodyAnimSpeed = 1.5 else - if ply:GetActiveWeapon():GetClass() ~= "runnerhands" then - roll.AnimString = "merollgun" - else + if ply:UsingRH() then roll.AnimString = "meroll" + else + roll.AnimString = "merollgun" end roll.animmodelstring = "climbanim" @@ -172,10 +172,10 @@ hook.Add("OnPlayerHitGround", "SafetyRoll", function(ply, water, floater, speed) ply:SetSafetyRollAng(ang) ply:SetSafetyRollTime(CurTime() + 1.05) - if ply:GetActiveWeapon():GetClass() ~= "runnerhands" then - roll.AnimString = "merollgun" - else + if ply:UsingRH() then roll.AnimString = "meroll" + else + roll.AnimString = "merollgun" end roll.animmodelstring = "climbanim" diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Vaulting.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Vaulting.lua index 6db9195..166697a 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Vaulting.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Vaulting.lua @@ -48,7 +48,7 @@ end local function PlayVaultAnim(ply, legs, ang) local activewep = ply:GetActiveWeapon() - if IsValid(activewep) and activewep:GetClass() == "runnerhands" and activewep:GetSequence() == 17 then + if ply:UsingRH() and activewep:GetSequence() == 17 then activewep:SendWeaponAnim(ACT_VM_DRAW) end @@ -764,7 +764,7 @@ hook.Add("SetupMove", "BeatrunVaulting", function(ply, mv, cmd) local activewep = ply:GetActiveWeapon() - if IsValid(activewep) and activewep:GetClass() == "runnerhands" and mantletype == 1 then + if ply:UsingRH() and mantletype == 1 then activewep:SendWeaponAnim(ACT_VM_RECOIL1) end end diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Wallrun.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Wallrun.lua index 113ca01..f710327 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Wallrun.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Wallrun.lua @@ -105,11 +105,7 @@ local function WallrunningThink(ply, mv, cmd) local activewep = ply:GetActiveWeapon() - if IsValid(activewep) then - usingrh = activewep:GetClass() == "runnerhands" - end - - if usingrh then + if ply:UsingRH() then activewep:SendWeaponAnim(ACT_VM_HITCENTER) activewep:SetBlockAnims(false) end @@ -132,11 +128,7 @@ local function WallrunningThink(ply, mv, cmd) local activewep = ply:GetActiveWeapon() - if IsValid(activewep) then - usingrh = activewep:GetClass() == "runnerhands" - end - - if usingrh then + if ply:UsingRH() then activewep:SendWeaponAnim(ACT_VM_HITCENTER) activewep:SetBlockAnims(false) end diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/WallrunME.lua b/beatrun/gamemodes/beatrun/gamemode/sh/WallrunME.lua index 93320f3..c1d34e0 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/WallrunME.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/WallrunME.lua @@ -198,11 +198,7 @@ function PuristWallrunningThink(ply, mv, cmd, wr, wrtimeremains) local activewep = ply:GetActiveWeapon() - if IsValid(activewep) then - usingrh = activewep:GetClass() == "runnerhands" - end - - if usingrh then + if ply:UsingRH() then activewep:SendWeaponAnim(ACT_VM_HITCENTER) activewep:SetBlockAnims(false) end @@ -225,11 +221,7 @@ function PuristWallrunningThink(ply, mv, cmd, wr, wrtimeremains) local activewep = ply:GetActiveWeapon() - if IsValid(activewep) then - usingrh = activewep:GetClass() == "runnerhands" - end - - if usingrh then + if ply:UsingRH() then activewep:SendWeaponAnim(ACT_VM_HITCENTER) activewep:SetBlockAnims(false) end