aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/ScriptedAI
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2019-10-22 13:36:23 +0200
committerShauren <shauren.trinity@gmail.com>2021-12-18 23:13:20 +0100
commit50c90728b2079070037608c28ba33a714582ffa8 (patch)
tree6d358b6d4681e6981a6cadb9ae26d1a94d074d49 /src/server/game/AI/ScriptedAI
parent2f5d97b951f577b28adfdd37959ecba8711d7c23 (diff)
Core/AI: 06443e3 followup
(cherry picked from commit bb9af06cd4ff80f078fcb6ae4871c74a1a174bcc)
Diffstat (limited to 'src/server/game/AI/ScriptedAI')
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp58
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.h6
2 files changed, 40 insertions, 24 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index c0643792227..80ce28a98ee 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -236,6 +236,42 @@ float ScriptedAI::GetThreat(Unit const* victim, Unit const* who)
return who->GetThreatManager().GetThreat(victim);
}
+void ScriptedAI::ForceCombatStop(Creature* who, bool reset /*= true*/)
+{
+ if (!who || !who->IsInCombat())
+ return;
+
+ who->CombatStop(true);
+ who->DoNotReacquireSpellFocusTarget();
+ who->GetMotionMaster()->Clear(MOTION_PRIORITY_NORMAL);
+
+ if (reset) {
+ who->LoadCreaturesAddon();
+ who->SetLootRecipient(nullptr);
+ who->ResetPlayerDamageReq();
+ who->SetLastDamagedTime(0);
+ who->SetCannotReachTarget(false);
+ }
+}
+
+void ScriptedAI::ForceCombatStopForCreatureEntry(uint32 entry, float maxSearchRange /*= 250.0f*/, bool /*samePhase*/ /*= true*/, bool reset /*= true*/)
+{
+ TC_LOG_DEBUG("scripts.ai", "ScriptedAI::ForceCombatStopForCreatureEntry: called on '%s'. Debug info: %s", me->GetGUID().ToString().c_str(), me->GetDebugInfo().c_str());
+
+ std::list<Creature*> creatures;
+ Trinity::AllCreaturesOfEntryInRange check(me, entry, maxSearchRange);
+ Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(me, creatures, check);
+
+ // TODO: FIX THIS
+ //if (!samePhase)
+ // searcher.i_phaseMask = PHASEMASK_ANYWHERE;
+
+ Cell::VisitGridObjects(me, searcher, maxSearchRange);
+
+ for (Creature* creature : creatures)
+ ForceCombatStop(creature, reset);
+}
+
Creature* ScriptedAI::DoSpawnCreature(uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime)
{
return me->SummonCreature(entry, me->GetPositionX() + offsetX, me->GetPositionY() + offsetY, me->GetPositionZ() + offsetZ, angle, TempSummonType(type), despawntime);
@@ -515,28 +551,6 @@ void BossAI::TeleportCheaters()
}
}
-void BossAI::ForceCombatStopForCreatureEntry(uint32 entry, float maxSearchRange /*= 250.0f*/, bool reset /*= true*/)
-{
- TC_LOG_DEBUG("scripts.ai", "BossAI::ForceCombatStopForCreatureEntry: called on '%s'. Debug info: %s", me->GetGUID().ToString().c_str(), me->GetDebugInfo().c_str());
-
- std::list<Creature*> creatures;
- me->GetCreatureListWithEntryInGrid(creatures, entry, maxSearchRange);
-
- for (Creature* creature : creatures) {
- creature->CombatStop(true);
- creature->DoNotReacquireSpellFocusTarget();
- creature->GetMotionMaster()->Clear(MOTION_PRIORITY_NORMAL);
-
- if (reset) {
- creature->LoadCreaturesAddon();
- creature->SetLootRecipient(nullptr);
- creature->ResetPlayerDamageReq();
- creature->SetLastDamagedTime(0);
- creature->SetCannotReachTarget(false);
- }
- }
-}
-
void BossAI::JustSummoned(Creature* summon)
{
summons.Summon(summon);
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
index f31a274f06f..42d2006ebd4 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
@@ -188,6 +188,10 @@ struct TC_GAME_API ScriptedAI : public CreatureAI
void ResetThreatList(Unit* who = nullptr);
// Returns the threat level of victim towards who (or me if not specified)
float GetThreat(Unit const* victim, Unit const* who = nullptr);
+ // Stops combat, ignoring restrictions, for the given creature
+ void ForceCombatStop(Creature* who, bool reset = true);
+ // Stops combat, ignoring restrictions, for the found creatures
+ void ForceCombatStopForCreatureEntry(uint32 entry, float maxSearchRange = 250.0f, bool samePhase = true, bool reset = true);
void DoTeleportTo(float x, float y, float z, uint32 time = 0);
void DoTeleportTo(float const pos[4]);
@@ -339,8 +343,6 @@ class TC_GAME_API BossAI : public ScriptedAI
void TeleportCheaters();
- void ForceCombatStopForCreatureEntry(uint32 entry, float maxSearchRange = 250.0f, bool reset = true);
-
EventMap events;
SummonList summons;
TaskScheduler scheduler;