mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[2008_10_31_01_mangos_creature_template.sql] Creature related code and DB cleanups.
* Rename 2 creature_template fields to more clean names and related code update also. * Use enum values instead raw values for type_flags, use halper functions instead code repeating. * Move tamed pet creating code to new function.
This commit is contained in:
parent
c7ac8577ae
commit
41b876b395
11 changed files with 103 additions and 76 deletions
|
|
@ -10817,3 +10817,34 @@ void Unit::RemovePetAura(PetAura const* petSpell)
|
|||
if(Pet* pet = GetPet())
|
||||
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->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, this->GetGUID());
|
||||
pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, this->GetGUID());
|
||||
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,this->getFaction());
|
||||
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);
|
||||
|
||||
if(!pet->InitStatsForLevel(creatureTarget->getLevel()))
|
||||
{
|
||||
sLog.outError("ERROR: Pet::InitStatsForLevel() failed for creature (Entry: %u)!",creatureTarget->GetEntry());
|
||||
delete pet;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pet->GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true);
|
||||
// this enables pet details window (Shift+P)
|
||||
pet->AIM_Initialize();
|
||||
pet->InitPetCreateSpells();
|
||||
pet->SetHealth(pet->GetMaxHealth());
|
||||
|
||||
return pet;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue