@@ -28,6 +28,7 @@ using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Toolshed.Syntax;
|
||||
|
||||
namespace Content.Shared.Weapons.Melee;
|
||||
|
||||
@@ -350,7 +351,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
case LightAttackEvent light:
|
||||
var lightTarget = GetEntity(light.Target);
|
||||
|
||||
if (!Blocker.CanAttack(user, lightTarget))
|
||||
if (!Blocker.CanAttack(user, lightTarget, (weaponUid, weapon)))
|
||||
return false;
|
||||
|
||||
// Can't self-attack if you're the weapon
|
||||
@@ -361,11 +362,11 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
case DisarmAttackEvent disarm:
|
||||
var disarmTarget = GetEntity(disarm.Target);
|
||||
|
||||
if (!Blocker.CanAttack(user, disarmTarget))
|
||||
if (!Blocker.CanAttack(user, disarmTarget, (weaponUid, weapon), true))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
if (!Blocker.CanAttack(user))
|
||||
if (!Blocker.CanAttack(user, weapon: (weaponUid, weapon)))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
@@ -642,20 +643,27 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
|
||||
foreach (var entity in targets)
|
||||
{
|
||||
// We raise an attack attempt here as well,
|
||||
// primarily because this was an untargeted wideswing: if a subscriber to that event cared about
|
||||
// the potential target (such as for pacifism), they need to be made aware of the target here.
|
||||
// In that case, just continue.
|
||||
if (!Blocker.CanAttack(user, entity, (weapon, component)))
|
||||
continue;
|
||||
|
||||
var attackedEvent = new AttackedEvent(meleeUid, user, GetCoordinates(ev.Coordinates));
|
||||
RaiseLocalEvent(entity, attackedEvent);
|
||||
var modifiedDamage = DamageSpecifier.ApplyModifierSets(damage + hitEvent.BonusDamage + attackedEvent.BonusDamage, hitEvent.ModifiersList);
|
||||
|
||||
var damageResult = Damageable.TryChangeDamage(entity, modifiedDamage, origin:user);
|
||||
|
||||
if (damageResult != null && damageResult.Total > FixedPoint2.Zero)
|
||||
if (damageResult != null && damageResult.GetTotal() > FixedPoint2.Zero)
|
||||
{
|
||||
appliedDamage += damageResult;
|
||||
|
||||
if (meleeUid == user)
|
||||
{
|
||||
AdminLogger.Add(LogType.MeleeHit, LogImpact.Medium,
|
||||
$"{ToPrettyString(user):actor} melee attacked (heavy) {ToPrettyString(entity):subject} using their hands and dealt {damageResult.Total:damage} damage");
|
||||
$"{ToPrettyString(user):actor} melee attacked (heavy) {ToPrettyString(entity):subject} using their hands and dealt {damageResult.GetTotal():damage} damage");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -667,7 +675,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
|
||||
if (entities.Count != 0)
|
||||
{
|
||||
if (appliedDamage.Total > FixedPoint2.Zero)
|
||||
if (appliedDamage.GetTotal() > FixedPoint2.Zero)
|
||||
{
|
||||
var target = entities.First();
|
||||
PlayHitSound(target, user, GetHighestDamageSound(appliedDamage, _protoManager), hitEvent.HitSoundOverride, component.HitSound);
|
||||
@@ -685,7 +693,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
if (appliedDamage.Total > FixedPoint2.Zero)
|
||||
if (appliedDamage.GetTotal() > FixedPoint2.Zero)
|
||||
{
|
||||
DoDamageEffect(targets, user, Transform(targets[0]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user