fix(Scripts/Pet): Fix crash when spawning lightwell by hand (#18660)

Co-authored-by: Pagani Walter <paganiwalter@gmail.com>
This commit is contained in:
Andrew
2024-04-17 03:12:20 -03:00
committed by GitHub
parent eced002ef9
commit ef0ebe38d0
+4 -1
View File
@@ -40,13 +40,16 @@ struct npc_pet_pri_lightwell : public TotemAI
void InitializeAI() override void InitializeAI() override
{ {
if (Unit* owner = me->ToTempSummon()->GetSummonerUnit()) if (TempSummon* tempSummon = me->ToTempSummon())
{
if (Unit* owner = tempSummon->GetSummonerUnit())
{ {
uint32 hp = uint32(owner->GetMaxHealth() * 0.3f); uint32 hp = uint32(owner->GetMaxHealth() * 0.3f);
me->SetMaxHealth(hp); me->SetMaxHealth(hp);
me->SetHealth(hp); me->SetHealth(hp);
me->SetLevel(owner->GetLevel()); me->SetLevel(owner->GetLevel());
} }
}
me->CastSpell(me, SPELL_PRIEST_LIGHTWELL_CHARGES, false); // Spell for Lightwell Charges me->CastSpell(me, SPELL_PRIEST_LIGHTWELL_CHARGES, false); // Spell for Lightwell Charges
TotemAI::InitializeAI(); TotemAI::InitializeAI();