Skip to content

Commit

Permalink
[Port] Blood Dagger / Кровавый Кинжал (#86)
Browse files Browse the repository at this point in the history
add: blood dagger
  • Loading branch information
Spatison authored Oct 16, 2024
1 parent 921d814 commit d61d9cd
Show file tree
Hide file tree
Showing 20 changed files with 330 additions and 34 deletions.
17 changes: 15 additions & 2 deletions Content.Server/Body/Systems/BloodstreamSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server._White.Other.BloodLust;
using Content.Server.Body.Components;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Chemistry.ReactionEffects;
Expand All @@ -14,6 +15,7 @@
using Content.Shared.Drunk;
using Content.Shared.FixedPoint;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Systems;
using Content.Shared.Popups;
using Content.Shared.Rejuvenate;
using Content.Shared.Speech.EntitySystems;
Expand All @@ -39,6 +41,7 @@ public sealed class BloodstreamSystem : EntitySystem
[Dependency] private readonly SharedStutteringSystem _stutteringSystem = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
[Dependency] private readonly ForensicsSystem _forensicsSystem = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!; // WD

public override void Initialize()
{
Expand Down Expand Up @@ -352,7 +355,7 @@ public void SetBloodLossThreshold(EntityUid uid, float threshold, BloodstreamCom
/// <summary>
/// Attempts to modify the blood level of this entity directly.
/// </summary>
public bool TryModifyBloodLevel(EntityUid uid, FixedPoint2 amount, BloodstreamComponent? component = null)
public bool TryModifyBloodLevel(EntityUid uid, FixedPoint2 amount, BloodstreamComponent? component = null, bool createPuddle = true) // WD EDIT
{
if (!Resolve(uid, ref component, logMissing: false)
|| !_solutionContainerSystem.ResolveSolution(uid, component.BloodSolutionName, ref component.BloodSolution))
Expand All @@ -373,7 +376,7 @@ public bool TryModifyBloodLevel(EntityUid uid, FixedPoint2 amount, BloodstreamCo

tempSolution.AddSolution(newSol, _prototypeManager);

if (tempSolution.Volume > component.BleedPuddleThreshold)
if (tempSolution.Volume > component.BleedPuddleThreshold && createPuddle) // WD EDIT
{
// Pass some of the chemstream into the spilled blood.
if (_solutionContainerSystem.ResolveSolution(uid, component.ChemicalSolutionName, ref component.ChemicalSolution))
Expand Down Expand Up @@ -406,6 +409,16 @@ public bool TryModifyBleedAmount(EntityUid uid, float amount, BloodstreamCompone
component.BleedAmount += amount;
component.BleedAmount = Math.Clamp(component.BleedAmount, 0, component.MaxBleedAmount);

// WD EDIT START
if (HasComp<BloodLustComponent>(uid))
{
if (component.BleedAmount == 0f)
RemComp<BloodLustComponent>(uid);

_movementSpeedModifier.RefreshMovementSpeedModifiers(uid);
}
// WD EDIT END

if (component.BleedAmount == 0)
_alertsSystem.ClearAlert(uid, AlertType.Bleed);
else
Expand Down
17 changes: 17 additions & 0 deletions Content.Server/_White/Melee/BloodAbsorb/BloodAbsorbComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Content.Server._White.Melee.BloodAbsorb;

[RegisterComponent]
public sealed partial class BloodAbsorbComponent : Component
{
[DataField]
public bool BloodLust;

[DataField]
public int MinAbsorb = 1;

[DataField]
public int MaxAbsorb = 20;

[DataField]
public float AbsorbModifierOnHeavy = 0.7f;
}
71 changes: 71 additions & 0 deletions Content.Server/_White/Melee/BloodAbsorb/BloodAbsorbSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Content.Server._White.Melee.Crit;
using Content.Server._White.Other.BloodLust;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

namespace Content.Server._White.Melee.BloodAbsorb;

public sealed class BloodAbsorbSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly BloodstreamSystem _bloodstream = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;

public override void Initialize()
{
SubscribeLocalEvent<BloodAbsorbComponent, CritHitEvent>(OnCritHit);
SubscribeLocalEvent<BloodAbsorbComponent, MeleeHitEvent>(OnMeleeHit);
}

private void OnCritHit(EntityUid uid, BloodAbsorbComponent component, CritHitEvent args)
{
if(args.Targets.Count == 0
|| args.Targets[0] == args.User)
return;

var absorbed = _random.Next(component.MinAbsorb, component.MaxAbsorb);

if (args.Targets.Count != 1) // Heavy attack
absorbed = (int) MathF.Round(absorbed * 0.7f);

foreach (var target in args.Targets)
{
if (!TryComp(target, out BloodstreamComponent? bloodstream))
continue;

var blood = bloodstream.BloodSolution;

if (blood == null)
continue;

var bloodLevel = blood.Value.Comp.Solution.Volume.Int();

if (!_bloodstream.TryModifyBloodLevel(target, -absorbed, bloodstream, false))
continue;

absorbed = Math.Min(absorbed, bloodLevel);
_bloodstream.TryModifyBloodLevel(args.User, absorbed);
_damageable.TryChangeDamage(args.User, new DamageSpecifier(_prototype.Index<DamageGroupPrototype>("Brute"), -absorbed));
_damageable.TryChangeDamage(args.User, new DamageSpecifier(_prototype.Index<DamageGroupPrototype>("Burn"), -absorbed));
_damageable.TryChangeDamage(args.User, new DamageSpecifier(_prototype.Index<DamageGroupPrototype>("Airloss"), -absorbed));
}
}

private void OnMeleeHit(EntityUid uid, BloodAbsorbComponent component, MeleeHitEvent args)
{
if (args.HitEntities.Count == 0
|| args.HitEntities[0] != args.User
|| !component.BloodLust
|| !TryComp(args.User, out BloodstreamComponent? bloodstream))
return;

EnsureComp<BloodLustComponent>(args.User);
_bloodstream.TryModifyBleedAmount(args.User, bloodstream.MaxBleedAmount, bloodstream);
}
}
17 changes: 16 additions & 1 deletion Content.Server/_White/Melee/Crit/CritSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override void Initialize()
SubscribeLocalEvent<CritComponent, MeleeHitEvent>(HandleHit, before: new [] {typeof(MeleeBlockSystem)});
}

private void HandleHit(EntityUid uid, CritComponent component, MeleeHitEvent args)
private void HandleHit(EntityUid uid, CritComponent component, ref MeleeHitEvent args)
{
if (args.HitEntities.Count == 0 || !IsCriticalHit(component))
return;
Expand All @@ -32,6 +32,8 @@ private void HandleHit(EntityUid uid, CritComponent component, MeleeHitEvent arg

var message = Loc.GetString("melee-crit-damage", ("damage", damage));
_popup.PopupEntity(message, args.User, args.User, PopupType.MediumCaution);

RaiseLocalEvent(uid, new CritHitEvent(args.User, args.HitEntities));
}

private bool IsCriticalHit(CritComponent component)
Expand All @@ -48,3 +50,16 @@ private bool IsCriticalHit(CritComponent component)
return isCritical;
}
}

public sealed class CritHitEvent(EntityUid user, IReadOnlyList<EntityUid> target)
{
/// <summary>
/// Entity who attacked with a critical attack
/// </summary>
public EntityUid User = user;

/// <summary>
/// Entities who was attacked with a critical attack
/// </summary>
public IReadOnlyList<EntityUid> Targets = target;
}
14 changes: 14 additions & 0 deletions Content.Server/_White/Other/BloodLust/BloodLustComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Content.Server._White.Other.BloodLust;

[RegisterComponent]
public sealed partial class BloodLustComponent : Component
{
[DataField]
public float SprintModifier = 1.3f;

[DataField]
public float WalkModifier = 1.3f;

[DataField]
public float AttackRateModifier = 1.5f;
}
42 changes: 42 additions & 0 deletions Content.Server/_White/Other/BloodLust/BloodLustSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Content.Server.Body.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Weapons.Melee.Events;

namespace Content.Server._White.Other.BloodLust;

public sealed class BloodLustSystem : EntitySystem
{
public override void Initialize()
{
SubscribeLocalEvent<BloodLustComponent, GetMeleeAttackRateEvent>(OnGetMeleeAttackRate);
SubscribeLocalEvent<BloodLustComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeedModifiers);
}

private void OnGetMeleeAttackRate(EntityUid uid, BloodLustComponent component, GetMeleeAttackRateEvent args)
{
if (!TryComp(args.User, out BloodLustComponent? bloodLust))
return;

args.Multipliers *= GetBloodLustMultiplier(bloodLust.AttackRateModifier, GetBloodLustModifier(args.User));
}

private void OnRefreshMovementSpeedModifiers(EntityUid uid, BloodLustComponent component, RefreshMovementSpeedModifiersEvent args)
{
var modifier = GetBloodLustModifier(uid);
args.ModifySpeed(GetBloodLustMultiplier(component.WalkModifier, modifier),
GetBloodLustMultiplier(component.SprintModifier, modifier));
}

private float GetBloodLustModifier(EntityUid uid)
{
if (!TryComp(uid, out BloodstreamComponent? bloodstream) || bloodstream.MaxBleedAmount == 0f)
return 1f;

return Math.Clamp(bloodstream.BleedAmount / bloodstream.MaxBleedAmount, 0f, 1f);
}

private float GetBloodLustMultiplier(float multiplier, float modifier)
{
return float.Lerp(1f, multiplier, modifier);
}
}
7 changes: 5 additions & 2 deletions Resources/Locale/en-US/_white/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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.
uplink-betrayal-dagger-name = Betrayal dagger
uplink-betrayal-dagger-desc = The betrayal dagger allows the user to teleport a short distance, and also causes significant damage when stabbed in the back.
uplink-betrayal-knife-name = Experimental syndicate teleporter
uplink-betrayal-knife-desc = Syndicate teleporter, when used, moves 3-8 meters forward. In case of teleportation into a wall, uses emergency teleportation. Has 4 charge.
Expand All @@ -18,3 +18,6 @@ uplink-implanter-desc = An advanced implant that allows you to quickly insert an
uplink-smoke-implant-name = Smoke implant
uplink-smoke-implant-desc = Releases a cloud of smoke when activated.
uplink-blood-dagger-name = Blood dagger
uplink-blood-dagger-desc = A dagger of pain and blood. It has deadly accuracy, allowing you to deal critical damage and extract blood from opponents, treating the owner in proportion to the sucked blood. When absorbing the owner's blood, it briefly enhances his valuable profuse bleeding.
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
ent-BetrayalKnife = предательский кинжал
.desc = Береги спину.
ent-BetrayalDagger = предательский кинжал
.desc = Береги спину.
ent-BloodDagger = кровавый кинжал
.desc = Кинжал из боли и крови. С него что-то капает...
7 changes: 5 additions & 2 deletions Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
uplink-emp-flashlight-name = Электромагнитный фонарик
uplink-emp-flashlight-desc = Замаскированное под фонарик устройство. При ударе выпускает ЭМИ, поражающий электрические устройства.
uplink-betrayal-knife-name = Предательский кинжал
uplink-betrayal-knife-desc = Предательский кинжал позволяет пользователю телепортироваться на короткое расстояние, а также наносит значительные повреждения при ударе в спину.
uplink-betrayal-dagger-name = Предательский кинжал
uplink-betrayal-dagger-desc = Предательский кинжал позволяет пользователю телепортироваться на короткое расстояние, а также наносит значительные повреждения при ударе в спину.
uplink-experimental-syndicate-teleporter-name = Экспериментальный телепортер синдиката
uplink-experimental-syndicate-teleporter-desc = Телепортер синдиката, при использовании перемещает на 3-8 метров вперед. В случае телепортации в стену, использует экстренную телепортацию. Имеет 4 заряда и автоматически заряжается.
Expand All @@ -18,3 +18,6 @@ uplink-implanter-desc = Продвинутый имплантер, позвол
uplink-smoke-implant-name = Имплант дыма
uplink-smoke-implant-desc = Выпускает облако дыма при активации.
uplink-blood-dagger-name = Кровавый кинжал
uplink-blood-dagger-desc = Кинжал из боли и крови. Обладает смертоносной точностью, позволяя наносить критический урон и извлекать кровь из противников, леча владельца пропорционально высосанной крови. При поглощении крови владельца кратковременно усиливает его ценной обильного кровотечения.
20 changes: 1 addition & 19 deletions Resources/Locale/ru-RU/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -440,22 +440,4 @@ uplink-hypodart-name = Гиподротик
uplink-hypodart-desc = Неприметный на первый взгляд дротик с увеличенным резервуаром для химических веществ. Он вмещает в себя до 7 ед. реагентов и мгновенно впрыскивает их при попадании в цель. Изначально пуст.
uplink-helmet-name = Шлем спецназа
uplink-helmet-desc = Чрезвычайно прочный шлем, обычно используемый военизированными формированиями. Он украшен гнусным рисунком в красную и черную полоску.
uplink-ebow-name = Маленький энергетический арбалет
uplink-ebow-desc = Довольно тихое оружие, которое автоматически перезаряжается и оглушает. Хорошо сочетается с другими видами оружия.
uplink-blood-dagger-name = Кинжал жажды
uplink-blood-dagger-desc = Критическая жажда: Кинжал Жажды обладает смертоносной точностью. Его владелец имеет 50% шанс нанести критический урон, поражая врага в его самые уязвимые места. При ударе по себе кинжал наделит пользователя временным усилением скорости атаки и передвижения ценой обильного кровотечения. Кровавый абсорб: При каждом успешном критическом ударе, кинжал извлекает кровь из цели, восстанавливая здоровье владельцу пропорционально количеству высосанной крови.
uplink-night-vision-name = ПНВ [Хамелеон]
uplink-night-vision-desc = Теперь ты видишь во тьме!
uplink-thermal-vision-name = Оптический термальный сканер [Хамелеон]
uplink-thermal-vision-desc = Позволяет вам видеть существ через стены.
uplink-betrayal-knife-name = Предательский нож
uplink-betrayal-knife-desc = Предательский нож позволяет пользователю телепортироваться на короткое расстояние, а также наносит значительные повреждения, пробивая броню противника, при ударе в спину.
uplink-implanter-name = Имплантер
uplink-implanter-desc = Продвинутый имплантер, позволяющий быстро вкалывать и вытаскивать импланты.
uplink-helmet-desc = Чрезвычайно прочный шлем, обычно используемый военизированными формированиями. Он украшен гнусным рисунком в красную и черную полоску.
24 changes: 20 additions & 4 deletions Resources/Prototypes/_White/Catalog/uplink_catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
- UplinkUtility

- type: listing
id: UplinkBetrayalKnife
name: uplink-betrayal-knife-name
description: uplink-betrayal-knife-desc
productEntity: BetrayalKnife
id: UplinkBetrayalDagger
name: uplink-betrayal-dagger-name
description: uplink-betrayal-dagger-desc
productEntity: BetrayalDagger
cost:
Telecrystal: 10
categories:
Expand Down Expand Up @@ -81,3 +81,19 @@
Telecrystal: 2
categories:
- UplinkImplants

- type: listing
id: UplinkBloodDagger
name: uplink-blood-dagger-name
description: uplink-blood-dagger-desc
productEntity: BloodDagger
cost:
Telecrystal: 8
categories:
- UplinkWeapons
conditions:
- !type:StoreWhitelistCondition
blacklist:
tags:
- NukeOpsUplink
saleLimit: 1
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
name: betrayal dagger
description: Watch your back.
parent: BaseKnife
id: BetrayalKnife
id: BetrayalDagger
components:
- type: Sprite
sprite: _White/Objects/Weapons/Melee/Daggers/betrayal_knife.rsi
sprite: _White/Objects/Weapons/Melee/Daggers/betrayal_dagger.rsi
state: icon
- type: Item
size: Small
Expand All @@ -31,3 +31,36 @@
- type: BackStab
- type: Blink
blinkRate: 0.33

- type: entity
name: blood dagger
description: A dagger of pain and blood. Something is dripping from it...
parent: BaseKnife
id: BloodDagger
components:
- type: Sprite
sprite: _White/Objects/Weapons/Melee/Daggers/blood_dagger.rsi
state: icon
- type: MeleeWeapon
wideAnimationRotation: 135
swingLeft: true
attackRate: 1.3
damage:
types:
Slash: 10.5
soundHit:
path: /Audio/Weapons/bladeslice.ogg
- type: Item
size: Normal
- type: Clothing
sprite: _White/Objects/Weapons/Melee/Daggers/blood_dagger.rsi
slots:
- back
- type: DisarmMalus
- type: Crit
critChance: 0.5
critMultiplier: 2
- type: BloodAbsorb
bloodLust: true
- type: MeleeBlock
delay: 12.1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d61d9cd

Please sign in to comment.