From 27d4cf977f0595ef1ec40e50e457b745690a3459 Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Wed, 31 Jan 2024 21:47:18 +0900 Subject: [PATCH] Hardlight spear tweaks (#3) * - tweak: Increased hardlight spear throw force and use delay * - fix: Hardlight spear can now hit holocarps when thrown * - add: New sprites for hardlight spear * - fix: Fix duping hardlight spears by inserting them into containers --- Content.Server/Hands/Systems/HandsSystem.cs | 9 +++++++++ .../ChangeThrowForceComponent.cs | 8 ++++++++ .../ChangeThrowForceSystem.cs | 17 +++++++++++++++++ .../HardlightSpear/HardlightSpearSystem.cs | 9 +++++++++ Resources/Prototypes/White/Actions/types.yml | 2 +- .../Objects/Weapons/hardlight_spear.yml | 16 ++++++++++++++++ .../_White/Entities/Cult/Items/forge_craft.yml | 2 ++ .../Weapons/hardlight_spear.rsi/meta.json | 2 +- .../wielded-inhand-left.png | Bin 400 -> 442 bytes .../wielded-inhand-right.png | Bin 375 -> 436 bytes 10 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 Content.Server/_White/Other/ChangeThrowForceSystem/ChangeThrowForceComponent.cs create mode 100644 Content.Server/_White/Other/ChangeThrowForceSystem/ChangeThrowForceSystem.cs diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 9d664d0f9a..ba4e6fde10 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -1,4 +1,5 @@ using System.Numerics; +using Content.Server._White.Other.ChangeThrowForceSystem; using Content.Server.Inventory; using Content.Server.Pulling; using Content.Server.Stack; @@ -206,6 +207,12 @@ namespace Content.Server.Hands.Systems var throwStrength = hands.ThrowForceMultiplier; + if (TryComp(throwEnt, out var thrownChangeForceComponent)) + { + var component = EnsureComp(player); + component.ThrowForce = thrownChangeForceComponent.ThrowForce; + } + // Let other systems change the thrown entity (useful for virtual items) // or the throw strength. var ev = new BeforeThrowEvent(throwEnt, direction, throwStrength, player); @@ -220,6 +227,8 @@ namespace Content.Server.Hands.Systems _throwingSystem.TryThrow(ev.ItemUid, ev.Direction, ev.ThrowStrength, ev.PlayerUid); + RemComp(player); + return true; } diff --git a/Content.Server/_White/Other/ChangeThrowForceSystem/ChangeThrowForceComponent.cs b/Content.Server/_White/Other/ChangeThrowForceSystem/ChangeThrowForceComponent.cs new file mode 100644 index 0000000000..5f5f78c5a2 --- /dev/null +++ b/Content.Server/_White/Other/ChangeThrowForceSystem/ChangeThrowForceComponent.cs @@ -0,0 +1,8 @@ +namespace Content.Server._White.Other.ChangeThrowForceSystem; + +[RegisterComponent] +public sealed partial class ChangeThrowForceComponent : Component +{ + [DataField, ViewVariables(VVAccess.ReadWrite)] + public float ThrowForce = 10f; +} diff --git a/Content.Server/_White/Other/ChangeThrowForceSystem/ChangeThrowForceSystem.cs b/Content.Server/_White/Other/ChangeThrowForceSystem/ChangeThrowForceSystem.cs new file mode 100644 index 0000000000..285c42ac14 --- /dev/null +++ b/Content.Server/_White/Other/ChangeThrowForceSystem/ChangeThrowForceSystem.cs @@ -0,0 +1,17 @@ +using Content.Shared.Throwing; + +namespace Content.Server._White.Other.ChangeThrowForceSystem; + +public sealed class ChangeThrowForceSystem : EntitySystem +{ + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(HandleThrow); + } + + private void HandleThrow(EntityUid uid, ChangeThrowForceComponent component, ref BeforeThrowEvent args) + { + args.ThrowStrength = component.ThrowForce; + } +} diff --git a/Content.Shared/_White/HardlightSpear/HardlightSpearSystem.cs b/Content.Shared/_White/HardlightSpear/HardlightSpearSystem.cs index eda42518a9..09deb9ddb6 100644 --- a/Content.Shared/_White/HardlightSpear/HardlightSpearSystem.cs +++ b/Content.Shared/_White/HardlightSpear/HardlightSpearSystem.cs @@ -1,4 +1,5 @@ using System.Linq; +using Content.Shared.Body.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Implants.Components; using Content.Shared.Interaction.Events; @@ -7,6 +8,7 @@ using Content.Shared.Physics; using Content.Shared.Popups; using Content.Shared.Throwing; using Robust.Shared.Audio.Systems; +using Robust.Shared.Containers; using Robust.Shared.Physics; using Robust.Shared.Physics.Events; using Robust.Shared.Spawners; @@ -25,6 +27,7 @@ public sealed class HardlightSpearSystem : EntitySystem SubscribeLocalEvent(OnLand); SubscribeLocalEvent(OnDrop); + SubscribeLocalEvent(OnInsert); SubscribeLocalEvent(OnPickupAttempt); SubscribeLocalEvent(OnPreventCollision); SubscribeLocalEvent(OnImplantActivate); @@ -76,4 +79,10 @@ public sealed class HardlightSpearSystem : EntitySystem { EnsureComp(uid); } + + private void OnInsert(EntityUid uid, HardlightSpearComponent component, EntGotInsertedIntoContainerMessage args) + { + if (!HasComp(args.Container.Owner)) + EnsureComp(uid); + } } diff --git a/Resources/Prototypes/White/Actions/types.yml b/Resources/Prototypes/White/Actions/types.yml index 58a92d084a..25f9ce71b9 100644 --- a/Resources/Prototypes/White/Actions/types.yml +++ b/Resources/Prototypes/White/Actions/types.yml @@ -20,7 +20,7 @@ noSpawn: true components: - type: InstantAction - useDelay: 1.5 + useDelay: 2 itemIconStyle: BigAction priority: -20 icon: diff --git a/Resources/Prototypes/White/Entities/Objects/Weapons/hardlight_spear.yml b/Resources/Prototypes/White/Entities/Objects/Weapons/hardlight_spear.yml index e9eb44397e..56570149b5 100644 --- a/Resources/Prototypes/White/Entities/Objects/Weapons/hardlight_spear.yml +++ b/Resources/Prototypes/White/Entities/Objects/Weapons/hardlight_spear.yml @@ -42,3 +42,19 @@ radius: 1.5 energy: 2 color: yellow + - type: ChangeThrowForce + throwForce: 20 + - type: Fixtures + fixtures: + fix1: + shape: !type:PolygonShape + vertices: + - -0.20,-0.10 + - -0.10,-0.20 + - 0.40,0.30 + - 0.30,0.40 + density: 20 + mask: + - Opaque + restitution: 0.3 + friction: 0.2 diff --git a/Resources/Prototypes/_White/Entities/Cult/Items/forge_craft.yml b/Resources/Prototypes/_White/Entities/Cult/Items/forge_craft.yml index 1eb0b9dff5..f699037893 100644 --- a/Resources/Prototypes/_White/Entities/Cult/Items/forge_craft.yml +++ b/Resources/Prototypes/_White/Entities/Cult/Items/forge_craft.yml @@ -33,6 +33,8 @@ - Energy - type: ReturnItemOnThrow - type: CultItem + - type: ChangeThrowForce + throwForce: 6.5 - type: cultistFactoryProduction diff --git a/Resources/Textures/White/Objects/Weapons/hardlight_spear.rsi/meta.json b/Resources/Textures/White/Objects/Weapons/hardlight_spear.rsi/meta.json index 94fc8982f9..dafd46851a 100644 --- a/Resources/Textures/White/Objects/Weapons/hardlight_spear.rsi/meta.json +++ b/Resources/Textures/White/Objects/Weapons/hardlight_spear.rsi/meta.json @@ -1,7 +1,7 @@ { "version": 1, "license": "CC-BY-SA-3.0", - "copyright": "Taken from monkestation at https://github.com/Monkestation/MonkeStation/commit/c995c9bda2c23386614ac1cb00aca552f573ba9f, equipped and wielded sprites by Aviu", + "copyright": "Taken from monkestation at https://github.com/Monkestation/MonkeStation/commit/c995c9bda2c23386614ac1cb00aca552f573ba9f, equipped sprite by Aviu, wielded sprites by antohag", "size": { "x": 32, "y": 32 diff --git a/Resources/Textures/White/Objects/Weapons/hardlight_spear.rsi/wielded-inhand-left.png b/Resources/Textures/White/Objects/Weapons/hardlight_spear.rsi/wielded-inhand-left.png index 74cbb4eaf82f7a1736ccf41fb194dc1f6721536e..416a73d8ba3ebee632eee94fd4a8eb9d25047ffe 100644 GIT binary patch delta 403 zcmV;E0c`$|1G)o{F@JPPL_t(|ob8%Xu7n^AMY{sl<>K9k%jo-f;y@{)C`>XrCoz*z zpzT#4@hSoU00000001B&x-A+)_;wnv5JC{$7QNM2RaIBH*6GWr>T$T&SNX5!?566r zsIH>N@7}>3%(Q*Ang+4Rv}k)2eUclR=Kg6A3wE%Ixs4ivRDT0|1-8aIDclnvgitRo z9l!Pj6aqL;fW=9=9@viE9_zjUtta5D!{{1YJpx==13VEz2ojGTYDqom zUpwcK=KnLh+7m$m0000000000001gPW5T{yf8rC|#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