From b3759bb7b092f92ded8424d232851aea8b439c99 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 24 Dec 2021 20:57:58 -0500 Subject: [PATCH] Core/SAI: do not pass old creatureData to UpdateEntry() and keep current health when changing a NPC's entry. Port From (https://github.com/TrinityCore/TrinityCore/commit/62f5d9b46bd20faf90dd973e2786d1517b1b3bd2) --- Source/Game/AI/SmartScripts/SmartScript.cs | 2 +- Source/Game/Entities/Creature/Creature.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 08b1f4fc1..2e4b2e4af 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -960,7 +960,7 @@ namespace Game.AI { foreach (var target in targets) if (IsCreature(target)) - target.ToCreature().UpdateEntry(e.Action.updateTemplate.creature, target.ToCreature().GetCreatureData(), e.Action.updateTemplate.updateLevel != 0); + target.ToCreature().UpdateEntry(e.Action.updateTemplate.creature, null, e.Action.updateTemplate.updateLevel != 0); break; } case SmartActions.Die: diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index fdc608cb3..f05ef6e54 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -370,7 +370,12 @@ namespace Game.Entities if (updateLevel) SelectLevel(); else + { + ulong previousHealth = GetHealth(); UpdateLevelDependantStats(); // We still re-initialize level dependant stats on entry update + if (previousHealth > 0) + SetHealth(previousHealth); + } SetMeleeDamageSchool((SpellSchools)cInfo.DmgSchool); SetStatFlatModifier(UnitMods.ResistanceHoly, UnitModifierFlatType.Base, cInfo.Resistance[(int)SpellSchools.Holy]);