From 71db52c5443a7bf82d9a23a770994a42b043be04 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Thu, 27 Jul 2023 22:11:31 +0100 Subject: Initial commit --- code/weapon/Knife.cs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 code/weapon/Knife.cs (limited to 'code/weapon/Knife.cs') diff --git a/code/weapon/Knife.cs b/code/weapon/Knife.cs new file mode 100644 index 0000000..1bc74ed --- /dev/null +++ b/code/weapon/Knife.cs @@ -0,0 +1,37 @@ +using Sandbox; + +namespace MurderGame; + +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 Knife() + { + Ammo = -1; + MaxAmmo = -1; + } + + [ClientRpc] + 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" ); + ShootEffects( Melee( 100, 100 ) ); + } + + protected override void Animate() + { + Pawn.SetAnimParameter( "holdtype", (int)CitizenAnimationHelper.HoldTypes.Swing ); + } +} -- cgit v1.2.3-70-g09d2