From 3a9c7a40b07703bf4d195a7b2b3e98c5daffcd6a Mon Sep 17 00:00:00 2001 From: ratkosrb Date: Tue, 30 Apr 2024 01:08:19 +0300 Subject: [PATCH 1/2] Follow up to last commit. --- sql/migrations/20240428090619_world.sql | 4 ++-- src/game/Objects/CreatureDefines.h | 4 ++-- src/game/Objects/Unit.cpp | 15 +++++++++++---- src/game/Objects/Unit.h | 2 +- src/game/Threat/ThreatManager.cpp | 19 ++++++------------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sql/migrations/20240428090619_world.sql b/sql/migrations/20240428090619_world.sql index 598e5d2738f..e24601fc0ea 100644 --- a/sql/migrations/20240428090619_world.sql +++ b/sql/migrations/20240428090619_world.sql @@ -9,8 +9,8 @@ INSERT INTO `migrations` VALUES ('20240428090619'); -- Add your query below. --- Add No Target flag to Grobbulus Cloud and Scourge Summoning Crystal. -UPDATE `creature_template` SET `flags_extra`=(`flags_extra` | 0x00020000) WHERE `entry`IN (11623, 16363); +-- Add No Threat List flag to Grobbulus Cloud and Scourge Summoning Crystal. +UPDATE `creature_template` SET `flags_extra`=(`flags_extra` | (0x00000800 | 0x00020000)) WHERE `entry`IN (11623, 16363); -- End of migration. diff --git a/src/game/Objects/CreatureDefines.h b/src/game/Objects/CreatureDefines.h index 6bb82ca5e30..812576dbfdd 100644 --- a/src/game/Objects/CreatureDefines.h +++ b/src/game/Objects/CreatureDefines.h @@ -167,13 +167,13 @@ enum CreatureFlagsExtra CREATURE_FLAG_EXTRA_GIGANTIC_AOI = 0x00000100, // 256 CREATURE_DIFFICULTYFLAGS_3_GIGANTIC_AOI (400 yards) CREATURE_FLAG_EXTRA_INFINITE_AOI = 0x00000200, // 512 CREATURE_DIFFICULTYFLAGS_3_INFINITE_AOI CREATURE_FLAG_EXTRA_GUARD = 0x00000400, // 1024 Creature is a guard - CREATURE_FLAG_EXTRA_NO_THREAT_LIST = 0x00000800, // 2048 Creature does not select targets based on threat (all enemies have 0 threat) + CREATURE_FLAG_EXTRA_NO_THREAT_LIST = 0x00000800, // 2048 Creature does not keep track of enemies in threat list, uses 5 second combat timer like players CREATURE_FLAG_EXTRA_KEEP_POSITIVE_AURAS_ON_EVADE = 0x00001000, // 4096 Creature keeps positive auras at reset CREATURE_FLAG_EXTRA_ALWAYS_CRUSH = 0x00002000, // 8192 Creature always roll a crushing melee outcome when not miss/crit/dodge/parry/block CREATURE_FLAG_EXTRA_APPEAR_DEAD = 0x00004000, // 16384 Creature will have UNIT_DYNFLAG_DEAD applied CREATURE_FLAG_EXTRA_CHASE_GEN_NO_BACKING = 0x00008000, // 32768 Creature does not move back when target is within bounding radius CREATURE_FLAG_EXTRA_NO_ASSIST = 0x00010000, // 65536 Creature does not aggro when nearby creatures aggro - CREATURE_FLAG_EXTRA_NO_TARGET = 0x00020000, // 131072 Creature is passive and does not acquire targets, uses 5 second combat timer like players + CREATURE_FLAG_EXTRA_NO_TARGET = 0x00020000, // 131072 Creature is passive and does not acquire targets CREATURE_FLAG_EXTRA_ONLY_VISIBLE_TO_FRIENDLY = 0x00040000, // 262144 Creature can only be seen by friendly units CREATURE_FLAG_EXTRA_CAN_ASSIST = 0x00080000, // 524288 CREATURE_TYPEFLAGS_CAN_ASSIST from TBC }; diff --git a/src/game/Objects/Unit.cpp b/src/game/Objects/Unit.cpp index dc6d9e7adbb..c9c8e06e504 100644 --- a/src/game/Objects/Unit.cpp +++ b/src/game/Objects/Unit.cpp @@ -267,7 +267,7 @@ void Unit::Update(uint32 update_diff, uint32 p_time) { if (m_HostileRefManager.isEmpty()) { - if (!IsCharmerOrOwnerPlayerOrPlayerItself() && static_cast(this)->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_TARGET)) + if (!IsCharmerOrOwnerPlayerOrPlayerItself() && static_cast(this)->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_THREAT_LIST)) OnLeaveCombat(); else ClearInCombat(); @@ -346,7 +346,7 @@ bool Unit::UsesPvPCombatTimer() const if (GetCharmerGuid().IsPlayer()) return true; - if (static_cast(this)->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_TARGET)) + if (static_cast(this)->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_THREAT_LIST)) return true; return false; @@ -7454,6 +7454,9 @@ bool Unit::CanHaveThreatList() const if (pCreature->GetCharmerGuid().IsPlayer()) return false; + if (pCreature->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_THREAT_LIST)) + return false; + return true; } @@ -7619,6 +7622,10 @@ bool Unit::SelectHostileTarget() if (!target && !m_ThreatManager.isThreatListEmpty()) target = m_ThreatManager.getHostileTarget(); + // stick to current target if no threat list + if (!target && ((Creature*)this)->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_THREAT_LIST)) + target = GetVictim(); + if (target) { // Nostalrius : Correction bug sheep/fear @@ -7630,8 +7637,8 @@ bool Unit::SelectHostileTarget() return true; } - // mobs that dont acquire targets use 5 second combat timer like players - if (((Creature*)this)->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_TARGET)) + // mobs that dont have threat list use 5 second combat timer like players + if (((Creature*)this)->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_THREAT_LIST)) return false; // no target but something prevent go to evade mode // Nostalrius - fix evade quand CM. diff --git a/src/game/Objects/Unit.h b/src/game/Objects/Unit.h index d4c619f3cd5..c39726c835d 100644 --- a/src/game/Objects/Unit.h +++ b/src/game/Objects/Unit.h @@ -909,7 +909,7 @@ class Unit : public SpellCaster float m_meleeZLimit; float m_meleeZReach; ThreatManager m_ThreatManager; // Manage all Units threatening us - HostileRefManager m_HostileRefManager; // Manage all Units that are threatened by us + HostileRefManager m_HostileRefManager; // Manage all Units that are threatened by us (has list of creatures that have us in their threat list) std::vector m_tauntGuids; protected: uint32 m_attackTimer[MAX_ATTACK]; diff --git a/src/game/Threat/ThreatManager.cpp b/src/game/Threat/ThreatManager.cpp index 6b4485b45e0..fff661576ca 100644 --- a/src/game/Threat/ThreatManager.cpp +++ b/src/game/Threat/ThreatManager.cpp @@ -406,21 +406,14 @@ void ThreatManager::addThreat(Unit* pVictim, float threat, bool crit, SpellSchoo MANGOS_ASSERT(getOwner()->GetTypeId() == TYPEID_UNIT); - if (threat) + // don't add assist threat to targets under hard CC + // check for fear, blind, freezing trap, reckless charge, banish, etc. + if (isAssistThreat) { - // mob does not count threat, just keeps list of enemies - if (static_cast(getOwner())->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_THREAT_LIST)) - threat = 0; - - // don't add assist threat to targets under hard CC - // check for fear, blind, freezing trap, reckless charge, banish, etc. - else if (isAssistThreat) + if (getOwner()->HasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_ISOLATED) || + (getOwner()->HasUnitState(UNIT_STAT_STUNNED) && getOwner()->HasBreakableByDamageAuraType(SPELL_AURA_MOD_STUN, 0))) { - if (getOwner()->HasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_ISOLATED) || - (getOwner()->HasUnitState(UNIT_STAT_STUNNED) && getOwner()->HasBreakableByDamageAuraType(SPELL_AURA_MOD_STUN, 0))) - { - threat = 0.0f; - } + threat = 0.0f; } } From f94b3b4c8be5038176e4b824b432fa8ca56c34df Mon Sep 17 00:00:00 2001 From: ratkosrb Date: Tue, 30 Apr 2024 01:44:24 +0300 Subject: [PATCH 2/2] Pet should stop moving while channeling. --- src/game/Handlers/PetHandler.cpp | 17 +++++++++++++---- src/game/Objects/SpellCaster.cpp | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/game/Handlers/PetHandler.cpp b/src/game/Handlers/PetHandler.cpp index 3661c702f76..b904bc68178 100644 --- a/src/game/Handlers/PetHandler.cpp +++ b/src/game/Handlers/PetHandler.cpp @@ -166,11 +166,20 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) } pCharmedUnit->ClearUnitState(UNIT_STAT_MOVING); - auto result = pCharmedUnit->CastSpell(pUnitTarget, spellInfo, false); - if (result != SPELL_CAST_OK) + SpellCastResult result = pCharmedUnit->CastSpell(pUnitTarget, spellInfo, false); + + if (result == SPELL_CAST_OK) + { + if (pCharmedUnit->IsPet()) + ((Pet*)pCharmedUnit)->CheckLearning(spellid); + + if (pCharmedUnit->IsMoving() && pCharmedUnit->IsNoMovementSpellCasted()) + pCharmedUnit->StopMoving(); + } + else pCharmedUnit->SendPetCastFail(spellid, result); - else if (((Creature*)pCharmedUnit)->IsPet()) - ((Pet*)pCharmedUnit)->CheckLearning(spellid); + + break; } default: diff --git a/src/game/Objects/SpellCaster.cpp b/src/game/Objects/SpellCaster.cpp index 629f9a0fd36..846d898d78e 100644 --- a/src/game/Objects/SpellCaster.cpp +++ b/src/game/Objects/SpellCaster.cpp @@ -1758,7 +1758,8 @@ bool SpellCaster::IsNoMovementSpellCasted() const return (true); else if (m_currentSpells[CURRENT_CHANNELED_SPELL] && m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED && - m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->HasSpellInterruptFlag(SPELL_INTERRUPT_FLAG_MOVEMENT)) + (m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->HasSpellInterruptFlag(SPELL_INTERRUPT_FLAG_MOVEMENT) || + m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->HasChannelInterruptFlag(AURA_INTERRUPT_MOVING_CANCELS))) return (true); // don't need to check for AUTOREPEAT_SPELL