From db0c27fe43e697d07ccb5d71cd7d2f66e9d11718 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Thu, 21 Oct 2021 20:54:36 +0200 Subject: [PATCH] fix(Core/Combat): Removed some invalid code about auto-acquiring a nearby target if primary target is not detectable by creature. (#8624) Spells with sanctuary always delete hostile references (if not during encounter). Update visibility should be always forced in case of invisibility/stealth auras. Restored old Shadowmeld code. Fixes #4764 Fixes #7125 --- .../rev_1634671396926649200.sql | 7 +++ src/server/game/Combat/HostileRefMgr.cpp | 3 +- src/server/game/Entities/Unit/Unit.cpp | 8 --- .../game/Spells/Auras/SpellAuraEffects.cpp | 18 ++---- src/server/scripts/Spells/spell_generic.cpp | 57 ------------------- 5 files changed, 12 insertions(+), 81 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1634671396926649200.sql diff --git a/data/sql/updates/pending_db_world/rev_1634671396926649200.sql b/data/sql/updates/pending_db_world/rev_1634671396926649200.sql new file mode 100644 index 000000000..06f10105f --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1634671396926649200.sql @@ -0,0 +1,7 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1634671396926649200'); + +DELETE FROM `spell_script_names` WHERE `spell_id`=58984; +DELETE FROM `spell_linked_spell` WHERE `spell_trigger`=58984; +INSERT INTO `spell_linked_spell` (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES +(58984,59646,0,'Shadowmeld: Sanctuary'), +(58984,62196,0,'Shadowmeld: Force deselect'); diff --git a/src/server/game/Combat/HostileRefMgr.cpp b/src/server/game/Combat/HostileRefMgr.cpp index 94a51e6e2..63762da8a 100644 --- a/src/server/game/Combat/HostileRefMgr.cpp +++ b/src/server/game/Combat/HostileRefMgr.cpp @@ -228,8 +228,7 @@ void HostileRefMgr::UpdateVisibility(bool checkThreat) while (ref) { HostileReference* nextRef = ref->next(); - if ((!checkThreat || ref->GetSource()->getThreatList().size() <= 1) && - !ref->GetSource()->GetOwner()->CanSeeOrDetect(GetOwner())) + if ((!checkThreat || ref->GetSource()->getThreatList().size() <= 1)) { nextRef = ref->next(); ref->removeReference(); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index b7c9434e9..b916203d7 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -13896,14 +13896,6 @@ Unit* Creature::SelectVictim() if (GetVehicle()) return nullptr; - // search nearby enemies before evading - if (HasReactState(REACT_AGGRESSIVE)) - { - target = SelectNearestTargetInAttackDistance(std::max(m_CombatDistance, ATTACK_DISTANCE)); - if (target && _CanDetectFeignDeathOf(target) && CanCreatureAttack(target)) - return target; - } - // pussywizard: not sure why it's here // pussywizard: can't evade when having invisibility aura with duration? o_O Unit::AuraEffectList const& iAuras = GetAuraEffectsByType(SPELL_AURA_MOD_INVISIBILITY); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index ebe520e7f..992d2fb66 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -1575,13 +1575,8 @@ void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); } - if (!apply && aurApp->GetRemoveMode() == AURA_REMOVE_BY_DEFAULT) - { - target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable(), true); - target->bRequestForcedVisibilityUpdate = false; - } - else - target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable()); + target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable(), true); + target->bRequestForcedVisibilityUpdate = false; } void AuraEffect::HandleModStealthDetect(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -1654,13 +1649,8 @@ void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, boo target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); } - if (!apply && aurApp->GetRemoveMode() == AURA_REMOVE_BY_DEFAULT) - { - target->UpdateObjectVisibility((target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable()), true); - target->bRequestForcedVisibilityUpdate = false; - } - else - target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable()); + target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable(), true); + target->bRequestForcedVisibilityUpdate = false; } void AuraEffect::HandleModStealthLevel(AuraApplication const* aurApp, uint8 mode, bool apply) const diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 50d42631d..6a3fb2c6b 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -5411,62 +5411,6 @@ public: } }; -// 58984 - Shadowmeld -class spell_gen_shadowmeld : public SpellScriptLoader -{ -public: - spell_gen_shadowmeld() : SpellScriptLoader("spell_gen_shadowmeld") {} - - class spell_gen_shadowmeld_SpellScript : public SpellScript - { - PrepareSpellScript(spell_gen_shadowmeld_SpellScript); - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - if (!caster) - return; - - caster->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); // break Auto Shot and autohit - caster->InterruptSpell(CURRENT_CHANNELED_SPELL); // break channeled spells - - bool instant_exit = true; - if (Player* pCaster = caster->ToPlayer()) // if is a creature instant exits combat, else check if someone in party is in combat in visibility distance - { - ObjectGuid myGUID = pCaster->GetGUID(); - float visibilityRange = pCaster->GetMap()->GetVisibilityRange(); - if (Group* pGroup = pCaster->GetGroup()) - { - const Group::MemberSlotList membersList = pGroup->GetMemberSlots(); - for (Group::member_citerator itr = membersList.begin(); itr != membersList.end() && instant_exit; ++itr) - if (itr->guid != myGUID) - if (Player* GroupMember = ObjectAccessor::GetPlayer(*pCaster, itr->guid)) - if (GroupMember->IsInCombat() && pCaster->GetMap() == GroupMember->GetMap() && pCaster->IsWithinDistInMap(GroupMember, visibilityRange)) - instant_exit = false; - } - - pCaster->SendAttackSwingCancelAttack(); - } - - if (instant_exit) - { - caster->getHostileRefMgr().deleteReferences(); - } - caster->CombatStop(); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_gen_shadowmeld_SpellScript::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_gen_shadowmeld_SpellScript(); - } -}; - // 7102 Contagion of Rot class spell_contagion_of_rot : public SpellScriptLoader { @@ -5631,6 +5575,5 @@ void AddSC_generic_spell_scripts() new spell_gen_eject_all_passengers(); new spell_gen_eject_passenger(); new spell_gen_charmed_unit_spell_cooldown(); - new spell_gen_shadowmeld(); new spell_contagion_of_rot(); }