From 9bf53a4218cf0b3bc28605dcce68a783bfc71a6b Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Sun, 21 Jun 2020 18:31:56 -0700 Subject: [PATCH 1/2] Implement unarmed combat --- .../Weapon/Melee/UnarmedCombatComponent.cs | 12 +++++++ .../EntitySystems/Click/InteractionSystem.cs | 36 ++++++++++++------- Resources/Prototypes/Entities/Mobs/human.yml | 1 + 3 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 Content.Server/GameObjects/Components/Weapon/Melee/UnarmedCombatComponent.cs 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 From 264d3d39427e642582e69661147cbf79f2c27a4e Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Tue, 23 Jun 2020 05:53:38 -0700 Subject: [PATCH 2/2] Add fist graphic and change some punch settings --- .../Weapon/Melee/UnarmedCombatComponent.cs | 4 +--- Resources/Prototypes/Entities/Mobs/human.yml | 3 +++ .../Prototypes/MeleeWeaponAnimations/default.yml | 7 +++++++ .../Textures/Effects/weapons/arcs.rsi/fist.png | Bin 0 -> 190 bytes .../Textures/Effects/weapons/arcs.rsi/meta.json | 4 ++++ 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 Resources/Textures/Effects/weapons/arcs.rsi/fist.png diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/UnarmedCombatComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/UnarmedCombatComponent.cs index 0cd7cb189c..9841f283a0 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/UnarmedCombatComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/UnarmedCombatComponent.cs @@ -1,6 +1,4 @@ - -using Content.Server.GameObjects.EntitySystems; -using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects; namespace Content.Server.GameObjects.Components.Weapon.Melee { diff --git a/Resources/Prototypes/Entities/Mobs/human.yml b/Resources/Prototypes/Entities/Mobs/human.yml index 629926bc51..ba2e459c0c 100644 --- a/Resources/Prototypes/Entities/Mobs/human.yml +++ b/Resources/Prototypes/Entities/Mobs/human.yml @@ -135,6 +135,9 @@ - type: Stunnable - type: AnimationPlayer - type: UnarmedCombat + range: 0.8 + arcwidth: 30 + arc: fist - type: entity save: false diff --git a/Resources/Prototypes/MeleeWeaponAnimations/default.yml b/Resources/Prototypes/MeleeWeaponAnimations/default.yml index c7fe845719..0259f33948 100644 --- a/Resources/Prototypes/MeleeWeaponAnimations/default.yml +++ b/Resources/Prototypes/MeleeWeaponAnimations/default.yml @@ -5,3 +5,10 @@ length: 0.1 color: 255,255,255,1020 colorDelta: 0,0,0,-5100 + +- type: MeleeWeaponAnimation + id: fist + state: fist + arcType: Poke + length: 0.15 + speed: 1 diff --git a/Resources/Textures/Effects/weapons/arcs.rsi/fist.png b/Resources/Textures/Effects/weapons/arcs.rsi/fist.png new file mode 100644 index 0000000000000000000000000000000000000000..337d57adc28b31a7e1d84c2eed5d212dedb6996c GIT binary patch literal 190 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}6`n4RArY-_ zCwp@pFyLVIeR