Auto hand switching fixes (#237)

* Bug fix and slight adjustments

* Better ladder/bar detection and fixes

---------

Co-authored-by: Globalsl <Globalsl>
This commit is contained in:
Global silver 2025-02-17 20:35:19 +02:00 committed by GitHub
parent ef9e860636
commit 4e6630d974
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,25 +12,7 @@ local requires_arms = {
hangfoldedheaveup = true, hangfoldedheaveup = true,
hangstrafeleft = true, hangstrafeleft = true,
hangstraferight = true, hangstraferight = true,
hanghardstart = 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 = { local animtable = {
@ -1544,8 +1526,8 @@ local weapon_before_hands
local function JumpThink() local function JumpThink()
local ply = LocalPlayer() local ply = LocalPlayer()
if AutoHandSwitching:GetBool() and ply:Alive() then -- Auto hand switching part if AutoHandSwitching:GetBool() and ply:Alive() and IsValid(ply:GetWeapon("runnerhands")) then -- Auto hand switching part
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 if (ply:GetWallrun() == 1 or ply:GetMantle() > 1 or IsValid(ply:GetZipline()) or IsValid(ply:GetLadder()) or IsValid(ply:GetSwingbar()) or requires_arms[BodyAnimString]) and not using_hands and not ply:UsingRH() then
weapon_before_hands = ply:GetActiveWeapon() weapon_before_hands = ply:GetActiveWeapon()
input.SelectWeapon(ply:GetWeapon("runnerhands")) input.SelectWeapon(ply:GetWeapon("runnerhands"))
@ -1568,8 +1550,10 @@ local function JumpThink()
if IsValid(ply:GetZipline()) then BodyAnim:SetSequence("zipline") end if IsValid(ply:GetZipline()) then BodyAnim:SetSequence("zipline") end
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 using_hands and not ply:UsingRH() then input.SelectWeapon(ply:GetWeapon("runnerhands")) end --blocks weapon switching
if IsValid(weapon_before_hands) and ply:UsingRH() then input.SelectWeapon(weapon_before_hands) end
if ply:GetWallrun() == 0 and not requires_arms[BodyAnimString] and ply:GetMantle() == 0 and not IsValid(ply:GetLadder()) and not IsValid(ply:GetSwingbar()) and using_hands and not IsValid(ply:GetZipline()) and ply:UsingRH() then
if IsValid(weapon_before_hands) then input.SelectWeapon(weapon_before_hands) end
using_hands = false using_hands = false
end end