]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Chances of triggering effects (#27056)
authorEd <96445749+TheShuEd@users.noreply.github.com>
Thu, 18 Apr 2024 00:08:42 +0000 (03:08 +0300)
committerGitHub <noreply@github.com>
Thu, 18 Apr 2024 00:08:42 +0000 (10:08 +1000)
* electrocution

* slippery

* flashibg

* Update SlipperyComponent.cs

* Update SlipperySystem.cs

Content.Server/Electrocution/Components/ElectrifiedComponent.cs
Content.Server/Electrocution/ElectrocutionSystem.cs
Content.Server/Explosion/EntitySystems/TriggerSystem.cs
Content.Server/Flash/FlashSystem.cs
Content.Shared/Flash/Components/FlashComponent.cs
Content.Shared/Flash/Components/FlashOnTriggerComponent.cs

index 65a539eb08ea99f122caddfc05df4e32052f063d..4ef07a0cca8b5894f9342678ba5bd11ce4d79c31 100644 (file)
@@ -85,4 +85,7 @@ public sealed partial class ElectrifiedComponent : Component
 
     [DataField("shockVolume")]
     public float ShockVolume = 20;
+
+    [DataField]
+    public float Probability = 1f;
 }
index 116330628299f448f3babc2ef6dd3b58fc74e909..8291e97efe44ae1edadfa45da29200d4c5fd7772 100644 (file)
@@ -213,6 +213,9 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
         if (!IsPowered(uid, electrified, transform))
             return false;
 
+        if (!_random.Prob(electrified.Probability))
+            return false;
+
         EnsureComp<ActivatedElectrifiedComponent>(uid);
         _appearance.SetData(uid, ElectrifiedVisuals.IsPowered, true);
 
index 94f55855362e4548240901736f04fdf52694f93c..3675c214b14fa5676a66c90d8c4e9b445b704ce2 100644 (file)
@@ -153,7 +153,7 @@ namespace Content.Server.Explosion.EntitySystems
         private void HandleFlashTrigger(EntityUid uid, FlashOnTriggerComponent component, TriggerEvent args)
         {
             // TODO Make flash durations sane ffs.
-            _flashSystem.FlashArea(uid, args.User, component.Range, component.Duration * 1000f);
+            _flashSystem.FlashArea(uid, args.User, component.Range, component.Duration * 1000f, probability: component.Probability);
             args.Handled = true;
         }
 
index fe7eb81d1e132f3a984da8223aca2c1f66133129..b096e2c93fcc49b1b8944ffd7418d53ebe50939e 100644 (file)
@@ -19,6 +19,7 @@ using Content.Shared.Weapons.Melee.Events;
 using Robust.Server.Audio;
 using Robust.Server.GameObjects;
 using Robust.Shared.Audio;
+using Robust.Shared.Random;
 using Robust.Shared.Timing;
 using InventoryComponent = Content.Shared.Inventory.InventoryComponent;
 
@@ -37,6 +38,7 @@ namespace Content.Server.Flash
         [Dependency] private readonly PopupSystem _popup = default!;
         [Dependency] private readonly StunSystem _stun = default!;
         [Dependency] private readonly TagSystem _tag = default!;
+        [Dependency] private readonly IRobustRandom _random = default!;
 
         public override void Initialize()
         {
@@ -73,7 +75,7 @@ namespace Content.Server.Flash
                 return;
 
             args.Handled = true;
-            FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, true);
+            FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, true, comp.Probability);
         }
 
         private bool UseFlash(EntityUid uid, FlashComponent comp, EntityUid user)
@@ -148,7 +150,7 @@ namespace Content.Server.Flash
 
         }
 
-        public void FlashArea(EntityUid source, EntityUid? user, float range, float duration, float slowTo = 0.8f, bool displayPopup = false, SoundSpecifier? sound = null)
+        public void FlashArea(EntityUid source, EntityUid? user, float range, float duration, float slowTo = 0.8f, bool displayPopup = false, float probability = 1f, SoundSpecifier? sound = null)
         {
             var transform = EntityManager.GetComponent<TransformComponent>(source);
             var mapPosition = _transform.GetMapCoordinates(transform);
@@ -159,6 +161,8 @@ namespace Content.Server.Flash
                 if (!flashableQuery.TryGetComponent(entity, out var flashable))
                     continue;
 
+                if (!_random.Prob(probability))
+                    continue;
 
                 // Check for unobstructed entities while ignoring the mobs with flashable components.
                 if (!_interaction.InRangeUnobstructed(entity, mapPosition, range, flashable.CollisionGroup, (e) => e == source))
index a26e32cb70f5776ca488e71134fa7410e95017f1..6522db3b693322374ebb8d6373c8b454137b0fa5 100644 (file)
@@ -32,5 +32,8 @@ namespace Content.Shared.Flash.Components
         };
 
         public bool Flashing;
+
+        [DataField]
+        public float Probability = 1f;
     }
 }
index d1270e9db74f9d7a280fcca49bd4aab5d6ead5fa..7658ca0ae5aae55ffd551beca2ec821113c0ac15 100644 (file)
@@ -9,4 +9,5 @@ public sealed partial class FlashOnTriggerComponent : Component
 {
     [DataField] public float Range = 1.0f;
     [DataField] public float Duration = 8.0f;
+    [DataField] public float Probability = 1.0f;
 }