fix(Core/Units): charmed creatures do not need to check hostility to attacked creature (#7043)

Properly remove channelled charm auras on demand.
- Closes #5447
This commit is contained in:
UltraNix
2021-07-23 09:31:04 +02:00
committed by GitHub
parent da392517cb
commit e450fd6f68
2 changed files with 17 additions and 6 deletions
+5 -4
View File
@@ -558,10 +558,11 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
if (!owner->IsValidAttackTarget(TargetUnit)) if (!owner->IsValidAttackTarget(TargetUnit))
return; return;
// pussywizard: // pussywizard (excluded charmed)
if (Creature* creaturePet = pet->ToCreature()) if (!pet->IsCharmed())
if (!creaturePet->_CanDetectFeignDeathOf(TargetUnit) || !creaturePet->CanCreatureAttack(TargetUnit)) if (Creature* creaturePet = pet->ToCreature())
return; if (!creaturePet->_CanDetectFeignDeathOf(TargetUnit) || !creaturePet->CanCreatureAttack(TargetUnit))
return;
// Not let attack through obstructions // Not let attack through obstructions
bool checkLos = !DisableMgr::IsPathfindingEnabled(pet->GetMap()) || bool checkLos = !DisableMgr::IsPathfindingEnabled(pet->GetMap()) ||
+12 -2
View File
@@ -462,9 +462,11 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket)
if (!spellInfo) if (!spellInfo)
return; return;
// not allow remove non positive spells and spells with attr SPELL_ATTR0_NO_AURA_CANCEL // not allow remove spells with attr SPELL_ATTR0_CANT_CANCEL
if ((!spellInfo->IsPositive() || spellInfo->HasAttribute(SPELL_ATTR0_NO_AURA_CANCEL) || spellInfo->IsPassive()) && spellId != 605) if (spellInfo->HasAttribute(SPELL_ATTR0_NO_AURA_CANCEL))
{
return; return;
}
// channeled spell case (it currently casted then) // channeled spell case (it currently casted then)
if (spellInfo->IsChanneled()) if (spellInfo->IsChanneled())
@@ -475,6 +477,14 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket)
return; 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? // maybe should only remove one buff when there are multiple?
_player->RemoveOwnedAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_CANCEL); _player->RemoveOwnedAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_CANCEL);
} }