]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Weapon Random Fixes (documented and removed hardcoded cluwnecomp) (#22352)
authorbrainfood1183 <113240905+brainfood1183@users.noreply.github.com>
Mon, 18 Dec 2023 19:42:57 +0000 (19:42 +0000)
committerGitHub <noreply@github.com>
Mon, 18 Dec 2023 19:42:57 +0000 (14:42 -0500)
Weapon Random Fixes

Content.Server/Weapons/Melee/WeaponRandom/WeaponRandomComponent.cs
Content.Server/Weapons/Melee/WeaponRandom/WeaponRandomSystem.cs

index c8cb5d2f28599dbcf20f0322427226230b4f9be6..ef15498a700563c2047004755441fc7fa625dbbe 100644 (file)
@@ -14,25 +14,13 @@ internal sealed partial class WeaponRandomComponent : Component
     public DamageSpecifier DamageBonus = new();
 
     /// <summary>
-    /// Chance for the damage bonus to occur.
+    /// Chance for the damage bonus to occur (1 = 100%).
     /// </summary>
     [ViewVariables(VVAccess.ReadWrite)]
     public float RandomDamageChance = 0.00001f;
 
     /// <summary>
-    /// If this is true then the random damage will occur.
-    /// </summary>
-    [DataField("randomDamage")]
-    public bool RandomDamage = true;
-
-    /// <summary>
-    /// If this is true then the weapon will have a unique interaction with cluwnes.
-    /// </summary>
-    [DataField("antiCluwne")]
-    public bool AntiCluwne = true;
-
-    /// <summary>
-    /// Noise to play when the damage bonus occurs.
+    /// Sound effect to play when the damage bonus occurs.
     /// </summary>
     [DataField("damageSound")]
     public SoundSpecifier DamageSound = new SoundPathSpecifier("/Audio/Items/bikehorn.ogg");
index 8cb22ca8bdb2958d4734daf0b7b9e992e4ad8fc5..7b246b8d0981a9fbbcde88cfda06fbf72104b27d 100644 (file)
@@ -1,11 +1,12 @@
 using Content.Shared.Weapons.Melee.Events;
 using Robust.Shared.Random;
-using Content.Shared.Cluwne;
-using Robust.Shared.Audio;
 using Robust.Shared.Audio.Systems;
 
 namespace Content.Server.Weapons.Melee.WeaponRandom;
 
+/// <summary>
+/// This adds a random damage bonus to melee attacks based on damage bonus amount and probability.
+/// </summary>
 public sealed class WeaponRandomSystem : EntitySystem
 {
     [Dependency] private readonly IRobustRandom _random = default!;
@@ -17,22 +18,15 @@ public sealed class WeaponRandomSystem : EntitySystem
 
         SubscribeLocalEvent<WeaponRandomComponent, MeleeHitEvent>(OnMeleeHit);
     }
-
+    /// <summary>
+    /// On Melee hit there is a possible chance of additional bonus damage occuring.
+    /// </summary>
     private void OnMeleeHit(EntityUid uid, WeaponRandomComponent component, MeleeHitEvent args)
     {
-        foreach (var entity in args.HitEntities)
+        if (_random.Prob(component.RandomDamageChance))
         {
-            if (HasComp<CluwneComponent>(entity) && component.AntiCluwne)
-            {
-                _audio.PlayPvs(component.DamageSound, uid);
-                args.BonusDamage = component.DamageBonus;
-            }
-
-            else if (_random.Prob(component.RandomDamageChance) && component.RandomDamage)
-            {
-                _audio.PlayPvs(component.DamageSound, uid);
-                args.BonusDamage = component.DamageBonus;
-            }
+            _audio.PlayPvs(component.DamageSound, uid);
+            args.BonusDamage = component.DamageBonus;
         }
     }
 }