fix cauterization (#23264)
* fix cauterization * remove if statement * revert DamageTest change * fix (cherry picked from commit 9115994abf15401bca84b9695cb543cb518e1c68)
This commit is contained in:
parent
9e741af383
commit
231b9d0368
|
|
@ -1,4 +1,4 @@
|
|||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
|
||||
|
||||
|
|
@ -12,7 +12,6 @@ namespace Content.Shared.Damage
|
|||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The modifier will only ever be applied to damage that is being dealt. Healing is unmodified.
|
||||
/// The modifier can also never convert damage into healing.
|
||||
/// </remarks>
|
||||
[DataDefinition]
|
||||
[Serializable, NetSerializable]
|
||||
|
|
|
|||
|
|
@ -151,12 +151,12 @@ namespace Content.Shared.Damage
|
|||
float newValue = value.Float();
|
||||
|
||||
if (modifierSet.FlatReduction.TryGetValue(key, out var reduction))
|
||||
newValue -= reduction;
|
||||
newValue = Math.Max(0f, newValue - reduction); // flat reductions can't heal you
|
||||
|
||||
if (modifierSet.Coefficients.TryGetValue(key, out var coefficient))
|
||||
newValue *= coefficient;
|
||||
newValue *= coefficient; // coefficients can heal you, e.g. cauterizing bleeding
|
||||
|
||||
if (newValue > 0)
|
||||
if(newValue != 0)
|
||||
newDamage.DamageDict[key] = FixedPoint2.New(newValue);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Content.Tests.Shared
|
|||
private static Dictionary<string, float> _resistanceCoefficientDict = new()
|
||||
{
|
||||
// "missing" blunt entry
|
||||
{ "Piercing", -2 }, // negative multipliers just cause the damage to be ignored.
|
||||
{ "Piercing", -2 },// Turn Piercing into Healing
|
||||
{ "Slash", 3 },
|
||||
{ "Radiation", 1.5f },
|
||||
};
|
||||
|
|
@ -152,14 +152,14 @@ namespace Content.Tests.Shared
|
|||
// Apply once
|
||||
damageSpec = DamageSpecifier.ApplyModifierSet(damageSpec, modifierSet);
|
||||
Assert.That(damageSpec.DamageDict["Blunt"], Is.EqualTo(FixedPoint2.New(25)));
|
||||
Assert.That(!damageSpec.DamageDict.ContainsKey("Piercing")); // Cannot convert damage into healing.
|
||||
Assert.That(damageSpec.DamageDict["Piercing"], Is.EqualTo(FixedPoint2.New(-40))); // became healing
|
||||
Assert.That(damageSpec.DamageDict["Slash"], Is.EqualTo(FixedPoint2.New(6)));
|
||||
Assert.That(damageSpec.DamageDict["Radiation"], Is.EqualTo(FixedPoint2.New(44.25)));
|
||||
|
||||
// And again, checking for some other behavior
|
||||
damageSpec = DamageSpecifier.ApplyModifierSet(damageSpec, modifierSet);
|
||||
Assert.That(damageSpec.DamageDict["Blunt"], Is.EqualTo(FixedPoint2.New(30)));
|
||||
Assert.That(!damageSpec.DamageDict.ContainsKey("Piercing"));
|
||||
Assert.That(damageSpec.DamageDict["Piercing"], Is.EqualTo(FixedPoint2.New(-40))); // resistances don't apply to healing
|
||||
Assert.That(!damageSpec.DamageDict.ContainsKey("Slash")); // Reduction reduced to 0, and removed from specifier
|
||||
Assert.That(damageSpec.DamageDict["Radiation"], Is.EqualTo(FixedPoint2.New(65.63)));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue