fix(Core/Spells): Revive pet cannot be used on alive pets. (#8434)
Fixes #8315
This commit is contained in:
@@ -115,7 +115,7 @@ void Pet::RemoveFromWorld()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SpellCastResult Pet::TryLoadFromDB(Player* owner, bool current /*= false*/, PetType mandatoryPetType /*= MAX_PET_TYPE*/)
|
SpellCastResult Pet::TryLoadFromDB(Player* owner, bool current /*= false*/, PetType mandatoryPetType /*= MAX_PET_TYPE*/, bool checkDead /*= false*/)
|
||||||
{
|
{
|
||||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT_SYNS);
|
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT_SYNS);
|
||||||
stmt->setUInt32(0, owner->GetGUID().GetCounter());
|
stmt->setUInt32(0, owner->GetGUID().GetCounter());
|
||||||
@@ -151,10 +151,17 @@ SpellCastResult Pet::TryLoadFromDB(Player* owner, bool current /*= false*/, PetT
|
|||||||
if (current && isTemporarySummoned)
|
if (current && isTemporarySummoned)
|
||||||
return SPELL_FAILED_NO_PET;
|
return SPELL_FAILED_NO_PET;
|
||||||
|
|
||||||
if (!savedHealth)
|
if (!checkDead)
|
||||||
{
|
{
|
||||||
owner->ToPlayer()->SendTameFailure(PET_TAME_DEAD);
|
if (!savedHealth)
|
||||||
return SPELL_FAILED_TARGETS_DEAD;
|
{
|
||||||
|
owner->ToPlayer()->SendTameFailure(PET_TAME_DEAD);
|
||||||
|
return SPELL_FAILED_TARGETS_DEAD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (savedHealth)
|
||||||
|
{
|
||||||
|
return SPELL_FAILED_TARGET_NOT_DEAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mandatoryPetType != MAX_PET_TYPE && petType != mandatoryPetType)
|
if (mandatoryPetType != MAX_PET_TYPE && petType != mandatoryPetType)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
bool CreateBaseAtCreature(Creature* creature);
|
bool CreateBaseAtCreature(Creature* creature);
|
||||||
bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner);
|
bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner);
|
||||||
bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask);
|
bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask);
|
||||||
static SpellCastResult TryLoadFromDB(Player* owner, bool current = false, PetType mandatoryPetType = MAX_PET_TYPE);
|
static SpellCastResult TryLoadFromDB(Player* owner, bool current = false, PetType mandatoryPetType = MAX_PET_TYPE, bool checkDead = false);
|
||||||
static bool LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry = 0, uint32 petnumber = 0, bool current = false, AsynchPetSummon* info = nullptr);
|
static bool LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry = 0, uint32 petnumber = 0, bool current = false, AsynchPetSummon* info = nullptr);
|
||||||
bool isBeingLoaded() const override { return m_loading;}
|
bool isBeingLoaded() const override { return m_loading;}
|
||||||
void SavePetToDB(PetSaveMode mode, bool logout);
|
void SavePetToDB(PetSaveMode mode, bool logout);
|
||||||
|
|||||||
@@ -5898,10 +5898,21 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||||||
}
|
}
|
||||||
case SPELL_EFFECT_RESURRECT_PET:
|
case SPELL_EFFECT_RESURRECT_PET:
|
||||||
{
|
{
|
||||||
Creature* pet = m_caster->GetGuardianPet();
|
if (Creature* pet = m_caster->GetGuardianPet())
|
||||||
|
{
|
||||||
if (pet && pet->IsAlive())
|
if (pet->IsAlive())
|
||||||
return SPELL_FAILED_ALREADY_HAVE_SUMMON;
|
{
|
||||||
|
return SPELL_FAILED_ALREADY_HAVE_SUMMON;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Player* player = m_caster->ToPlayer())
|
||||||
|
{
|
||||||
|
SpellCastResult loadResult = Pet::TryLoadFromDB(player, false, MAX_PET_TYPE, true);
|
||||||
|
if (loadResult != SPELL_CAST_OK)
|
||||||
|
{
|
||||||
|
return loadResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user