Play tap.ogg when no damage is being done (#9489)
This commit is contained in:
@@ -10,6 +10,10 @@ namespace Content.Server.Weapon.Melee.Components
|
||||
[DataField("hitSound")]
|
||||
public SoundSpecifier? HitSound;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("noDamageSound")]
|
||||
public SoundSpecifier NoDamageSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/tap.ogg");
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("missSound")]
|
||||
public SoundSpecifier MissSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/punchmiss.ogg");
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Content.Server.Weapon.Melee
|
||||
var modifiedDamage = DamageSpecifier.ApplyModifierSets(comp.Damage + hitEvent.BonusDamage, hitEvent.ModifiersList);
|
||||
var damageResult = _damageableSystem.TryChangeDamage(target, modifiedDamage);
|
||||
|
||||
if (damageResult != null)
|
||||
if (damageResult != null && damageResult.Total > FixedPoint2.Zero)
|
||||
{
|
||||
if (args.Used == args.User)
|
||||
_adminLogger.Add(LogType.MeleeHit,
|
||||
@@ -108,15 +108,18 @@ namespace Content.Server.Weapon.Melee
|
||||
else
|
||||
_adminLogger.Add(LogType.MeleeHit,
|
||||
$"{ToPrettyString(args.User):user} melee attacked {ToPrettyString(args.Target.Value):target} using {ToPrettyString(args.Used):used} and dealt {damageResult.Total:damage} damage");
|
||||
}
|
||||
|
||||
PlayHitSound(target, GetHighestDamageSound(modifiedDamage, _protoManager), hitEvent.HitSoundOverride, comp.HitSound);
|
||||
PlayHitSound(target, GetHighestDamageSound(modifiedDamage, _protoManager), hitEvent.HitSoundOverride, comp.HitSound);
|
||||
}
|
||||
else
|
||||
{
|
||||
SoundSystem.Play(comp.NoDamageSound.GetSound(), Filter.Pvs(owner, entityManager: EntityManager), owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SoundSystem.Play(comp.MissSound.GetSound(), Filter.Pvs(owner, entityManager: EntityManager), args.User);
|
||||
return;
|
||||
SoundSystem.Play(comp.MissSound.GetSound(), Filter.Pvs(owner, entityManager: EntityManager), owner);
|
||||
}
|
||||
|
||||
comp.LastAttackTime = curTime;
|
||||
@@ -176,18 +179,7 @@ namespace Content.Server.Weapon.Melee
|
||||
if (!hitEvent.Handled)
|
||||
{
|
||||
var modifiedDamage = DamageSpecifier.ApplyModifierSets(comp.Damage + hitEvent.BonusDamage, hitEvent.ModifiersList);
|
||||
|
||||
if (entities.Count != 0)
|
||||
{
|
||||
var target = entities.First();
|
||||
TryComp<MeleeWeaponComponent>(target, out var meleeWeapon);
|
||||
|
||||
PlayHitSound(target, GetHighestDamageSound(modifiedDamage, _protoManager), hitEvent.HitSoundOverride, meleeWeapon?.HitSound);
|
||||
}
|
||||
else
|
||||
{
|
||||
SoundSystem.Play(comp.MissSound.GetSound(), Filter.Pvs(owner), Transform(args.User).Coordinates);
|
||||
}
|
||||
var appliedDamage = new DamageSpecifier();
|
||||
|
||||
foreach (var entity in hitEntities)
|
||||
{
|
||||
@@ -195,8 +187,10 @@ namespace Content.Server.Weapon.Melee
|
||||
|
||||
var damageResult = _damageableSystem.TryChangeDamage(entity, modifiedDamage);
|
||||
|
||||
if (damageResult != null)
|
||||
if (damageResult != null && damageResult.Total > FixedPoint2.Zero)
|
||||
{
|
||||
appliedDamage += damageResult;
|
||||
|
||||
if (args.Used == args.User)
|
||||
_adminLogger.Add(LogType.MeleeHit,
|
||||
$"{ToPrettyString(args.User):user} melee attacked {ToPrettyString(entity):target} using their hands and dealt {damageResult.Total:damage} damage");
|
||||
@@ -205,12 +199,28 @@ namespace Content.Server.Weapon.Melee
|
||||
$"{ToPrettyString(args.User):user} melee attacked {ToPrettyString(entity):target} using {ToPrettyString(args.Used):used} and dealt {damageResult.Total:damage} damage");
|
||||
}
|
||||
}
|
||||
|
||||
if (entities.Count != 0)
|
||||
{
|
||||
if (appliedDamage.Total > FixedPoint2.Zero)
|
||||
{
|
||||
var target = entities.First();
|
||||
PlayHitSound(target, GetHighestDamageSound(modifiedDamage, _protoManager), hitEvent.HitSoundOverride, comp.HitSound);
|
||||
}
|
||||
else
|
||||
{
|
||||
SoundSystem.Play(comp.NoDamageSound.GetSound(), Filter.Pvs(owner, entityManager: EntityManager), owner);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SoundSystem.Play(comp.MissSound.GetSound(), Filter.Pvs(owner, entityManager: EntityManager), owner);
|
||||
}
|
||||
}
|
||||
|
||||
comp.LastAttackTime = curTime;
|
||||
comp.CooldownEnd = comp.LastAttackTime + TimeSpan.FromSeconds(comp.ArcCooldownTime);
|
||||
|
||||
RaiseLocalEvent(owner, new RefreshItemCooldownEvent(comp.LastAttackTime, comp.CooldownEnd), false);
|
||||
RaiseLocalEvent(owner, new RefreshItemCooldownEvent(comp.LastAttackTime, comp.CooldownEnd));
|
||||
}
|
||||
|
||||
public static string? GetHighestDamageSound(DamageSpecifier modifiedDamage, IPrototypeManager protoManager)
|
||||
|
||||
Reference in New Issue
Block a user