Skip to content

Commit

Permalink
Followup to previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ratkosrb committed Dec 18, 2023
1 parent dc3c752 commit b285c90
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
11 changes: 6 additions & 5 deletions src/game/Objects/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1275,8 +1275,6 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
return false;
}

InitializeDefaultName();

if (cinfo->type == CREATURE_TYPE_CRITTER)
{
setPetType(MINI_PET);
Expand Down Expand Up @@ -2262,10 +2260,13 @@ void Pet::InitializeDefaultName()
case SUMMON_PET:
case HUNTER_PET:
{
if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(GetCreatureInfo()->pet_family))
if (GetOwnerGuid().IsPlayer())
{
SetName(cFamily->Name[sWorld.GetDefaultDbcLocale()]);
break;
if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(GetCreatureInfo()->pet_family))
{
SetName(cFamily->Name[sWorld.GetDefaultDbcLocale()]);
break;
}
}
// no break
}
Expand Down
18 changes: 9 additions & 9 deletions src/game/Spells/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3106,7 +3106,6 @@ void Spell::EffectSummon(SpellEffectIndex effIdx)
if (m_duration > 0)
spawnCreature->SetDuration(m_duration);

spawnCreature->InitializeDefaultName();
spawnCreature->SetOwnerGuid(m_casterUnit->GetObjectGuid());
spawnCreature->SetCreatorGuid(m_casterUnit->GetObjectGuid());
spawnCreature->SetFactionTemplateId(m_casterUnit->GetFactionTemplateId());
Expand All @@ -3123,6 +3122,7 @@ void Spell::EffectSummon(SpellEffectIndex effIdx)
else
spawnCreature->SetReactState(REACT_AGGRESSIVE);

spawnCreature->InitializeDefaultName();
spawnCreature->AIM_Initialize();
spawnCreature->InitPetCreateSpells();
spawnCreature->SetHealth(spawnCreature->GetMaxHealth());
Expand Down Expand Up @@ -3647,7 +3647,6 @@ void Spell::EffectSummonGuardian(SpellEffectIndex effIdx)
if (m_duration > 0)
spawnCreature->SetDuration(m_duration);

spawnCreature->InitializeDefaultName();
spawnCreature->SetOwnerGuid(m_casterUnit->GetObjectGuid());
spawnCreature->SetCreatorGuid(m_casterUnit->GetObjectGuid());
spawnCreature->SetFactionTemplateId(m_casterUnit->GetFactionTemplateId());
Expand All @@ -3665,6 +3664,7 @@ void Spell::EffectSummonGuardian(SpellEffectIndex effIdx)
spawnCreature->SetFollowAngle(followAngle);
}

spawnCreature->InitializeDefaultName();
spawnCreature->AIM_Initialize();
spawnCreature->LoadCreatureAddon();

Expand Down Expand Up @@ -3951,6 +3951,7 @@ void Spell::EffectTameCreature(SpellEffectIndex /*effIdx*/)

pet->GetCharmInfo()->SetPetNumber(sObjectMgr.GeneratePetNumber(), true);
pet->GetCharmInfo()->SetReactState(REACT_DEFENSIVE);
pet->InitializeDefaultName();
pet->AIM_Initialize();
pet->InitPetCreateSpells();
pet->SetHealth(pet->GetMaxHealth());
Expand Down Expand Up @@ -4066,11 +4067,6 @@ ObjectGuid Unit::EffectSummonPet(uint32 spellId, uint32 petEntry, uint32 petLeve
else
newSummon->SetReactState(REACT_DEFENSIVE);

newSummon->AIM_Initialize();
newSummon->InitPetCreateSpells();
newSummon->SetHealth(newSummon->GetMaxHealth());
newSummon->SetPower(POWER_MANA, newSummon->GetMaxPower(POWER_MANA));

if (newSummon->getPetType() == SUMMON_PET)
{
// Remove Demonic Sacrifice auras (new pet)
Expand Down Expand Up @@ -4099,6 +4095,11 @@ ObjectGuid Unit::EffectSummonPet(uint32 spellId, uint32 petEntry, uint32 petLeve
newSummon->InitializeDefaultName();
}

newSummon->AIM_Initialize();
newSummon->InitPetCreateSpells();
newSummon->SetHealth(newSummon->GetMaxHealth());
newSummon->SetPower(POWER_MANA, newSummon->GetMaxPower(POWER_MANA));

if (IsPvP())
newSummon->SetPvP(true);

Expand Down Expand Up @@ -6407,13 +6408,12 @@ void Spell::EffectSummonCritter(SpellEffectIndex effIdx)
if (m_duration > 0)
critter->SetDuration(m_duration);

critter->InitializeDefaultName();
critter->SetOwnerGuid(m_caster->GetObjectGuid());
critter->SetCreatorGuid(m_caster->GetObjectGuid());
critter->SetFactionTemplateId(m_caster->GetFactionTemplateId());
critter->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
critter->SetUInt32Value(UNIT_NPC_FLAGS, critter->GetCreatureInfo()->npc_flags); // some mini-pets have quests

critter->InitializeDefaultName();
critter->AIM_Initialize();
critter->InitPetCreateSpells(); // e.g. disgusting oozeling has a create spell as critter...
critter->SelectLevel(); // some summoned creatures have different from 1 DB data for level/hp
Expand Down

0 comments on commit b285c90

Please sign in to comment.