Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Core/Pets: no longer allow dead pets to be called via summon pet spel…
Browse files Browse the repository at this point in the history
…l effect
  • Loading branch information
Ovahlord committed Sep 29, 2023
1 parent 3d9d969 commit 5bfc3d7
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/server/game/Server/Packets/PetPackets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,10 @@ void WorldPackets::Pet::PetSetAction::Read()
_worldPacket >> Index;
_worldPacket >> Action;
}

WorldPacket const* WorldPackets::Pet::PetTameFailure::Write()
{
_worldPacket << uint8(Result);

return &_worldPacket;
}
8 changes: 8 additions & 0 deletions src/server/game/Server/Packets/PetPackets.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,15 @@ namespace WorldPackets
uint32 Index = 0;
};

class PetTameFailure final : public ServerPacket
{
public:
PetTameFailure() : ServerPacket(SMSG_PET_TAME_FAILURE, 1) { }

WorldPacket const* Write() override;

uint8 Result = 0;
};
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/server/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6215,6 +6215,20 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
return SPELL_FAILED_ALREADY_HAVE_SUMMON;
break;
}
case SPELL_EFFECT_DISMISS_PET:
{
Unit* unitCaster = m_caster->ToUnit();
if (!unitCaster)
return SPELL_FAILED_BAD_TARGETS;

NewPet* pet = unitCaster->GetActivelyControlledSummon();
if (!pet)
return SPELL_FAILED_BAD_TARGETS;

if (!pet->IsAlive())
return SPELL_FAILED_TARGETS_DEAD;
break;
}
// This is generic summon effect
case SPELL_EFFECT_SUMMON:
{
Expand Down
19 changes: 18 additions & 1 deletion src/server/game/Spells/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ SpellEffectHandlerFn SpellEffectHandlers[TOTAL_SPELL_EFFECTS] =
&Spell::EffectSkinPlayerCorpse, //116 SPELL_EFFECT_SKIN_PLAYER_CORPSE one spell: Remove Insignia, bg usage, required special corpse flags...
&Spell::EffectSpiritHeal, //117 SPELL_EFFECT_SPIRIT_HEAL one spell: Spirit Heal
&Spell::EffectSkill, //118 SPELL_EFFECT_SKILL professions and more
&Spell::EffectUnused , //119 SPELL_EFFECT_APPLY_AREA_AURA_PET
&Spell::EffectUnused, //119 SPELL_EFFECT_APPLY_AREA_AURA_PET
&Spell::EffectUnused, //120 SPELL_EFFECT_TELEPORT_GRAVEYARD one spell: Graveyard Teleport Test
&Spell::EffectWeaponDmg, //121 SPELL_EFFECT_NORMALIZED_WEAPON_DMG
&Spell::EffectUnused, //122 SPELL_EFFECT_122 unused
Expand Down Expand Up @@ -2603,6 +2603,23 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)

bool isClassPet = m_spellInfo->SpellFamilyName != SPELLFAMILY_GENERIC || petCreatureId == 0;

// Dead Hunter Pets cannot be summoned and must be brought back by a resurrect pet spell effect
if (petCreatureId == 0)
{
if (Player* player = unitCaster->ToPlayer())
{
PlayerPetData* petData = player->GetPlayerPetData(petSlotIndex, petCreatureId);
if (petData && petData->SavedHealth == 0)
{
WorldPackets::Pet::PetTameFailure packet;
packet.Result = PET_TAME_FAILURE_DEAD_PET;
player->SendDirectMessage(packet.Write());
unitCaster->GetSpellHistory()->ResetCooldown(GetSpellInfo()->Id, true);
return;
}
}
}

if (NewPet* summon = unitCaster->SummonPet(petCreatureId, petSlotIndex, m_spellInfo->Id, isClassPet, *destTarget))
{
ExecuteLogEffectSummonObject(effIndex, summon);
Expand Down

0 comments on commit 5bfc3d7

Please sign in to comment.