-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* someone had to be brave enough to kill this * it's finally real * god himself couldn't fix this shit *
- Loading branch information
Showing
12 changed files
with
185 additions
and
7 deletions.
There are no files selected for viewing
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
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,99 @@ | ||
using Content.Shared.Armor; | ||
using Content.Shared.Damage.Components; | ||
using Content.Shared.Inventory; | ||
using Robust.Shared.Audio; | ||
|
||
namespace Content.Shared.Damage.Systems; | ||
|
||
public sealed partial class StaminaSystem | ||
{ | ||
[Dependency] private readonly InventorySystem _inventory = default!; | ||
|
||
/// <summary> | ||
/// Gets the combined stamina protection coefficients from all armor worn by an entity | ||
/// </summary> | ||
private float GetMeleeCoefficient(EntityUid target) | ||
{ | ||
var coefficient = 1.0f; | ||
|
||
if (!_inventory.TryGetSlots(target, out var slots)) | ||
return coefficient; | ||
|
||
foreach (var slot in slots) | ||
{ | ||
if (!_inventory.TryGetSlotEntity(target, slot.Name, out var equipped)) | ||
continue; | ||
|
||
if (TryComp<ArmorComponent>(equipped, out var armor)) | ||
{ | ||
coefficient *= armor.StaminaMeleeDamageCoefficient; | ||
} | ||
} | ||
|
||
return coefficient; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the combined stamina protection coefficients from all armor worn by an entity | ||
/// </summary> | ||
private float GetProjectileCoefficient(EntityUid target) | ||
{ | ||
var coefficient = 1.0f; | ||
|
||
if (!_inventory.TryGetSlots(target, out var slots)) | ||
return coefficient; | ||
|
||
foreach (var slot in slots) | ||
{ | ||
if (!_inventory.TryGetSlotEntity(target, slot.Name, out var equipped)) | ||
continue; | ||
|
||
if (TryComp<ArmorComponent>(equipped, out var armor)) | ||
{ | ||
coefficient *= armor.StaminaDamageCoefficient; | ||
} | ||
} | ||
|
||
return coefficient; | ||
} | ||
|
||
/// <summary> | ||
/// Applies stamina damage from melee attacks with armor resistance calculations | ||
/// </summary> | ||
public void TakeMeleeStaminaDamage(EntityUid target, | ||
float damage, | ||
StaminaComponent? stamina = null, | ||
EntityUid? source = null, | ||
EntityUid? with = null, | ||
bool visual = true, | ||
SoundSpecifier? sound = null) | ||
{ | ||
if (!Resolve(target, ref stamina)) | ||
return; | ||
|
||
var coefficient = GetMeleeCoefficient(target); | ||
var finalDamage = damage * coefficient; | ||
|
||
TakeStaminaDamage(target, finalDamage, stamina, source, with, visual, sound); | ||
} | ||
|
||
/// <summary> | ||
/// Applies stamina damage from projectiles with armor resistance calculations | ||
/// </summary> | ||
public void TakeProjectileStaminaDamage(EntityUid target, | ||
float damage, | ||
StaminaComponent? stamina = null, | ||
EntityUid? source = null, | ||
EntityUid? with = null, | ||
bool visual = true, | ||
SoundSpecifier? sound = null) | ||
{ | ||
if (!Resolve(target, ref stamina)) | ||
return; | ||
|
||
var coefficient = GetProjectileCoefficient(target); | ||
var finalDamage = damage * coefficient; | ||
|
||
TakeStaminaDamage(target, finalDamage, stamina, source, with, visual, sound); | ||
} | ||
} |
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,2 @@ | ||
armor-stamina-projectile-coefficient-value = - [color=yellow]Stamina projectile[/color] damage reduced by [color=lightblue]{$value}%[/color]. | ||
armor-stamina-melee-coefficient-value = - [color=yellow]Stamina melee[/color] damage reduced by [color=lightblue]{$value}%[/color]. |
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
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
Oops, something went wrong.