diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2023-07-27 22:11:31 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2023-07-27 22:11:31 +0100 |
| commit | 71db52c5443a7bf82d9a23a770994a42b043be04 (patch) | |
| tree | f75f2605bb1bdc53842cd85c90d105dcc77e1c10 /code/weapon/Pistol.cs | |
Initial commit
Diffstat (limited to 'code/weapon/Pistol.cs')
| -rw-r--r-- | code/weapon/Pistol.cs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/code/weapon/Pistol.cs b/code/weapon/Pistol.cs new file mode 100644 index 0000000..567eb3e --- /dev/null +++ b/code/weapon/Pistol.cs @@ -0,0 +1,52 @@ +using Sandbox;
+
+namespace MurderGame;
+
+public partial class Pistol : Weapon
+{
+ public override string ModelPath => "weapons/rust_pistol/rust_pistol.vmdl";
+ public override string ViewModelPath => "weapons/rust_pistol/v_rust_pistol.vmdl";
+
+ public Pistol()
+ {
+ MaxAmmo = 1;
+ }
+
+ [ClientRpc]
+ protected virtual void ShootEffects()
+ {
+ Game.AssertClient();
+
+ Particles.Create( "particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle" );
+
+ Pawn?.SetAnimParameter( "b_attack", true );
+ ViewModelEntity?.SetAnimParameter( "fire", true );
+ }
+
+ public override void PrimaryAttack()
+ {
+ if (Ammo > 0)
+ {
+ --Ammo;
+ ShootEffects();
+ Pawn?.PlaySound( "rust_pistol.shoot" );
+ ShootBullet( 100, 100, 1 );
+ }
+ }
+
+ public override void Reload()
+ {
+ ReloadEffects();
+ }
+
+ [ClientRpc]
+ protected virtual void ReloadEffects()
+ {
+ ViewModelEntity?.SetAnimParameter( "reload", true );
+ }
+
+ protected override void Animate()
+ {
+ Pawn?.SetAnimParameter( "holdtype", (int)CitizenAnimationHelper.HoldTypes.Pistol );
+ }
+}
|
