}
// TODO probably cache this or something. humans get hurt a lot
- if (!_prototypeManager.TryIndex<DamageModifierSetPrototype>(ent.Comp.DamageBleedModifiers, out var modifiers))
+ if (!_prototypeManager.TryIndex(ent.Comp.DamageBleedModifiers, out var modifiers))
return;
- var bloodloss = DamageSpecifier.ApplyModifierSet(args.DamageDelta, modifiers);
+ // some reagents may deal and heal different damage types in the same tick, which means DamageIncreased will be true
+ // but we only want to consider the dealt damage when causing bleeding
+ var damage = DamageSpecifier.GetPositive(args.DamageDelta);
+ var bloodloss = DamageSpecifier.ApplyModifierSet(damage, modifiers);
if (bloodloss.Empty)
return;
var prob = Math.Clamp(totalFloat / 25, 0, 1);
if (totalFloat > 0 && _robustRandom.Prob(prob))
{
- TryModifyBloodLevel(ent, (-total) / 5, ent);
+ TryModifyBloodLevel(ent, -total / 5, ent);
_audio.PlayPvs(ent.Comp.InstantBloodSound, ent);
}
[JsonPropertyName("types")]
[DataField("types", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, DamageTypePrototype>))]
[UsedImplicitly]
- private Dictionary<string,FixedPoint2>? _damageTypeDictionary;
+ private Dictionary<string, FixedPoint2>? _damageTypeDictionary;
[JsonPropertyName("groups")]
[DataField("groups", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, DamageGroupPrototype>))]
if (modifierSet.Coefficients.TryGetValue(key, out var coefficient))
newValue *= coefficient; // coefficients can heal you, e.g. cauterizing bleeding
- if(newValue != 0)
+ if (newValue != 0)
newDamage.DamageDict[key] = FixedPoint2.New(newValue);
}
return newDamage;
}
+ /// <summary>
+ /// Returns a new DamageSpecifier that only contains the entries with positive value.
+ /// </summary>
+ public static DamageSpecifier GetPositive(DamageSpecifier damageSpec)
+ {
+ DamageSpecifier newDamage = new();
+
+ foreach (var (key, value) in damageSpec.DamageDict)
+ {
+ if (value > 0)
+ newDamage.DamageDict[key] = value;
+ }
+
+ return newDamage;
+ }
+
+ /// <summary>
+ /// Returns a new DamageSpecifier that only contains the entries with negative value.
+ /// </summary>
+ public static DamageSpecifier GetNegative(DamageSpecifier damageSpec)
+ {
+ DamageSpecifier newDamage = new();
+
+ foreach (var (key, value) in damageSpec.DamageDict)
+ {
+ if (value < 0)
+ newDamage.DamageDict[key] = value;
+ }
+
+ return newDamage;
+ }
+
/// <summary>
/// Remove any damage entries with zero damage.
/// </summary>
# Represents which damage types should be modified
# in relation to how they cause bleed rate.
+# Make sure to add any new damage type here.
- type: damageModifierSet
id: BloodlossHuman
coefficients:
+ Asphyxiation: 0.0
+ Bloodloss: 0.0 # no double dipping
Blunt: 0.08
- Slash: 0.25
- Piercing: 0.2
- Shock: 0.0
+ Caustic: 0.0
+ Cellular: 0.0
Cold: 0.0
Heat: -0.5 # heat damage cauterizes wounds, but will still hurt obviously.
+ Holy: 0
+ Piercing: 0.2
Poison: 0.0
Radiation: 0.0
- Asphyxiation: 0.0
- Bloodloss: 0.0 # no double dipping
- Cellular: 0.0
- Caustic: 0.0
+ Shock: 0.0
+ Slash: 0.25
+ Structural: 0.0
- type: damageModifierSet
id: SlimePet # Very survivable slimes