2021-11-29 02:34:44 +13:00
|
|
|
using Content.Server.Administration.Logs;
|
2021-08-21 09:18:23 +02:00
|
|
|
using Content.Server.Damage.Components;
|
2021-09-15 03:07:37 +10:00
|
|
|
using Content.Shared.Damage;
|
2021-11-28 14:56:53 +01:00
|
|
|
using Content.Shared.Database;
|
2023-01-13 16:57:10 -08:00
|
|
|
using Content.Shared.Mobs.Components;
|
2021-08-21 09:18:23 +02:00
|
|
|
using Content.Shared.Throwing;
|
|
|
|
|
|
2021-09-12 16:22:58 +10:00
|
|
|
namespace Content.Server.Damage.Systems
|
2021-08-21 09:18:23 +02:00
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class DamageOtherOnHitSystem : EntitySystem
|
2021-08-21 09:18:23 +02:00
|
|
|
{
|
2021-09-15 03:07:37 +10:00
|
|
|
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
2022-05-28 23:41:17 -07:00
|
|
|
[Dependency] private readonly IAdminLogManager _adminLogger= default!;
|
2021-11-29 02:34:44 +13:00
|
|
|
|
2021-08-21 09:18:23 +02:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
SubscribeLocalEvent<DamageOtherOnHitComponent, ThrowDoHitEvent>(OnDoHit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDoHit(EntityUid uid, DamageOtherOnHitComponent component, ThrowDoHitEvent args)
|
|
|
|
|
{
|
2022-10-08 12:15:27 +02:00
|
|
|
var dmg = _damageableSystem.TryChangeDamage(args.Target, component.Damage, component.IgnoreResistances, origin: args.User);
|
2022-02-07 14:52:58 +13:00
|
|
|
|
|
|
|
|
// Log damage only for mobs. Useful for when people throw spears at each other, but also avoids log-spam when explosions send glass shards flying.
|
|
|
|
|
if (dmg != null && HasComp<MobStateComponent>(args.Target))
|
2022-05-28 23:41:17 -07:00
|
|
|
_adminLogger.Add(LogType.ThrowHit, $"{ToPrettyString(args.Target):target} received {dmg.Total:damage} damage from collision");
|
2021-08-21 09:18:23 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|