mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
Retain pet buffs/debuffs/spells when pet is resummoned after lagout/flightpath unsummon
Research and patch by Liberate (minor assist by click) Fixes issue #689 Fixes issue #794 Fixes issue #1454 --HG-- branch : trunk
This commit is contained in:
@@ -378,6 +378,9 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
||||
uint32 curhealth = GetHealth();
|
||||
uint32 curmana = GetPower(POWER_MANA);
|
||||
|
||||
// save auras before possibly removing them
|
||||
_SaveAuras();
|
||||
|
||||
// stable and not in slot saves
|
||||
if (mode > PET_SAVE_AS_CURRENT)
|
||||
{
|
||||
@@ -386,7 +389,6 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
||||
|
||||
_SaveSpells();
|
||||
_SaveSpellCooldowns();
|
||||
_SaveAuras();
|
||||
|
||||
// current/stable/not_in_slot
|
||||
if (mode >= PET_SAVE_AS_CURRENT)
|
||||
@@ -1261,7 +1263,8 @@ void Pet::_SaveAuras()
|
||||
|
||||
for (AuraMap::const_iterator itr = m_ownedAuras.begin(); itr != m_ownedAuras.end() ; ++itr)
|
||||
{
|
||||
if (!itr->second->CanBeSaved())
|
||||
// check if the aura has to be saved
|
||||
if (!itr->second->CanBeSaved() || IsPetAura(itr->second))
|
||||
continue;
|
||||
|
||||
Aura * aura = itr->second;
|
||||
@@ -1935,6 +1938,24 @@ void Pet::CastPetAura(PetAura const* aura)
|
||||
CastSpell(this, auraId, true);
|
||||
}
|
||||
|
||||
bool Pet::IsPetAura(Aura const* aura)
|
||||
{
|
||||
Unit* owner = GetOwner();
|
||||
|
||||
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
|
||||
return false;
|
||||
|
||||
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
PetAura const* pa = spellmgr.GetPetAura(aura->GetId(),i);
|
||||
|
||||
// if the owner has that pet aura, return true
|
||||
if (owner->m_petAuras.find(pa) != m_petAuras.end())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Pet::learnSpellHighRank(uint32 spellid)
|
||||
{
|
||||
learnSpell(spellid);
|
||||
|
||||
@@ -186,6 +186,7 @@ class Pet : public Guardian
|
||||
void LearnPetPassives();
|
||||
void CastPetAuras(bool current);
|
||||
void CastPetAura(PetAura const* aura);
|
||||
bool IsPetAura(Aura const* aura);
|
||||
|
||||
void _LoadSpellCooldowns();
|
||||
void _SaveSpellCooldowns();
|
||||
|
||||
Reference in New Issue
Block a user