-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Port] BackStab / Удар В Спину (#30)
* add: BackStab * test
- Loading branch information
Showing
8 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
backstab-damage-betrayal-dagger = A stab in the back: {$damage}! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
backstab-damage-betrayal-dagger = Удар в спину: {$damage}! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = Предательский кинжал позволяет пользователю телепортироваться на короткое расстояние, а также наносит значительные повреждения при ударе в спину. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,6 @@ | |
Slash: 20 | ||
- type: DisarmMalus | ||
malus: 0.225 | ||
- type: BackStab | ||
- type: Blink | ||
blinkRate: 0.33 |