diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/UnarmedCombatComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/UnarmedCombatComponent.cs new file mode 100644 index 0000000000..0cd7cb189c --- /dev/null +++ b/Content.Server/GameObjects/Components/Weapon/Melee/UnarmedCombatComponent.cs @@ -0,0 +1,12 @@ + +using Content.Server.GameObjects.EntitySystems; +using Robust.Shared.GameObjects; + +namespace Content.Server.GameObjects.Components.Weapon.Melee +{ + [RegisterComponent] + public class UnarmedCombatComponent : MeleeWeaponComponent + { + public override string Name => "UnarmedCombat"; + } +} diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 66692a5543..c92df5fcc5 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Timing; @@ -955,22 +955,34 @@ namespace Content.Server.GameObjects.EntitySystems return; } - // Verify player has a hand, and find what object he is currently holding in his active hand - if (!player.TryGetComponent(out var hands)) - { - return; - } - - var item = hands.GetActiveHand?.Owner; - - // TODO: If item is null we need some kinda unarmed combat. - if (!ActionBlockerSystem.CanAttack(player) || item == null) + if (!ActionBlockerSystem.CanAttack(player)) { return; } var eventArgs = new AttackEventArgs(player, coordinates); - foreach (var attackComponent in item.GetAllComponents()) + + // Verify player has a hand, and find what object he is currently holding in his active hand + if (player.TryGetComponent(out var hands)) + { + var item = hands.GetActiveHand?.Owner; + + if (item != null) + { + var attacked = false; + foreach (var attackComponent in item.GetAllComponents()) + { + attackComponent.Attack(eventArgs); + attacked = true; + } + if (attacked) + { + return; + } + } + } + + foreach (var attackComponent in player.GetAllComponents()) { attackComponent.Attack(eventArgs); } diff --git a/Resources/Prototypes/Entities/Mobs/human.yml b/Resources/Prototypes/Entities/Mobs/human.yml index 5bb8d68aaf..629926bc51 100644 --- a/Resources/Prototypes/Entities/Mobs/human.yml +++ b/Resources/Prototypes/Entities/Mobs/human.yml @@ -134,6 +134,7 @@ - type: HumanoidAppearance - type: Stunnable - type: AnimationPlayer + - type: UnarmedCombat - type: entity save: false