diff --git a/Content.Server/GameObjects/Components/Mobs/ClumsyComponent.cs b/Content.Server/GameObjects/Components/Mobs/ClumsyComponent.cs
index 5e55a21a3e..02a278a29b 100644
--- a/Content.Server/GameObjects/Components/Mobs/ClumsyComponent.cs
+++ b/Content.Server/GameObjects/Components/Mobs/ClumsyComponent.cs
@@ -1,4 +1,10 @@
using Robust.Shared.GameObjects;
+using Robust.Shared.Interfaces.GameObjects;
+using Robust.Shared.Interfaces.Random;
+using Robust.Shared.IoC;
+using Robust.Shared.Random;
+
+#nullable enable
namespace Content.Server.GameObjects.Components.Mobs
{
@@ -8,6 +14,27 @@ namespace Content.Server.GameObjects.Components.Mobs
[RegisterComponent]
public class ClumsyComponent : Component
{
+ [Dependency] private readonly IRobustRandom _random = default!;
+
public override string Name => "Clumsy";
+
+ public bool RollClumsy(float chance)
+ {
+ return Running && _random.Prob(chance);
+ }
+
+ ///
+ /// Rolls a probability chance for a "bad action" if the target entity is clumsy.
+ ///
+ /// The entity that the clumsy check is happening for.
+ ///
+ /// The chance that a "bad action" happens if the user is clumsy, between 0 and 1 inclusive.
+ ///
+ /// True if a "bad action" happened, false if the normal action should happen.
+ public static bool TryRollClumsy(IEntity entity, float chance)
+ {
+ return entity.TryGetComponent(out ClumsyComponent? clumsy)
+ && clumsy.RollClumsy(chance);
+ }
}
}
diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/ServerRangedWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/ServerRangedWeaponComponent.cs
index f1331d4e7e..7f554a5eed 100644
--- a/Content.Server/GameObjects/Components/Weapon/Ranged/ServerRangedWeaponComponent.cs
+++ b/Content.Server/GameObjects/Components/Weapon/Ranged/ServerRangedWeaponComponent.cs
@@ -161,9 +161,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
_lastFireTime = curTime;
- if (ClumsyCheck &&
- user.HasComponent() &&
- _random.Prob(ClumsyExplodeChance))
+ if (ClumsyCheck && ClumsyComponent.TryRollClumsy(user, ClumsyExplodeChance))
{
var soundSystem = EntitySystem.Get();
soundSystem.PlayAtCoords("/Audio/Items/bikehorn.ogg",