Make flare gun explode, damage and stun the player when used with the wrong ammo (#22349)

* Flare gun can now only be loaded with actual flares

* Make flare gun loadable with other shells, but destroy it and damage and stun the user when used

* tweak

* Logic fix + QOL add-ons

* damageOnWrongAmmo in gun component

* cleanup
This commit is contained in:
MendaxxDev
2023-12-15 10:57:59 +01:00
committed by GitHub
parent 353ab95446
commit e301378114
7 changed files with 52 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ using Content.Shared.Damage;
using Content.Shared.Damage.Systems;
using Content.Shared.Database;
using Content.Shared.Effects;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction.Components;
using Content.Shared.Projectiles;
using Content.Shared.Weapons.Melee;
@@ -132,6 +133,27 @@ public sealed partial class GunSystem : SharedGunSystem
case CartridgeAmmoComponent cartridge:
if (!cartridge.Spent)
{
if (gun.CompatibleAmmo != null &&
!gun.CompatibleAmmo.Exists(ammoAllowed => ammoAllowed.Equals(cartridge.Prototype))
&& user != null)
{
if (gun.DamageOnWrongAmmo != null)
Damageable.TryChangeDamage(user, gun.DamageOnWrongAmmo, origin: user);
_stun.TryParalyze(user.Value, TimeSpan.FromSeconds(3f), true);
Audio.PlayPvs(new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/bang.ogg"), gunUid);
PopupSystem.PopupEntity(Loc.GetString("gun-component-wrong-ammo"), user.Value);
_adminLogger.Add(LogType.EntityDelete, LogImpact.Medium, $"Shot wrong ammo by {ToPrettyString(user.Value)} deleted {ToPrettyString(gunUid)}");
userImpulse = false;
SetCartridgeSpent(ent!.Value, cartridge, true);
MuzzleFlash(gunUid, cartridge, user);
Del(gunUid);
if (cartridge.DeleteOnSpawn)
Del(ent.Value);
return;
}
if (cartridge.Count > 1)
{
var angles = LinearSpread(mapAngle - cartridge.Spread / 2,