* Creat Execution Component and add to sharp items * Kill Server ExecutionSystem. Create ExecutionSystem in shared. Create ActiveExecution Component. Transferred the Execution system into shared. Heavily re-wrote the system in order to reduce duplication, and remove gun code from the system. The melee weapon modifier which was dependant on swing rate was removed. The ActiveExecutionComponent was created in order to apply the damage modifier to the shot from a gun execution. It is added just before the gun fires and removed after an attempt is made. * Fix bugs The execution completed text will now only show up if the gun fires. The client also no longer crashes because I forgot to network the component. * Remove clumsy text * Make BaseSword abstract * Add ExecutionComponent to every weapon * Fix bug * Remove execution comp from battery weapons Currently the gun system does not have a way to alter hitscan damage like it does with projectiles. * Cleanup * Revert "Remove clumsy text" This reverts commit a46da6448d5d179a4e936f9213d5622bedb58a16. * Actually fix the ExecutionSystem Everything about the shot goes through the gun system now. The Damage multiplier is only applied when a projectile impacts the target so people that get in the way don't get hit with 9 times damage for no reason. In order to make suicides work I needed to create fake EntityCoordinates because the gun system and the projectile system do not play well with a projectile that has the same start and end position. * Make launchers able to execute * Fix prediction bug The OnAmmoShotEvent is only raised on the server. * Readd ability for clowns to accidentally shoot themselves while executing * Cleanup * Reset melee cooldown to initial value * Address reviews fix bug Addressed reviews on overriding messages. Now I actually mark doafters as handled. Return normal cooldown to some meleeweapons I forgot on the previous commit. * Address Reviews Remove duplication * Exorcise codebase Remove evil null coercion that I was sure I removed a while ago * Address reviews again * Remove melee weapon attack logic and rely on the system. Remove gun and melee checks. * Make system functional again and cleanup * Remove code I forgot to remove * Cleanup * stalled * Selectively revert gun penetration The collision layer check doesn't work and I don't have time to fix it. * Fixes --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
104 lines
4.0 KiB
C#
104 lines
4.0 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 Robust.Shared.Physics.Events;
|
|
using Robust.Shared.Player;
|
|
|
|
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!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
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;
|
|
|
|
// 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;
|
|
}
|
|
|
|
if (TryHandleProjectile(target, (uid, component)))
|
|
{
|
|
var direction = args.OurBody.LinearVelocity.Normalized();
|
|
_sharedCameraRecoil.KickCamera(target, direction);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tries to handle a projectile interacting with the target.
|
|
/// </summary>
|
|
/// <returns>True if the target isn't deleted.</returns>
|
|
public bool TryHandleProjectile(EntityUid target, Entity<ProjectileComponent> projectile)
|
|
{
|
|
var uid = projectile.Owner;
|
|
var component = projectile.Comp;
|
|
|
|
var ev = new ProjectileHitEvent(component.Damage, target, component.Shooter);
|
|
RaiseLocalEvent(uid, ref ev);
|
|
|
|
var otherName = ToPrettyString(target);
|
|
var modifiedDamage = _damageableSystem.TryChangeDamage(target, ev.Damage, component.IgnoreResistances, origin: component.Shooter);
|
|
var deleted = Deleted(target);
|
|
|
|
if (modifiedDamage is not null && EntityManager.EntityExists(component.Shooter))
|
|
{
|
|
if (modifiedDamage.Any() && !deleted)
|
|
{
|
|
_color.RaiseEffect(Color.Red, new List<EntityUid> { target }, Filter.Pvs(target, entityManager: EntityManager));
|
|
}
|
|
|
|
_adminLogger.Add(LogType.BulletHit,
|
|
HasComp<ActorComponent>(target) ? LogImpact.Extreme : LogImpact.High,
|
|
$"Projectile {ToPrettyString(uid):projectile} shot by {ToPrettyString(component.Shooter!.Value):user} hit {otherName:target} and dealt {modifiedDamage.GetTotal():damage} damage");
|
|
}
|
|
|
|
if (!deleted)
|
|
{
|
|
_guns.PlayImpactSound(target, modifiedDamage, component.SoundHit, component.ForceSound);
|
|
}
|
|
|
|
component.DamagedEntity = true;
|
|
|
|
var afterProjectileHitEvent = new AfterProjectileHitEvent(component.Damage, target);
|
|
RaiseLocalEvent(uid, ref afterProjectileHitEvent);
|
|
|
|
if (component.DeleteOnCollide)
|
|
QueueDel(uid);
|
|
|
|
if (component.ImpactEffect != null && TryComp<TransformComponent>(uid, out var xform))
|
|
{
|
|
RaiseNetworkEvent(new ImpactEffectEvent(component.ImpactEffect, GetNetCoordinates(xform.Coordinates)), Filter.Pvs(xform.Coordinates, entityMan: EntityManager));
|
|
}
|
|
|
|
return !deleted;
|
|
}
|
|
}
|