- add: Update blood dagger. (#281)

This commit is contained in:
Aviu00
2024-04-12 23:08:17 +09:00
committed by GitHub
parent 6abfa020a2
commit 7632c7c99d
5 changed files with 107 additions and 28 deletions

View File

@@ -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<BloodLustComponent>(uid)) // WD
{
if (component.BleedAmount == 0f)
RemComp<BloodLustComponent>(uid);
_speed.RefreshMovementSpeedModifiers(uid);
}
if (component.BleedAmount == 0)
_alertsSystem.ClearAlert(uid, AlertType.Bleed);
else

View File

@@ -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;
}

View File

@@ -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<CritComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<CritComponent, MeleeHitEvent>(HandleHit);
SubscribeLocalEvent<CritComponent, GetMeleeAttackRateEvent>(GetMeleeAttackRate);
SubscribeLocalEvent<BloodLustComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMoveSpeed);
}
private void OnRefreshMoveSpeed(Entity<BloodLustComponent> ent, ref RefreshMovementSpeedModifiersEvent args)
{
var modifier = GetBloodLustModifier(ent);
args.ModifySpeed(GetBloodLustMultiplier(ent.Comp.WalkModifier, modifier),
GetBloodLustMultiplier(ent.Comp.SprintModifier, modifier));
}
private void GetMeleeAttackRate(Entity<CritComponent> 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<MobStateComponent>(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<DamageGroupPrototype>("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<DamageTypePrototype>("Slash"),
damage - args.BaseDamage.GetTotal());
_popup.PopupEntity($"Crit! {damage}", args.User, args.User, PopupType.MediumCaution);
EnsureComp<BloodLustComponent>(args.User);
_bloodstream.TryModifyBleedAmount(args.User, bloodstream.MaxBleedAmount, bloodstream);
return;
}
if (!IsCriticalHit(component))
return;
var ohio = 0;
if (component.IsBloodDagger)
{
var bruteGroup = _prototypeManager.Index<DamageGroupPrototype>("Brute");
var burnGroup = _prototypeManager.Index<DamageGroupPrototype>("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<DamageTypePrototype>("Slash"),
damage - args.BaseDamage.GetTotal());
_popup.PopupEntity($"Crit! {damage}", args.User, args.User, PopupType.MediumCaution);
}
private bool IsCriticalHit(CritComponent component)

View File

@@ -24,7 +24,7 @@
- back
- type: DisarmMalus
- type: Crit
critChance: 40
critChance: 50
critMultiplier: 2
isBloodDagger: true

View File

@@ -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: