diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index df1efee88..20cd43335 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -211,6 +211,9 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool sLog.outError("Pet have incorrect type (%u) for pet loading.", getPetType()); } + if(owner->IsPvP()) + SetPvP(true); + InitStatsForLevel(petlevel); SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL)); SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, fields[5].GetUInt32()); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index bc1778a85..dd2282e74 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -2079,6 +2079,11 @@ void Player::SetGameMaster(bool on) pet->getHostilRefManager().setOnlineOfflineState(false); } + for (int8 i = 0; i < MAX_TOTEM; ++i) + if(m_TotemSlot[i]) + if(Creature *totem = GetMap()->GetCreature(m_TotemSlot[i])) + totem->setFaction(35); + RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); ResetContestedPvP(); @@ -2103,6 +2108,11 @@ void Player::SetGameMaster(bool on) pet->getHostilRefManager().setOnlineOfflineState(true); } + for (int8 i = 0; i < MAX_TOTEM; ++i) + if(m_TotemSlot[i]) + if(Creature *totem = GetMap()->GetCreature(m_TotemSlot[i])) + totem->setFaction(getFaction()); + // restore FFA PvP Server state if(sWorld.IsFFAPvPRealm()) SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); @@ -17371,11 +17381,6 @@ void Player::UpdatePvP(bool state, bool ovrride) if(!state || ovrride) { SetPvP(state); - if(Pet* pet = GetPet()) - pet->SetPvP(state); - if(Unit* charmed = GetCharm()) - charmed->SetPvP(state); - pvpInfo.endTimer = 0; } else @@ -17383,14 +17388,7 @@ void Player::UpdatePvP(bool state, bool ovrride) if(pvpInfo.endTimer != 0) pvpInfo.endTimer = time(NULL); else - { SetPvP(state); - - if(Pet* pet = GetPet()) - pet->SetPvP(state); - if(Unit* charmed = GetCharm()) - charmed->SetPvP(state); - } } } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 2b5846e00..6bf1a5330 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4181,6 +4181,9 @@ void Spell::EffectSummonPet(uint32 i) if(m_caster->GetTypeId() == TYPEID_PLAYER) NewSummon->SetUInt32Value(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); + if(m_caster->IsPvP()) + NewSummon->SetPvP(true); + NewSummon->InitStatsForLevel(petlevel); NewSummon->InitPetCreateSpells(); NewSummon->InitLevelupSpellsForLevel(); @@ -5515,6 +5518,9 @@ void Spell::EffectSummonTotem(uint32 i) if(m_caster->GetTypeId() == TYPEID_PLAYER) pTotem->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); + if(m_caster->IsPvP()) + pTotem->SetPvP(true); + pTotem->Summon(m_caster); if(slot < MAX_TOTEM && m_caster->GetTypeId() == TYPEID_PLAYER) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 1e4adbab1..685ca2e8d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -11398,6 +11398,9 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id) if(GetTypeId()==TYPEID_PLAYER) pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); + if(IsPvP()) + pet->SetPvP(true); + uint32 level = (creatureTarget->getLevel() < (getLevel() - 5)) ? (getLevel() - 5) : creatureTarget->getLevel(); if(!pet->InitStatsForLevel(level)) @@ -11602,3 +11605,21 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca SendMessageToSet(&data, false); } } + +void Unit::SetPvP( bool state ) +{ + if(state) + SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); + else + RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); + + if(Pet* pet = GetPet()) + pet->SetPvP(state); + if(Unit* charmed = GetCharm()) + charmed->SetPvP(state); + + for (int8 i = 0; i < MAX_TOTEM; ++i) + if(m_TotemSlot[i]) + if(Creature *totem = GetMap()->GetCreature(m_TotemSlot[i])) + totem->SetPvP(state); +} \ No newline at end of file diff --git a/src/game/Unit.h b/src/game/Unit.h index 4636c52ba..95507d23b 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -924,13 +924,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject return false; } bool IsPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); } - void SetPvP(bool state) - { - if(state) - SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); - else - RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); - } + void SetPvP(bool state); uint32 GetCreatureType() const; uint32 GetCreatureTypeMask() const { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 52a8002a7..9b676ab15 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7876" + #define REVISION_NR "7877" #endif // __REVISION_NR_H__