Garry's Mod

Garry's Mod

Original Counter Strike: Source Playermodels
HATE™ 2024 年 8 月 19 日 下午 6:28
Allow to Override Holdtype Based on Weapon/Swep
Some hold types don't look right and etc.

Please add a way to override thirdperson animations for certain sweps/weapons.

Here's some code ChatGPT generated. I have no idea how to actually hook it and since I don't pay for it, I wasn't able to get a complete LUA.


-- Function to override animations for specific weapons local function OverrideWeaponAnimations(pl) local weapon = pl:GetActiveWeapon() -- Check if the weapon is valid if not weapon:IsValid() then return end -- Override animations for specific weapons local weaponClass = weapon:GetClass() if weaponClass == "weapon_physgun" then -- Override with AWP animations OverrideAWPAnimations(pl) elseif weaponClass == "weapon_pistol" then -- Example: Override with custom animations for a pistol (replace with actual sequences) OverridePistolAnimations(pl) elseif weaponClass == "weapon_smg1" then -- Example: Override with custom animations for an SMG (replace with actual sequences) OverrideSMGAnimations(pl) end end -- Helper function to apply AWP animations local function OverrideAWPAnimations(pl) if pl:Crouching() then if pl:GetVelocity():Length2D() > 10 then pl:SetSequence(pl:LookupSequence("crouch_walk_upper_awp")) else pl:SetSequence(pl:LookupSequence("crouch_idle_upper_awp")) end else if pl:GetVelocity():Length2D() > 10 then if pl:KeyDown(IN_WALK) then pl:SetSequence(pl:LookupSequence("walk_upper_awp")) else pl:SetSequence(pl:LookupSequence("run_upper_awp")) end else pl:SetSequence(pl:LookupSequence("idle_upper_awp")) end end end -- Helper function for Pistol animations (example) local function OverridePistolAnimations(pl) if pl:Crouching() then pl:SetSequence(pl:LookupSequence("crouch_idle_upper_pistol")) -- Replace with actual sequence else pl:SetSequence(pl:LookupSequence("idle_upper_pistol")) -- Replace with actual sequence end end -- Helper function for SMG animations (example) local function OverrideSMGAnimations(pl) if pl:Crouching() then pl:SetSequence(pl:LookupSequence("crouch_idle_upper_smg")) -- Replace with actual sequence else pl:SetSequence(pl:LookupSequence("idle_upper_smg")) -- Replace with actual sequence end end -- Hook into CalcMainActivity to override animations hook.Add("CalcMainActivity", "OverrideSpecificWeaponAnimations", function(pl, vel) OverrideWeaponAnimations(pl) -- Default activity handling (can be customized further if needed) return pl:SelectWeightedSequence(ACT_HL2MP_IDLE), pl:SelectWeightedSequence(ACT_HL2MP_IDLE) end)
< >
正在显示第 1 - 3 条,共 3 条留言
siob  [开发者] 2024 年 8 月 19 日 下午 7:27 
ai generated code? bleh
however i could use it in the near future
siob  [开发者] 2024 年 8 月 19 日 下午 7:27 
thanks for your suggestion
HATE™ 2024 年 8 月 21 日 下午 2:46 
Edit (2024-09-02):

Turns out the script wasn't watching for current weapon in both shooting and reload events. Though this was a pretty obvious mistake I corrected it. Feel free to paste as you'd like. Optionally credit if you feel like it.

https://pastebin.com/raw/JZSyLMwS

Looking forward to any future improvements this gets. Would be nice if the snapping would get fixed or be reduced and any performance issues with PAC also get addressed if there are any.
最后由 HATE™ 编辑于; 2024 年 9 月 2 日 下午 7:46
< >
正在显示第 1 - 3 条,共 3 条留言
每页显示数: 1530 50