Files
wwdpublic/Content.Server/NPC/Components/NPCRangedCombatComponent.cs
VMSolidus df74a915f7 Turrets Shoot Laying Down People (#2427)
This fixes an issue whereby turrets were not capable of hitting players
who lay down on the floor. Now turrets have a 50% chance to hit them
anways, meaning that laying down offers some, but not perfect protection
from turrets.

<details><summary><h1>Media</h1></summary>
<p>

https://github.com/user-attachments/assets/599583be-d298-452c-8b1b-f32d8d545131

</p>
</details>

🆑
- fix: Turrets and NPCs can now hit players who are laying down on the
floor. They (by default) have a 50% chance to miss players who are
laying down, meaning it still offers some protection, but not perfect
protection from turrets.
2025-07-12 00:57:29 +10:00

77 lines
2.1 KiB
C#

using Content.Server.NPC.Systems;
using Robust.Shared.Audio;
namespace Content.Server.NPC.Components;
/// <summary>
/// Added to an NPC doing ranged combat.
/// </summary>
[RegisterComponent]
public sealed partial class NPCRangedCombatComponent : Component
{
[ViewVariables]
public EntityUid Target;
[ViewVariables]
public CombatStatus Status = CombatStatus.Normal;
// Most of the below is to deal with turrets.
/// <summary>
/// If null it will instantly turn.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)] public Angle? RotationSpeed;
/// <summary>
/// Maximum distance, between our rotation and the target's, to consider shooting it.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public Angle AccuracyThreshold = Angle.FromDegrees(30);
/// <summary>
/// How long until the last line of sight check.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float LOSAccumulator = 0f;
/// <summary>
/// Is the target still considered in LOS since the last check.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public bool TargetInLOS = false;
/// <summary>
/// If true, only opaque objects will block line of sight.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
// ReSharper disable once InconsistentNaming
public bool UseOpaqueForLOSChecks = false;
/// <summary>
/// Delay after target is in LOS before we start shooting.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float ShootDelay = 0.2f;
[ViewVariables(VVAccess.ReadWrite)]
public float ShootAccumulator;
/// <summary>
/// Sound to play if the target enters line of sight.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier? SoundTargetInLOS;
/// <summary>
/// Whether or not the NPC will always attempt to shoot targets that are laying down.
/// </summary>
[DataField]
public bool AlwaysDirectTargets;
/// <summary>
/// The chance that an NPC will aim to hit targets that are laying down.
/// </summary>
[DataField]
public float DirectTargetChance = 0.5f;
}