Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Traits: Steadfast And Feeble #1431

Merged
merged 7 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Content.Server/Traits/TraitSystem.Functions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.FixedPoint;
using Content.Shared.Traits;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
Expand All @@ -11,6 +12,7 @@
using Content.Shared.Mood;
using Content.Shared.Traits.Assorted.Components;
using Content.Shared.Damage;
using Content.Shared.Damage.Components;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Mobs.Components;
Expand Down Expand Up @@ -547,3 +549,39 @@ public override void OnPlayerSpawn(EntityUid uid,
staminaComponent.Cooldown += CooldownModifier;
}
}

/// <summary>
/// Used for traits that modify SlowOnDamageComponent.
/// </summary>
[UsedImplicitly]
public sealed partial class TraitModifySlowOnDamage : TraitFunction
{
// <summary>
// A flat modifier to add to all damage threshold keys.
// </summary>
[DataField, AlwaysPushInheritance]
public float DamageThresholdsModifier;

// <summary>
// A multiplier applied to all speed modifier values.
// The higher the multiplier, the stronger the slowdown.
// </summary>
[DataField, AlwaysPushInheritance]
public float SpeedModifierMultiplier = 1f;

public override void OnPlayerSpawn(EntityUid uid,
IComponentFactory factory,
IEntityManager entityManager,
ISerializationManager serializationManager)
{
if (!entityManager.TryGetComponent<SlowOnDamageComponent>(uid, out var slowOnDamage))
return;

var newSpeedModifierThresholds = new Dictionary<FixedPoint2, float>();

foreach (var (damageThreshold, speedModifier) in slowOnDamage.SpeedModifierThresholds)
newSpeedModifierThresholds[damageThreshold + DamageThresholdsModifier] = 1 - (1 - speedModifier) * SpeedModifierMultiplier;

slowOnDamage.SpeedModifierThresholds = newSpeedModifierThresholds;
}
}
8 changes: 2 additions & 6 deletions Content.Shared/Damage/Systems/SlowOnDamageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,13 @@ private void OnDamageChanged(EntityUid uid, SlowOnDamageComponent component, Dam

private void OnModifySpeed(Entity<ClothingSlowOnDamageModifierComponent> ent, ref InventoryRelayedEvent<ModifySlowOnDamageSpeedEvent> args)
{
var dif = 1 - args.Args.Speed;
if (dif <= 0)
return;

// reduces the slowness modifier by the given coefficient
args.Args.Speed += dif * ent.Comp.Modifier;
args.Args.Speed = 1 - (1 - args.Args.Speed) * ent.Comp.Modifier;
}

private void OnExamined(Entity<ClothingSlowOnDamageModifierComponent> ent, ref ExaminedEvent args)
{
var msg = Loc.GetString("slow-on-damage-modifier-examine", ("mod", (1 - ent.Comp.Modifier) * 100));
var msg = Loc.GetString("slow-on-damage-modifier-examine", ("mod", Math.Round((1 - ent.Comp.Modifier) * 100)));
args.PushMarkup(msg);
}

Expand Down
2 changes: 1 addition & 1 deletion Resources/Locale/en-US/damage/stamina.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
melee-stamina = Not enough stamina

slow-on-damage-modifier-examine = Slowness from injuries is reduced by [color=yellow]{$mod}%[/color]
slow-on-damage-modifier-examine = Slowness from injuries is reduced by [color=yellow]{$mod}%[/color].

throw-no-stamina = You don't have enough stamina to throw the {$item}!
14 changes: 14 additions & 0 deletions Resources/Locale/en-US/traits/traits.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@ trait-description-LowPainTolerance =
Your tolerance for pain is far below average, and its effects are more inhibiting.
Your melee/throwing damage is penalized by up to an additional 15% when taking stamina damage.

trait-name-Steadfast = Steadfast
trait-description-Steadfast =
When others would buckle from the weight of your injuries, you still march forward unrelentingly.
For most species [color=gray](excluding IPC/Shadowkin)[/color], this trait modifies:
- [color=yellow]25%[/color] movement slow at [color=red]60[/color] damage ➔ [color=yellow]17%[/color] movement slow at [color=red]70[/color] damage
- [color=yellow]45%[/color] movement slow at [color=red]80[/color] damage ➔ [color=yellow]30%[/color] movement slow at [color=red]90[/color] damage

trait-name-Feeble = Feeble
trait-description-Feeble =
Your body responds poorly to injuries, making damage affect your movement more severely.
For most species [color=gray](excluding IPC/Shadowkin)[/color], this trait modifies:
- [color=yellow]25%[/color] movement slow at [color=red]60[/color] damage ➔ [color=yellow]30%[/color] movement slow at [color=red]45[/color] damage
- [color=yellow]45%[/color] movement slow at [color=red]80[/color] damage ➔ [color=yellow]54%[/color] movement slow at [color=red]65[/color] damage

trait-name-MartialArtist = Martial Artist
trait-description-MartialArtist =
You have received formal training in unarmed combat, whether with Fists, Feet, or Claws.
Expand Down
6 changes: 5 additions & 1 deletion Resources/Prototypes/Entities/Clothing/Shoes/boots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- type: Clothing
sprite: Clothing/Shoes/Boots/jackboots.rsi
- type: ClothingSlowOnDamageModifier
modifier: 0.5
modifier: 0.8

- type: entity
parent: ClothingShoesMilitaryBase
Expand Down Expand Up @@ -67,6 +67,8 @@
sprite: Clothing/Shoes/Boots/combatboots.rsi
- type: Clothing
sprite: Clothing/Shoes/Boots/combatboots.rsi
- type: ClothingSlowOnDamageModifier
modifier: 0.8

- type: entity
parent: ClothingShoesMilitaryBase
Expand All @@ -93,6 +95,8 @@
sprite: Clothing/Shoes/Boots/mercboots.rsi
- type: Clothing
sprite: Clothing/Shoes/Boots/mercboots.rsi
- type: ClothingSlowOnDamageModifier
modifier: 0.6

- type: entity
parent: ClothingShoesBaseButcherable
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Clothing/Shoes/specific.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
- type: Clothing
sprite: Clothing/Shoes/Specific/swat.rsi
- type: ClothingSlowOnDamageModifier
modifier: 0.5
modifier: 0.7

- type: entity
parent: ClothingShoesBaseButcherable
Expand Down
4 changes: 2 additions & 2 deletions Resources/Prototypes/Entities/Mobs/Player/ipc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
- !type:GibBehavior { }
- type: SlowOnDamage
speedModifierThresholds:
60: 0.7
60: 0.75
90: 0.5
120: 0.3
- type: SiliconDownOnDead
Expand Down Expand Up @@ -142,4 +142,4 @@
- type: HumanoidAppearance
species: IPC
- type: Inventory
templateId: ipc
templateId: ipc
4 changes: 2 additions & 2 deletions Resources/Prototypes/Entities/Mobs/Species/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
species: Human
- type: SlowOnDamage
speedModifierThresholds:
60: 0.8 # DV - Was 0.7
80: 0.6 # DV - Was 0.5
60: 0.75
80: 0.55
- type: Fixtures
fixtures: # TODO: This needs a second fixture just for mob collisions.
fix1:
Expand Down
46 changes: 46 additions & 0 deletions Resources/Prototypes/Traits/physical.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,52 @@
- type: PainTolerance
rangeModifier: 0.6

- type: trait
id: Steadfast
category: Physical
points: -4
requirements:
- !type:CharacterJobRequirement
inverted: true
jobs:
- Borg
- MedicalBorg
- !type:CharacterSpeciesRequirement
inverted: true
species:
- Felinid
- !type:CharacterTraitRequirement
inverted: true
traits:
- Feeble
functions:
- !type:TraitModifySlowOnDamage
damageThresholdsModifier: 10
speedModifierMultiplier: 0.68

- type: trait
id: Feeble
category: Physical
points: 3
requirements:
- !type:CharacterJobRequirement
inverted: true
jobs:
- Borg
- MedicalBorg
- !type:CharacterSpeciesRequirement
inverted: true
species:
- Felinid
- !type:CharacterTraitRequirement
inverted: true
traits:
- Steadfast
functions:
- !type:TraitModifySlowOnDamage
damageThresholdsModifier: -15
speedModifierMultiplier: 1.2

- type: trait
id: MartialArtist
category: Physical
Expand Down
Loading