From 2b1dacbf2f72cf2f7b3e4d12b3e92338c6eab551 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 8 Oct 2018 11:23:52 +0300 Subject: [PATCH] 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). --- .../BarotraumaShared/Source/Characters/Attack.cs | 10 +++++++--- Barotrauma/BarotraumaShared/Source/Items/Item.cs | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs b/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs index bc498df98..841d965d8 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Attack.cs @@ -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) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index 54ef20b8d..2bc3bf6a6 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -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