From 13b1fcba71918e606b4134822e535a68517a07e0 Mon Sep 17 00:00:00 2001 From: Global silver <87803221+Global0Silver@users.noreply.github.com> Date: Fri, 14 Feb 2025 16:22:48 +0200 Subject: [PATCH] Added auto hand switching/put away weapon feature (#235) * Added auto hand switching/put away weapon feature * feat:Add toolmenu toggle for hand switching * fix:Toolmenu: Separate hand switch desc from toggle text * feat:Add English localization to toolmenu hand switch setting * Auto hand switching cleanup * small spelling fix * Bug fix and added switching for more hang animations * Added more scenarios(ladders, monkey bars and ziplines) * Bug fix and a tweak to wallrunning * Cleanup * Bug fix :/ --------- Co-authored-by: Globalsl Co-authored-by: UnderSet --- .../localization/en/beatrun.properties | 4 ++ .../beatrun/gamemode/cl/JumpAnim.lua | 69 ++++++++++++++++++- .../beatrun/gamemode/cl/ToolMenuSettings.lua | 3 + 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/beatrun/gamemodes/beatrun/content/resource/localization/en/beatrun.properties b/beatrun/gamemodes/beatrun/content/resource/localization/en/beatrun.properties index 4364a28..9f0089d 100644 --- a/beatrun/gamemodes/beatrun/content/resource/localization/en/beatrun.properties +++ b/beatrun/gamemodes/beatrun/content/resource/localization/en/beatrun.properties @@ -155,6 +155,10 @@ beatrun.toolsmenu.gameplay.quickturngrounddesc=Toggles quickturning with seconda beatrun.toolsmenu.gameplay.quickturnhandsonly=Quickturn Hands Only beatrun.toolsmenu.gameplay.quickturnhandsonlydesc=Toggles quickturning with "Runner Hands" only +# This is written pretty awkwardly, please rewrite if necessary - UnderSet +beatrun.toolsmenu.gameplay.autohandswitch=Automatic Hand Switching +beatrun.toolsmenu.gameplay.autohandswitchdesc=Automatically switches to Beatrun's hands during certain movement scenarios. + beatrun.toolsmenu.gameplay.puristmode=Purist Mode beatrun.toolsmenu.gameplay.puristmodedesc=Purist mode is a clientside preference that severely weakens the ability to strafe while in the air, which is how Mirror's Edge games handle this.\nDisabled = No restrictions\nEnabled = Reduced move speed in the air diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua b/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua index eb32834..d15a661 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/JumpAnim.lua @@ -1,4 +1,36 @@ local OldAnims = CreateClientConVar("Beatrun_OldAnims", "0", true, false, "") +local AutoHandSw = CreateClientConVar("Beatrun_AutoHandSwitching", "1", true, false) + +local requires_arms = { -- animations that use arms for auto hand switching + hang = true, + hanghardstartvertical = true, + hangheaveup = true, + hangfoldedstart = true, + hanghardstart2 = true, + hangfoldedendhang = true, + hangfoldedheaveup= true, + hangstrafeleft = true, + hangstraferight = true, + hanghardstart = true, + ladder = true, + ladderclimbdownfast = true, + ladderclimbhangstart = true, + ladderclimbleft = true, + ladderclimbright = true, + ladderclimbuplefthand = true, + ladderclimbuplefthandstill = true, + ladderclimbuprighthand = true, + ladderclimbuprighthandstill = true, + ladderenterbottom = true, + ladderenter = true, + ladderenterhang = true, + ladderexitarm1 = true, + ladderexitarm2 = true, + ladderexittoplefthand = true, + ladderexittoprighthand = true, + swingstraight = true, + swingjumpoff = true +} local animtable = { lockang = false, @@ -1504,8 +1536,43 @@ end) local animtr, animtr_result = nil, nil local oldnewang = Angle() +--auto hand switching variables +local using_hands = false +local weapon_before_hands local function JumpThink() + -- auto hand switching code + local ply = LocalPlayer() + if AutoHandSw:GetBool() and ply:Alive() then + if ((ply:GetWallrun() == 1 or ply:GetMantle() > 0 or IsValid(ply:GetZipline()) or requires_arms[BodyAnimString]) and not using_hands) and not ply:UsingRH() then + weapon_before_hands = (ply:GetActiveWeapon()) + input.SelectWeapon(ply:GetWeapon("runnerhands")) + using_hands = true + if ply:GetWallrun() == 1 then -- 1 = verticaL + BodyLimitX = 25 -- fixes a bug where if u look behind u will vault over air + BodyLimitY = 70 + BodyAnim:SetSequence("wallrunverticalstart") + end + + if ply:GetMantle() == 2 then + BodyAnim:SetSequence("vaultover") + elseif ply:GetMantle() == 3 then + BodyAnim:SetSequence("vaultkong") + end + + if IsValid(ply:GetZipline()) then + BodyAnim:SetSequence("zipline") + end + end + if ply:GetWallrun() == 0 and not requires_arms[BodyAnimString] and ply:GetMantle() == 0 and using_hands and not IsValid(ply:GetZipline()) then + if IsValid(weapon_before_hands) and ply:UsingRH() then + input.SelectWeapon(weapon_before_hands) + end + + using_hands = false + end + end + if IsValid(BodyAnim) then if not animtr then animtr = {} @@ -1826,4 +1893,4 @@ local function JumpThink() end end -hook.Add("Think", "JumpThink", JumpThink) +hook.Add("Think", "JumpThink", JumpThink) \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/ToolMenuSettings.lua b/beatrun/gamemodes/beatrun/gamemode/cl/ToolMenuSettings.lua index d3726c7..05b6a1e 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/ToolMenuSettings.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/ToolMenuSettings.lua @@ -246,6 +246,9 @@ hook.Add("PopulateToolMenu", "Beatrun_ToolMenu", function() panel:CheckBox("#beatrun.toolsmenu.gameplay.quickturnhandsonly", "Beatrun_QuickturnHandsOnly") panel:ControlHelp("#beatrun.toolsmenu.gameplay.quickturnhandsonlydesc") + panel:CheckBox("#beatrun.toolsmenu.gameplay.autohandswitch", "Beatrun_AutoHandSwitching") + panel:ControlHelp("#beatrun.toolsmenu.gameplay.autohandswitchdesc") + panel:CheckBox("#beatrun.toolsmenu.gameplay.puristmode", "Beatrun_PuristMode") panel:ControlHelp(language.GetPhrase("beatrun.toolsmenu.gameplay.puristmodedesc"))