Skip to content

Commit

Permalink
Targeting & Healing Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Roudenn committed Oct 30, 2024
1 parent e92f013 commit 01dd348
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 37 deletions.
5 changes: 3 additions & 2 deletions Content.Client/Backmen/Targeting/TargetingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Content.Shared.Backmen.Targeting;
using Content.Shared.Input;
using Content.Shared.Targeting;
using Content.Shared.Targeting.Events;
using Robust.Client.Player;
using Robust.Shared.Input.Binding;
using Robust.Shared.Player;

namespace Content.Client.Targeting;
namespace Content.Client.Backmen.Targeting;
public sealed class TargetingSystem : SharedTargetingSystem
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
Expand Down Expand Up @@ -91,4 +92,4 @@ private void HandleTargetChange(ICommonSession? session, TargetBodyPart target)

TargetChange?.Invoke(target);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Content.Client.Backmen.UserInterface.Systems.PartStatus.Widgets;
using Content.Client.Gameplay;
using Content.Shared.Targeting;
using Content.Client.Targeting;
using Content.Client.Backmen.Targeting;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controllers;
using Robust.Shared.Utility;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Content.Client.Backmen.UserInterface.Systems.Targeting.Widgets;
using Content.Client.Gameplay;
using Content.Shared.Targeting;
using Content.Client.Targeting;
using Content.Client.Backmen.Targeting;
using Content.Shared.Targeting.Events;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.Player;
Expand Down
8 changes: 3 additions & 5 deletions Content.Server/Backmen/Targeting/TargetingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using Content.Shared.Backmen.Targeting;
using Content.Shared.Body.Systems;
using Content.Shared.Mobs;
using Content.Shared.Targeting;
using Content.Shared.Targeting.Events;
using Robust.Server.Audio;
using Robust.Shared.Audio;

namespace Content.Server.Targeting;
namespace Content.Server.Backmen.Targeting;
public sealed class TargetingSystem : SharedTargetingSystem
{
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly SharedBodySystem _bodySystem = default!;

public override void Initialize()
Expand Down Expand Up @@ -54,4 +52,4 @@ private void OnMobStateChange(EntityUid uid, TargetingComponent component, MobSt
RaiseNetworkEvent(new TargetIntegrityChangeEvent(GetNetEntity(uid)), uid);
}
}
}
}
37 changes: 18 additions & 19 deletions Content.Server/Medical/HealingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,6 @@ entity.Comp.DamageContainerID is not null &&
if (healed == null && healing.BloodlossModifier != 0)
return;

/* This is rather shitcodey. Problem is that right now damage is coupled to integrity.
If the body is fully healed, all of the checks on TryChangeDamage stop us from actually healing.
So in this case we add a special check to heal anyway if TryChangeDamage returns null.
*/
if (healed != null && healed.GetTotal() == 0)
{
if (TryComp<TargetingComponent>(args.User, out var user)
&& TryComp<TargetingComponent>(args.Target, out var target)
&& healing.Damage.GetTotal() < 0)
{
// If they are valid, we check for body part presence,
// and integrity, then apply a direct integrity change.
var (type, symmetry) = _bodySystem.ConvertTargetBodyPart(user.Target);
if (_bodySystem.GetBodyChildrenOfType(args.Target.Value, type, symmetry: symmetry).FirstOrDefault() is { } bodyPart
&& bodyPart.Component.Integrity < BodyPartComponent.MaxIntegrity)
_bodySystem.TryChangeIntegrity(bodyPart, healing.Damage.GetTotal().Float(), false, target.Target, out var _);
}
}

var total = healed?.GetTotal() ?? FixedPoint2.Zero;

// Re-verify that we can heal the damage.
Expand All @@ -126,6 +107,24 @@ entity.Comp.DamageContainerID is not null &&
QueueDel(args.Used.Value);
}

// start-backmen: surgery
// This is still pretty shitcodey, but a lot better than previous iteration.
// We are just trying to heal the most damaged body part.
if (healed != null)
{
var parts = _bodySystem.GetBodyChildren(args.Target).ToList();
// Get the severest body part, selected by taking the one with lowest Integrity.
var severestPart = parts.MinBy(x => x.Component.Integrity);
// Convert this thing into a target
var targetBodyPart = _bodySystem.GetTargetBodyPart(severestPart);

if (targetBodyPart != null)
{
_bodySystem.TryChangeIntegrity(severestPart, healing.Damage.GetTotal().Float(), false, targetBodyPart.Value, out _);
}
}
// end-backmen: surgery

if (entity.Owner != args.User)
{
_adminLogger.Add(LogType.Healed,
Expand Down
11 changes: 2 additions & 9 deletions Content.Shared/Backmen/Targeting/SharedTargetingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
namespace Content.Shared.Targeting;
public abstract class SharedTargetingSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
}
namespace Content.Shared.Backmen.Targeting;


}
public abstract class SharedTargetingSystem : EntitySystem;

0 comments on commit 01dd348

Please sign in to comment.