diff options
Diffstat (limited to 'src/game/Object.cpp')
-rw-r--r-- | src/game/Object.cpp | 122 |
1 files changed, 85 insertions, 37 deletions
diff --git a/src/game/Object.cpp b/src/game/Object.cpp index a9534723354..272de775195 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1103,12 +1103,6 @@ WorldObject::WorldObject() m_isActive = false; } -WorldObject::~WorldObject() -{ - if(m_isActive && !isType(TYPEMASK_PLAYER) && IsInWorld()) - GetMap()->RemoveActiveObject(this); -} - void WorldObject::setActive(bool isActive) { // if already in the same activity state as we try to set, do nothing @@ -1125,20 +1119,6 @@ void WorldObject::setActive(bool isActive) } } -void WorldObject::AddToWorld() -{ - Object::AddToWorld(); - if(m_isActive && !isType(TYPEMASK_PLAYER)) - GetMap()->AddActiveObject(this); -} - -void WorldObject::RemoveFromWorld() -{ - if(m_isActive && IsInWorld() && !isType(TYPEMASK_PLAYER)) - GetMap()->RemoveActiveObject(this); - Object::RemoveFromWorld(); -} - void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid, uint32 phaseMask ) { Object::_Create(guidlow, 0, guidhigh); @@ -1615,42 +1595,110 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration) { - Pet* pCreature = new Pet(petType); + Pet* pet = new Pet(petType); + + if(petType == SUMMON_PET && pet->LoadPetFromDB(this, entry)) + { + // Remove Demonic Sacrifice auras (known pet) + Unit::AuraList const& auraClassScripts = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for(Unit::AuraList::const_iterator itr = auraClassScripts.begin();itr!=auraClassScripts.end();) + { + if((*itr)->GetModifier()->m_miscvalue==2228) + { + RemoveAurasDueToSpell((*itr)->GetId()); + itr = auraClassScripts.begin(); + } + else + ++itr; + } + + if(duration > 0) + pet->SetDuration(duration); + + return NULL; + } + + // petentry==0 for hunter "call pet" (current pet summoned if any) + if(!entry) + { + delete pet; + return NULL; + } Map *map = GetMap(); uint32 pet_number = objmgr.GeneratePetNumber(); - if(!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map, GetPhaseMask(), entry, pet_number)) + if(!pet->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map, GetPhaseMask(), entry, pet_number)) { sLog.outError("no such creature entry %u", entry); - delete pCreature; + delete pet; return NULL; } - pCreature->Relocate(x, y, z, ang); + pet->Relocate(x, y, z, ang); - if(!pCreature->IsPositionValid()) + if(!pet->IsPositionValid()) { - sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); - delete pCreature; + sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",pet->GetGUIDLow(),pet->GetEntry(),pet->GetPositionX(),pet->GetPositionY()); + delete pet; return NULL; } - if(duration > 0) - pCreature->SetDuration(duration); + pet->SetOwnerGUID(GetGUID()); + pet->SetCreatorGUID(GetGUID()); + pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction()); + + // this enables pet details window (Shift+P) + pet->GetCharmInfo()->SetPetNumber(pet_number, false); + + pet->AIM_Initialize(); - pCreature->SetOwnerGUID(GetGUID()); - pCreature->SetCreatorGUID(GetGUID()); - pCreature->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction()); + map->Add((Creature*)pet); - pCreature->GetCharmInfo()->SetPetNumber(pet_number, false); + pet->setPowerType(POWER_MANA); + pet->SetUInt32Value(UNIT_NPC_FLAGS , 0); + pet->SetUInt32Value(UNIT_FIELD_BYTES_1,0); + pet->InitStatsForLevel(getLevel()); - pCreature->AIM_Initialize(); + switch(petType) + { + case GUARDIAN_PET: + case POSSESSED_PET: + pet->SetUInt32Value(UNIT_FIELD_FLAGS,0); + AddGuardian(pet); + break; + case SUMMON_PET: + pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048); + pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); + pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); + pet->SetHealth(pet->GetMaxHealth()); + pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA)); + pet->InitPetCreateSpells(); + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + SetPet(pet); + PetSpellInitialize(); + break; + } - map->Add((Creature*)pCreature); + if(petType == SUMMON_PET) + { + // Remove Demonic Sacrifice auras (known pet) + Unit::AuraList const& auraClassScripts = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for(Unit::AuraList::const_iterator itr = auraClassScripts.begin();itr!=auraClassScripts.end();) + { + if((*itr)->GetModifier()->m_miscvalue==2228) + { + RemoveAurasDueToSpell((*itr)->GetId()); + itr = auraClassScripts.begin(); + } + else + ++itr; + } + } - AddGuardian(pCreature); + if(duration > 0) + pet->SetDuration(duration); - return pCreature; + return pet; } GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime) |