Better melee combat (#542)

* - add: NextMobAttack, EquipCooldown.

* - fix: Some combat fixes.

* - add: Telebaton.

* - add: Stun baton rework.

* - tweak: Reduce melee range.

* - add: Rework melee block system.

* - add: ExaminedEvent.
This commit is contained in:
Aviu00
2024-08-02 11:50:26 +00:00
committed by GitHub
parent 6ca036189e
commit 27268d4e28
83 changed files with 772 additions and 222 deletions

View File

@@ -1,5 +1,6 @@
using Content.Shared.Damage;
using Content.Shared.Item.ItemToggle.Components;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
@@ -19,8 +20,33 @@ public sealed partial class BlockingSystem
SubscribeLocalEvent<BlockingUserComponent, ContainerGettingInsertedAttemptEvent>(OnInsertAttempt);
SubscribeLocalEvent<BlockingUserComponent, AnchorStateChangedEvent>(OnAnchorChanged);
SubscribeLocalEvent<BlockingUserComponent, EntityTerminatingEvent>(OnEntityTerminating);
SubscribeLocalEvent<BlockingUserComponent, MeleeBlockAttemptEvent>(OnMeleeBlockAttempt); // WD
}
// WD START
private void OnMeleeBlockAttempt(Entity<BlockingUserComponent> ent, ref MeleeBlockAttemptEvent args)
{
if (args.Handled)
return;
var uid = ent.Comp.BlockingItem;
if (!TryComp(uid, out BlockingComponent? blocking) || !blocking.IsBlocking)
return;
if (TryComp(uid.Value, out ItemToggleComponent? toggle) && !toggle.Activated)
return;
if (!TryComp(uid.Value, out DamageableComponent? damageable))
return;
_audio.PlayPredicted(blocking.BlockSound, ent, args.Attacker);
_popupSystem.PopupPredicted(Loc.GetString("melee-block-event-blocked"), ent, args.Attacker);
_damageable.TryChangeDamage(uid.Value, args.Damage, damageable: damageable);
args.Handled = true;
}
// WD END
private void OnParentChanged(EntityUid uid, BlockingUserComponent component, ref EntParentChangedMessage args)
{
UserStopBlocking(uid, component);