From 673bebcabf638adbb6057898604b10a0995f19e6 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Tue, 15 Aug 2023 21:49:33 -0700 Subject: [PATCH] shotgun recoil --- Items/Weapons/ProjectileSpawner.cs | 5 +++++ Items/Weapons/Ranged.cs | 3 +++ Items/Weapons/Shotgun.tscn | 1 + 3 files changed, 9 insertions(+) diff --git a/Items/Weapons/ProjectileSpawner.cs b/Items/Weapons/ProjectileSpawner.cs index da1a56a..e2cee4b 100644 --- a/Items/Weapons/ProjectileSpawner.cs +++ b/Items/Weapons/ProjectileSpawner.cs @@ -67,6 +67,11 @@ public partial class ProjectileSpawner : Ranged Vector2 target = Character.Target.Normalized(); + if (CharacterRecoil > 0) + { + Character.ApplyImpulse(-target * CharacterRecoil); + } + // avoid unnecessary math if only spawning 1 projectile if (ProjectileCount == 1) { diff --git a/Items/Weapons/Ranged.cs b/Items/Weapons/Ranged.cs index 5c324b1..a282e0d 100644 --- a/Items/Weapons/Ranged.cs +++ b/Items/Weapons/Ranged.cs @@ -4,6 +4,9 @@ namespace SupaLidlGame.Items.Weapons; public abstract partial class Ranged : Weapon { + [Export] + public float CharacterRecoil { get; set; } = 0; + [Export] public float AngleDeviation { get; set; } diff --git a/Items/Weapons/Shotgun.tscn b/Items/Weapons/Shotgun.tscn index ec12712..9fcd5d5 100644 --- a/Items/Weapons/Shotgun.tscn +++ b/Items/Weapons/Shotgun.tscn @@ -253,6 +253,7 @@ script = ExtResource("1_4xyyt") Projectile = ExtResource("2_p3wx2") ProjectileCount = 3 ProjectileAngleDeviation = 10.0 +CharacterRecoil = 128.0 StateMachine = NodePath("State") Damage = 12.0 UseTime = 1.5