(f2e516dfe) v0.9.3.2

This commit is contained in:
Joonas Rikkonen
2019-09-20 20:11:18 +03:00
parent 80698b58b0
commit 9aa12bcac2
144 changed files with 1653 additions and 1559 deletions
@@ -20,7 +20,8 @@ namespace Barotrauma
SpeciesName,
HasTag,
HasStatusTag,
Affliction
Affliction,
EntityType
}
public enum Comparison
@@ -161,15 +162,18 @@ namespace Barotrauma
{
case ConditionType.PropertyValue:
SerializableProperty property;
if (target?.SerializableProperties == null) { return Operator == OperatorType.NotEquals; }
if (target.SerializableProperties.TryGetValue(AttributeName, out property))
{
return Matches(target, property);
}
return false;
case ConditionType.Name:
if (target == null) { return Operator == OperatorType.NotEquals; }
return (Operator == OperatorType.Equals) == (target.Name == valStr);
case ConditionType.HasTag:
{
if (target == null) { return Operator == OperatorType.NotEquals; }
string[] readTags = valStr.Split(',');
int matches = 0;
foreach (string tag in readTags)
@@ -179,6 +183,8 @@ namespace Barotrauma
return Operator == OperatorType.Equals ? matches >= readTags.Length : matches <= 0;
}
case ConditionType.HasStatusTag:
if (target == null) { return Operator == OperatorType.NotEquals; }
List<DurationListElement> durations = StatusEffect.DurationList.FindAll(d => d.Targets.Contains(target));
List<DelayedListElement> delays = DelayedEffect.DelayList.FindAll(d => d.Targets.Contains(target));
@@ -218,10 +224,29 @@ namespace Barotrauma
}
return success;
case ConditionType.SpeciesName:
if (target == null) { return Operator == OperatorType.NotEquals; }
Character targetCharacter = target as Character;
if (targetCharacter == null) return false;
if (targetCharacter == null) { return false; }
return (Operator == OperatorType.Equals) == (targetCharacter.SpeciesName == valStr);
case ConditionType.EntityType:
switch (valStr)
{
case "character":
case "Character":
return (Operator == OperatorType.Equals) == target is Character;
case "item":
case "Item":
return (Operator == OperatorType.Equals) == target is Item;
case "structure":
case "Structure":
return (Operator == OperatorType.Equals) == target is Structure;
case "null":
return (Operator == OperatorType.Equals) == (target == null);
default:
return false;
}
case ConditionType.Affliction:
if (target == null) { return Operator == OperatorType.NotEquals; }
if (target is Character targetChar)
{
var health = targetChar.CharacterHealth;
@@ -13,6 +13,7 @@ namespace Barotrauma
public Entity Entity;
public List<ISerializableEntity> Targets;
public float Timer;
public Character User;
}
partial class StatusEffect
@@ -432,7 +433,6 @@ namespace Barotrauma
case PropertyConditional.Comparison.Or:
foreach (ISerializableEntity target in targets)
{
if (target == null || target.SerializableProperties == null) { continue; }
foreach (PropertyConditional pc in propertyConditionals)
{
if (!string.IsNullOrEmpty(pc.TargetItemComponentName))
@@ -449,7 +449,6 @@ namespace Barotrauma
case PropertyConditional.Comparison.And:
foreach (ISerializableEntity target in targets)
{
if (target == null || target.SerializableProperties == null) { continue; }
foreach (PropertyConditional pc in propertyConditionals)
{
if (!string.IsNullOrEmpty(pc.TargetItemComponentName))
@@ -516,6 +515,7 @@ namespace Barotrauma
if (existingEffect != null)
{
existingEffect.Timer = Math.Max(existingEffect.Timer, duration);
existingEffect.User = user;
return;
}
}
@@ -554,6 +554,7 @@ namespace Barotrauma
if (existingEffect != null)
{
existingEffect.Timer = Math.Max(existingEffect.Timer, duration);
existingEffect.User = user;
return;
}
}
@@ -607,7 +608,8 @@ namespace Barotrauma
Parent = this,
Timer = duration,
Entity = entity,
Targets = targets
Targets = targets,
User = user
};
DurationList.Add(element);
@@ -641,6 +643,7 @@ namespace Barotrauma
if (target is Character character)
{
if (character.Removed) { continue; }
character.LastDamageSource = entity;
foreach (Limb limb in character.AnimController.Limbs)
{
@@ -651,6 +654,7 @@ namespace Barotrauma
}
else if (target is Limb limb)
{
if (limb.character.Removed) { continue; }
limb.character.DamageLimb(entity.WorldPosition, limb, new List<Affliction>() { multipliedAffliction }, stun: 0.0f, playSound: false, attackImpulse: 0.0f, attacker: affliction.Source);
}
}
@@ -669,7 +673,7 @@ namespace Barotrauma
targetLimb = limb;
targetCharacter = limb.character;
}
if (targetCharacter != null)
if (targetCharacter != null && !targetCharacter.Removed)
{
float prevVitality = targetCharacter.Vitality;
targetCharacter.CharacterHealth.ReduceAffliction(targetLimb, reduceAffliction.First, reduceAmount);
@@ -827,11 +831,13 @@ namespace Barotrauma
if (target is Character character)
{
character.AddDamage(character.WorldPosition, new List<Affliction>() { multipliedAffliction }, stun: 0.0f, playSound: false);
if (character.Removed) { continue; }
character.AddDamage(character.WorldPosition, new List<Affliction>() { multipliedAffliction }, stun: 0.0f, playSound: false, attacker: element.User);
}
else if (target is Limb limb)
{
limb.character.DamageLimb(limb.WorldPosition, limb, new List<Affliction>() { multipliedAffliction }, stun: 0.0f, playSound: false, attackImpulse: 0.0f);
if (limb.character.Removed) { continue; }
limb.character.DamageLimb(limb.WorldPosition, limb, new List<Affliction>() { multipliedAffliction }, stun: 0.0f, playSound: false, attackImpulse: 0.0f, attacker: element.User);
}
}
@@ -848,12 +854,12 @@ namespace Barotrauma
targetLimb = limb;
targetCharacter = limb.character;
}
if (targetCharacter != null)
if (targetCharacter != null && !targetCharacter.Removed)
{
float prevVitality = targetCharacter.Vitality;
targetCharacter.CharacterHealth.ReduceAffliction(targetLimb, reduceAffliction.First, reduceAffliction.Second * deltaTime);
#if SERVER
GameMain.Server.KarmaManager.OnCharacterHealthChanged(targetCharacter, element.Parent.user, prevVitality - targetCharacter.Vitality);
GameMain.Server.KarmaManager.OnCharacterHealthChanged(targetCharacter, element.User, prevVitality - targetCharacter.Vitality);
#endif
}
}
@@ -861,7 +867,7 @@ namespace Barotrauma
element.Timer -= deltaTime;
if (element.Timer > 0.0f) continue;
if (element.Timer > 0.0f) { continue; }
DurationList.Remove(element);
}
}
@@ -873,20 +879,17 @@ namespace Barotrauma
CoroutineManager.StopCoroutines("statuseffect");
DelayedEffect.DelayList.Clear();
DurationList.Clear();
#if CLIENT
//ActiveLoopingSounds.Clear();
#endif
}
public void AddTag(string tag)
{
if (tags.Contains(tag)) return;
if (tags.Contains(tag)) { return; }
tags.Add(tag);
}
public bool HasTag(string tag)
{
if (tag == null) return true;
if (tag == null) { return true; }
return (tags.Contains(tag) || tags.Contains(tag.ToLowerInvariant()));
}