Fix limb healing on evenhealing (#4315)
* Fix EvenHealing on bodyParts (#1469) <!-- Guidelines: https://docs.spacestation14.io/en/getting-started/pr-guideline --> <!-- NOTE: All code submitted to this repository is ALWAYS licensed under the AGPL-3.0-or-later license. The REUSE Specification headers or separate .license files indicate a secondary license (e.g., MPL or MIT) solely to facilitate integration for projects that do not use the AGPL license. This secondary license does not replace the fact that AGPL-3.0-or-later remains the primary and binding license. Uncomment and modify the following line if you wish to change the license from the default of AGPL.--> <!--- LICENSE: AGPL --> <!-- What did you change? --> Fixed EvenHealing not working on limb damage when there was no general damage. <!-- Discuss how this would affect game balance or explain why it was changed. Link any relevant discussions or issues. --> When you had a massively burned victim, healing them via aloxadone would heal their general damage, and each limb profited half of that general healing. However, as soon as the general damage was healed, Aloxadone wasn't outputting any healing anymore, since even healing is dependent on damage types on the general damage - And thus, with no healing, the limbs couldn't benefit anymore. This is wrong. I fixed it. <!-- Summary of code changes for easier review. --> Separated the healing of the general damage and limb damage, they are independent of each other. Healing General Damage won't heal limb damage and vice versa. Added a way to heal each limb specifically. I tested it thoroughly, and generally, it worked. Either with multiple different damage types, or just one. Multiple damage parts, or just one. Very much encourage to find a more elegant technical solution. <!-- Attach media if the PR makes ingame changes (clothing, items, features, etc). Small fixes/refactors are exempt. Media may be used in SS14 progress reports with credit. --> I can't do videos, but videos would be required. Please try it out yourself. <!-- Confirm the following by placing an X in the brackets [X]: --> - [X] I have read and am following the [Pull Request and Changelog Guidelines](https://docs.spacestation14.com/en/general-development/codebase-info/pull-request-guidelines.html). - [X] I have added media to this PR or it does not require an ingame showcase. - [X] I can confirm this PR contains no AI-generated content, and did not use any AI-generated content. <!-- You should understand that not following the above may get your PR closed at maintainer’s discretion --> <!-- List any breaking changes, including namespaces, public class/method/field changes, prototype renames; and provide instructions for fixing them. This will be posted in #codebase-changes. --> **Changelog** <!-- Add a Changelog entry to make players aware of new features or changes that could affect gameplay. Make sure to read the guidelines and take this Changelog template out of the comment block in order for it to show up. Changelog must have a 🆑 symbol, so the bot recognizes the changes and adds them to the game's changelog. --> 🆑 - fix: Fixed Chemicals with the EvenHealing attribute to not work on patient's limbs without General Damage. Aloxadone will now finally heal the burned Salvager's limbs. * Fix Port to Delta * Fixes * Made comments even more commenty? Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * Update Content.Shared/Damage/Systems/DamageableSystem.cs Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * Add Comments * Update Content.Shared/EntityEffects/Effects/EvenHealthChange.cs Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * Update Content.Shared/Damage/Systems/DamageableSystem.cs Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * Fix Comments * Update Content.Shared/EntityEffects/Effects/EvenHealthChange.cs Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * commenty commenta WHEN DO THE COMMENTS END --------- Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com>
This commit is contained in:
parent
7dbe09c822
commit
75caa105e6
|
|
@ -181,7 +181,7 @@ namespace Content.Shared.Damage
|
|||
public DamageSpecifier? TryChangeDamage(EntityUid? uid, DamageSpecifier damage, bool ignoreResistances = false,
|
||||
bool interruptsDoAfters = true, DamageableComponent? damageable = null, EntityUid? origin = null,
|
||||
// Shitmed Change
|
||||
bool? canSever = true, bool? canEvade = false, float? partMultiplier = 1.00f, TargetBodyPart? targetPart = null)
|
||||
bool? canSever = true, bool? canEvade = false, float? partMultiplier = 1.00f, TargetBodyPart? targetPart = null, bool doPartDamage = true, bool onlyDamageParts = false) // DeltaV - Fix EvenHealing on Limbs.
|
||||
{
|
||||
if (!uid.HasValue || !_damageableQuery.Resolve(uid.Value, ref damageable, false))
|
||||
{
|
||||
|
|
@ -194,20 +194,24 @@ namespace Content.Shared.Damage
|
|||
return damage;
|
||||
}
|
||||
|
||||
damage = ApplyUniversalAllModifiers(damage); // DeltaV - Fix EvenHealing with Limbs.
|
||||
|
||||
var before = new BeforeDamageChangedEvent(damage, origin, targetPart); // Shitmed Change
|
||||
RaiseLocalEvent(uid.Value, ref before);
|
||||
|
||||
if (before.Cancelled)
|
||||
return null;
|
||||
|
||||
// Shitmed Change Start
|
||||
var partDamage = new TryChangePartDamageEvent(damage, origin, targetPart, ignoreResistances, canSever ?? true, canEvade ?? false, partMultiplier ?? 1.00f);
|
||||
RaiseLocalEvent(uid.Value, ref partDamage);
|
||||
if (doPartDamage) // DeltaV - Fix EvenHealing with Limbs.
|
||||
{
|
||||
// ShitMed Start
|
||||
var partDamage = new TryChangePartDamageEvent(damage, origin, targetPart, ignoreResistances, canSever ?? true, canEvade ?? false, partMultiplier ?? 1.00f);
|
||||
RaiseLocalEvent(uid.Value, ref partDamage);
|
||||
|
||||
if (partDamage.Evaded || partDamage.Cancelled)
|
||||
return null;
|
||||
|
||||
// Shitmed Change End
|
||||
if (partDamage.Evaded || partDamage.Cancelled)
|
||||
return null;
|
||||
//ShitMed End
|
||||
}
|
||||
|
||||
// Apply resistances
|
||||
if (!ignoreResistances)
|
||||
|
|
@ -231,7 +235,8 @@ namespace Content.Shared.Damage
|
|||
}
|
||||
}
|
||||
|
||||
damage = ApplyUniversalAllModifiers(damage);
|
||||
if (onlyDamageParts) // DeltaV - Fix EvenHealing with Limbs.
|
||||
return null;
|
||||
|
||||
// TODO DAMAGE PERFORMANCE
|
||||
// Consider using a local private field instead of creating a new dictionary here.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
// DeltaV Start - Fix EvenHealing with Limbs.
|
||||
using System.Linq;
|
||||
using Content.Shared._Shitmed.Targeting;
|
||||
using Content.Shared.Body.Systems;
|
||||
// DeltaV End - Fix EvenHealing with Limbs.
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.EntityEffects;
|
||||
|
|
@ -91,10 +96,47 @@ public sealed partial class EvenHealthChange : EntityEffect
|
|||
}
|
||||
|
||||
var damagableSystem = args.EntityManager.System<DamageableSystem>();
|
||||
var universalReagentDamageModifier = damagableSystem.UniversalReagentDamageModifier;
|
||||
var universalReagentHealModifier = damagableSystem.UniversalReagentHealModifier;
|
||||
var dspec = GetDamageSpec(protoMan, damageable); // DeltaV - Fix EvenHealing with Limbs.
|
||||
|
||||
var dspec = new DamageSpecifier();
|
||||
damagableSystem.TryChangeDamage(
|
||||
args.TargetEntity,
|
||||
dspec * scale,
|
||||
IgnoreResistances,
|
||||
interruptsDoAfters: false,
|
||||
doPartDamage: false); // DeltaV - Fix EvenHealing with Limbs.
|
||||
|
||||
// DeltaV Start - Fix EvenHealing with Limbs.
|
||||
var bodySystem = args.EntityManager.System<SharedBodySystem>();
|
||||
var bodyParts = SharedTargetingSystem.GetValidParts();
|
||||
foreach (var bodyPart in bodyParts)
|
||||
{
|
||||
var (targetType, targetSymmetry) = bodySystem.ConvertTargetBodyPart(bodyPart);
|
||||
if (bodySystem.GetBodyChildrenOfType(args.TargetEntity, targetType, symmetry: targetSymmetry) is { } part)
|
||||
{
|
||||
if (!args.EntityManager.TryGetComponent<DamageableComponent>(part.FirstOrDefault().Id, out var damageablePart))
|
||||
continue;
|
||||
dspec = GetDamageSpec(protoMan, damageablePart);
|
||||
|
||||
if (dspec.GetTotal() == 0)
|
||||
continue;
|
||||
|
||||
damagableSystem.TryChangeDamage(
|
||||
args.TargetEntity,
|
||||
dspec * scale,
|
||||
IgnoreResistances,
|
||||
interruptsDoAfters: false,
|
||||
targetPart: bodyPart,
|
||||
onlyDamageParts: true,
|
||||
partMultiplier: 0.5f,
|
||||
canSever: false);
|
||||
}
|
||||
}
|
||||
// DeltaV End - Fix EvenHealing with Limbs.
|
||||
}
|
||||
|
||||
private DamageSpecifier GetDamageSpec(IPrototypeManager protoMan, DamageableComponent damageable) // DeltaV - Fix EvenHealing with Limbs.
|
||||
{
|
||||
var damageSpecifier = new DamageSpecifier(); // DeltaV - Fix EvenHealing with Limbs.
|
||||
|
||||
foreach (var (group, amount) in Damage)
|
||||
{
|
||||
|
|
@ -110,30 +152,10 @@ public sealed partial class EvenHealthChange : EntityEffect
|
|||
var sum = groupDamage.Values.Sum();
|
||||
foreach (var (damageId, damageAmount) in groupDamage)
|
||||
{
|
||||
var existing = dspec.DamageDict.GetOrNew(damageId);
|
||||
dspec.DamageDict[damageId] = existing + damageAmount / sum * amount;
|
||||
var existing = damageSpecifier.DamageDict.GetOrNew(damageId); // DeltaV - Fix EvenHealing with Limbs.
|
||||
damageSpecifier.DamageDict[damageId] = existing + damageAmount / sum * amount; // DeltaV - Fix EvenHealing with Limbs.
|
||||
}
|
||||
}
|
||||
|
||||
if (universalReagentDamageModifier != 1 || universalReagentHealModifier != 1)
|
||||
{
|
||||
foreach (var (type, val) in dspec.DamageDict)
|
||||
{
|
||||
if (val < 0f)
|
||||
{
|
||||
dspec.DamageDict[type] = val * universalReagentHealModifier;
|
||||
}
|
||||
if (val > 0f)
|
||||
{
|
||||
dspec.DamageDict[type] = val * universalReagentDamageModifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
damagableSystem.TryChangeDamage(
|
||||
args.TargetEntity,
|
||||
dspec * scale,
|
||||
IgnoreResistances,
|
||||
interruptsDoAfters: false);
|
||||
return damageSpecifier; // DeltaV - Fix EvenHealing with Limbs.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue