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

View File

@@ -40,12 +40,15 @@ struct npc_pet_pri_lightwell : public TotemAI
void InitializeAI() override void InitializeAI() override
{ {
if (Unit* owner = me->ToTempSummon()->GetSummonerUnit()) if (TempSummon* tempSummon = me->ToTempSummon())
{ {
uint32 hp = uint32(owner->GetMaxHealth() * 0.3f); if (Unit* owner = tempSummon->GetSummonerUnit())
me->SetMaxHealth(hp); {
me->SetHealth(hp); uint32 hp = uint32(owner->GetMaxHealth() * 0.3f);
me->SetLevel(owner->GetLevel()); me->SetMaxHealth(hp);
me->SetHealth(hp);
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