Unstable 0.17.10.0
This commit is contained in:
@@ -360,7 +360,7 @@ namespace Barotrauma
|
||||
public List<Order> CurrentOrders => Info?.CurrentOrders;
|
||||
public bool IsDismissed => GetCurrentOrderWithTopPriority() == null;
|
||||
|
||||
private readonly List<StatusEffect> statusEffects = new List<StatusEffect>();
|
||||
private readonly Dictionary<ActionType, List<StatusEffect>> statusEffects = new Dictionary<ActionType, List<StatusEffect>>();
|
||||
|
||||
public Entity ViewTarget
|
||||
{
|
||||
@@ -1033,34 +1033,6 @@ namespace Barotrauma
|
||||
newCharacter = new Character(prefab, position, seed, characterInfo, id, isRemotePlayer, ragdoll);
|
||||
}
|
||||
|
||||
float healthRegen = newCharacter.Params.Health.ConstantHealthRegeneration;
|
||||
if (healthRegen > 0)
|
||||
{
|
||||
AddDamageReduction("damage", healthRegen);
|
||||
}
|
||||
float eatingRegen = newCharacter.Params.Health.HealthRegenerationWhenEating;
|
||||
if (eatingRegen > 0)
|
||||
{
|
||||
AddDamageReduction("damage", eatingRegen, ActionType.OnEating);
|
||||
}
|
||||
float burnReduction = newCharacter.Params.Health.BurnReduction;
|
||||
if (burnReduction > 0)
|
||||
{
|
||||
AddDamageReduction("burn", burnReduction);
|
||||
}
|
||||
float bleedReduction = newCharacter.Params.Health.BleedingReduction;
|
||||
if (bleedReduction > 0)
|
||||
{
|
||||
AddDamageReduction("bleeding", bleedReduction);
|
||||
}
|
||||
|
||||
void AddDamageReduction(string affliction, float amount, ActionType actionType = ActionType.Always)
|
||||
{
|
||||
newCharacter.statusEffects.Add(StatusEffect.Load(
|
||||
new XElement("StatusEffect", new XAttribute("type", actionType), new XAttribute("target", "Character"),
|
||||
new XElement("ReduceAffliction", new XAttribute("identifier", affliction), new XAttribute("amount", amount))).FromPackage(null), $"automatic damage reduction ({affliction})"));
|
||||
}
|
||||
|
||||
#if SERVER
|
||||
if (GameMain.Server != null && Spawner != null && createNetworkEvent)
|
||||
{
|
||||
@@ -1138,7 +1110,15 @@ namespace Barotrauma
|
||||
healthCommonness.Add(subElement.GetAttributeFloat("commonness", 1.0f));
|
||||
break;
|
||||
case "statuseffect":
|
||||
statusEffects.Add(StatusEffect.Load(subElement, Name));
|
||||
var statusEffect = StatusEffect.Load(subElement, Name);
|
||||
if (statusEffect != null)
|
||||
{
|
||||
if (!statusEffects.ContainsKey(statusEffect.type))
|
||||
{
|
||||
statusEffects.Add(statusEffect.type, new List<StatusEffect>());
|
||||
}
|
||||
statusEffects[statusEffect.type].Add(statusEffect);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3681,13 +3661,19 @@ namespace Barotrauma
|
||||
otherLimb.body.ApplyLinearImpulse(targetLimb.LinearVelocity * targetLimb.Mass, maxVelocity: NetConfig.MaxPhysicsBodyVelocity * 0.5f);
|
||||
if (attacker != null)
|
||||
{
|
||||
foreach (var statusEffect in statusEffects)
|
||||
if (statusEffects.TryGetValue(ActionType.OnSevered, out var statusEffectList))
|
||||
{
|
||||
if (statusEffect.type == ActionType.OnSevered) { statusEffect.SetUser(attacker); }
|
||||
foreach (var statusEffect in statusEffectList)
|
||||
{
|
||||
statusEffect.SetUser(attacker);
|
||||
}
|
||||
}
|
||||
foreach (var statusEffect in targetLimb.StatusEffects)
|
||||
if (targetLimb.StatusEffects.TryGetValue(ActionType.OnSevered, out var limbStatusEffectList))
|
||||
{
|
||||
if (statusEffect.type == ActionType.OnSevered) { statusEffect.SetUser(attacker); }
|
||||
foreach (var statusEffect in limbStatusEffectList)
|
||||
{
|
||||
statusEffect.SetUser(attacker);
|
||||
}
|
||||
}
|
||||
}
|
||||
ApplyStatusEffects(ActionType.OnSevered, 1.0f);
|
||||
@@ -3889,9 +3875,17 @@ namespace Barotrauma
|
||||
private readonly List<ISerializableEntity> targets = new List<ISerializableEntity>();
|
||||
public void ApplyStatusEffects(ActionType actionType, float deltaTime)
|
||||
{
|
||||
foreach (StatusEffect statusEffect in statusEffects)
|
||||
if (actionType == ActionType.OnEating)
|
||||
{
|
||||
float eatingRegen = Params.Health.HealthRegenerationWhenEating;
|
||||
if (eatingRegen > 0)
|
||||
{
|
||||
CharacterHealth.ReduceAfflictionOnAllLimbs("damage".ToIdentifier(), eatingRegen * deltaTime);
|
||||
}
|
||||
}
|
||||
if (!statusEffects.TryGetValue(actionType, out var statusEffectList)) { return; }
|
||||
foreach (StatusEffect statusEffect in statusEffectList)
|
||||
{
|
||||
if (statusEffect.type != actionType) { continue; }
|
||||
if (statusEffect.type == ActionType.OnDamaged)
|
||||
{
|
||||
if (!statusEffect.HasRequiredAfflictions(LastDamage)) { continue; }
|
||||
|
||||
@@ -327,16 +327,13 @@ namespace Barotrauma
|
||||
|
||||
public Limb GetAfflictionLimb(Affliction affliction)
|
||||
{
|
||||
foreach (KeyValuePair<Affliction, LimbHealth> kvp in afflictions)
|
||||
if (afflictions.TryGetValue(affliction, out LimbHealth limbHealth))
|
||||
{
|
||||
if (kvp.Key == affliction)
|
||||
if (limbHealth == null) { return null; }
|
||||
int limbHealthIndex = limbHealths.IndexOf(limbHealth);
|
||||
foreach (Limb limb in Character.AnimController.Limbs)
|
||||
{
|
||||
int limbHealthIndex = limbHealths.IndexOf(kvp.Value);
|
||||
foreach (Limb limb in Character.AnimController.Limbs)
|
||||
{
|
||||
if (limb.HealthIndex == limbHealthIndex) { return limb; }
|
||||
}
|
||||
return null;
|
||||
if (limb.HealthIndex == limbHealthIndex) { return limb; }
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -508,8 +505,8 @@ namespace Barotrauma
|
||||
amount -= matchingAffliction.Strength;
|
||||
matchingAffliction.Strength = 0.0f;
|
||||
matchingAfflictions.RemoveAt(i);
|
||||
if (i == 0) i = matchingAfflictions.Count;
|
||||
if (i > 0) reduceAmount += surplus / i;
|
||||
if (i == 0) { i = matchingAfflictions.Count; }
|
||||
if (i > 0) { reduceAmount += surplus / i; }
|
||||
SteamAchievementManager.OnAfflictionRemoved(matchingAffliction, Character);
|
||||
}
|
||||
else
|
||||
@@ -786,6 +783,8 @@ namespace Barotrauma
|
||||
Character.StackSpeedMultiplier(1f + Character.GetStatValue(StatTypes.WalkingSpeed));
|
||||
}
|
||||
|
||||
UpdateDamageReductions(deltaTime);
|
||||
|
||||
if (!Character.GodMode)
|
||||
{
|
||||
UpdateLimbAfflictionOverlays();
|
||||
@@ -816,6 +815,25 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDamageReductions(float deltaTime)
|
||||
{
|
||||
float healthRegen = Character.Params.Health.ConstantHealthRegeneration;
|
||||
if (healthRegen > 0)
|
||||
{
|
||||
ReduceAfflictionOnAllLimbs("damage".ToIdentifier(), healthRegen * deltaTime);
|
||||
}
|
||||
float burnReduction = Character.Params.Health.BurnReduction;
|
||||
if (burnReduction > 0)
|
||||
{
|
||||
ReduceAfflictionOnAllLimbs("burn".ToIdentifier(), burnReduction * deltaTime);
|
||||
}
|
||||
float bleedingReduction = Character.Params.Health.BleedingReduction;
|
||||
if (bleedingReduction > 0)
|
||||
{
|
||||
ReduceAfflictionOnAllLimbs("bleeding".ToIdentifier(), bleedingReduction * deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateOxygen(float deltaTime)
|
||||
{
|
||||
if (!Character.NeedsOxygen) { return; }
|
||||
@@ -897,28 +915,14 @@ namespace Barotrauma
|
||||
|
||||
// We need to use another list of the afflictions when we call the status effects triggered by afflictions,
|
||||
// because those status effects may add or remove other afflictions while iterating the collection.
|
||||
private readonly List<(Affliction affliction, Limb limb)> afflictionsCopy = new List<(Affliction affliction, Limb limb)>();
|
||||
private readonly List<Affliction> afflictionsCopy = new List<Affliction>();
|
||||
public void ApplyAfflictionStatusEffects(ActionType type)
|
||||
{
|
||||
afflictionsCopy.Clear();
|
||||
foreach (KeyValuePair<Affliction, LimbHealth> kvp in afflictions)
|
||||
afflictionsCopy.AddRange(afflictions.Keys);
|
||||
foreach (Affliction affliction in afflictionsCopy)
|
||||
{
|
||||
var affliction = kvp.Key;
|
||||
var limbHealth = kvp.Value;
|
||||
Limb targetLimb = null;
|
||||
if (limbHealth != null)
|
||||
{
|
||||
int healthIndex = limbHealths.IndexOf(limbHealth);
|
||||
targetLimb =
|
||||
Character.AnimController.Limbs.LastOrDefault(l => !l.IsSevered && !l.Hidden && l.HealthIndex == healthIndex) ??
|
||||
Character.AnimController.MainLimb;
|
||||
}
|
||||
afflictionsCopy.Add((affliction, GetAfflictionLimb(affliction)));
|
||||
}
|
||||
|
||||
foreach ((Affliction affliction, Limb limb) in afflictionsCopy)
|
||||
{
|
||||
affliction.ApplyStatusEffects(type, 1.0f, this, targetLimb: limb);
|
||||
affliction.ApplyStatusEffects(type, 1.0f, this, targetLimb: GetAfflictionLimb(affliction));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -584,9 +584,9 @@ namespace Barotrauma
|
||||
private set;
|
||||
}
|
||||
|
||||
private readonly List<StatusEffect> statusEffects = new List<StatusEffect>();
|
||||
private readonly Dictionary<ActionType, List<StatusEffect>> statusEffects = new Dictionary<ActionType, List<StatusEffect>>();
|
||||
|
||||
public IEnumerable<StatusEffect> StatusEffects { get { return statusEffects; } }
|
||||
public Dictionary<ActionType, List<StatusEffect>> StatusEffects { get { return statusEffects; } }
|
||||
|
||||
public Limb(Ragdoll ragdoll, Character character, LimbParams limbParams)
|
||||
{
|
||||
@@ -662,7 +662,15 @@ namespace Barotrauma
|
||||
DamageModifiers.Add(new DamageModifier(subElement, character.Name));
|
||||
break;
|
||||
case "statuseffect":
|
||||
statusEffects.Add(StatusEffect.Load(subElement, Name));
|
||||
var statusEffect = StatusEffect.Load(subElement, Name);
|
||||
if (statusEffect != null)
|
||||
{
|
||||
if (!statusEffects.ContainsKey(statusEffect.type))
|
||||
{
|
||||
statusEffects.Add(statusEffect.type, new List<StatusEffect>());
|
||||
}
|
||||
statusEffects[statusEffect.type].Add(statusEffect);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1159,9 +1167,9 @@ namespace Barotrauma
|
||||
private readonly List<ISerializableEntity> targets = new List<ISerializableEntity>();
|
||||
public void ApplyStatusEffects(ActionType actionType, float deltaTime)
|
||||
{
|
||||
foreach (StatusEffect statusEffect in statusEffects)
|
||||
if (!statusEffects.TryGetValue(actionType, out var statusEffectList)) { return; }
|
||||
foreach (StatusEffect statusEffect in statusEffectList)
|
||||
{
|
||||
if (statusEffect.type != actionType) { continue; }
|
||||
if (statusEffect.type == ActionType.OnDamaged)
|
||||
{
|
||||
if (!statusEffect.HasRequiredAfflictions(character.LastDamage)) { continue; }
|
||||
|
||||
@@ -481,16 +481,16 @@ namespace Barotrauma
|
||||
public bool UseHealthWindow { get; set; }
|
||||
|
||||
[Serialize(0f, IsPropertySaveable.Yes, description: "How easily the character heals from the bleeding wounds. Default 0 (no extra healing)."), Editable(MinValueFloat = 0, MaxValueFloat = 100, DecimalCount = 2)]
|
||||
public float BleedingReduction { get; private set; }
|
||||
public float BleedingReduction { get; set; }
|
||||
|
||||
[Serialize(0f, IsPropertySaveable.Yes, description: "How easily the character heals from the burn wounds. Default 0 (no extra healing)."), Editable(MinValueFloat = 0, MaxValueFloat = 100, DecimalCount = 2)]
|
||||
public float BurnReduction { get; private set; }
|
||||
public float BurnReduction { get; set; }
|
||||
|
||||
[Serialize(0f, IsPropertySaveable.Yes), Editable(MinValueFloat = 0, MaxValueFloat = 10, DecimalCount = 2)]
|
||||
public float ConstantHealthRegeneration { get; private set; }
|
||||
public float ConstantHealthRegeneration { get; set; }
|
||||
|
||||
[Serialize(0f, IsPropertySaveable.Yes), Editable(MinValueFloat = 0, MaxValueFloat = 100, DecimalCount = 2)]
|
||||
public float HealthRegenerationWhenEating { get; private set; }
|
||||
public float HealthRegenerationWhenEating { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes), Editable]
|
||||
public bool StunImmunity { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user