From 7632c7c99d128224086c1a8b075840af27329b13 Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Fri, 12 Apr 2024 23:08:17 +0900 Subject: [PATCH] - add: Update blood dagger. (#281) --- .../Body/Systems/BloodstreamSystem.cs | 11 ++ .../Other/CritSystem/BloodLustComponent.cs | 14 +++ .../_White/Other/CritSystem/CritSystem.cs | 106 +++++++++++++----- .../Objects/Weapons/Melee/daggers.yml | 2 +- .../Prototypes/_White/Catalog/uplink.yml | 2 +- 5 files changed, 107 insertions(+), 28 deletions(-) create mode 100644 Content.Server/_White/Other/CritSystem/BloodLustComponent.cs diff --git a/Content.Server/Body/Systems/BloodstreamSystem.cs b/Content.Server/Body/Systems/BloodstreamSystem.cs index 1f04431eaf..5523f66dfd 100644 --- a/Content.Server/Body/Systems/BloodstreamSystem.cs +++ b/Content.Server/Body/Systems/BloodstreamSystem.cs @@ -6,6 +6,7 @@ using Content.Server.Forensics; using Content.Server.HealthExaminable; using Content.Server.Popups; using Content.Server._White.EndOfRoundStats.BloodLost; +using Content.Server._White.Other.CritSystem; using Content.Shared.Alert; using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.EntitySystems; @@ -16,6 +17,7 @@ using Content.Shared.Drunk; using Content.Shared.FixedPoint; using Content.Shared.IdentityManagement; using Content.Shared.Mobs.Systems; +using Content.Shared.Movement.Systems; using Content.Shared.Popups; using Content.Shared.Rejuvenate; using Content.Shared.Speech.EntitySystems; @@ -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 _speed = default!; // WD public override void Initialize() { @@ -385,6 +388,14 @@ public sealed class BloodstreamSystem : EntitySystem component.BleedAmount += amount; component.BleedAmount = Math.Clamp(component.BleedAmount, 0, component.MaxBleedAmount); + if (HasComp(uid)) // WD + { + if (component.BleedAmount == 0f) + RemComp(uid); + + _speed.RefreshMovementSpeedModifiers(uid); + } + if (component.BleedAmount == 0) _alertsSystem.ClearAlert(uid, AlertType.Bleed); else diff --git a/Content.Server/_White/Other/CritSystem/BloodLustComponent.cs b/Content.Server/_White/Other/CritSystem/BloodLustComponent.cs new file mode 100644 index 0000000000..7b1232fe51 --- /dev/null +++ b/Content.Server/_White/Other/CritSystem/BloodLustComponent.cs @@ -0,0 +1,14 @@ +namespace Content.Server._White.Other.CritSystem; + +[RegisterComponent] +public sealed partial class BloodLustComponent : Component +{ + [ViewVariables(VVAccess.ReadWrite)] + public float SprintModifier = 1.4f; + + [ViewVariables(VVAccess.ReadWrite)] + public float WalkModifier = 1.3f; + + [ViewVariables(VVAccess.ReadWrite)] + public float AttackRateModifier = 1.5f; +} diff --git a/Content.Server/_White/Other/CritSystem/CritSystem.cs b/Content.Server/_White/Other/CritSystem/CritSystem.cs index 5bfca01d6a..1c6825f300 100644 --- a/Content.Server/_White/Other/CritSystem/CritSystem.cs +++ b/Content.Server/_White/Other/CritSystem/CritSystem.cs @@ -1,10 +1,10 @@ +using Content.Server.Body.Components; using Content.Server.Body.Systems; using Content.Server.Popups; using Content.Shared.Damage; using Content.Shared.Damage.Prototypes; using Content.Shared.Examine; -using Content.Shared.Mobs.Components; -using Content.Shared.Mobs.Systems; +using Content.Shared.Movement.Systems; using Content.Shared.Popups; using Content.Shared.Weapons.Melee.Events; using Robust.Shared.Prototypes; @@ -19,7 +19,6 @@ public sealed class CritSystem : EntitySystem [Dependency] private readonly PopupSystem _popup = default!; [Dependency] private readonly BloodstreamSystem _bloodstream = default!; [Dependency] private readonly DamageableSystem _damageableSystem = default!; - [Dependency] private readonly MobStateSystem _mobState = default!; public override void Initialize() { @@ -27,6 +26,39 @@ public sealed class CritSystem : EntitySystem SubscribeLocalEvent(OnExamine); SubscribeLocalEvent(HandleHit); + SubscribeLocalEvent(GetMeleeAttackRate); + SubscribeLocalEvent(OnRefreshMoveSpeed); + } + + private void OnRefreshMoveSpeed(Entity ent, ref RefreshMovementSpeedModifiersEvent args) + { + var modifier = GetBloodLustModifier(ent); + args.ModifySpeed(GetBloodLustMultiplier(ent.Comp.WalkModifier, modifier), + GetBloodLustMultiplier(ent.Comp.SprintModifier, modifier)); + } + + private void GetMeleeAttackRate(Entity ent, ref GetMeleeAttackRateEvent args) + { + if (!ent.Comp.IsBloodDagger) + return; + + if (!TryComp(args.User, out BloodLustComponent? bloodLust)) + return; + + args.Multipliers *= GetBloodLustMultiplier(bloodLust.AttackRateModifier, GetBloodLustModifier(args.User)); + } + + 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); } private void OnExamine(EntityUid uid, CritComponent component, ExaminedEvent args) @@ -34,7 +66,8 @@ public sealed class CritSystem : EntitySystem if (component.IsBloodDagger) { args.PushMarkup( - "[color=red]Критическая жажда: Кинжал Жажды обладает смертоносной точностью. Его владелец имеет 40% шанс нанести критический урон, поражая врага в его самые уязвимые места.\n" + + "[color=red]Критическая жажда: Кинжал Жажды обладает смертоносной точностью. Его владелец имеет 50% шанс нанести критический урон, поражая врага в его самые уязвимые места.\n" + + "При ударе по себе кинжал наделит пользователя временным усилением скорости атаки и передвижения ценой обильного кровотечения.\n" + "Кровавый абсорб: При каждом успешном критическом ударе, кинжал извлекает кровь из цели, восстанавливая здоровье владельцу пропорционально количеству высосанной крови.[/color]" ); } @@ -42,33 +75,54 @@ public sealed class CritSystem : EntitySystem private void HandleHit(EntityUid uid, CritComponent component, MeleeHitEvent args) { - foreach (var target in args.HitEntities) + if (args.HitEntities.Count == 0) + return; + + if (args.HitEntities[0] == args.User) { - if (!IsCriticalHit(component)) + if (!component.IsBloodDagger) return; - if (!TryComp(target, out var mobState) || _mobState.IsDead(target, mobState)) - continue; + if (!TryComp(args.User, out BloodstreamComponent? bloodstream)) + return; - var damage = args.BaseDamage.GetTotal() * component.CritMultiplier; - - if (component.IsBloodDagger) - { - var ohio = _random.Next(1, 20); - var damageGroup = _prototypeManager.Index("Brute"); - - _bloodstream.TryModifyBloodLevel(target, -ohio); - _bloodstream.TryModifyBloodLevel(args.User, ohio); - _damageableSystem.TryChangeDamage(args.User, new DamageSpecifier(damageGroup, -ohio)); - - damage = args.BaseDamage.GetTotal() * component.CritMultiplier + ohio; - } - - args.BonusDamage = new DamageSpecifier(_prototypeManager.Index("Slash"), - damage - args.BaseDamage.GetTotal()); - - _popup.PopupEntity($"Crit! {damage}", args.User, args.User, PopupType.MediumCaution); + EnsureComp(args.User); + _bloodstream.TryModifyBleedAmount(args.User, bloodstream.MaxBleedAmount, bloodstream); + return; } + + if (!IsCriticalHit(component)) + return; + + var ohio = 0; + + if (component.IsBloodDagger) + { + var bruteGroup = _prototypeManager.Index("Brute"); + var burnGroup = _prototypeManager.Index("Burn"); + + ohio = _random.Next(1, 21); + + foreach (var target in args.HitEntities) + { + if (!TryComp(target, out BloodstreamComponent? bloodstream)) + continue; + + if (!_bloodstream.TryModifyBloodLevel(target, -ohio, bloodstream, false)) + continue; + + _bloodstream.TryModifyBloodLevel(args.User, ohio); + _damageableSystem.TryChangeDamage(args.User, new DamageSpecifier(bruteGroup, -ohio)); + _damageableSystem.TryChangeDamage(args.User, new DamageSpecifier(burnGroup, -ohio)); + } + } + + var damage = args.BaseDamage.GetTotal() * component.CritMultiplier + ohio; + + args.BonusDamage = new DamageSpecifier(_prototypeManager.Index("Slash"), + damage - args.BaseDamage.GetTotal()); + + _popup.PopupEntity($"Crit! {damage}", args.User, args.User, PopupType.MediumCaution); } private bool IsCriticalHit(CritComponent component) diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/daggers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/daggers.yml index 1c5525e876..366b79cd15 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/daggers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/daggers.yml @@ -24,7 +24,7 @@ - back - type: DisarmMalus - type: Crit - critChance: 40 + critChance: 50 critMultiplier: 2 isBloodDagger: true diff --git a/Resources/Prototypes/_White/Catalog/uplink.yml b/Resources/Prototypes/_White/Catalog/uplink.yml index 4159d89afe..e6ed0d6181 100644 --- a/Resources/Prototypes/_White/Catalog/uplink.yml +++ b/Resources/Prototypes/_White/Catalog/uplink.yml @@ -28,7 +28,7 @@ - type: listing id: UplinkBloodDagger name: Кинжал жажды - description: "Критическая жажда: Кинжал Жажды обладает смертоносной точностью. Его владелец имеет 40% шанс нанести критический урон, поражая врага в его самые уязвимые места. Кровавый абсорб: При каждом успешном критическом ударе, кинжал извлекает кровь из цели, восстанавливая здоровье владельцу пропорционально количеству высосанной крови." + description: "Критическая жажда: Кинжал Жажды обладает смертоносной точностью. Его владелец имеет 50% шанс нанести критический урон, поражая врага в его самые уязвимые места. При ударе по себе кинжал наделит пользователя временным усилением скорости атаки и передвижения ценой обильного кровотечения. Кровавый абсорб: При каждом успешном критическом ударе, кинжал извлекает кровь из цели, восстанавливая здоровье владельцу пропорционально количеству высосанной крови." icon: { sprite: /Textures/Objects/Weapons/Melee/blood_dagger.rsi, state: icon } productEntity: BloodSuckerDagger cost: