From ef0ebe38d0d665317955b1650d355dceb1058d4d Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Wed, 17 Apr 2024 03:12:20 -0300 Subject: [PATCH] fix(Scripts/Pet): Fix crash when spawning lightwell by hand (#18660) Co-authored-by: Pagani Walter --- src/server/scripts/Pet/pet_priest.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/server/scripts/Pet/pet_priest.cpp b/src/server/scripts/Pet/pet_priest.cpp index 88bcfc05a..41a77a49e 100644 --- a/src/server/scripts/Pet/pet_priest.cpp +++ b/src/server/scripts/Pet/pet_priest.cpp @@ -40,12 +40,15 @@ struct npc_pet_pri_lightwell : public TotemAI void InitializeAI() override { - if (Unit* owner = me->ToTempSummon()->GetSummonerUnit()) + if (TempSummon* tempSummon = me->ToTempSummon()) { - uint32 hp = uint32(owner->GetMaxHealth() * 0.3f); - me->SetMaxHealth(hp); - me->SetHealth(hp); - me->SetLevel(owner->GetLevel()); + if (Unit* owner = tempSummon->GetSummonerUnit()) + { + uint32 hp = uint32(owner->GetMaxHealth() * 0.3f); + me->SetMaxHealth(hp); + me->SetHealth(hp); + me->SetLevel(owner->GetLevel()); + } } me->CastSpell(me, SPELL_PRIEST_LIGHTWELL_CHARGES, false); // Spell for Lightwell Charges