[7877] Correctly set totem PvP state at loading and owner PvP state change, including GM totem case.

* Also set PvP state in proper way at pet loading if owner in PvP state.
This commit is contained in:
VladimirMangos 2009-05-23 00:30:18 +04:00
parent e0e5ed7bd8
commit bc4611e8c0
6 changed files with 42 additions and 20 deletions

View file

@ -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);
}