From 77140245e900c31e3b140b343d22619a42130db1 Mon Sep 17 00:00:00 2001 From: relaxtakenotes <134127331+jeffthekillerz@users.noreply.github.com> Date: Fri, 2 Jun 2023 17:16:10 +0500 Subject: [PATCH] grapple: move with attached ent, show rope to everyone --- .../gamemodes/beatrun/gamemode/sh/Grapple.lua | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Grapple.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Grapple.lua index 75774bd..0cb372f 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Grapple.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Grapple.lua @@ -83,6 +83,7 @@ hook.Add("SetupMove", "Grapple", function(ply, mv, cmd) ply:SetWallrunCount(0) ply:SetJumpTurn(false) ply:SetCrouchJumpBlocked(false) + ply:SetNW2Entity("grappleEntity", trout.Entity) if CLIENT_IFTP() or game.SinglePlayer() then ply:EmitSound("MirrorsEdge/Gadgets/ME_Magrope_Fire.wav", 40, 100 + math.random(-25, 10)) @@ -102,9 +103,17 @@ hook.Add("SetupMove", "Grapple", function(ply, mv, cmd) -- local gpos = ply:GetGrapplePos() local pos = mv:GetOrigin() local eyepos = mv:GetOrigin() + + local ent = ply:GetNW2Entity("grappleEntity") + eyepos.z = eyepos.z + 64 - if not ply:Alive() or mv:KeyPressed(IN_JUMP) and not grappled and not ply:OnGround() or ply:GetClimbing() ~= 0 or ply:GetMantle() ~= 0 or not usingrh then + if (not ply:Alive() or mv:KeyPressed(IN_JUMP) and not grappled and not ply:OnGround() or ply:GetClimbing() ~= 0 or ply:GetMantle() ~= 0 or not usingrh) or (ent == NULL or ent == nil) then + if IsValid(ent) and ent != NULL then + ent:SetNW2Vector("glastpos", nil) + ent:SetNW2Vector("gpos", nil) + end + ply:SetGrappling(false) if CLIENT_IFTP() or game.SinglePlayer() then @@ -130,6 +139,12 @@ hook.Add("SetupMove", "Grapple", function(ply, mv, cmd) return end + if ent:GetClass() != "worldspawn" then + ent:SetNW2Vector("glastpos", ent:GetNW2Vector("gpos", ent:GetPos())) + ent:SetNW2Vector("gpos", ent:GetPos()) + ply:SetGrapplePos(ply:GetGrapplePos() + (ent:GetNW2Vector("gpos") - ent:GetNW2Vector("glastpos"))) + end + if mv:KeyDown(IN_ATTACK) and mv:GetOrigin().z < ply:GetGrapplePos().z - 64 then ply:SetGrappleLength(ply:GetGrappleLength() - FrameTime() * 100) elseif mv:KeyDown(IN_ATTACK2) then @@ -203,12 +218,12 @@ local ropelerp = 0 local ropedown = Vector(0, 0, 20) hook.Add("PostDrawTranslucentRenderables", "GrappleBeam", function() - local ply = LocalPlayer() + local lp = LocalPlayer() - if ply:GetGrappling() then + if lp:GetGrappling() then local BA = BodyAnimArmCopy - if ply:ShouldDrawLocalPlayer() then + if lp:ShouldDrawLocalPlayer() then BA = BodyAnim end @@ -239,7 +254,7 @@ hook.Add("PostDrawTranslucentRenderables", "GrappleBeam", function() rhandpos:Add(up) render.DrawBeam(LerpVector(ropelerp, lhandpos - ropedown, rhandpos), lhandpos, 1.5, 0, 1) - render.DrawBeam(ropetop, ply:GetGrapplePos(), 1.5, 0, 1) + render.DrawBeam(ropetop, lp:GetGrapplePos(), 1.5, 0, 1) BodyAnim:SetSequence("grapplecenter") @@ -247,6 +262,15 @@ hook.Add("PostDrawTranslucentRenderables", "GrappleBeam", function() else ropelerp = 0 end + + for i, ply in ipairs(player.GetAll()) do + if ply == lp then continue end + if ply:GetGrappling() then + local pos = ply:GetPos() + pos.z = pos.z + 32 + render.DrawBeam(pos, ply:GetGrapplePos(), 1.5, 0, 1) + end + end end) function CreateSwingrope(startpos, length)