Skip to content

Commit

Permalink
Fixed bola effect stacking (#34723)
Browse files Browse the repository at this point in the history
  • Loading branch information
impubbi authored Feb 4, 2025
1 parent d531a9d commit a71a79d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Content.Shared/Ensnaring/Components/EnsnareableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public sealed partial class EnsnareableComponent : Component
/// <summary>
/// How much should this slow down the entities walk?
/// </summary>
[DataField]
[DataField, AutoNetworkedField]
public float WalkSpeed = 1.0f;

/// <summary>
/// How much should this slow down the entities sprint?
/// </summary>
[DataField]
[DataField, AutoNetworkedField]
public float SprintSpeed = 1.0f;

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Ensnaring/Components/EnsnaringComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public sealed partial class EnsnaringComponent : Component
[DataField]
public float StaminaDamage = 55f;

/// <summary>
/// How many times can the ensnare be applied to the same target?
/// </summary>
[DataField]
public float MaxEnsnares = 1;

/// <summary>
/// Should this ensnare someone when thrown?
/// </summary>
Expand Down
21 changes: 8 additions & 13 deletions Content.Shared/Ensnaring/SharedEnsnareableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,23 +256,18 @@ public bool TryEnsnare(EntityUid target, EntityUid ensnare, EnsnaringComponent c
if (!TryComp<EnsnareableComponent>(target, out var ensnareable))
return false;

// Need to insert before free legs check.
Container.Insert(ensnare, ensnareable.Container);

var legs = _body.GetBodyChildrenOfType(target, BodyPartType.Leg).Count();
var ensnaredLegs = (2 * ensnareable.Container.ContainedEntities.Count);
var freeLegs = legs - ensnaredLegs;
var numEnsnares = ensnareable.Container.ContainedEntities.Count;

if (freeLegs > 0)
//Don't do anything if the maximum number of ensnares is applied.
if (numEnsnares >= component.MaxEnsnares)
return false;

// Apply stamina damage to target if they weren't ensnared before.
if (ensnareable.IsEnsnared != true)
Container.Insert(ensnare, ensnareable.Container);

// Apply stamina damage to target
if (TryComp<StaminaComponent>(target, out var stamina))
{
if (TryComp<StaminaComponent>(target, out var stamina))
{
_stamina.TakeStaminaDamage(target, component.StaminaDamage, with: ensnare, component: stamina);
}
_stamina.TakeStaminaDamage(target, component.StaminaDamage, with: ensnare, component: stamina);
}

component.Ensnared = target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@
staminaDamage: 0 # anything but this is gamebreaking
canThrowTrigger: true
canMoveBreakout: true
maxEnsnares: 1
- type: LandAtCursor

0 comments on commit a71a79d

Please sign in to comment.