Fixed bola effect stacking (#34723)

This commit is contained in:
pubbi
2025-02-04 10:11:46 -06:00
committed by GitHub
parent d531a9db9c
commit a71a79d785
4 changed files with 17 additions and 15 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -256,24 +256,19 @@ public abstract class SharedEnsnareableSystem : EntitySystem
if (!TryComp<EnsnareableComponent>(target, out var ensnareable))
return false;
// Need to insert before free legs check.
Container.Insert(ensnare, ensnareable.Container);
var numEnsnares = ensnareable.Container.ContainedEntities.Count;
var legs = _body.GetBodyChildrenOfType(target, BodyPartType.Leg).Count();
var ensnaredLegs = (2 * ensnareable.Container.ContainedEntities.Count);
var freeLegs = legs - ensnaredLegs;
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))
{
_stamina.TakeStaminaDamage(target, component.StaminaDamage, with: ensnare, component: stamina);
}
}
component.Ensnared = target;
ensnareable.IsEnsnared = true;

View File

@@ -47,4 +47,5 @@
staminaDamage: 0 # anything but this is gamebreaking
canThrowTrigger: true
canMoveBreakout: true
maxEnsnares: 1
- type: LandAtCursor