Skip to content

Commit

Permalink
Small strange jackboots buff (space-wizards#30586)
Browse files Browse the repository at this point in the history
* Small strange jackboots buff

* Update ClothingSlowOnDamageModifierComponent.cs
  • Loading branch information
EmoGarbage404 authored Aug 22, 2024
1 parent 7e57b0d commit 5c21b4e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Damage.Components;

/// <summary>
/// This is used for a clothing item that modifies the slowdown from taking damage.
/// Used for entities with <see cref="SlowOnDamageComponent"/>
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(SlowOnDamageSystem))]
public sealed partial class ClothingSlowOnDamageModifierComponent : Component
{
/// <summary>
/// A coefficient modifier for the slowdown
/// </summary>
[DataField]
public float Modifier = 1;
}
45 changes: 44 additions & 1 deletion Content.Shared/Damage/Systems/SlowOnDamageSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Content.Shared.Clothing;
using Content.Shared.Damage.Components;
using Content.Shared.Examine;
using Content.Shared.FixedPoint;
using Content.Shared.Inventory;
using Content.Shared.Movement.Systems;

namespace Content.Shared.Damage
Expand All @@ -14,6 +17,11 @@ public override void Initialize()

SubscribeLocalEvent<SlowOnDamageComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<SlowOnDamageComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);

SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, InventoryRelayedEvent<ModifySlowOnDamageSpeedEvent>>(OnModifySpeed);
SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, ClothingGotEquippedEvent>(OnGotEquipped);
SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, ClothingGotUnequippedEvent>(OnGotUnequipped);
}

private void OnRefreshMovespeed(EntityUid uid, SlowOnDamageComponent component, RefreshMovementSpeedModifiersEvent args)
Expand All @@ -36,7 +44,10 @@ private void OnRefreshMovespeed(EntityUid uid, SlowOnDamageComponent component,
if (closest != FixedPoint2.Zero)
{
var speed = component.SpeedModifierThresholds[closest];
args.ModifySpeed(speed, speed);

var ev = new ModifySlowOnDamageSpeedEvent(speed);
RaiseLocalEvent(uid, ref ev);
args.ModifySpeed(ev.Speed, ev.Speed);
}
}

Expand All @@ -47,5 +58,37 @@ private void OnDamageChanged(EntityUid uid, SlowOnDamageComponent component, Dam

_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(uid);
}

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

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

private void OnGotEquipped(Entity<ClothingSlowOnDamageModifierComponent> ent, ref ClothingGotEquippedEvent args)
{
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(args.Wearer);
}

private void OnGotUnequipped(Entity<ClothingSlowOnDamageModifierComponent> ent, ref ClothingGotUnequippedEvent args)
{
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(args.Wearer);
}
}

[ByRefEvent]
public record struct ModifySlowOnDamageSpeedEvent(float Speed) : IInventoryRelayEvent
{
public SlotFlags TargetSlots => SlotFlags.WITHOUT_POCKET;
}
}
1 change: 1 addition & 0 deletions Content.Shared/Inventory/InventorySystem.Relay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void InitializeRelay()
// by-ref events
SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RefRelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, IsWeightlessEvent>(RefRelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, ModifySlowOnDamageSpeedEvent>(RefRelayInventoryEvent);

// Eye/vision events
SubscribeLocalEvent<InventoryComponent, CanSeeAttemptEvent>(RelayInventoryEvent);
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/damage/stamina.ftl
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
melee-stamina = Not enough stamina
slow-on-damage-modifier-examine = Slowness from injuries is reduced by [color=yellow]{$mod}%[/color]
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Clothing/Shoes/boots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
sprite: Clothing/Shoes/Boots/jackboots.rsi
- type: Clothing
sprite: Clothing/Shoes/Boots/jackboots.rsi
- type: ClothingSlowOnDamageModifier
modifier: 0.5

- type: entity
parent: ClothingShoesBaseButcherable
Expand Down
1 change: 0 additions & 1 deletion Resources/Prototypes/Loadouts/loadout_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,6 @@
id: SecurityShoes
name: loadout-group-security-shoes
loadouts:
- CombatBoots
- JackBoots
- SecurityWinterBoots

Expand Down

0 comments on commit 5c21b4e

Please sign in to comment.