From e450fd6f6819a0d23336267671460db959961161 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Fri, 23 Jul 2021 09:31:04 +0200 Subject: [PATCH] fix(Core/Units): charmed creatures do not need to check hostility to attacked creature (#7043) Properly remove channelled charm auras on demand. - Closes #5447 --- src/server/game/Handlers/PetHandler.cpp | 9 +++++---- src/server/game/Handlers/SpellHandler.cpp | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 686fe1b77..892d611b4 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -558,10 +558,11 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe if (!owner->IsValidAttackTarget(TargetUnit)) return; - // pussywizard: - if (Creature* creaturePet = pet->ToCreature()) - if (!creaturePet->_CanDetectFeignDeathOf(TargetUnit) || !creaturePet->CanCreatureAttack(TargetUnit)) - return; + // pussywizard (excluded charmed) + if (!pet->IsCharmed()) + if (Creature* creaturePet = pet->ToCreature()) + if (!creaturePet->_CanDetectFeignDeathOf(TargetUnit) || !creaturePet->CanCreatureAttack(TargetUnit)) + return; // Not let attack through obstructions bool checkLos = !DisableMgr::IsPathfindingEnabled(pet->GetMap()) || diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index e22396178..fe65762ab 100644 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -462,9 +462,11 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) if (!spellInfo) return; - // not allow remove non positive spells and spells with attr SPELL_ATTR0_NO_AURA_CANCEL - if ((!spellInfo->IsPositive() || spellInfo->HasAttribute(SPELL_ATTR0_NO_AURA_CANCEL) || spellInfo->IsPassive()) && spellId != 605) + // not allow remove spells with attr SPELL_ATTR0_CANT_CANCEL + if (spellInfo->HasAttribute(SPELL_ATTR0_NO_AURA_CANCEL)) + { return; + } // channeled spell case (it currently casted then) if (spellInfo->IsChanneled()) @@ -475,6 +477,14 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) return; } + // non channeled case: + // don't allow remove non positive spells + // don't allow cancelling passive auras (some of them are visible) + if (!spellInfo->IsPositive() || spellInfo->IsPassive()) + { + return; + } + // maybe should only remove one buff when there are multiple? _player->RemoveOwnedAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_CANCEL); }