Merge branch 'space-wizards:master' into ion-storm-refactor
This commit is contained in:
@@ -146,8 +146,8 @@ namespace Content.Server.Abilities.Mime
|
||||
mimePowers.ReadyToRepent = false;
|
||||
mimePowers.VowBroken = false;
|
||||
AddComp<MutedComponent>(uid);
|
||||
_alertsSystem.ClearAlert(uid, mimePowers.VowAlert);
|
||||
_alertsSystem.ShowAlert(uid, mimePowers.VowBrokenAlert);
|
||||
_alertsSystem.ClearAlert(uid, mimePowers.VowBrokenAlert);
|
||||
_alertsSystem.ShowAlert(uid, mimePowers.VowAlert);
|
||||
_actionsSystem.AddAction(uid, ref mimePowers.InvisibleWallActionEntity, mimePowers.InvisibleWallAction, uid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ using Content.Shared.Administration;
|
||||
using Content.Shared.Administration.Components;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Clumsy;
|
||||
using Content.Shared.Clothing.Components;
|
||||
using Content.Shared.Cluwne;
|
||||
using Content.Shared.Damage;
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
using Content.Server.Administration.Components;
|
||||
using Content.Shared.Climbing.Components;
|
||||
using Content.Shared.Climbing.Events;
|
||||
using Content.Shared.Climbing.Systems;
|
||||
using Content.Shared.Interaction.Components;
|
||||
using Content.Shared.Clumsy;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
|
||||
namespace Content.Server.Administration.Systems;
|
||||
|
||||
public sealed class SuperBonkSystem: EntitySystem
|
||||
public sealed class SuperBonkSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly BonkSystem _bonkSystem = default!;
|
||||
[Dependency] private readonly ClumsySystem _clumsySystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SuperBonkComponent, ComponentShutdown>(OnBonkShutdown);
|
||||
SubscribeLocalEvent<SuperBonkComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||
SubscribeLocalEvent<SuperBonkComponent, ComponentShutdown>(OnBonkShutdown);
|
||||
}
|
||||
|
||||
public void StartSuperBonk(EntityUid target, float delay = 0.1f, bool stopWhenDead = false )
|
||||
public void StartSuperBonk(EntityUid target, float delay = 0.1f, bool stopWhenDead = false)
|
||||
{
|
||||
|
||||
//The other check in the code to stop when the target dies does not work if the target is already dead.
|
||||
@@ -31,7 +31,6 @@ public sealed class SuperBonkSystem: EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var hadClumsy = EnsureComp<ClumsyComponent>(target, out _);
|
||||
|
||||
var tables = EntityQueryEnumerator<BonkableComponent>();
|
||||
@@ -79,16 +78,17 @@ public sealed class SuperBonkSystem: EntitySystem
|
||||
private void Bonk(SuperBonkComponent comp)
|
||||
{
|
||||
var uid = comp.Tables.Current.Key;
|
||||
var bonkComp = comp.Tables.Current.Value;
|
||||
|
||||
// It would be very weird for something without a transform component to have a bonk component
|
||||
// but just in case because I don't want to crash the server.
|
||||
if (!HasComp<TransformComponent>(uid))
|
||||
if (!HasComp<TransformComponent>(uid) || !TryComp<ClumsyComponent>(comp.Target, out var clumsyComp))
|
||||
return;
|
||||
|
||||
_transformSystem.SetCoordinates(comp.Target, Transform(uid).Coordinates);
|
||||
|
||||
_bonkSystem.TryBonk(comp.Target, uid, bonkComp);
|
||||
_clumsySystem.HitHeadClumsy((comp.Target, clumsyComp), uid);
|
||||
|
||||
_audioSystem.PlayPvs(clumsyComp.TableBonkSound, comp.Target);
|
||||
}
|
||||
|
||||
private void OnMobStateChanged(EntityUid uid, SuperBonkComponent comp, MobStateChangedEvent args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Chemistry.Hypospray.Events;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.FixedPoint;
|
||||
@@ -85,14 +86,44 @@ public sealed class HypospraySystem : SharedHypospraySystem
|
||||
|
||||
string? msgFormat = null;
|
||||
|
||||
if (target == user)
|
||||
msgFormat = "hypospray-component-inject-self-message";
|
||||
else if (EligibleEntity(user, EntityManager, component) && _interaction.TryRollClumsy(user, component.ClumsyFailChance))
|
||||
// Self event
|
||||
var selfEvent = new SelfBeforeHyposprayInjectsEvent(user, entity.Owner, target);
|
||||
RaiseLocalEvent(user, selfEvent);
|
||||
|
||||
if (selfEvent.Cancelled)
|
||||
{
|
||||
msgFormat = "hypospray-component-inject-self-clumsy-message";
|
||||
target = user;
|
||||
_popup.PopupEntity(Loc.GetString(selfEvent.InjectMessageOverride ?? "hypospray-cant-inject", ("owner", Identity.Entity(target, EntityManager))), target, user);
|
||||
return false;
|
||||
}
|
||||
|
||||
target = selfEvent.TargetGettingInjected;
|
||||
|
||||
if (!EligibleEntity(target, EntityManager, component))
|
||||
return false;
|
||||
|
||||
// Target event
|
||||
var targetEvent = new TargetBeforeHyposprayInjectsEvent(user, entity.Owner, target);
|
||||
RaiseLocalEvent(target, targetEvent);
|
||||
|
||||
if (targetEvent.Cancelled)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString(targetEvent.InjectMessageOverride ?? "hypospray-cant-inject", ("owner", Identity.Entity(target, EntityManager))), target, user);
|
||||
return false;
|
||||
}
|
||||
|
||||
target = targetEvent.TargetGettingInjected;
|
||||
|
||||
if (!EligibleEntity(target, EntityManager, component))
|
||||
return false;
|
||||
|
||||
// The target event gets priority for the overriden message.
|
||||
if (targetEvent.InjectMessageOverride != null)
|
||||
msgFormat = targetEvent.InjectMessageOverride;
|
||||
else if (selfEvent.InjectMessageOverride != null)
|
||||
msgFormat = selfEvent.InjectMessageOverride;
|
||||
else if (target == user)
|
||||
msgFormat = "hypospray-component-inject-self-message";
|
||||
|
||||
if (!_solutionContainers.TryGetSolution(uid, component.SolutionName, out var hypoSpraySoln, out var hypoSpraySolution) || hypoSpraySolution.Volume == 0)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("hypospray-component-empty-message"), target, user);
|
||||
|
||||
@@ -16,6 +16,7 @@ using Content.Shared.Cluwne;
|
||||
using Content.Shared.Interaction.Components;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Content.Shared.NameModifier.EntitySystems;
|
||||
using Content.Shared.Clumsy;
|
||||
|
||||
namespace Content.Server.Cluwne;
|
||||
|
||||
|
||||
@@ -77,7 +77,20 @@ public sealed class DefibrillatorSystem : EntitySystem
|
||||
Zap(uid, target, args.User, component);
|
||||
}
|
||||
|
||||
public bool CanZap(EntityUid uid, EntityUid target, EntityUid? user = null, DefibrillatorComponent? component = null)
|
||||
/// <summary>
|
||||
/// Checks if you can actually defib a target.
|
||||
/// </summary>
|
||||
/// <param name="uid">Uid of the defib</param>
|
||||
/// <param name="target">Uid of the target getting defibbed</param>
|
||||
/// <param name="user">Uid of the entity using the defibrillator</param>
|
||||
/// <param name="component">Defib component</param>
|
||||
/// <param name="targetCanBeAlive">
|
||||
/// If true, the target can be alive. If false, the function will check if the target is alive and will return false if they are.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Returns true if the target is valid to be defibed, false otherwise.
|
||||
/// </returns>
|
||||
public bool CanZap(EntityUid uid, EntityUid target, EntityUid? user = null, DefibrillatorComponent? component = null, bool targetCanBeAlive = false)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return false;
|
||||
@@ -98,15 +111,25 @@ public sealed class DefibrillatorSystem : EntitySystem
|
||||
if (!_powerCell.HasActivatableCharge(uid, user: user))
|
||||
return false;
|
||||
|
||||
if (_mobState.IsAlive(target, mobState))
|
||||
if (!targetCanBeAlive && _mobState.IsAlive(target, mobState))
|
||||
return false;
|
||||
|
||||
if (!component.CanDefibCrit && _mobState.IsCritical(target, mobState))
|
||||
if (!targetCanBeAlive && !component.CanDefibCrit && _mobState.IsCritical(target, mobState))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to start defibrillating the target. If the target is valid, will start the defib do-after.
|
||||
/// </summary>
|
||||
/// <param name="uid">Uid of the defib</param>
|
||||
/// <param name="target">Uid of the target getting defibbed</param>
|
||||
/// <param name="user">Uid of the entity using the defibrillator</param>
|
||||
/// <param name="component">Defib component</param>
|
||||
/// <returns>
|
||||
/// Returns true if the defibrillation do-after started, otherwise false.
|
||||
/// </returns>
|
||||
public bool TryStartZap(EntityUid uid, EntityUid target, EntityUid user, DefibrillatorComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
@@ -118,27 +141,44 @@ public sealed class DefibrillatorSystem : EntitySystem
|
||||
_audio.PlayPvs(component.ChargeSound, uid);
|
||||
return _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.DoAfterDuration, new DefibrillatorZapDoAfterEvent(),
|
||||
uid, target, uid)
|
||||
{
|
||||
NeedHand = true,
|
||||
BreakOnMove = !component.AllowDoAfterMovement
|
||||
});
|
||||
{
|
||||
NeedHand = true,
|
||||
BreakOnMove = !component.AllowDoAfterMovement
|
||||
});
|
||||
}
|
||||
|
||||
public void Zap(EntityUid uid, EntityUid target, EntityUid user, DefibrillatorComponent? component = null, MobStateComponent? mob = null, MobThresholdsComponent? thresholds = null)
|
||||
/// <summary>
|
||||
/// Tries to defibrillate the target with the given defibrillator.
|
||||
/// </summary>
|
||||
public void Zap(EntityUid uid, EntityUid target, EntityUid user, DefibrillatorComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component) || !Resolve(target, ref mob, ref thresholds, false))
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
// clowns zap themselves
|
||||
if (HasComp<ClumsyComponent>(user) && user != target)
|
||||
{
|
||||
Zap(uid, user, user, component);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_powerCell.TryUseActivatableCharge(uid, user: user))
|
||||
return;
|
||||
|
||||
var selfEvent = new SelfBeforeDefibrillatorZapsEvent(user, uid, target);
|
||||
RaiseLocalEvent(user, selfEvent);
|
||||
|
||||
target = selfEvent.DefibTarget;
|
||||
|
||||
// Ensure thet new target is still valid.
|
||||
if (selfEvent.Cancelled || !CanZap(uid, target, user, component, true))
|
||||
return;
|
||||
|
||||
var targetEvent = new TargetBeforeDefibrillatorZapsEvent(user, uid, target);
|
||||
RaiseLocalEvent(target, targetEvent);
|
||||
|
||||
target = targetEvent.DefibTarget;
|
||||
|
||||
if (targetEvent.Cancelled || !CanZap(uid, target, user, component, true))
|
||||
return;
|
||||
|
||||
if (!TryComp<MobStateComponent>(target, out var mob) ||
|
||||
!TryComp<MobThresholdsComponent>(target, out var thresholds))
|
||||
return;
|
||||
|
||||
_audio.PlayPvs(component.ZapSound, uid);
|
||||
_electrocution.TryDoElectrocution(target, null, component.ZapDamage, component.WritheDuration, true, ignoreInsulation: true);
|
||||
component.NextZapTime = _timing.CurTime + component.ZapDelay;
|
||||
|
||||
82
Content.Server/Silicons/Borgs/BorgSwitchableTypeSystem.cs
Normal file
82
Content.Server/Silicons/Borgs/BorgSwitchableTypeSystem.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using Content.Server.Inventory;
|
||||
using Content.Server.Radio.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Silicons.Borgs;
|
||||
using Content.Shared.Silicons.Borgs.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Silicons.Borgs;
|
||||
|
||||
/// <summary>
|
||||
/// Server-side logic for borg type switching. Handles more heavyweight and server-specific switching logic.
|
||||
/// </summary>
|
||||
public sealed class BorgSwitchableTypeSystem : SharedBorgSwitchableTypeSystem
|
||||
{
|
||||
[Dependency] private readonly BorgSystem _borgSystem = default!;
|
||||
[Dependency] private readonly ServerInventorySystem _inventorySystem = default!;
|
||||
|
||||
protected override void SelectBorgModule(Entity<BorgSwitchableTypeComponent> ent, ProtoId<BorgTypePrototype> borgType)
|
||||
{
|
||||
var prototype = Prototypes.Index(borgType);
|
||||
|
||||
// Assign radio channels
|
||||
string[] radioChannels = [.. ent.Comp.InherentRadioChannels, .. prototype.RadioChannels];
|
||||
if (TryComp(ent, out IntrinsicRadioTransmitterComponent? transmitter))
|
||||
transmitter.Channels = [.. radioChannels];
|
||||
|
||||
if (TryComp(ent, out ActiveRadioComponent? activeRadio))
|
||||
activeRadio.Channels = [.. radioChannels];
|
||||
|
||||
// Borg transponder for the robotics console
|
||||
if (TryComp(ent, out BorgTransponderComponent? transponder))
|
||||
{
|
||||
_borgSystem.SetTransponderSprite(
|
||||
(ent.Owner, transponder),
|
||||
new SpriteSpecifier.Rsi(new ResPath("Mobs/Silicon/chassis.rsi"), prototype.SpriteBodyState));
|
||||
|
||||
_borgSystem.SetTransponderName(
|
||||
(ent.Owner, transponder),
|
||||
Loc.GetString($"borg-type-{borgType}-transponder"));
|
||||
}
|
||||
|
||||
// Configure modules
|
||||
if (TryComp(ent, out BorgChassisComponent? chassis))
|
||||
{
|
||||
var chassisEnt = (ent.Owner, chassis);
|
||||
_borgSystem.SetMaxModules(
|
||||
chassisEnt,
|
||||
prototype.ExtraModuleCount + prototype.DefaultModules.Length);
|
||||
|
||||
_borgSystem.SetModuleWhitelist(chassisEnt, prototype.ModuleWhitelist);
|
||||
|
||||
foreach (var module in prototype.DefaultModules)
|
||||
{
|
||||
var moduleEntity = Spawn(module);
|
||||
var borgModule = Comp<BorgModuleComponent>(moduleEntity);
|
||||
_borgSystem.SetBorgModuleDefault((moduleEntity, borgModule), true);
|
||||
_borgSystem.InsertModule(chassisEnt, moduleEntity);
|
||||
}
|
||||
}
|
||||
|
||||
// Configure special components
|
||||
if (Prototypes.TryIndex(ent.Comp.SelectedBorgType, out var previousPrototype))
|
||||
{
|
||||
if (previousPrototype.AddComponents is { } removeComponents)
|
||||
EntityManager.RemoveComponents(ent, removeComponents);
|
||||
}
|
||||
|
||||
if (prototype.AddComponents is { } addComponents)
|
||||
{
|
||||
EntityManager.AddComponents(ent, addComponents);
|
||||
}
|
||||
|
||||
// Configure inventory template (used for hat spacing)
|
||||
if (TryComp(ent, out InventoryComponent? inventory))
|
||||
{
|
||||
_inventorySystem.SetTemplateId((ent.Owner, inventory), prototype.InventoryTemplateId);
|
||||
}
|
||||
|
||||
base.SelectBorgModule(ent, borgType);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction.Components;
|
||||
using Content.Shared.Silicons.Borgs.Components;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Server.Silicons.Borgs;
|
||||
@@ -300,6 +301,24 @@ public sealed partial class BorgSystem
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a module can be removed from a borg.
|
||||
/// </summary>
|
||||
/// <param name="borg">The borg that the module is being removed from.</param>
|
||||
/// <param name="module">The module to remove from the borg.</param>
|
||||
/// <param name="user">The user attempting to remove the module.</param>
|
||||
/// <returns>True if the module can be removed.</returns>
|
||||
public bool CanRemoveModule(
|
||||
Entity<BorgChassisComponent> borg,
|
||||
Entity<BorgModuleComponent> module,
|
||||
EntityUid? user = null)
|
||||
{
|
||||
if (module.Comp.DefaultModule)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Installs and activates all modules currently inside the borg's module container
|
||||
/// </summary>
|
||||
@@ -369,4 +388,24 @@ public sealed partial class BorgSystem
|
||||
var ev = new BorgModuleUninstalledEvent(uid);
|
||||
RaiseLocalEvent(module, ref ev);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="BorgChassisComponent.MaxModules"/>.
|
||||
/// </summary>
|
||||
/// <param name="ent">The borg to modify.</param>
|
||||
/// <param name="maxModules">The new max module count.</param>
|
||||
public void SetMaxModules(Entity<BorgChassisComponent> ent, int maxModules)
|
||||
{
|
||||
ent.Comp.MaxModules = maxModules;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="BorgChassisComponent.ModuleWhitelist"/>.
|
||||
/// </summary>
|
||||
/// <param name="ent">The borg to modify.</param>
|
||||
/// <param name="whitelist">The new module whitelist.</param>
|
||||
public void SetModuleWhitelist(Entity<BorgChassisComponent> ent, EntityWhitelist? whitelist)
|
||||
{
|
||||
ent.Comp.ModuleWhitelist = whitelist;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Explosion.Components;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Silicons.Borgs;
|
||||
|
||||
@@ -134,4 +135,20 @@ public sealed partial class BorgSystem
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="BorgTransponderComponent.Sprite"/>.
|
||||
/// </summary>
|
||||
public void SetTransponderSprite(Entity<BorgTransponderComponent> ent, SpriteSpecifier sprite)
|
||||
{
|
||||
ent.Comp.Sprite = sprite;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="BorgTransponderComponent.Name"/>.
|
||||
/// </summary>
|
||||
public void SetTransponderName(Entity<BorgTransponderComponent> ent, string name)
|
||||
{
|
||||
ent.Comp.Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,9 @@ public sealed partial class BorgSystem
|
||||
if (!component.ModuleContainer.Contains(module))
|
||||
return;
|
||||
|
||||
if (!CanRemoveModule((uid, component), (module, Comp<BorgModuleComponent>(module)), args.Actor))
|
||||
return;
|
||||
|
||||
_adminLog.Add(LogType.Action, LogImpact.Medium,
|
||||
$"{ToPrettyString(args.Actor):player} removed module {ToPrettyString(module)} from borg {ToPrettyString(uid)}");
|
||||
_container.Remove(module, component.ModuleContainer);
|
||||
|
||||
@@ -129,7 +129,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
|
||||
|
||||
if (module != null && CanInsertModule(uid, used, component, module, args.User))
|
||||
{
|
||||
_container.Insert(used, component.ModuleContainer);
|
||||
InsertModule((uid, component), used);
|
||||
_adminLog.Add(LogType.Action, LogImpact.Low,
|
||||
$"{ToPrettyString(args.User):player} installed module {ToPrettyString(used)} into borg {ToPrettyString(uid)}");
|
||||
args.Handled = true;
|
||||
@@ -137,6 +137,19 @@ public sealed partial class BorgSystem : SharedBorgSystem
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a new module into a borg, the same as if a player inserted it manually.
|
||||
/// </summary>
|
||||
/// <para>
|
||||
/// This does not run checks to see if the borg is actually allowed to be inserted, such as whitelists.
|
||||
/// </para>
|
||||
/// <param name="ent">The borg to insert into.</param>
|
||||
/// <param name="module">The module to insert.</param>
|
||||
public void InsertModule(Entity<BorgChassisComponent> ent, EntityUid module)
|
||||
{
|
||||
_container.Insert(module, ent.Comp.ModuleContainer);
|
||||
}
|
||||
|
||||
// todo: consider transferring over the ghost role? managing that might suck.
|
||||
protected override void OnInserted(EntityUid uid, BorgChassisComponent component, EntInsertedIntoContainerMessage args)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Cargo.Systems;
|
||||
using Content.Server.Interaction;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Server.Weapons.Ranged.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Effects;
|
||||
using Content.Shared.Interaction.Components;
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Content.Shared.Weapons.Ranged;
|
||||
@@ -33,16 +30,13 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
[Dependency] private readonly IComponentFactory _factory = default!;
|
||||
[Dependency] private readonly BatterySystem _battery = default!;
|
||||
[Dependency] private readonly DamageExamineSystem _damageExamine = default!;
|
||||
[Dependency] private readonly InteractionSystem _interaction = default!;
|
||||
[Dependency] private readonly PricingSystem _pricing = default!;
|
||||
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly StaminaSystem _stamina = default!;
|
||||
[Dependency] private readonly StunSystem _stun = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
|
||||
private const float DamagePitchVariation = 0.05f;
|
||||
public const float GunClumsyChance = 0.5f;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -71,26 +65,14 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
{
|
||||
userImpulse = true;
|
||||
|
||||
// Try a clumsy roll
|
||||
// TODO: Who put this here
|
||||
if (TryComp<ClumsyComponent>(user, out var clumsy) && gun.ClumsyProof == false)
|
||||
if (user != null)
|
||||
{
|
||||
for (var i = 0; i < ammo.Count; i++)
|
||||
var selfEvent = new SelfBeforeGunShotEvent(user.Value, (gunUid, gun), ammo);
|
||||
RaiseLocalEvent(user.Value, selfEvent);
|
||||
if (selfEvent.Cancelled)
|
||||
{
|
||||
if (_interaction.TryRollClumsy(user.Value, GunClumsyChance, clumsy))
|
||||
{
|
||||
// Wound them
|
||||
Damageable.TryChangeDamage(user, clumsy.ClumsyDamage, origin: user);
|
||||
_stun.TryParalyze(user.Value, TimeSpan.FromSeconds(3f), true);
|
||||
|
||||
// Apply salt to the wound ("Honk!")
|
||||
Audio.PlayPvs(new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/bang.ogg"), gunUid);
|
||||
Audio.PlayPvs(clumsy.ClumsySound, gunUid);
|
||||
|
||||
PopupSystem.PopupEntity(Loc.GetString("gun-clumsy"), user.Value);
|
||||
userImpulse = false;
|
||||
return;
|
||||
}
|
||||
userImpulse = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user