]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Flash buff (#25730)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Thu, 18 Apr 2024 06:30:01 +0000 (02:30 -0400)
committerGitHub <noreply@github.com>
Thu, 18 Apr 2024 06:30:01 +0000 (16:30 +1000)
* flash buff

* oops!

* bool

* 3 -> 1.5 seconds

* okay fix

* sluth

Content.Server/Flash/FlashSystem.cs
Content.Server/GameTicking/Rules/RevolutionaryRuleSystem.cs
Content.Shared/Flash/Components/FlashComponent.cs

index b096e2c93fcc49b1b8944ffd7418d53ebe50939e..dd8cdab426cbd16508c34c21350ec7887ff3b383 100644 (file)
@@ -65,7 +65,7 @@ namespace Content.Server.Flash
             args.Handled = true;
             foreach (var e in args.HitEntities)
             {
-                Flash(e, args.User, uid, comp.FlashDuration, comp.SlowTo, melee: true);
+                Flash(e, args.User, uid, comp.FlashDuration, comp.SlowTo, melee: true, stunDuration: comp.MeleeStunDuration);
             }
         }
 
@@ -115,7 +115,8 @@ namespace Content.Server.Flash
             float slowTo,
             bool displayPopup = true,
             FlashableComponent? flashable = null,
-            bool melee = false)
+            bool melee = false,
+            TimeSpan? stunDuration = null)
         {
             if (!Resolve(target, ref flashable, false))
                 return;
@@ -139,43 +140,46 @@ namespace Content.Server.Flash
             flashable.Duration = flashDuration / 1000f; // TODO: Make this sane...
             Dirty(target, flashable);
 
-            _stun.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration/1000f), true,
+            if (stunDuration != null)
+            {
+                _stun.TryParalyze(target, stunDuration.Value, true);
+            }
+            else
+            {
+                _stun.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration/1000f), true,
                 slowTo, slowTo);
+            }
 
             if (displayPopup && user != null && target != user && Exists(user.Value))
             {
                 _popup.PopupEntity(Loc.GetString("flash-component-user-blinds-you",
                     ("user", Identity.Entity(user.Value, EntityManager))), target, target);
             }
-
         }
 
-        public void FlashArea(EntityUid source, EntityUid? user, float range, float duration, float slowTo = 0.8f, bool displayPopup = false, float probability = 1f, SoundSpecifier? sound = null)
+        public void FlashArea(Entity<FlashComponent?> 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 transform = Transform(source);
             var mapPosition = _transform.GetMapCoordinates(transform);
             var flashableQuery = GetEntityQuery<FlashableComponent>();
 
             foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, range))
             {
-                if (!flashableQuery.TryGetComponent(entity, out var flashable))
+                if (!_random.Prob(probability))
                     continue;
 
-                if (!_random.Prob(probability))
+                if (!flashableQuery.TryGetComponent(entity, out var flashable))
                     continue;
 
                 // Check for unobstructed entities while ignoring the mobs with flashable components.
-                if (!_interaction.InRangeUnobstructed(entity, mapPosition, range, flashable.CollisionGroup, (e) => e == source))
+                if (!_interaction.InRangeUnobstructed(entity, mapPosition, range, flashable.CollisionGroup, predicate: (e) => flashableQuery.HasComponent(e) || e == source.Owner))
                     continue;
 
                 // They shouldn't have flash removed in between right?
                 Flash(entity, user, source, duration, slowTo, displayPopup, flashableQuery.GetComponent(entity));
             }
 
-            if (sound != null)
-            {
-                _audio.PlayPvs(sound, source, AudioParams.Default.WithVolume(1f).WithMaxDistance(3f));
-            }
+            _audio.PlayPvs(sound, source, AudioParams.Default.WithVolume(1f).WithMaxDistance(3f));
         }
 
         private void OnInventoryFlashAttempt(EntityUid uid, InventoryComponent component, FlashAttemptEvent args)
index 5caa223c9c1b9ae86852c9738425b2d13b0fe3e0..ba9fb2ccbccfd273b89b4417c29b5db1f7083ee7 100644 (file)
@@ -217,7 +217,6 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
 
         _npcFaction.AddFaction(ev.Target, RevolutionaryNpcFaction);
         var revComp = EnsureComp<RevolutionaryComponent>(ev.Target);
-        _stun.TryParalyze(ev.Target, comp.StunTime, true);
 
         if (ev.User != null)
         {
index 6522db3b693322374ebb8d6373c8b454137b0fa5..a9098bc85a9752e44fd93232d934826ccbc356bf 100644 (file)
@@ -12,6 +12,13 @@ namespace Content.Shared.Flash.Components
         [ViewVariables(VVAccess.ReadWrite)]
         public int FlashDuration { get; set; } = 5000;
 
+        /// <summary>
+        /// How long a target is stunned when a melee flash is used.
+        /// If null, melee flashes will not stun at all
+        /// </summary>
+        [DataField]
+        public TimeSpan? MeleeStunDuration = TimeSpan.FromSeconds(1.5);
+
         [DataField("range")]
         [ViewVariables(VVAccess.ReadWrite)]
         public float Range { get; set; } = 7f;