Stun baton tweaks (#9225)

* Stun baton tweaks

* a

* sprotes
This commit is contained in:
metalgearsloth
2022-06-27 17:51:38 +10:00
committed by GitHub
parent 86f70994bf
commit c3a208234a
5 changed files with 74 additions and 49 deletions

View File

@@ -74,7 +74,10 @@ namespace Content.Server.Weapon.Melee
args.Handled = true;
var curTime = _gameTiming.CurTime;
if (curTime < comp.CooldownEnd || args.Target == null || args.Target == owner)
if (curTime < comp.CooldownEnd ||
args.Target == null ||
args.Target == owner ||
args.User == args.Target)
return;
var location = Transform(args.User).Coordinates;
@@ -117,9 +120,21 @@ namespace Content.Server.Weapon.Melee
}
comp.LastAttackTime = curTime;
comp.CooldownEnd = comp.LastAttackTime + TimeSpan.FromSeconds(comp.CooldownTime);
SetAttackCooldown(owner, comp.LastAttackTime + TimeSpan.FromSeconds(comp.CooldownTime), comp);
RaiseLocalEvent(owner, new RefreshItemCooldownEvent(comp.LastAttackTime, comp.CooldownEnd), false);
RaiseLocalEvent(owner, new RefreshItemCooldownEvent(comp.LastAttackTime, comp.CooldownEnd));
}
/// <summary>
/// Set the melee weapon cooldown's end to the specified value. Will use the maximum of the existing cooldown or the new one.
/// </summary>
public void SetAttackCooldown(EntityUid uid, TimeSpan endTime, MeleeWeaponComponent? component = null)
{
// Some other system may want to artificially inflate melee weapon CD.
if (!Resolve(uid, ref component) || component.CooldownEnd > endTime) return;
component.CooldownEnd = endTime;
RaiseLocalEvent(uid, new RefreshItemCooldownEvent(component.LastAttackTime, component.CooldownEnd));
}
private void OnWideAttack(EntityUid owner, MeleeWeaponComponent comp, WideAttackEvent args)