* Add data field for id card microwave behaviour (#28087) * Move replacement chance from ReplacementAccentComponent to ReplacementAccentPrototype (#28049) Move replacement chance to ReplacementAccentPrototype * Resolves Bible summon message being sent to all users (#28104) * Changed PopupEntity overload used to ensure message is only sent to user * Updated uid for PopupEntity call * Updating _popupSystem.PopupEntity call in AttemptSummon * Random book story generator refactor (#28082) * Randomized book overhaul * Fix prototype names * Improved setting paper content * Praise Ratvar * Fix activatable UI popup message spam (#28123) Fixed activatable UI popup message spam * Modify battery assert to avoid floating point errors (#28007) * Update component query benchmarks (#27967) * Add more component query benchmarks. * Rename benchmark * Use non-generic `TryComp()` for metadata & transform (#28133) * sleeper agent appear later into the round and only once (#28160) --------- Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com> Co-authored-by: double_b <40827162+benjamin-burges@users.noreply.github.com> Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Co-authored-by: Killerqu00 <47712032+Killerqu00@users.noreply.github.com>
104 lines
4.1 KiB
C#
104 lines
4.1 KiB
C#
using Content.Server.Administration.Logs;
|
|
using Content.Server.Effects;
|
|
using Content.Server.Weapons.Ranged.Systems;
|
|
using Content.Shared.Camera;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.Projectiles;
|
|
using Content.Shared._White;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Physics.Events;
|
|
|
|
namespace Content.Server.Projectiles;
|
|
|
|
public sealed class ProjectileSystem : SharedProjectileSystem
|
|
{
|
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
|
[Dependency] private readonly ColorFlashEffectSystem _color = default!;
|
|
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
|
[Dependency] private readonly GunSystem _guns = default!;
|
|
[Dependency] private readonly SharedCameraRecoilSystem _sharedCameraRecoil = default!;
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
|
|
private float DamageModifier { get; set; }
|
|
|
|
private void SetDamage(float value) => DamageModifier = value;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
_cfg.OnValueChanged(WhiteCVars.DamageModifier, SetDamage, true);
|
|
|
|
SubscribeLocalEvent<ProjectileComponent, StartCollideEvent>(OnStartCollide);
|
|
}
|
|
|
|
private void OnStartCollide(EntityUid uid, ProjectileComponent component, ref StartCollideEvent args)
|
|
{
|
|
// This is so entities that shouldn't get a collision are ignored.
|
|
if (args.OurFixtureId != ProjectileFixture || !args.OtherFixture.Hard
|
|
|| component.DamagedEntity || component is { Weapon: null, OnlyCollideWhenShot: true })
|
|
{
|
|
return;
|
|
}
|
|
|
|
var target = args.OtherEntity;
|
|
|
|
var collideAttemptEv = new ProjectileCollideAttemptEvent(uid, component, false);
|
|
RaiseLocalEvent(target, ref collideAttemptEv);
|
|
if (collideAttemptEv.Cancelled)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// it's here so this check is only done once before possible hit
|
|
var attemptEv = new ProjectileReflectAttemptEvent(uid, component, false);
|
|
RaiseLocalEvent(target, ref attemptEv);
|
|
if (attemptEv.Cancelled)
|
|
{
|
|
SetShooter(uid, component, target);
|
|
return;
|
|
}
|
|
|
|
var ev = new ProjectileHitEvent(component.Damage, target, component.Shooter);
|
|
RaiseLocalEvent(uid, ref ev);
|
|
|
|
var otherName = ToPrettyString(target);
|
|
var direction = args.OurBody.LinearVelocity.Normalized();
|
|
var modifiedDamage = _damageableSystem.TryChangeDamage(target, ev.Damage * DamageModifier, component.IgnoreResistances, origin: component.Shooter);
|
|
var deleted = Deleted(target);
|
|
|
|
if (modifiedDamage is not null && (EntityManager.EntityExists(component.Shooter) || EntityManager.EntityExists(component.Weapon)))
|
|
{
|
|
if (modifiedDamage.Any() && !deleted)
|
|
{
|
|
_color.RaiseEffect(Color.Red, new List<EntityUid> { target }, Filter.Pvs(target, entityManager: EntityManager));
|
|
}
|
|
|
|
var shooterOrWeapon = EntityManager.EntityExists(component.Shooter) ? component.Shooter!.Value : component.Weapon!.Value;
|
|
|
|
_adminLogger.Add(LogType.BulletHit,
|
|
HasComp<ActorComponent>(target) ? LogImpact.Extreme : LogImpact.High,
|
|
$"Projectile {ToPrettyString(uid):projectile} shot by {ToPrettyString(shooterOrWeapon):source} hit {otherName:target} and dealt {modifiedDamage.GetTotal():damage} damage");
|
|
}
|
|
|
|
if (!deleted)
|
|
{
|
|
_guns.PlayImpactSound(target, modifiedDamage, component.SoundHit, component.ForceSound);
|
|
// _sharedCameraRecoil.KickCamera(target, direction);
|
|
// WD EDIT
|
|
}
|
|
|
|
component.DamagedEntity = true;
|
|
|
|
if (component.DeleteOnCollide)
|
|
QueueDel(uid);
|
|
|
|
if (component.ImpactEffect != null && TryComp(uid, out TransformComponent? xform))
|
|
{
|
|
RaiseNetworkEvent(new ImpactEffectEvent(component.ImpactEffect, GetNetCoordinates(xform.Coordinates)), Filter.Pvs(xform.Coordinates, entityMan: EntityManager));
|
|
}
|
|
}
|
|
}
|