* - tweak: Shotgun firerate standartization.
* - tweak: Less storage clothing size.
* - tweak: No spears for nukies.
* - tweak: Slightly buff ling armor.
* - tweak: Nerf tranquilizers.
* Revert "Tranquilizer balance (#23979)"
This reverts commit 9e1342f3e4.
* - remove: Disable whisper aspect.
* - fix: Borer fix on transform person.
* - fix: Items no longer get dropped on transform.
* - tweak: Reduce ling tentacle stun time.
* - tweak: Update chitinous armor desc.
* - fix: Transform sting range check.
* - tweak: More explosion resistance.
* - tweak: Fuel tanks can't create vacuum.
* - fix: Fix transform while being carried.
* - fix: Monkey form.
* - fix: I have no brain but I must live.
* - tweak: Update ling desc.
* - tweak: Fleshmend heals airloss.
* - fix: New wiki rules.
* - fix: Fix missing polymorph.
* - tweak: Structural damage now works better.
* - tweak: Less reflect prob.
* - fix: Popup fix.
93 lines
3.6 KiB
C#
93 lines
3.6 KiB
C#
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.Popups;
|
||
using Content.Shared.Weapons.Melee.Events;
|
||
using Robust.Shared.Prototypes;
|
||
using Robust.Shared.Random;
|
||
|
||
namespace Content.Server._White.Other.CritSystem;
|
||
|
||
public sealed class CritSystem : EntitySystem
|
||
{
|
||
[Dependency] private readonly IRobustRandom _random = default!;
|
||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||
[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()
|
||
{
|
||
base.Initialize();
|
||
|
||
SubscribeLocalEvent<CritComponent, ExaminedEvent>(OnExamine);
|
||
SubscribeLocalEvent<CritComponent, MeleeHitEvent>(HandleHit);
|
||
}
|
||
|
||
private void OnExamine(EntityUid uid, CritComponent component, ExaminedEvent args)
|
||
{
|
||
if (component.IsBloodDagger)
|
||
{
|
||
args.PushMarkup(
|
||
"[color=red]Критическая жажда: Кинжал Жажды обладает смертоносной точностью. Его владелец имеет 40% шанс нанести критический урон, поражая врага в его самые уязвимые места.\n" +
|
||
"Кровавый абсорб: При каждом успешном критическом ударе, кинжал извлекает кровь из цели, восстанавливая здоровье владельцу пропорционально количеству высосанной крови.[/color]"
|
||
);
|
||
}
|
||
}
|
||
|
||
private void HandleHit(EntityUid uid, CritComponent component, MeleeHitEvent args)
|
||
{
|
||
foreach (var target in args.HitEntities)
|
||
{
|
||
if (!IsCriticalHit(component))
|
||
return;
|
||
|
||
if (!TryComp<MobStateComponent>(target, out var mobState) || _mobState.IsDead(target, mobState))
|
||
continue;
|
||
|
||
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);
|
||
}
|
||
}
|
||
|
||
private bool IsCriticalHit(CritComponent component)
|
||
{
|
||
var roll = _random.Next(1, 101);
|
||
|
||
var critChance = component.CritChance;
|
||
|
||
component.WorkingChance ??= component.CritChance;
|
||
|
||
var isCritical = roll <= component.WorkingChance;
|
||
|
||
if (isCritical)
|
||
component.WorkingChance = critChance;
|
||
else
|
||
component.WorkingChance++;
|
||
|
||
return isCritical;
|
||
}
|
||
}
|
||
|