From 6116f9a8414177d9f5a5b609f63359c0ccddab5d Mon Sep 17 00:00:00 2001 From: Spatison <137375981+Spatison@users.noreply.github.com> Date: Sat, 7 Sep 2024 05:50:31 +0300 Subject: [PATCH] =?UTF-8?q?[Port]=20BackStab=20/=20=D0=A3=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=20=D0=92=20=D0=A1=D0=BF=D0=B8=D0=BD=D1=83=20(#30)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add: BackStab * test --- .../_White/BackStab/BackStabComponent.cs | 11 ++++ .../_White/BackStab/BackStabSystem.cs | 58 +++++++++++++++++++ .../Locale/en-US/_white/backstab/backstab.ftl | 1 + .../en-US/_white/store/uplink-catalog.ftl | 3 + .../Locale/ru-RU/_white/backstab/backstab.ftl | 1 + .../ru-RU/_white/store/uplink-catalog.ftl | 3 + .../_White/Catalog/uplink_catalog.yml | 17 ++++++ .../Objects/Weapons/Melee/daggers.yml | 1 + 8 files changed, 95 insertions(+) create mode 100644 Content.Shared/_White/BackStab/BackStabComponent.cs create mode 100644 Content.Shared/_White/BackStab/BackStabSystem.cs create mode 100644 Resources/Locale/en-US/_white/backstab/backstab.ftl create mode 100644 Resources/Locale/ru-RU/_white/backstab/backstab.ftl diff --git a/Content.Shared/_White/BackStab/BackStabComponent.cs b/Content.Shared/_White/BackStab/BackStabComponent.cs new file mode 100644 index 0000000000..8d45386df0 --- /dev/null +++ b/Content.Shared/_White/BackStab/BackStabComponent.cs @@ -0,0 +1,11 @@ +namespace Content.Shared._White.BackStab; + +[RegisterComponent] +public sealed partial class BackStabComponent : Component +{ + [DataField, ViewVariables(VVAccess.ReadWrite)] + public float DamageMultiplier = 2f; + + [DataField, ViewVariables(VVAccess.ReadWrite)] + public Angle Tolerance = Angle.FromDegrees(45d); +} diff --git a/Content.Shared/_White/BackStab/BackStabSystem.cs b/Content.Shared/_White/BackStab/BackStabSystem.cs new file mode 100644 index 0000000000..f4663fa7de --- /dev/null +++ b/Content.Shared/_White/BackStab/BackStabSystem.cs @@ -0,0 +1,58 @@ +using Content.Shared.Damage; +using Content.Shared.Damage.Prototypes; +using Content.Shared.Mobs.Components; +using Content.Shared.Popups; +using Content.Shared.Weapons.Melee.Events; +using Robust.Shared.Network; +using Robust.Shared.Prototypes; + +namespace Content.Shared._White.BackStab; + +public sealed class BackStabSystem : EntitySystem +{ + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly INetManager _net = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(HandleHit); + } + + private void HandleHit(Entity ent, ref MeleeHitEvent args) + { + if (args.HitEntities.Count != 1) + return; + + var target = args.HitEntities[0]; + + if (target == args.User + || !HasComp(target) + || !TryComp(target, out TransformComponent? xform)) + { + return; + } + + var userXform = Transform(args.User); + var v1 = (_transform.GetWorldRotation(xform) + MathHelper.PiOver2).ToVec(); // Flipped WorldVec + var v2 = _transform.GetWorldPosition(userXform) - _transform.GetWorldPosition(xform); + var angle = Vector3.CalculateAngle(new Vector3(v1), new Vector3(v2)); + + if (angle > ent.Comp.Tolerance.Theta) + return; + + var damage = args.BaseDamage.GetTotal() * ent.Comp.DamageMultiplier; + + args.BonusDamage = new DamageSpecifier(_prototypeManager.Index("Slash"), + damage - args.BaseDamage.GetTotal()); + + if (!_net.IsServer) + return; + + var message = Loc.GetString("backstab-damage-betrayal-dagger", ("damage", damage)); + _popup.PopupEntity(message, args.User, args.User, PopupType.MediumCaution); + } +} diff --git a/Resources/Locale/en-US/_white/backstab/backstab.ftl b/Resources/Locale/en-US/_white/backstab/backstab.ftl new file mode 100644 index 0000000000..cead93b330 --- /dev/null +++ b/Resources/Locale/en-US/_white/backstab/backstab.ftl @@ -0,0 +1 @@ +backstab-damage-betrayal-dagger = A stab in the back: {$damage}! \ No newline at end of file diff --git a/Resources/Locale/en-US/_white/store/uplink-catalog.ftl b/Resources/Locale/en-US/_white/store/uplink-catalog.ftl index 7e0b0b791e..44ce8ca0fa 100644 --- a/Resources/Locale/en-US/_white/store/uplink-catalog.ftl +++ b/Resources/Locale/en-US/_white/store/uplink-catalog.ftl @@ -1,2 +1,5 @@ uplink-emp-flashlight-name = Emp Flashlight uplink-emp-flashlight-desc = A rechargeable device disguised as a flashlight designed to disrupt electronic systems. Useful for disrupting communications, security's energy weapons, and APCs when you're in a tight spot. + +uplink-betrayal-knife-name = Betrayal dagger +uplink-betrayal-knife-desc = The betrayal dagger allows the user to teleport a short distance, and also causes significant damage when stabbed in the back. \ No newline at end of file diff --git a/Resources/Locale/ru-RU/_white/backstab/backstab.ftl b/Resources/Locale/ru-RU/_white/backstab/backstab.ftl new file mode 100644 index 0000000000..eb69776cb3 --- /dev/null +++ b/Resources/Locale/ru-RU/_white/backstab/backstab.ftl @@ -0,0 +1 @@ +backstab-damage-betrayal-dagger = Удар в спину: {$damage}! \ No newline at end of file diff --git a/Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl b/Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl index 5bb4067557..5953a18549 100644 --- a/Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl +++ b/Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl @@ -1,2 +1,5 @@ uplink-emp-flashlight-name = Электромагнитный фонарик uplink-emp-flashlight-desc = Замаскированное под фонарик устройство. При ударе выпускает ЭМИ, поражающий электрические устройства. + +uplink-betrayal-knife-name = Предательский кинжал +uplink-betrayal-knife-desc = Предательский кинжал позволяет пользователю телепортироваться на короткое расстояние, а также наносит значительные повреждения при ударе в спину. \ No newline at end of file diff --git a/Resources/Prototypes/_White/Catalog/uplink_catalog.yml b/Resources/Prototypes/_White/Catalog/uplink_catalog.yml index ed2e10a2ee..4c1e4b0a60 100644 --- a/Resources/Prototypes/_White/Catalog/uplink_catalog.yml +++ b/Resources/Prototypes/_White/Catalog/uplink_catalog.yml @@ -7,3 +7,20 @@ Telecrystal: 3 categories: - UplinkUtility + +- type: listing + id: UplinkBetrayalKnife + name: uplink-betrayal-knife-name + description: uplink-betrayal-knife-desc + icon: { sprite: /Textures/_White/Objects/Weapons/Melee/Daggers/betrayal_knife.rsi, state: icon } + productEntity: BetrayalKnife + cost: + Telecrystal: 10 + categories: + - UplinkWeapons + conditions: + - !type:StoreWhitelistCondition + blacklist: + tags: + - NukeOpsUplink + saleLimit: 1 diff --git a/Resources/Prototypes/_White/Entities/Objects/Weapons/Melee/daggers.yml b/Resources/Prototypes/_White/Entities/Objects/Weapons/Melee/daggers.yml index 815e2192d9..86f111e2b5 100644 --- a/Resources/Prototypes/_White/Entities/Objects/Weapons/Melee/daggers.yml +++ b/Resources/Prototypes/_White/Entities/Objects/Weapons/Melee/daggers.yml @@ -28,5 +28,6 @@ Slash: 20 - type: DisarmMalus malus: 0.225 + - type: BackStab - type: Blink blinkRate: 0.33