diff options
| author | joschiwald <joschiwald@online.de> | 2013-08-14 15:45:36 +0200 |
|---|---|---|
| committer | joschiwald <joschiwald@online.de> | 2013-08-14 15:45:36 +0200 |
| commit | e87402dd05680b9d1ae40c8672babe23f4613989 (patch) | |
| tree | 1bdce82783c1bb50bb98f7dd7843e7edcc9e56b0 /src/server/game/Handlers/PetHandler.cpp | |
| parent | 783021a8cb124533db1fb5cbfccd4f250720a78c (diff) | |
Core/Spells:
- corrected structure of SMSG_PET_CAST_FAILED (fixes highlighted action buttons)
- simplified spell focus check
Diffstat (limited to 'src/server/game/Handlers/PetHandler.cpp')
| -rw-r--r-- | src/server/game/Handlers/PetHandler.cpp | 61 |
1 files changed, 10 insertions, 51 deletions
diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 2a14be85cc5..32cd7ee4725 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -32,9 +32,6 @@ #include "Group.h" #include "SpellInfo.h" #include "Player.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" -#include "CellImpl.h" void WorldSession::HandleDismissCritter(WorldPacket& recvData) { @@ -298,10 +295,6 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint32 spellid return; } - if (spellInfo->StartRecoveryCategory > 0) - if (pet->GetCharmInfo() && pet->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo)) - return; - for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if (spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY || spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY || spellInfo->Effects[i].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY) @@ -381,10 +374,10 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint32 spellid } else { - if (pet->isPossessed() || pet->IsVehicle()) + if (pet->isPossessed() || pet->IsVehicle()) /// @todo: confirm this check Spell::SendCastResult(GetPlayer(), spellInfo, 0, result); else - pet->SendPetCastFail(spellid, result); + spell->SendPetCastResult(result); if (!pet->ToCreature()->HasSpellCooldown(spellid)) GetPlayer()->SendClearCooldown(spellid, pet); @@ -774,34 +767,6 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) return; } - if (spellInfo->StartRecoveryCategory > 0) // Check if spell is affected by GCD - if (caster->GetTypeId() == TYPEID_UNIT && caster->GetCharmInfo() && caster->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo)) - { - caster->SendPetCastFail(spellId, SPELL_FAILED_NOT_READY); - return; - } - - // check spell focus object - if (spellInfo->RequiresSpellFocus && caster->IsVehicle()) - { - CellCoord p(Trinity::ComputeCellCoord(caster->GetPositionX(), caster->GetPositionY())); - Cell cell(p); - - GameObject* ok = NULL; - Trinity::GameObjectFocusCheck goCheck(caster, spellInfo->RequiresSpellFocus); - Trinity::GameObjectSearcher<Trinity::GameObjectFocusCheck> checker(caster, ok, goCheck); - - TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectFocusCheck>, GridTypeMapContainer > objectChecker(checker); - Map& map = *caster->GetMap(); - cell.Visit(p, objectChecker, map, *caster, caster->GetVisibilityRange()); - - if (!ok) - { - caster->SendPetCastFail(spellId, SPELL_FAILED_REQUIRES_SPELL_FOCUS); - return; - } - } - // do not cast not learned spells if (!caster->HasSpell(spellId) || spellInfo->IsPassive()) return; @@ -816,26 +781,19 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) spell->m_cast_count = castCount; // probably pending spell cast spell->m_targets = targets; - /// @todo need to check victim? - SpellCastResult result; - if (caster->m_movedPlayer) - result = spell->CheckPetCast(caster->m_movedPlayer->GetSelectedUnit()); - else - result = spell->CheckPetCast(NULL); + SpellCastResult result = spell->CheckPetCast(NULL); if (result == SPELL_CAST_OK) { - if (caster->GetTypeId() == TYPEID_UNIT) + if (Creature* creature = caster->ToCreature()) { - Creature* pet = caster->ToCreature(); - pet->AddCreatureSpellCooldown(spellId); - if (pet->IsPet()) + creature->AddCreatureSpellCooldown(spellId); + if (Pet* pet = creature->ToPet()) { - Pet* p = (Pet*)pet; // 10% chance to play special pet attack talk, else growl // actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell - if (p->getPetType() == SUMMON_PET && (urand(0, 100) < 10)) - pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL); + if (pet->getPetType() == SUMMON_PET && (urand(0, 100) < 10)) + pet->SendPetTalk(PET_TALK_SPECIAL_SPELL); else pet->SendPetAIReaction(guid); } @@ -845,7 +803,8 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) } else { - caster->SendPetCastFail(spellId, result); + spell->SendPetCastResult(result); + if (caster->GetTypeId() == TYPEID_PLAYER) { if (!caster->ToPlayer()->HasSpellCooldown(spellId)) |
