Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Port] BackStab / Удар В Спину #30

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Content.Shared/_White/BackStab/BackStabComponent.cs
Original file line number Diff line number Diff line change
@@ -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);
}
58 changes: 58 additions & 0 deletions Content.Shared/_White/BackStab/BackStabSystem.cs
Original file line number Diff line number Diff line change
@@ -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<BackStabComponent, MeleeHitEvent>(HandleHit);
}

private void HandleHit(Entity<BackStabComponent> ent, ref MeleeHitEvent args)
{
if (args.HitEntities.Count != 1)
return;

var target = args.HitEntities[0];

if (target == args.User
|| !HasComp<MobStateComponent>(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<DamageTypePrototype>("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);
}
}
1 change: 1 addition & 0 deletions Resources/Locale/en-US/_white/backstab/backstab.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
backstab-damage-betrayal-dagger = A stab in the back: {$damage}!
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/_white/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions Resources/Locale/ru-RU/_white/backstab/backstab.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
backstab-damage-betrayal-dagger = Удар в спину: {$damage}!
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
uplink-emp-flashlight-name = Электромагнитный фонарик
uplink-emp-flashlight-desc = Замаскированное под фонарик устройство. При ударе выпускает ЭМИ, поражающий электрические устройства.

uplink-betrayal-knife-name = Предательский кинжал
uplink-betrayal-knife-desc = Предательский кинжал позволяет пользователю телепортироваться на короткое расстояние, а также наносит значительные повреждения при ударе в спину.
17 changes: 17 additions & 0 deletions Resources/Prototypes/_White/Catalog/uplink_catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
Slash: 20
- type: DisarmMalus
malus: 0.225
- type: BackStab
- type: Blink
blinkRate: 0.33
Loading