*Update summon system.
*Fix the bug that shaman cannot summon fire elemental. *Fix the bug that totem meters cannot be displayed. --HG-- branch : trunk
This commit is contained in:
1 parent
abe9b27ee4
commit
122d944945
12 files changed
+124
-98
No files matched your search
+50
-25
@@ -8090,6 +8090,21 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const
|
||||
return GetTypeId()==TYPEID_PLAYER ? (Player*)this : NULL;
|
||||
}
|
||||
|
||||
Minion *Unit::GetFirstMinion() const
|
||||
{
|
||||
if(uint64 pet_guid = GetMinionGUID())
|
||||
{
|
||||
if(Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid))
|
||||
if(pet->HasSummonMask(SUMMON_MASK_MINION))
|
||||
return (Minion*)pet;
|
||||
|
||||
sLog.outError("Unit::GetFirstMinion: Minion %u not exist.",GUID_LOPART(pet_guid));
|
||||
const_cast<Unit*>(this)->SetMinionGUID(0);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Guardian* Unit::GetGuardianPet() const
|
||||
{
|
||||
if(uint64 pet_guid = GetPetGUID())
|
||||
@@ -8098,7 +8113,7 @@ Guardian* Unit::GetGuardianPet() const
|
||||
if(pet->HasSummonMask(SUMMON_MASK_GUARDIAN))
|
||||
return (Guardian*)pet;
|
||||
|
||||
sLog.outError("Unit::GetGuardianPet: Pet %u not exist.",GUID_LOPART(pet_guid));
|
||||
sLog.outError("Unit::GetGuardianPet: Guardian %u not exist.",GUID_LOPART(pet_guid));
|
||||
const_cast<Unit*>(this)->SetPetGUID(0);
|
||||
}
|
||||
|
||||
@@ -8119,44 +8134,54 @@ Unit* Unit::GetCharm() const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Unit::SetGuardian(Guardian* guardian, bool apply)
|
||||
void Unit::SetMinion(Minion *minion, bool apply)
|
||||
{
|
||||
sLog.outDebug("SetGuardian %u for %u, apply %u", guardian->GetEntry(), GetEntry(), apply);
|
||||
sLog.outDebug("SetMinion %u for %u, apply %u", minion->GetEntry(), GetEntry(), apply);
|
||||
|
||||
if(apply)
|
||||
{
|
||||
if(!guardian->SetOwner(this, true))
|
||||
if(!minion->SetOwner(this, true))
|
||||
return;
|
||||
|
||||
m_Controlled.insert(guardian);
|
||||
m_Controlled.insert(minion);
|
||||
|
||||
if(guardian->isPet() || guardian->m_Properties && guardian->m_Properties->Category == SUMMON_CATEGORY_PET)
|
||||
// Can only have one pet. If a new one is summoned, dismiss the old one.
|
||||
if(minion->isPet() || minion->m_Properties && minion->m_Properties->Category == SUMMON_CATEGORY_PET)
|
||||
{
|
||||
if(Guardian* oldPet = GetGuardianPet())
|
||||
{
|
||||
if(oldPet != guardian && (oldPet->isPet() || guardian->isPet() || oldPet->GetEntry() != guardian->GetEntry()))
|
||||
if(oldPet != minion && (oldPet->isPet() || minion->isPet() || oldPet->GetEntry() != minion->GetEntry()))
|
||||
{
|
||||
// remove existing guardian pet
|
||||
// remove existing minion pet
|
||||
if(oldPet->isPet())
|
||||
((Pet*)oldPet)->Remove(PET_SAVE_AS_CURRENT);
|
||||
else
|
||||
oldPet->UnSummon();
|
||||
SetPetGUID(guardian->GetGUID());
|
||||
SetGuardianGUID(0);
|
||||
SetPetGUID(minion->GetGUID());
|
||||
SetMinionGUID(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPetGUID(guardian->GetGUID());
|
||||
SetGuardianGUID(0);
|
||||
SetPetGUID(minion->GetGUID());
|
||||
SetMinionGUID(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(AddUInt64Value(UNIT_FIELD_SUMMON, guardian->GetGUID()))
|
||||
// Check priority.
|
||||
if(Minion *oldMinion = GetFirstMinion())
|
||||
{
|
||||
if(GetTypeId() == TYPEID_PLAYER && !GetCharmGUID())
|
||||
if(minion->HasSummonMask(SUMMON_MASK_GUARDIAN)
|
||||
&& !oldMinion->HasSummonMask(SUMMON_MASK_GUARDIAN))
|
||||
SetMinionGUID(0);
|
||||
}
|
||||
|
||||
// Set first minion
|
||||
if(AddUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID()))
|
||||
{
|
||||
if(GetTypeId() == TYPEID_PLAYER && !GetCharmGUID() && minion->HasSummonMask(SUMMON_MASK_GUARDIAN))
|
||||
{
|
||||
if(guardian->isPet())
|
||||
if(minion->isPet())
|
||||
((Player*)this)->PetSpellInitialize();
|
||||
else
|
||||
((Player*)this)->CharmSpellInitialize();
|
||||
@@ -8165,28 +8190,28 @@ void Unit::SetGuardian(Guardian* guardian, bool apply)
|
||||
|
||||
// FIXME: hack, speed must be set only at follow
|
||||
if(HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||
guardian->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||
minion->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||
|
||||
if(GetTypeId() == TYPEID_PLAYER && guardian->HasSummonMask(SUMMON_MASK_PET))
|
||||
if(GetTypeId() == TYPEID_PLAYER && minion->HasSummonMask(SUMMON_MASK_PET))
|
||||
for(int i = 0; i < MAX_MOVE_TYPE; ++i)
|
||||
guardian->SetSpeed(UnitMoveType(i), m_speed_rate[i], true);
|
||||
minion->SetSpeed(UnitMoveType(i), m_speed_rate[i], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!guardian->SetOwner(this, false))
|
||||
if(!minion->SetOwner(this, false))
|
||||
return;
|
||||
|
||||
m_Controlled.erase(guardian);
|
||||
m_Controlled.erase(minion);
|
||||
|
||||
if(guardian->isPet() || guardian->m_Properties && guardian->m_Properties->Category == SUMMON_CATEGORY_PET)
|
||||
if(minion->isPet() || minion->m_Properties && minion->m_Properties->Category == SUMMON_CATEGORY_PET)
|
||||
{
|
||||
if(GetPetGUID() == guardian->GetGUID())
|
||||
if(GetPetGUID() == minion->GetGUID())
|
||||
SetPetGUID(0);
|
||||
}
|
||||
|
||||
if(RemoveUInt64Value(UNIT_FIELD_SUMMON, guardian->GetGUID()))
|
||||
if(RemoveUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID()))
|
||||
{
|
||||
//Check if there is another guardian
|
||||
//Check if there is another minion
|
||||
for(ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
|
||||
{
|
||||
if(GetCharmGUID() == (*itr)->GetGUID())
|
||||
@@ -8197,7 +8222,7 @@ void Unit::SetGuardian(Guardian* guardian, bool apply)
|
||||
if(AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID()))
|
||||
{
|
||||
//show another pet bar if there is no charm bar
|
||||
if(GetTypeId() == TYPEID_PLAYER && !GetCharmGUID())
|
||||
if(GetTypeId() == TYPEID_PLAYER && !GetCharmGUID() && ((Creature*)(*itr))->HasSummonMask(SUMMON_MASK_GUARDIAN))
|
||||
{
|
||||
if(((Creature*)(*itr))->isPet())
|
||||
((Player*)this)->PetSpellInitialize();
|
||||
|
||||
Reference in new issue
Block a user