The ActionType of an Attack's statuseffect is considered "OnEating" instead of "OnUse" if the target is dead. Prevents husks from gaining health by attacking corpses (which allowed players to huskify themselves on purpose and stay alive indefinitely).

This commit is contained in:
Joonas Rikkonen
2018-10-08 11:23:52 +03:00
parent fec7740378
commit 2b1dacbf2f
2 changed files with 9 additions and 4 deletions

View File

@@ -161,16 +161,20 @@ namespace Barotrauma
public AttackResult DoDamage(Character attacker, IDamageable target, Vector2 worldPosition, float deltaTime, bool playSound = true)
{
Character targetCharacter = target as Character;
if (OnlyHumans)
{
Character character = target as Character;
if (character != null && character.ConfigPath != Character.HumanConfigFile) return new AttackResult();
if (targetCharacter != null && targetCharacter.ConfigPath != Character.HumanConfigFile) return new AttackResult();
}
DamageParticles(deltaTime, worldPosition);
var attackResult = target.AddDamage(attacker, worldPosition, this, deltaTime, playSound);
var effectType = attackResult.Damage > 0.0f ? ActionType.OnUse : ActionType.OnFailure;
if (targetCharacter != null && targetCharacter.IsDead)
{
effectType = ActionType.OnEating;
}
if (statusEffects == null) return attackResult;
foreach (StatusEffect effect in statusEffects)

View File

@@ -20,7 +20,8 @@ namespace Barotrauma
OnWearing, OnContaining, OnContained,
OnActive, OnFailure, OnBroken,
OnFire, InWater,
OnImpact
OnImpact,
OnEating
}
partial class Item : MapEntity, IDamageable, ISerializableEntity, IServerSerializable, IClientSerializable