-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tweak] Melee / Ближнее Оружие (#62)
* tweak: _White melee * fix
- Loading branch information
Showing
10 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ared/_White/BackStab/BackStabComponent.cs → ...White/Melee/BackStab/BackStabComponent.cs
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
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,13 @@ | ||
namespace Content.Server._White.Melee.Crit; | ||
|
||
[RegisterComponent] | ||
public sealed partial class CritComponent : Component | ||
{ | ||
[DataField] | ||
public float CritChance = 0.2f; | ||
|
||
[DataField] | ||
public float CritMultiplier = 2f; | ||
|
||
public float? RealChance; | ||
} |
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,50 @@ | ||
using Content.Server.Popups; | ||
using Content.Shared._White.Blocking; | ||
using Content.Shared.Damage; | ||
using Content.Shared.Damage.Prototypes; | ||
using Content.Shared.Popups; | ||
using Content.Shared.Weapons.Melee.Events; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server._White.Melee.Crit; | ||
|
||
public sealed class CritSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly PopupSystem _popup = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<CritComponent, MeleeHitEvent>(HandleHit, before: new [] {typeof(MeleeBlockSystem)}); | ||
} | ||
|
||
private void HandleHit(EntityUid uid, CritComponent component, MeleeHitEvent args) | ||
{ | ||
if (args.HitEntities.Count == 0 || !IsCriticalHit(component)) | ||
return; | ||
|
||
var damage = args.BaseDamage.GetTotal() * component.CritMultiplier; | ||
|
||
args.BonusDamage = new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>("Slash"), | ||
damage - args.BaseDamage.GetTotal()); | ||
|
||
var message = Loc.GetString("melee-crit-damage", ("damage", damage)); | ||
_popup.PopupEntity(message, args.User, args.User, PopupType.MediumCaution); | ||
} | ||
|
||
private bool IsCriticalHit(CritComponent component) | ||
{ | ||
component.RealChance ??= component.CritChance; | ||
|
||
var isCritical = _random.NextFloat() <= component.RealChance; | ||
|
||
if (isCritical) | ||
component.RealChance = component.CritChance; | ||
else | ||
component.RealChance += component.CritChance; | ||
|
||
return isCritical; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
melee-backstab-damage = 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
melee-crit-damage = Critical hit: {$damage}! |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
melee-backstab-damage = Удар в спину: {$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 |
---|---|---|
@@ -0,0 +1 @@ | ||
melee-crit-damage = Критическое попадание: {$damage}! |