[10847] Unsummon guardians at second item use for items without cooldown.

This commit is contained in:
VladimirMangos 2010-12-09 14:26:26 +03:00
parent e1b243f375
commit 4e72ead2fb
2 changed files with 15 additions and 12 deletions

View file

@ -4617,23 +4617,26 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction)
PetType petType = propEntry->Title == UNITNAME_SUMMON_TITLE_COMPANION ? PROTECTOR_PET : GUARDIAN_PET; PetType petType = propEntry->Title == UNITNAME_SUMMON_TITLE_COMPANION ? PROTECTOR_PET : GUARDIAN_PET;
// protectors allowed only in single amount // second cast unsummon guardian(s) (guardians without like functionality have cooldown > spawn time)
if (petType == PROTECTOR_PET) if (m_caster->GetTypeId() == TYPEID_PLAYER)
{ {
Pet* old_protector = m_caster->GetProtectorPet(); bool found = false;
// including protector
// for same pet just despawn while (Pet* old_summon = m_caster->FindGuardianWithEntry(pet_entry))
if (old_protector && old_protector->GetEntry() == pet_entry)
{ {
old_protector->Unsummon(PET_SAVE_AS_DELETED, m_caster); old_summon->Unsummon(PET_SAVE_AS_DELETED, m_caster);
return; found = true;
} }
// despawn old pet before summon new if (found)
if (old_protector) return;
old_protector->Unsummon(PET_SAVE_AS_DELETED, m_caster);
} }
// protectors allowed only in single amount
if (petType = PROTECTOR_PET)
if (Pet* old_protector = m_caster->GetProtectorPet())
old_protector->Unsummon(PET_SAVE_AS_DELETED, m_caster);
// in another case summon new // in another case summon new
uint32 level = m_caster->getLevel(); uint32 level = m_caster->getLevel();

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10846" #define REVISION_NR "10847"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__