Flash buff (#25730)

* flash buff

* oops!

* bool

* 3 -> 1.5 seconds

* okay fix

* sluth
This commit is contained in:
Nemanja
2024-04-18 02:30:01 -04:00
committed by GitHub
parent b1136c98d7
commit 3af744e4a9
3 changed files with 25 additions and 15 deletions

View File

@@ -65,7 +65,7 @@ namespace Content.Server.Flash
args.Handled = true; args.Handled = true;
foreach (var e in args.HitEntities) 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, float slowTo,
bool displayPopup = true, bool displayPopup = true,
FlashableComponent? flashable = null, FlashableComponent? flashable = null,
bool melee = false) bool melee = false,
TimeSpan? stunDuration = null)
{ {
if (!Resolve(target, ref flashable, false)) if (!Resolve(target, ref flashable, false))
return; return;
@@ -139,44 +140,47 @@ namespace Content.Server.Flash
flashable.Duration = flashDuration / 1000f; // TODO: Make this sane... flashable.Duration = flashDuration / 1000f; // TODO: Make this sane...
Dirty(target, flashable); Dirty(target, flashable);
if (stunDuration != null)
{
_stun.TryParalyze(target, stunDuration.Value, true);
}
else
{
_stun.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration/1000f), true, _stun.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration/1000f), true,
slowTo, slowTo); slowTo, slowTo);
}
if (displayPopup && user != null && target != user && Exists(user.Value)) if (displayPopup && user != null && target != user && Exists(user.Value))
{ {
_popup.PopupEntity(Loc.GetString("flash-component-user-blinds-you", _popup.PopupEntity(Loc.GetString("flash-component-user-blinds-you",
("user", Identity.Entity(user.Value, EntityManager))), target, target); ("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 mapPosition = _transform.GetMapCoordinates(transform);
var flashableQuery = GetEntityQuery<FlashableComponent>(); var flashableQuery = GetEntityQuery<FlashableComponent>();
foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, range)) foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, range))
{ {
if (!flashableQuery.TryGetComponent(entity, out var flashable))
continue;
if (!_random.Prob(probability)) if (!_random.Prob(probability))
continue; continue;
if (!flashableQuery.TryGetComponent(entity, out var flashable))
continue;
// Check for unobstructed entities while ignoring the mobs with flashable components. // 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; continue;
// They shouldn't have flash removed in between right? // They shouldn't have flash removed in between right?
Flash(entity, user, source, duration, slowTo, displayPopup, flashableQuery.GetComponent(entity)); 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) private void OnInventoryFlashAttempt(EntityUid uid, InventoryComponent component, FlashAttemptEvent args)
{ {

View File

@@ -217,7 +217,6 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
_npcFaction.AddFaction(ev.Target, RevolutionaryNpcFaction); _npcFaction.AddFaction(ev.Target, RevolutionaryNpcFaction);
var revComp = EnsureComp<RevolutionaryComponent>(ev.Target); var revComp = EnsureComp<RevolutionaryComponent>(ev.Target);
_stun.TryParalyze(ev.Target, comp.StunTime, true);
if (ev.User != null) if (ev.User != null)
{ {

View File

@@ -12,6 +12,13 @@ namespace Content.Shared.Flash.Components
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public int FlashDuration { get; set; } = 5000; 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")] [DataField("range")]
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public float Range { get; set; } = 7f; public float Range { get; set; } = 7f;