Chances of triggering effects (#27056)
* electrocution * slippery * flashibg * Update SlipperyComponent.cs * Update SlipperySystem.cs
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user