From b393d1abacc880b9d94d4ce5d48ae39fbe417ad5 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Tue, 1 Aug 2023 18:21:08 +0100 Subject: Add animations to knife --- code/weapon/Knife.cs | 10 +++++----- code/weapon/Pistol.cs | 1 + code/weapon/Weapon.cs | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/code/weapon/Knife.cs b/code/weapon/Knife.cs index 1bc74ed..8ff0bb2 100644 --- a/code/weapon/Knife.cs +++ b/code/weapon/Knife.cs @@ -7,7 +7,7 @@ public partial class Knife : Weapon public override string ModelPath => "weapons/swb/melee/bayonet/w_bayonet.vmdl"; public override string ViewModelPath => "weapons/swb/melee/bayonet/v_bayonet.vmdl"; public override string HandsModelPath => "weapons/swb/hands/rebel/v_hands_rebel.vmdl"; - public override float PrimaryRate => 1f; + public override float PrimaryRate => 1.5f; public Knife() { @@ -19,19 +19,19 @@ public partial class Knife : Weapon protected virtual void ShootEffects(bool hit) { Game.AssertClient(); - - Pawn.SetAnimParameter( "b_attack", true ); + ViewModelEntity?.SetAnimParameter( hit ? "swing" : "swing_miss" , true ); } public override void PrimaryAttack() { - Pawn.PlaySound( "bayonet.slash" ); + Pawn?.SetAnimParameter( "b_attack", true ); + Pawn?.PlaySound( "bayonet.slash" ); ShootEffects( Melee( 100, 100 ) ); } protected override void Animate() { - Pawn.SetAnimParameter( "holdtype", (int)CitizenAnimationHelper.HoldTypes.Swing ); + Pawn?.SetAnimParameter( "holdtype", (int)CitizenAnimationHelper.HoldTypes.Swing ); } } diff --git a/code/weapon/Pistol.cs b/code/weapon/Pistol.cs index 567eb3e..4c0c70b 100644 --- a/code/weapon/Pistol.cs +++ b/code/weapon/Pistol.cs @@ -37,6 +37,7 @@ public partial class Pistol : Weapon public override void Reload() { ReloadEffects(); + Pawn?.SetAnimParameter( "b_reload", true ); } [ClientRpc] diff --git a/code/weapon/Weapon.cs b/code/weapon/Weapon.cs index 6d6fc20..8eafbc3 100644 --- a/code/weapon/Weapon.cs +++ b/code/weapon/Weapon.cs @@ -171,7 +171,7 @@ public partial class Weapon : AnimatedEntity var pos = ray.Position; bool hit = false; - foreach (var tr in TraceBullet(pos, pos + forward * 50, 20)) + foreach (var tr in TraceBullet(pos, pos + forward * 80, 20)) { tr.Surface.DoBulletImpact(tr); hit = true; @@ -202,6 +202,7 @@ public partial class Weapon : AnimatedEntity vm.Model = Model.Load( ViewModelPath ); vm.Owner = Owner; vm.Parent = Game.LocalPawn; + vm.SetAnimParameter( "deploy", true ); ViewModelEntity = vm; if (!string.IsNullOrEmpty(HandsModelPath)) { -- cgit v1.2.3-70-g09d2