diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/BattleGround.cpp | 2 | ||||
-rw-r--r-- | src/game/Level2.cpp | 4 | ||||
-rw-r--r-- | src/game/Level3.cpp | 7 | ||||
-rw-r--r-- | src/game/Map.cpp | 2 | ||||
-rw-r--r-- | src/game/Object.cpp | 2 | ||||
-rw-r--r-- | src/game/Pet.cpp | 56 | ||||
-rw-r--r-- | src/game/Pet.h | 3 | ||||
-rw-r--r-- | src/game/PetHandler.cpp | 8 | ||||
-rw-r--r-- | src/game/Player.cpp | 25 | ||||
-rw-r--r-- | src/game/Player.h | 1 | ||||
-rw-r--r-- | src/game/Spell.cpp | 25 | ||||
-rw-r--r-- | src/game/SpellAuras.cpp | 21 | ||||
-rw-r--r-- | src/game/SpellEffects.cpp | 26 | ||||
-rw-r--r-- | src/game/SpellHandler.cpp | 9 | ||||
-rw-r--r-- | src/game/TemporarySummon.cpp | 25 | ||||
-rw-r--r-- | src/game/Totem.cpp | 6 | ||||
-rw-r--r-- | src/game/Unit.cpp | 200 | ||||
-rw-r--r-- | src/game/Unit.h | 20 |
18 files changed, 260 insertions, 182 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 004a3bfd730..4dbd1ae5a3b 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -955,7 +955,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac bgTypeId=BATTLEGROUND_AA; // set the bg type to all arenas (it will be used for queue refreshing) // summon old pet if there was one and there isn't a current pet - if(!plr->GetPet() && plr->GetTemporaryUnsummonedPetNumber()) + if(!plr->GetGuardianPet() && plr->GetTemporaryUnsummonedPetNumber()) { Pet* NewPet = new Pet(plr); if(!NewPet->LoadPetFromDB(plr, 0, (plr)->GetTemporaryUnsummonedPetNumber(), true)) diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index c4a716c951e..a6aca23f80c 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1839,7 +1839,7 @@ bool ChatHandler::HandleNpcTameCommand(const char* /*args*/) pet->SetUInt32Value(UNIT_FIELD_LEVEL, level); // caster have pet now - player->SetPet(pet, true); + player->SetGuardian(pet, true); pet->SavePetToDB(PET_SAVE_AS_CURRENT); player->PetSpellInitialize(); @@ -4377,7 +4377,7 @@ bool ChatHandler::HandleCreatePetCommand(const char* args) // visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()); - player->SetPet(pet, true); + player->SetGuardian(pet, true); pet->SavePetToDB(PET_SAVE_AS_CURRENT); player->PetSpellInitialize(); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 4677610927a..d3aa1d1a070 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -5081,11 +5081,12 @@ bool ChatHandler::HandleResetLevelCommand(const char * args) player->SetUInt32Value(PLAYER_XP,0); // reset level to summoned pet - Pet* pet = player->GetPet(); - if(pet && pet->getPetType()==SUMMON_PET) + Guardian* pet = player->GetGuardianPet(); + if(pet) { pet->InitStatsForLevel(1); - pet->InitTalentForLevel(); + if(pet->isPet()) + ((Pet*)pet)->InitTalentForLevel(); } return true; } diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 0d31be8aa98..6a8bc788e55 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -488,7 +488,7 @@ Map::Add(T *obj) DEBUG_LOG("Object %u enters grid[%u,%u]", GUID_LOPART(obj->GetGUID()), cell.GridX(), cell.GridY()); - UpdateObjectVisibility(obj,cell,p); + //UpdateObjectVisibility(obj,cell,p); AddNotifier(obj); } diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 20b2cf9eb12..b1523072548 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1831,7 +1831,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy pet->SetUInt32Value(UNIT_FIELD_BYTES_1,0); pet->InitStatsForLevel(getLevel()); - SetPet(pet, true); + SetGuardian(pet, true); switch(petType) { diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 91630eda9a4..13dc8d8342a 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -42,7 +42,7 @@ char const* petTypeSuffix[MAX_PET_TYPE] = Pet::Pet(Player *owner, PetType type) : Guardian(NULL, owner), m_petType(type), m_removed(false), m_happinessTimer(7500), m_duration(0), m_resetTalentsCost(0), m_resetTalentsTime(0), m_usedTalentCount(0), m_auraRaidUpdateMask(0), m_loading(false), -m_declinedname(NULL) +m_declinedname(NULL), m_owner(owner) { m_summonMask |= SUMMON_MASK_PET; m_name = "Pet"; @@ -184,6 +184,10 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool SetUInt32Value(UNIT_NPC_FLAGS, 0); SetName(fields[9].GetString()); + AIM_Initialize(); + map->Add((Creature*)this); + owner->SetGuardian(this, true); + switch(getPetType()) { case SUMMON_PET: @@ -209,8 +213,6 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool sLog.outError("Pet have incorrect type (%u) for pet loading.", getPetType()); } - owner->SetPet(this, true); - InitStatsForLevel(petlevel); SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL)); SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, fields[5].GetUInt32()); @@ -281,19 +283,6 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool //load spells/cooldowns/auras SetCanModifyStats(true); - _LoadAuras(timediff); - - //init AB - if(is_temporary_summoned) - { - // Temporary summoned pets always have initial spell list at load - InitPetCreateSpells(); - } - else - { - LearnPetPassives(); - CastPetAuras(current); - } if(getPetType() == SUMMON_PET && !current) //all (?) summon pets come with full health when called, but not when they are current { @@ -307,22 +296,19 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool } // Spells should be loaded after pet is added to map, because in CheckCast is check on it + _LoadAuras(timediff); _LoadSpells(); _LoadSpellCooldowns(); + LearnPetPassives(); + CastPetAuras(current); sLog.outDebug("New Pet has guid %u", GetGUIDLow()); - AIM_Initialize(); - map->Add((Creature*)this); - - if(owner->GetTypeId() == TYPEID_PLAYER) - { - ((Player*)owner)->PetSpellInitialize(); - if(((Player*)owner)->GetGroup()) - ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_PET); - } + owner->PetSpellInitialize(); + if(owner->GetGroup()) + owner->SetGroupUpdateFlag(GROUP_UPDATE_PET); - if(owner->GetTypeId() == TYPEID_PLAYER && getPetType() == HUNTER_PET) + if(getPetType() == HUNTER_PET) { result = CharacterDatabase.PQuery("SELECT genitive, dative, accusative, instrumental, prepositional FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", owner->GetGUIDLow(), GetCharmInfo()->GetPetNumber()); @@ -511,7 +497,7 @@ void Pet::Update(uint32 diff) case ALIVE: { // unsummon pet that lost owner - Unit* owner = GetOwner(); + Player* owner = GetOwner(); if(!owner || (!IsWithinDistInMap(owner, OWNER_MAX_DISTANCE) && !isPossessed()) || isControlled() && !owner->GetPetGUID()) //if(!owner || (!IsWithinDistInMap(owner, OWNER_MAX_DISTANCE) && (owner->GetCharmGUID() && (owner->GetCharmGUID() != GetGUID()))) || (isControlled() && !owner->GetPetGUID())) { @@ -523,6 +509,7 @@ void Pet::Update(uint32 diff) { if( owner->GetPetGUID() != GetGUID() ) { + sLog.outError("Pet %u is not pet of owner %u, removed", GetEntry(), m_owner->GetName()); Remove(getPetType()==HUNTER_PET?PET_SAVE_AS_DELETED:PET_SAVE_NOT_IN_SLOT); return; } @@ -644,20 +631,7 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid) void Pet::Remove(PetSaveMode mode, bool returnreagent) { - if(Unit* owner = GetOwner()) - { - if(owner->GetTypeId()==TYPEID_PLAYER) - { - ((Player*)owner)->RemovePet(this,mode,returnreagent); - return; - } - - owner->SetPet(this, false); - } - - CleanupsBeforeDelete(); - AddObjectToRemoveList(); - m_removed = true; + m_owner->RemovePet(this,mode,returnreagent); } void Pet::GivePetXP(uint32 xp) diff --git a/src/game/Pet.h b/src/game/Pet.h index 184584979f1..845ac089b71 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -218,7 +218,10 @@ class Pet : public Guardian DeclinedName const* GetDeclinedNames() const { return m_declinedname; } bool m_removed; // prevent overwrite pet state in DB at next Pet::Update if pet already removed(saved) + + Player *GetOwner() { return m_owner; } protected: + Player *m_owner; uint32 m_happinessTimer; PetType m_petType; int32 m_duration; // time until unsummon (used mostly for summoned guardians and not used for controlled pets) diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index ae12bce690b..79788d7a234 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -545,7 +545,7 @@ void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ) uint8 state; //1 for on, 0 for off recvPacket >> guid >> spellid >> spellid2 >> state; - if(!_player->GetPet() && !_player->GetCharm()) + if(!_player->GetGuardianPet() && !_player->GetCharm()) return; if(ObjectAccessor::FindPlayer(guid)) @@ -553,7 +553,7 @@ void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ) Creature* pet=ObjectAccessor::GetCreatureOrPetOrVehicle(*_player,guid); - if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm())) + if(!pet || (pet != _player->GetGuardianPet() && pet != _player->GetCharm())) { sLog.outError( "HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); return; @@ -598,12 +598,12 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) sLog.outDebug("WORLD: CMSG_PET_CAST_SPELL, cast_count: %u, spellid %u, unk_flags %u", cast_count, spellid, unk_flags); // This opcode is also sent from charmed and possessed units (players and creatures) - if(!_player->GetPet() && !_player->GetCharm()) + if(!_player->GetGuardianPet() && !_player->GetCharm()) return; Unit* caster = ObjectAccessor::GetUnit(*_player, guid); - if(!caster || (caster != _player->GetPet() && caster != _player->GetCharm())) + if(!caster || (caster != _player->GetGuardianPet() && caster != _player->GetCharm())) { sLog.outError( "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); return; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 20fc71d08bb..cb63810fbd3 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -16478,11 +16478,31 @@ void Player::UpdateDuelFlag(time_t currTime) duel->opponent->duel->startTime = currTime; } +Pet* Player::GetPet() const +{ + if(uint64 pet_guid = GetPetGUID()) + { + if(!IS_PET_GUID(pet_guid)) + return NULL; + + if(Pet* pet = ObjectAccessor::GetPet(pet_guid)) + return pet; + + sLog.outError("Player::GetPet: Pet %u not exist.",GUID_LOPART(pet_guid)); + const_cast<Player*>(this)->SetPetGUID(0); + } + + return NULL; +} + void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) { if(!pet) pet = GetPet(); + if(pet) + sLog.outDebug("RemovePet %u, %u, %u", pet->GetEntry(), mode, returnreagent); + if(returnreagent && (pet || m_temporaryUnsummonedPetNumber)) { //returning of reagents only for players, so best done here @@ -16536,7 +16556,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) case POSSESSED_PET: pet->RemoveCharmedOrPossessedBy(NULL); default: - SetPet(pet, false); + SetGuardian(pet, false); break; } @@ -19731,6 +19751,9 @@ void Player::InitGlyphsForLevel() void Player::EnterVehicle(Vehicle *vehicle) { + if(vehicle->GetCharmerGUID()) + return; + VehicleEntry const *ve = sVehicleStore.LookupEntry(vehicle->GetVehicleId()); if(!ve) return; diff --git a/src/game/Player.h b/src/game/Player.h index 5a3d943b797..74389247a9f 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -957,6 +957,7 @@ class TRINITY_DLL_SPEC Player : public Unit int GetTimeInnEnter() const { return time_inn_enter; }; void UpdateInnerTime (int time) { time_inn_enter = time; }; + Pet* GetPet() const; Pet* SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime); void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false); uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index fd362f56200..04589a759c5 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -573,7 +573,7 @@ void Spell::FillTargetMap() tmpUnitMap.push_back(m_caster); break; case SPELL_EFFECT_LEARN_PET_SPELL: - if(Pet* pet = m_caster->GetPet()) + if(Guardian* pet = m_caster->GetGuardianPet()) tmpUnitMap.push_back(pet); break; /*case SPELL_EFFECT_ENCHANT_ITEM: @@ -1539,7 +1539,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap) TagUnitMap.push_back(owner); break; case TARGET_UNIT_PET: - if(Pet* pet = m_caster->GetPet()) + if(Guardian* pet = m_caster->GetGuardianPet()) TagUnitMap.push_back(pet); break; case TARGET_UNIT_PARTY_CASTER: @@ -1566,7 +1566,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap) switch(cur) { case TARGET_UNIT_MINIPET: - if(target->GetGUID() == m_caster->m_TotemSlot[4]) + if(target->GetGUID() == m_caster->m_SummonSlot[4]) TagUnitMap.push_back(target); break; case TARGET_UNIT_TARGET_ALLY: @@ -2040,7 +2040,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap) ownerOrSelf->getPowerType() == POWER_MANA) TagUnitMap.push_back(ownerOrSelf); - if(Pet* pet = ownerOrSelf->GetPet()) + if(Pet* pet = ownerOrSelf->GetGuardianPet()) if( m_caster->IsWithinDistInMap(pet, radius) && pet->getPowerType() == POWER_MANA ) TagUnitMap.push_back(pet); } @@ -3690,7 +3690,7 @@ SpellCastResult Spell::CheckCast(bool strict) { if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_PET) { - target = m_caster->GetPet(); + target = m_caster->GetGuardianPet(); if(!target) { if(m_triggeredByAuraSpell) // not report pet not existence for triggered spells @@ -3998,10 +3998,13 @@ SpellCastResult Spell::CheckCast(bool strict) } case SPELL_EFFECT_LEARN_SPELL: { + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return SPELL_FAILED_BAD_TARGETS; + if(m_spellInfo->EffectImplicitTargetA[i] != TARGET_PET) break; - Pet* pet = m_caster->GetPet(); + Pet* pet = ((Player*)m_caster)->GetPet(); if(!pet) return SPELL_FAILED_NO_PET; @@ -4018,8 +4021,10 @@ SpellCastResult Spell::CheckCast(bool strict) } case SPELL_EFFECT_LEARN_PET_SPELL: { - Pet* pet = m_caster->GetPet(); + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return SPELL_FAILED_BAD_TARGETS; + Pet* pet = ((Player*)m_caster)->GetPet(); if(!pet) return SPELL_FAILED_NO_PET; @@ -4042,7 +4047,7 @@ SpellCastResult Spell::CheckCast(bool strict) if(!foodItem) return SPELL_FAILED_BAD_TARGETS; - Pet* pet = m_caster->GetPet(); + Pet* pet = ((Player*)m_caster)->GetPet(); if(!pet) return SPELL_FAILED_NO_PET; @@ -4155,7 +4160,7 @@ SpellCastResult Spell::CheckCast(bool strict) } case SPELL_EFFECT_SUMMON_DEAD_PET: { - Creature *pet = m_caster->GetPet(); + Creature *pet = m_caster->GetGuardianPet(); if(!pet) return SPELL_FAILED_NO_PET; @@ -4215,7 +4220,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_caster->GetTypeId()==TYPEID_PLAYER && m_caster->getClass()==CLASS_WARLOCK) { if (strict) //starting cast, trigger pet stun (cast by pet so it doesn't attack player) - if(Pet* pet = m_caster->GetPet()) + if(Pet* pet = ((Player*)m_caster)->GetPet()) pet->CastSpell(pet, 32752, true, NULL, NULL, pet->GetGUID()); } else diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 54c05ce10a5..018d72a265a 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -1825,9 +1825,9 @@ void Aura::TriggerSpell() case 38443: { bool all = true; - for(int i = 0; i < MAX_TOTEM; ++i) + for(int i = SUMMON_SLOT_TOTEM; i < MAX_TOTEM_SLOT; ++i) { - if(!caster->m_TotemSlot[i]) + if(!caster->m_SummonSlot[i]) { all = false; break; @@ -1963,7 +1963,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) return; case 34026: // kill command { - Unit * pet = m_target->GetPet(); + Unit * pet = m_target->GetGuardianPet(); if (!pet) return; @@ -2388,7 +2388,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { if (apply) { - uint64 guid = caster->m_TotemSlot[3]; + uint64 guid = caster->m_SummonSlot[3]; if (guid) { Creature *totem = ObjectAccessor::GetCreature(*caster, guid); @@ -3122,7 +3122,7 @@ void Aura::HandleModPossessPet(bool apply, bool Real) if(!caster || caster->GetTypeId() != TYPEID_PLAYER) return; - Pet *pet = caster->GetPet(); + Pet *pet = caster->GetGuardianPet(); if(!pet || pet != m_target) return; @@ -3154,8 +3154,11 @@ void Aura::HandleAuraModPetTalentsPoints(bool Apply, bool Real) if(!Real) return; + if(m_target->GetTypeId() != TYPEID_PLAYER) + return; + // Recalculate pet tlaent points - if (Pet *pet=m_target->GetPet()) + if (Pet *pet = ((Player*)m_target)->GetPet()) pet->InitTalentForLevel(); } @@ -4886,7 +4889,7 @@ void Aura::HandleModDamageDone(bool apply, bool Real) m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i,m_modifier.m_amount,apply); } } - Pet* pet = m_target->GetPet(); + Pet* pet = ((Player*)m_target)->GetPet(); if(pet) pet->UpdateAttackPowerAndDamage(); } @@ -6494,7 +6497,7 @@ void Aura::HandleAuraControlVehicle(bool apply, bool Real) if(m_target->GetTypeId() != TYPEID_PLAYER) return; - if(Pet *pet = m_target->GetPet()) + if(Pet *pet = ((Player*)m_target)->GetPet()) pet->Remove(PET_SAVE_AS_CURRENT); //WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0); @@ -6625,7 +6628,7 @@ void Aura::HandleModPossessPet(bool apply, bool Real) if(apply) { - if(caster->GetPet() != m_target) + if(caster->GetGuardianPet() != m_target) return; m_target->SetCharmedOrPossessedBy(caster, true); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 7ffe629b26a..bf9a9d261fe 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -2098,7 +2098,7 @@ void Spell::EffectTriggerSpell(uint32 i) // Priest Shadowfiend (34433) need apply mana gain trigger aura on pet case 41967: { - if (Unit *pet = m_caster->GetPet()) + if (Unit *pet = m_caster->GetGuardianPet()) pet->CastSpell(pet, 28305, true); return; } @@ -3946,7 +3946,7 @@ void Spell::EffectTameCreature(uint32 /*i*/) pet->SetUInt32Value(UNIT_FIELD_LEVEL, level); // caster have pet now - m_caster->SetPet(pet, true); + m_caster->SetGuardian(pet, true); if(m_caster->GetTypeId() == TYPEID_PLAYER) { @@ -5442,7 +5442,7 @@ void Spell::EffectDismissPet(uint32 /*i*/) if(m_caster->GetTypeId() != TYPEID_PLAYER) return; - Pet* pet = m_caster->GetPet(); + Pet* pet = ((Player*)m_caster)->GetPet(); // not let dismiss dead pet if(!pet||!pet->isAlive()) @@ -5948,12 +5948,12 @@ void Spell::EffectSummonDeadPet(uint32 /*i*/) void Spell::EffectDestroyAllTotems(uint32 /*i*/) { float mana = 0; - for(int slot = 0; slot < MAX_TOTEM; ++slot) + for(int slot = SUMMON_SLOT_TOTEM; slot < MAX_TOTEM_SLOT; ++slot) { - if(!m_caster->m_TotemSlot[slot]) + if(!m_caster->m_SummonSlot[slot]) continue; - Creature* totem = ObjectAccessor::GetCreature(*m_caster,m_caster->m_TotemSlot[slot]); + Creature* totem = ObjectAccessor::GetCreature(*m_caster,m_caster->m_SummonSlot[slot]); if(totem && totem->isTotem()) { uint32 spell_id = totem->GetUInt32Value(UNIT_CREATED_BY_SPELL); @@ -6401,11 +6401,11 @@ void Spell::EffectRedirectThreat(uint32 /*i*/) void Spell::SummonTotem(uint32 entry, SummonPropertiesEntry const *properties) { - int8 slot = (int8)properties->Slot - 1; + int8 slot = (int8)properties->Slot; - if(slot >= 0 && slot < MAX_TOTEM) + if(slot >= SUMMON_SLOT_TOTEM && slot < MAX_TOTEM_SLOT) { - uint64 guid = m_caster->m_TotemSlot[slot]; + uint64 guid = m_caster->m_SummonSlot[slot]; if(guid != 0) { Creature *OldTotem = ObjectAccessor::GetCreature(*m_caster, guid); @@ -6436,8 +6436,8 @@ void Spell::SummonTotem(uint32 entry, SummonPropertiesEntry const *properties) pTotem->Relocate(x, y, z, m_caster->GetOrientation()); - if(slot >= 0 && slot < MAX_TOTEM) - m_caster->m_TotemSlot[slot] = pTotem->GetGUID(); + if(slot >= SUMMON_SLOT_TOTEM && slot < MAX_TOTEM_SLOT) + m_caster->m_SummonSlot[slot] = pTotem->GetGUID(); pTotem->SetOwner(m_caster->GetGUID()); pTotem->SetTypeBySummonSpell(m_spellInfo); // must be after Create call where m_spells initilized @@ -6460,10 +6460,10 @@ void Spell::SummonTotem(uint32 entry, SummonPropertiesEntry const *properties) pTotem->Summon(m_caster); - if(slot >= 0 && slot < MAX_TOTEM && m_caster->GetTypeId() == TYPEID_PLAYER) + if(slot >= SUMMON_SLOT_TOTEM && slot < MAX_TOTEM_SLOT && m_caster->GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_TOTEM_CREATED, 1+8+4+4); - data << uint8(slot); + data << uint8(slot-1); data << uint64(pTotem->GetGUID()); data << uint32(duration); data << uint32(m_spellInfo->Id); diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 2fd5384d03e..c43bd1c45c9 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -369,7 +369,7 @@ void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket) return; } - if(pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm()) + if(pet != GetPlayer()->GetGuardianPet() && pet != GetPlayer()->GetCharm()) { sLog.outError( "HandlePetCancelAura.Pet %u isn't pet of player %s", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); return; @@ -417,13 +417,14 @@ void WorldSession::HandleTotemDestroy( WorldPacket& recvPacket) recvPacket >> slotId; - if (slotId >= MAX_TOTEM) + ++slotId; + if (slotId >= MAX_TOTEM_SLOT) return; - if(!_player->m_TotemSlot[slotId]) + if(!_player->m_SummonSlot[slotId]) return; - Creature* totem = ObjectAccessor::GetCreature(*_player,_player->m_TotemSlot[slotId]); + Creature* totem = ObjectAccessor::GetCreature(*_player,_player->m_SummonSlot[slotId]); // Don't unsummon sentry totem if(totem && totem->isTotem() && totem->GetEntry() != SENTRY_TOTEM_ENTRY) ((Totem*)totem)->UnSummon(); diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index 06dfea5a25a..fde2f4d7d84 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -182,16 +182,15 @@ void TempSummon::InitSummon(uint32 duration) Unit* owner = GetSummoner(); if(uint32 slot = m_Properties->Slot) { - --slot; if(owner) { - if(owner->m_TotemSlot[slot] && owner->m_TotemSlot[slot] != GetGUID()) + if(owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID()) { - Creature *OldTotem = ObjectAccessor::GetCreature(*this, owner->m_TotemSlot[slot]); + Creature *OldTotem = ObjectAccessor::GetCreature(*this, owner->m_SummonSlot[slot]); if(OldTotem && OldTotem->isSummon()) ((TempSummon*)OldTotem)->UnSummon(); } - owner->m_TotemSlot[slot] = GetGUID(); + owner->m_SummonSlot[slot] = GetGUID(); } } @@ -206,6 +205,8 @@ void TempSummon::SetTempSummonType(TempSummonType type) void TempSummon::UnSummon() { + assert(!isPet()); + Unit* owner = GetSummoner(); if(owner && owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->IsAIEnabled) ((Creature*)owner)->AI()->SummonedCreatureDespawn(this); @@ -225,12 +226,15 @@ void TempSummon::RemoveFromWorld() { if(Unit* owner = GetSummoner()) { - --slot; - if(owner->m_TotemSlot[slot] = GetGUID()) - owner->m_TotemSlot[slot] = 0; + if(owner->m_SummonSlot[slot] = GetGUID()) + owner->m_SummonSlot[slot] = 0; } } } + + if(GetOwnerGUID()) + sLog.outError("Unit %u has owner guid when removed from world", GetEntry()); + Creature::RemoveFromWorld(); } @@ -253,13 +257,14 @@ void Guardian::InitSummon(uint32 duration) SetCreatorGUID(m_owner->GetGUID()); setFaction(m_owner->getFaction()); - m_owner->SetPet(this, true); if(m_owner->GetTypeId() == TYPEID_PLAYER) { m_charmInfo->InitCharmCreateSpells(); - ((Player*)m_owner)->CharmSpellInitialize(); + //((Player*)m_owner)->CharmSpellInitialize(); } + + m_owner->SetGuardian(this, true); } void Guardian::RemoveFromWorld() @@ -267,7 +272,7 @@ void Guardian::RemoveFromWorld() if(!IsInWorld()) return; - m_owner->SetPet(this, false); + m_owner->SetGuardian(this, false); TempSummon::RemoveFromWorld(); } diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp index 266fe476012..df6c55dae82 100644 --- a/src/game/Totem.cpp +++ b/src/game/Totem.cpp @@ -111,11 +111,11 @@ void Totem::UnSummon() if (owner) { // clear owenr's totem slot - for(int i = 0; i < MAX_TOTEM; ++i) + for(int i = SUMMON_SLOT_TOTEM; i < MAX_TOTEM_SLOT; ++i) { - if(owner->m_TotemSlot[i]==GetGUID()) + if(owner->m_SummonSlot[i]==GetGUID()) { - owner->m_TotemSlot[i] = 0; + owner->m_SummonSlot[i] = 0; break; } } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index c7a5d45d285..53ee72a121e 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -107,7 +107,7 @@ Unit::Unit() m_addDmgOnce = 0; for(int i = 0; i < MAX_SUMMON_SLOT; ++i) - m_TotemSlot[i] = 0; + m_SummonSlot[i] = 0; m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0; //m_Aura = NULL; @@ -5685,7 +5685,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu // Fel Synergy if (dummySpell->SpellIconID == 3222) { - target = GetPet(); + target = GetGuardianPet(); if (!target) return false; triggered_spell_id = 54181; @@ -5714,7 +5714,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu if ((*i)->GetId()==54117 || (*i)->GetId()==54118) { basepoints0 = int32((*i)->GetModifier()->m_amount); - if (target = GetPet()) + if (target = GetGuardianPet()) { // regen mana for pet CastCustomSpell(target,54607,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); @@ -5755,7 +5755,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu // Pet Healing (Corruptor Raiment or Rift Stalker Armor) case 37381: { - target = GetPet(); + target = GetGuardianPet(); if(!target) return false; @@ -8187,23 +8187,15 @@ bool Unit::isAttackingPlayer() const if(hasUnitState(UNIT_STAT_ATTACK_PLAYER)) return true; - Pet* pet = GetPet(); - if(pet && pet->isAttackingPlayer()) - return true; - - Unit* charmed = GetCharm(); - if(charmed && charmed->isAttackingPlayer()) - return true; + for(ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) + if((*itr)->isAttackingPlayer()) + return true; - for (int8 i = 0; i < MAX_SUMMON_SLOT; ++i) - { - if(m_TotemSlot[i]) - { - Creature *totem = ObjectAccessor::GetCreature(*this, m_TotemSlot[i]); - if(totem && totem->isAttackingPlayer()) - return true; - } - } + for(int8 i = 0; i < MAX_SUMMON_SLOT; ++i) + if(m_SummonSlot[i]) + if(Creature *summon = ObjectAccessor::GetCreature(*this, m_SummonSlot[i])) + if(summon->isAttackingPlayer()) + return true; return false; } @@ -8262,18 +8254,16 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const return GetTypeId()==TYPEID_PLAYER ? (Player*)this : NULL; } -Pet* Unit::GetPet() const +Guardian* Unit::GetGuardianPet() const { if(uint64 pet_guid = GetPetGUID()) { - if(!IS_PET_GUID(pet_guid)) - return NULL; - - if(Pet* pet = ObjectAccessor::GetPet(pet_guid)) - return pet; + if(Creature* pet = ObjectAccessor::GetCreature(*this, pet_guid)) + if(pet->HasSummonMask(SUMMON_MASK_GUARDIAN)) + return (Guardian*)pet; - sLog.outError("Unit::GetPet: Pet %u not exist.",GUID_LOPART(pet_guid)); - //const_cast<Unit*>(this)->SetUInt64Value(UNIT_FIELD_SUMMON, 0); + sLog.outError("Player::GetPet: Pet %u not exist.",GUID_LOPART(pet_guid)); + const_cast<Unit*>(this)->SetPetGUID(0); } return NULL; @@ -8293,42 +8283,91 @@ Unit* Unit::GetCharm() const return NULL; } -void Unit::SetPet(Creature* pet, bool apply) +void Unit::SetGuardian(Guardian* guardian, bool apply) { + sLog.outDebug("SetGuardian %u for %u, apply %u", guardian->GetEntry(), GetEntry(), apply); + if(apply) { - if(!pet->AddUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID())) + if(!guardian->AddUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID())) { - sLog.outCrash("Pet %u is summoned by %u but it already has a owner", pet->GetEntry(), GetEntry()); + sLog.outCrash("Guardian %u is summoned by %u but it already has a owner", guardian->GetEntry(), GetEntry()); return; } - AddUInt64Value(UNIT_FIELD_SUMMON, pet->GetGUID()); - m_Controlled.insert(pet); + + m_Controlled.insert(guardian); + + if(guardian->isPet() || guardian->m_Properties && guardian->m_Properties->Category == SUMMON_CATEGORY_PET) + { + if(Guardian* oldPet = GetGuardianPet()) + { + if(oldPet != guardian && (oldPet->isPet() || guardian->isPet() || oldPet->GetEntry() != guardian->GetEntry())) + { + // remove existing guardian pet + if(oldPet->isPet()) + ((Pet*)oldPet)->Remove(PET_SAVE_AS_CURRENT); + else + oldPet->UnSummon(); + SetPetGUID(guardian->GetGUID()); + SetGuardianGUID(0); + } + } + else + { + SetPetGUID(guardian->GetGUID()); + SetGuardianGUID(0); + } + } + + if(AddUInt64Value(UNIT_FIELD_SUMMON, guardian->GetGUID())) + { + if(GetTypeId() == TYPEID_PLAYER) + { + if(guardian->isPet()) + ((Player*)this)->PetSpellInitialize(); + else + ((Player*)this)->CharmSpellInitialize(); + } + } // FIXME: hack, speed must be set only at follow - if(GetTypeId() == TYPEID_PLAYER && pet->HasSummonMask(SUMMON_MASK_PET)) + if(GetTypeId() == TYPEID_PLAYER && guardian->HasSummonMask(SUMMON_MASK_PET)) for(int i = 0; i < MAX_MOVE_TYPE; ++i) - pet->SetSpeed(UnitMoveType(i), m_speed_rate[i], true); + guardian->SetSpeed(UnitMoveType(i), m_speed_rate[i], true); } else { - if(!pet->RemoveUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID())) + if(!guardian->RemoveUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID())) { - sLog.outCrash("Pet %u is unsummoned by %u but it has another owner", pet->GetEntry(), GetEntry()); + sLog.outCrash("Pet %u is unsummoned by %u but it has another owner", guardian->GetEntry(), GetEntry()); return; } - m_Controlled.erase(pet); - if(RemoveUInt64Value(UNIT_FIELD_SUMMON, pet->GetGUID())) + m_Controlled.erase(guardian); + + if(guardian->isPet() || guardian->m_Properties && guardian->m_Properties->Category == SUMMON_CATEGORY_PET) { - //Check if there is other pet (guardian actually) + if(GetPetGUID() == guardian->GetGUID()) + SetPetGUID(0); + } + + if(RemoveUInt64Value(UNIT_FIELD_SUMMON, guardian->GetGUID())) + { + //Check if there is another guardian for(ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) { - if((*itr)->GetOwnerGUID() == GetGUID()) + assert((*itr)->GetOwnerGUID() == GetGUID()); + if(AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID())) { - AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID()); - break; + if(GetTypeId() == TYPEID_PLAYER) + { + if(guardian->isPet()) + ((Player*)this)->PetSpellInitialize(); + else + ((Player*)this)->CharmSpellInitialize(); + } } + break; } } } @@ -8366,10 +8405,11 @@ void Unit::SetCharm(Unit* charm, bool apply) Unit* Unit::GetFirstControlled() const { + //Sequence: charmed, pet, other guardians Unit *unit = GetCharm(); if(!unit) { - if(uint64 guid = GetPetGUID()) + if(uint64 guid = GetUInt64Value(UNIT_FIELD_SUMMON)) unit = ObjectAccessor::GetUnit(*this, guid); } return unit; @@ -8386,20 +8426,20 @@ void Unit::RemoveAllControlled() //TODO: possessed and vehicle target->RemoveCharmAuras(); } - else if(target->GetOwnerGUID() == GetGUID()) + else if(target->GetOwnerGUID() == GetGUID() + && target->GetTypeId() == TYPEID_UNIT + && ((Creature*)target)->HasSummonMask(SUMMON_MASK_SUMMON)) { - if(target->GetTypeId() == TYPEID_UNIT) - { - if(((Creature*)target)->HasSummonMask(SUMMON_MASK_SUMMON)) - ((TempSummon*)target)->UnSummon(); - } + + if(!((TempSummon*)target)->isPet()) + ((TempSummon*)target)->UnSummon(); } else { sLog.outError("Unit %u is trying to release unit %u which is neither charmed nor owned by it", GetEntry(), target->GetEntry()); } } - if(GetPetGUID()) + if(GetPetGUID() != GetUInt64Value(UNIT_FIELD_SUMMON)) sLog.outCrash("Unit %u is not able to release its summon %u", GetEntry(), GetPetGUID()); if(GetCharmGUID()) sLog.outCrash("Unit %u is not able to release its charm %u", GetEntry(), GetCharmGUID()); @@ -8423,7 +8463,7 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) // We are pet now, return owner if(player!=this) return IsWithinDistInMap(player, radius) ? player : NULL; - Unit * pet = GetPet(); + Unit * pet = GetGuardianPet(); //No pet, no group, nothing to return if (!pet) return NULL; @@ -8445,7 +8485,7 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) nearMembers.push_back(Target); // Push player's pet to vector - Unit * pet = Target->GetPet(); + Unit * pet = Target->GetGuardianPet(); if (pet && pet !=this && pet->isAlive() && IsWithinDistInMap(pet, radius) && !IsHostileTo(pet) ) nearMembers.push_back(pet); @@ -8496,10 +8536,10 @@ void Unit::UnsummonAllTotems() { for (int8 i = 0; i < MAX_SUMMON_SLOT; ++i) { - if(!m_TotemSlot[i]) + if(!m_SummonSlot[i]) continue; - Creature *OldTotem = ObjectAccessor::GetCreature(*this, m_TotemSlot[i]); + Creature *OldTotem = ObjectAccessor::GetCreature(*this, m_SummonSlot[i]); if(OldTotem && OldTotem->isSummon()) ((TempSummon*)OldTotem)->UnSummon(); } @@ -9720,7 +9760,7 @@ void Unit::Mount(uint32 mount) // unsummon pet if(GetTypeId() == TYPEID_PLAYER) { - Pet* pet = GetPet(); + Pet* pet = ((Player*)this)->GetPet(); if(pet) { if(pet->isControlled()) @@ -10250,6 +10290,10 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) // register forced speed changes for WorldSession::HandleForceSpeedChangeAck // and do it only for real sent packets and use run for run/mounted as client expected ++((Player*)this)->m_forced_speed_changes[mtype]; + + if(!isInCombat()) + if(Pet* pet = ((Player*)this)->GetPet()) + pet->SetSpeed(mtype, m_speed_rate[mtype], forced); } switch(mtype) @@ -10292,9 +10336,6 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) data << float(GetSpeed(mtype)); SendMessageToSet( &data, true ); } - if(GetPetGUID() && !isInCombat()) - if(Pet* pet = GetPet()) - pet->SetSpeed(mtype, m_speed_rate[mtype], forced); } void Unit::SetHover(bool on) @@ -11282,11 +11323,10 @@ void Unit::RemoveFromWorld() RemoveCharmAuras(); RemoveBindSightAuras(); RemoveNotOwnSingleTargetAuras(); - // if it has charmer or owner, it must be in someone's controllist and server will crash - /*if(GetCharmerGUID()) - sLog.outError("Unit %u has charmer guid when removed from world", GetEntry()); - if(GetOwnerGUID()); - sLog.outError("Unit %u has owner guid when removed from world", GetEntry());*/ + + if(GetCharmerGUID()) + sLog.outCrash("Unit %u has charmer guid when removed from world", GetEntry()); + WorldObject::RemoveFromWorld(); } } @@ -12446,15 +12486,21 @@ void Unit::SetContestedPvP(Player *attackedPlayer) void Unit::AddPetAura(PetAura const* petSpell) { + if(GetTypeId() != TYPEID_PLAYER) + return; + m_petAuras.insert(petSpell); - if(Pet* pet = GetPet()) + if(Pet* pet = ((Player*)this)->GetPet()) pet->CastPetAura(petSpell); } void Unit::RemovePetAura(PetAura const* petSpell) { + if(GetTypeId() != TYPEID_PLAYER) + return; + m_petAuras.erase(petSpell); - if(Pet* pet = GetPet()) + if(Pet* pet = ((Player*)this)->GetPet()) pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry())); } @@ -13324,7 +13370,7 @@ void Unit::GetRaidMember(std::list<Unit*> &nearMembers, float radius) if(Target->isAlive() && IsWithinDistInMap(Target, radius) ) nearMembers.push_back(Target); - if(Pet* pet = Target->GetPet()) + if(Guardian* pet = Target->GetGuardianPet()) if(pet->isAlive() && IsWithinDistInMap(pet, radius) ) nearMembers.push_back(pet); } @@ -13334,7 +13380,7 @@ void Unit::GetRaidMember(std::list<Unit*> &nearMembers, float radius) { if(owner->isAlive() && (owner == this || IsWithinDistInMap(owner, radius))) nearMembers.push_back(owner); - if(Pet* pet = owner->GetPet()) + if(Guardian* pet = owner->GetGuardianPet()) if(pet->isAlive() && (pet == this && IsWithinDistInMap(pet, radius))) nearMembers.push_back(pet); } @@ -13361,7 +13407,7 @@ void Unit::GetPartyMember(std::list<Unit*> &TagUnitMap, float radius) if(Target->isAlive() && IsWithinDistInMap(Target, radius) ) TagUnitMap.push_back(Target); - if(Pet* pet = Target->GetPet()) + if(Guardian* pet = Target->GetGuardianPet()) if(pet->isAlive() && IsWithinDistInMap(pet, radius) ) TagUnitMap.push_back(pet); } @@ -13371,7 +13417,7 @@ void Unit::GetPartyMember(std::list<Unit*> &TagUnitMap, float radius) { if(owner->isAlive() && (owner == this || IsWithinDistInMap(owner, radius))) TagUnitMap.push_back(owner); - if(Pet* pet = owner->GetPet()) + if(Guardian* pet = owner->GetGuardianPet()) if(pet->isAlive() && (pet == this && IsWithinDistInMap(pet, radius))) TagUnitMap.push_back(pet); } @@ -13524,9 +13570,17 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) { WorldObject::SetPhaseMask(newPhaseMask,update); - if(IsInWorld()) - if(Pet* pet = GetPet()) - pet->SetPhaseMask(newPhaseMask,true); + if(!IsInWorld()) + return; + + for(ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) + if((*itr)->GetOwnerGUID() == GetGUID()) + (*itr)->SetPhaseMask(newPhaseMask,true); + + for(int8 i = 0; i < MAX_SUMMON_SLOT; ++i) + if(m_SummonSlot[i]) + if(Creature *summon = ObjectAccessor::GetCreature(*this, m_SummonSlot[i])) + summon->SetPhaseMask(newPhaseMask,true); } void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool casting /*= false*/ ) diff --git a/src/game/Unit.h b/src/game/Unit.h index b8d58110352..e2952647b6e 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -294,6 +294,7 @@ class Item; class Pet; class Path; class PetAura; +class Guardian; struct SpellImmune { @@ -826,8 +827,12 @@ enum ReactiveType }; #define MAX_REACTIVE 3 -#define MAX_TOTEM 4 -#define MAX_SUMMON_SLOT 6 +#define SUMMON_SLOT_PET 0 +#define SUMMON_SLOT_TOTEM 1 +#define MAX_TOTEM_SLOT 5 +#define SUMMON_SLOT_MINIPET 5 +#define SUMMON_SLOT_QUEST 6 +#define MAX_SUMMON_SLOT 7 struct AuraSlotEntry { @@ -1171,10 +1176,13 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void SetOwnerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_SUMMONEDBY, owner); } uint64 GetCreatorGUID() const { return GetUInt64Value(UNIT_FIELD_CREATEDBY); } void SetCreatorGUID(uint64 creator) { SetUInt64Value(UNIT_FIELD_CREATEDBY, creator); } - uint64 GetPetGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON); } + uint64 GetGuardianGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON); } + void SetGuardianGUID(uint64 guid) { SetUInt64Value(UNIT_FIELD_SUMMON, guid); } uint64 GetCharmerGUID() const { return GetUInt64Value(UNIT_FIELD_CHARMEDBY); } void SetCharmerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_CHARMEDBY, owner); } uint64 GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM); } + void SetPetGUID(uint64 guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; } + uint64 GetPetGUID() const { return m_SummonSlot[SUMMON_SLOT_PET]; } uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); } uint64 GetCharmerOrOwnerOrOwnGUID() const @@ -1188,7 +1196,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject Player* GetSpellModOwner() const; Unit* GetOwner() const; - Pet* GetPet() const; + Guardian *GetGuardianPet() const; Unit* GetCharmer() const; Unit* GetCharm() const; Unit* GetCharmerOrOwner() const { return GetCharmerGUID() ? GetCharmer() : GetOwner(); } @@ -1201,7 +1209,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject } Player* GetCharmerOrOwnerPlayerOrPlayerItself() const; - void SetPet(Creature* target, bool apply); + void SetGuardian(Guardian* target, bool apply); void SetCharm(Unit* target, bool apply); Unit* GetNextRandomRaidMemberOrPet(float radius); void SetCharmedOrPossessedBy(Unit* charmer, bool possess); @@ -1313,7 +1321,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject Spell* m_currentSpells[CURRENT_MAX_SPELL]; uint32 m_addDmgOnce; - uint64 m_TotemSlot[MAX_SUMMON_SLOT]; + uint64 m_SummonSlot[MAX_SUMMON_SLOT]; uint64 m_ObjectSlot[4]; uint32 m_detectInvisibilityMask; uint32 m_invisibilityMask; |