(5a377a8ee) Unstable v0.9.1000.0
This commit is contained in:
+3
-1
@@ -19,7 +19,7 @@ namespace Barotrauma
|
||||
public virtual float Strength
|
||||
{
|
||||
get { return _strength; }
|
||||
set { _strength = value; }
|
||||
set { _strength = MathHelper.Clamp(value, 0.0f, Prefab.MaxStrength); }
|
||||
}
|
||||
|
||||
[Serialize("", true), Editable]
|
||||
@@ -184,6 +184,8 @@ namespace Barotrauma
|
||||
{
|
||||
_strength += currentEffect.StrengthChange * deltaTime * (1f - characterHealth.GetResistance(Prefab.Identifier));
|
||||
}
|
||||
// Don't use the property, because its virtual and some afflictions like husk overload it for external use.
|
||||
_strength = MathHelper.Clamp(_strength, 0.0f, Prefab.MaxStrength);
|
||||
|
||||
foreach (StatusEffect statusEffect in currentEffect.StatusEffects)
|
||||
{
|
||||
|
||||
+21
-22
@@ -97,13 +97,15 @@ namespace Barotrauma
|
||||
|
||||
private void ApplyDamage(float deltaTime, bool applyForce)
|
||||
{
|
||||
int limbCount = character.AnimController.Limbs.Count(l => !l.ignoreCollisions && !l.IsSevered);
|
||||
foreach (Limb limb in character.AnimController.Limbs)
|
||||
{
|
||||
if (limb.IsSevered) { continue; }
|
||||
float random = Rand.Value(Rand.RandSync.Server);
|
||||
huskInfection.Clear();
|
||||
huskInfection.Add(AfflictionPrefab.InternalDamage.Instantiate(random * deltaTime / character.AnimController.Limbs.Length));
|
||||
huskInfection.Add(AfflictionPrefab.InternalDamage.Instantiate(random * 10 * deltaTime / limbCount));
|
||||
character.LastDamageSource = null;
|
||||
float force = applyForce ? random * 0.1f * limb.Mass : 0;
|
||||
float force = applyForce ? random * 0.5f * limb.Mass : 0;
|
||||
character.DamageLimb(limb.WorldPosition, limb, huskInfection, 0, false, force);
|
||||
}
|
||||
}
|
||||
@@ -186,18 +188,20 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (character.Inventory.Items.Length != husk.Inventory.Items.Length)
|
||||
if (character.Inventory != null && husk.Inventory != null)
|
||||
{
|
||||
string errorMsg = "Failed to move items from the source character's inventory into a husk's inventory (inventory sizes don't match)";
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("AfflictionHusk.CreateAIHusk:InventoryMismatch", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
for (int i = 0; i < character.Inventory.Items.Length && i < husk.Inventory.Items.Length; i++)
|
||||
{
|
||||
if (character.Inventory.Items[i] == null) continue;
|
||||
husk.Inventory.TryPutItem(character.Inventory.Items[i], i, true, false, null);
|
||||
if (character.Inventory.Items.Length != husk.Inventory.Items.Length)
|
||||
{
|
||||
string errorMsg = "Failed to move items from the source character's inventory into a husk's inventory (inventory sizes don't match)";
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("AfflictionHusk.CreateAIHusk:InventoryMismatch", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
for (int i = 0; i < character.Inventory.Items.Length && i < husk.Inventory.Items.Length; i++)
|
||||
{
|
||||
if (character.Inventory.Items[i] == null) continue;
|
||||
husk.Inventory.TryPutItem(character.Inventory.Items[i], i, true, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
husk.SetStun(5);
|
||||
@@ -255,20 +259,19 @@ namespace Barotrauma
|
||||
Limb attachLimb = null;
|
||||
if (matchingAffliction.AttachLimbId > -1)
|
||||
{
|
||||
attachLimb = ragdoll.Limbs.FirstOrDefault(l => l.Params.ID == matchingAffliction.AttachLimbId);
|
||||
attachLimb = ragdoll.Limbs.FirstOrDefault(l => !l.IsSevered && l.Params.ID == matchingAffliction.AttachLimbId);
|
||||
}
|
||||
else if (matchingAffliction.AttachLimbName != null)
|
||||
{
|
||||
attachLimb = ragdoll.Limbs.FirstOrDefault(l => l.Name == matchingAffliction.AttachLimbName);
|
||||
attachLimb = ragdoll.Limbs.FirstOrDefault(l => !l.IsSevered && l.Name == matchingAffliction.AttachLimbName);
|
||||
}
|
||||
else if (matchingAffliction.AttachLimbType != LimbType.None)
|
||||
{
|
||||
attachLimb = ragdoll.Limbs.FirstOrDefault(l => l.type == matchingAffliction.AttachLimbType);
|
||||
attachLimb = ragdoll.Limbs.FirstOrDefault(l => !l.IsSevered && l.type == matchingAffliction.AttachLimbType);
|
||||
}
|
||||
if (attachLimb == null)
|
||||
{
|
||||
DebugConsole.Log("Attachment limb not defined in the affliction prefab or no matching limb could be found. Using the appendage definition as it is.");
|
||||
attachLimb = ragdoll.Limbs.FirstOrDefault(l => l.Params.ID == jointParams.Limb1);
|
||||
attachLimb = ragdoll.Limbs.FirstOrDefault(l => !l.IsSevered && l.Params.ID == jointParams.Limb1);
|
||||
}
|
||||
if (attachLimb != null)
|
||||
{
|
||||
@@ -286,10 +289,6 @@ namespace Barotrauma
|
||||
ragdoll.AddJoint(jointParams);
|
||||
appendage.Add(huskAppendage);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ThrowError("Attachment limb not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
return appendage;
|
||||
|
||||
+2
-1
@@ -265,7 +265,8 @@ namespace Barotrauma
|
||||
public readonly Sprite Icon;
|
||||
public readonly Color[] IconColors;
|
||||
|
||||
private List<Effect> effects = new List<Effect>();
|
||||
private readonly List<Effect> effects = new List<Effect>();
|
||||
public IEnumerable<Effect> Effects => effects;
|
||||
|
||||
private readonly string typeName;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
using System.Xml.Linq;
|
||||
|
||||
+8
-6
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -19,7 +20,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (Affliction affliction in afflictions)
|
||||
{
|
||||
if (!affliction.Prefab.IsBuff || affliction == this || affliction.MultiplierSource != this) continue;
|
||||
if (!affliction.Prefab.IsBuff || affliction == this || affliction.MultiplierSource != this) { continue; }
|
||||
affliction.MultiplierSource = null;
|
||||
affliction.StrengthDiminishMultiplier = 1f;
|
||||
}
|
||||
@@ -28,9 +29,9 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (Affliction affliction in afflictions)
|
||||
{
|
||||
if (!affliction.Prefab.IsBuff || affliction == this || affliction.MultiplierSource == this) continue;
|
||||
if (!affliction.Prefab.IsBuff || affliction == this) { continue; }
|
||||
float multiplier = GetDiminishMultiplier();
|
||||
if (affliction.StrengthDiminishMultiplier < multiplier) continue;
|
||||
if (affliction.StrengthDiminishMultiplier < multiplier && affliction.MultiplierSource != this) { continue; }
|
||||
|
||||
affliction.MultiplierSource = this;
|
||||
affliction.StrengthDiminishMultiplier = multiplier;
|
||||
@@ -40,14 +41,15 @@ namespace Barotrauma
|
||||
|
||||
private float GetDiminishMultiplier()
|
||||
{
|
||||
if (Strength < Prefab.ActivationThreshold) return 1.0f;
|
||||
if (Strength < Prefab.ActivationThreshold) { return 1.0f; }
|
||||
AfflictionPrefab.Effect currentEffect = Prefab.GetActiveEffect(Strength);
|
||||
if (currentEffect == null) return 1.0f;
|
||||
if (currentEffect == null) { return 1.0f; }
|
||||
|
||||
return MathHelper.Lerp(
|
||||
float multiplier = MathHelper.Lerp(
|
||||
currentEffect.MinBuffMultiplier,
|
||||
currentEffect.MaxBuffMultiplier,
|
||||
(Strength - currentEffect.MinStrength) / (currentEffect.MaxStrength - currentEffect.MinStrength));
|
||||
return 1.0f / Math.Max(multiplier, 0.001f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,13 +349,16 @@ namespace Barotrauma
|
||||
/// Most monsters for example don't have separate healths for different limbs, essentially meaning that every affliction is applied to every limb.</param>
|
||||
public float GetAfflictionStrength(string afflictionType, Limb limb, bool requireLimbSpecific)
|
||||
{
|
||||
if (requireLimbSpecific && limbHealths.Count == 1) return 0.0f;
|
||||
if (requireLimbSpecific && limbHealths.Count == 1) { return 0.0f; }
|
||||
|
||||
float strength = 0.0f;
|
||||
foreach (Affliction affliction in limbHealths[limb.HealthIndex].Afflictions)
|
||||
{
|
||||
if (affliction.Strength < affliction.Prefab.ActivationThreshold) continue;
|
||||
if (affliction.Prefab.AfflictionType == afflictionType) strength += affliction.Strength;
|
||||
if (affliction.Strength < affliction.Prefab.ActivationThreshold) { continue; }
|
||||
if (affliction.Prefab.AfflictionType == afflictionType)
|
||||
{
|
||||
strength += affliction.Strength;
|
||||
}
|
||||
}
|
||||
return strength;
|
||||
}
|
||||
@@ -365,17 +368,23 @@ namespace Barotrauma
|
||||
float strength = 0.0f;
|
||||
foreach (Affliction affliction in afflictions)
|
||||
{
|
||||
if (affliction.Strength < affliction.Prefab.ActivationThreshold) continue;
|
||||
if (affliction.Prefab.AfflictionType == afflictionType) strength += affliction.Strength;
|
||||
if (affliction.Strength < affliction.Prefab.ActivationThreshold) { continue; }
|
||||
if (affliction.Prefab.AfflictionType == afflictionType)
|
||||
{
|
||||
strength += affliction.Strength;
|
||||
}
|
||||
}
|
||||
if (!allowLimbAfflictions) return strength;
|
||||
if (!allowLimbAfflictions) { return strength; }
|
||||
|
||||
foreach (LimbHealth limbHealth in limbHealths)
|
||||
{
|
||||
foreach (Affliction affliction in limbHealth.Afflictions)
|
||||
{
|
||||
if (affliction.Strength < affliction.Prefab.ActivationThreshold) continue;
|
||||
if (affliction.Prefab.AfflictionType == afflictionType) strength += affliction.Strength;
|
||||
if (affliction.Strength < affliction.Prefab.ActivationThreshold) { continue; }
|
||||
if (affliction.Prefab.AfflictionType == afflictionType)
|
||||
{
|
||||
strength += affliction.Strength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,11 +428,11 @@ namespace Barotrauma
|
||||
return resistance;
|
||||
}
|
||||
|
||||
private List<Affliction> matchingAfflictions = new List<Affliction>();
|
||||
private readonly List<Affliction> matchingAfflictions = new List<Affliction>();
|
||||
public void ReduceAffliction(Limb targetLimb, string affliction, float amount)
|
||||
{
|
||||
matchingAfflictions.Clear();
|
||||
|
||||
matchingAfflictions.AddRange(afflictions);
|
||||
if (targetLimb != null)
|
||||
{
|
||||
matchingAfflictions.AddRange(limbHealths[targetLimb.HealthIndex].Afflictions);
|
||||
@@ -506,6 +515,27 @@ namespace Barotrauma
|
||||
if (Vitality <= MinVitality) { Kill(); }
|
||||
}
|
||||
|
||||
public float GetLimbDamage(Limb limb)
|
||||
{
|
||||
float damageStrength;
|
||||
if (limb.IsSevered)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Instead of using the limbhealth count here, I think it's best to define the max vitality per limb roughly with a constant value.
|
||||
// Therefore with e.g. 80 health, the max damage per limb would be 20.
|
||||
// Having at least 20 damage on both legs would cause maximum limping.
|
||||
float max = MaxVitality / 4;
|
||||
float damage = GetAfflictionStrength("damage", limb, true);
|
||||
float bleeding = GetAfflictionStrength("bleeding", limb, true);
|
||||
float burn = GetAfflictionStrength("burn", limb, true);
|
||||
damageStrength = Math.Min(damage + bleeding + burn, max);
|
||||
return damageStrength / max;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveAllAfflictions()
|
||||
{
|
||||
foreach (LimbHealth limbHealth in limbHealths)
|
||||
@@ -523,7 +553,7 @@ namespace Barotrauma
|
||||
|
||||
private void AddLimbAffliction(Limb limb, Affliction newAffliction)
|
||||
{
|
||||
if (!newAffliction.Prefab.LimbSpecific || limb == null) return;
|
||||
if (!newAffliction.Prefab.LimbSpecific || limb == null) { return; }
|
||||
if (limb.HealthIndex < 0 || limb.HealthIndex >= limbHealths.Count)
|
||||
{
|
||||
DebugConsole.ThrowError("Limb health index out of bounds. Character\"" + Character.Name +
|
||||
@@ -535,8 +565,8 @@ namespace Barotrauma
|
||||
|
||||
private void AddLimbAffliction(LimbHealth limbHealth, Affliction newAffliction)
|
||||
{
|
||||
if (!DoesBleed && newAffliction is AfflictionBleeding) return;
|
||||
if (!Character.NeedsOxygen && newAffliction.Prefab == AfflictionPrefab.OxygenLow) return;
|
||||
if (!DoesBleed && newAffliction is AfflictionBleeding) { return; }
|
||||
if (!Character.NeedsOxygen && newAffliction.Prefab == AfflictionPrefab.OxygenLow) { return; }
|
||||
|
||||
foreach (Affliction affliction in limbHealth.Afflictions)
|
||||
{
|
||||
@@ -545,7 +575,10 @@ namespace Barotrauma
|
||||
affliction.Strength = Math.Min(affliction.Prefab.MaxStrength, affliction.Strength + (newAffliction.Strength * (100.0f / MaxVitality) * (1f - GetResistance(affliction.Prefab.Identifier))));
|
||||
affliction.Source = newAffliction.Source;
|
||||
CalculateVitality();
|
||||
if (Vitality <= MinVitality) Kill();
|
||||
if (Vitality <= MinVitality)
|
||||
{
|
||||
Kill();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -560,7 +593,10 @@ namespace Barotrauma
|
||||
Character.HealthUpdateInterval = 0.0f;
|
||||
|
||||
CalculateVitality();
|
||||
if (Vitality <= MinVitality) Kill();
|
||||
if (Vitality <= MinVitality)
|
||||
{
|
||||
Kill();
|
||||
}
|
||||
#if CLIENT
|
||||
selectedLimbIndex = -1;
|
||||
#endif
|
||||
@@ -894,10 +930,7 @@ namespace Barotrauma
|
||||
|
||||
partial void RemoveProjSpecific();
|
||||
|
||||
/// <summary>
|
||||
/// Automatically filters out buffs.
|
||||
/// </summary>
|
||||
public static IEnumerable<Affliction> SortAfflictionsBySeverity(IEnumerable<Affliction> afflictions) =>
|
||||
afflictions.Where(a => !a.Prefab.IsBuff).OrderByDescending(a => a.DamagePerSecond).ThenByDescending(a => a.Strength);
|
||||
public static IEnumerable<Affliction> SortAfflictionsBySeverity(IEnumerable<Affliction> afflictions, bool excludeBuffs = true) =>
|
||||
afflictions.Where(a => !excludeBuffs || !a.Prefab.IsBuff).OrderByDescending(a => a.DamagePerSecond).ThenByDescending(a => a.Strength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,13 @@ namespace Barotrauma
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize(1.0f, false), Editable(DecimalCount = 2, MinValueFloat = 0, MaxValueFloat = 1)]
|
||||
public float ProbabilityMultiplier
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize("0.0,360", false), Editable]
|
||||
public Vector2 ArmorSector
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user