[11215] Replace direct code use in .npc tame by spell cast.

Only work different from old way: target creature despawned.
So if this not expected use .respawn to it in gm mode or area respawn.

Code simplification suggested originally by rsa.
This commit is contained in:
VladimirMangos 2011-03-03 21:31:02 +03:00
parent 9312ef7e78
commit 06fe777f82
6 changed files with 50 additions and 99 deletions

View file

@ -10397,51 +10397,6 @@ void Unit::RemovePetAura(PetAura const* petSpell)
pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry()));
}
Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
{
Pet* pet = new Pet(HUNTER_PET);
if(!pet->CreateBaseAtCreature(creatureTarget))
{
delete pet;
return NULL;
}
pet->SetOwnerGuid(GetObjectGuid());
pet->SetCreatorGuid(GetObjectGuid());
pet->setFaction(getFaction());
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);
if(GetTypeId()==TYPEID_PLAYER)
pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
if(IsPvP())
pet->SetPvP(true);
if(IsFFAPvP())
pet->SetFFAPvP(true);
// level of hunter pet can't be less owner level at 5 levels
uint32 level = creatureTarget->getLevel() + 5 < getLevel() ? (getLevel() - 5) : creatureTarget->getLevel();
if(!pet->InitStatsForLevel(level))
{
sLog.outError("Pet::InitStatsForLevel() failed for creature (Entry: %u)!",creatureTarget->GetEntry());
delete pet;
return NULL;
}
pet->GetCharmInfo()->SetPetNumber(sObjectMgr.GeneratePetNumber(), true);
// this enables pet details window (Shift+P)
pet->AIM_Initialize();
pet->InitPetCreateSpells();
pet->InitLevelupSpellsForLevel();
pet->InitTalentForLevel();
pet->SetHealth(pet->GetMaxHealth());
return pet;
}
void Unit::RemoveAurasAtMechanicImmunity(uint32 mechMask, uint32 exceptSpellId, bool non_positive /*= false*/)
{
Unit::SpellAuraHolderMap& auras = GetSpellAuraHolderMap();