aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/CreatureAI.cpp
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2019-06-26 01:04:27 +0200
committerShauren <shauren.trinity@gmail.com>2021-12-13 00:42:16 +0100
commitc9d52c954793404af02f75af97390d7c82c433ff (patch)
tree1def2651d94fbd57b494c6ce74e1398b3b9cac99 /src/server/game/AI/CreatureAI.cpp
parenteda6e5c316cd034a51130f0a45e784ec0947db4c (diff)
Core/AI: Actually accurately reproduce the logic from before 8499434 that determines what summons start following on appearance. Third time's the charm?
Closes #23513. (cherry picked from commit 3cdf27494ffe18d674a37561a2c573517a2cb533) (cherry picked from commit 63383da36e27657734cba6ad23c1bd3d68039d90)
Diffstat (limited to 'src/server/game/AI/CreatureAI.cpp')
-rw-r--r--src/server/game/AI/CreatureAI.cpp55
1 files changed, 40 insertions, 15 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index c74fd04ce57..9ded80817a1 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -159,25 +159,50 @@ void CreatureAI::TriggerAlert(Unit const* who) const
me->GetMotionMaster()->MoveDistract(5 * IN_MILLISECONDS, me->GetAbsoluteAngle(who));
}
-void CreatureAI::JustAppeared()
+// adapted from logic in Spell:EFfectSummonType before commit 8499434
+static bool ShouldFollowOnSpawn(SummonPropertiesEntry const* properties)
{
- // Filter which type of summons apply the following follow handling
- if (!me->IsSummon())
- return;
-
// Summons without SummonProperties are generally scripted summons that don't belong to any owner
- TempSummon* summon = me->ToTempSummon();
- if (!summon->m_Properties || (summon->m_Properties->Control != SUMMON_CATEGORY_UNK && summon->m_Properties->Control != SUMMON_CATEGORY_PET))
- return;
-
- // Not applied to vehicles
- if (summon->GetVehicle())
- return;
+ if (!properties)
+ return false;
- if (Unit* owner = summon->GetCharmerOrOwner())
+ switch (properties->Control)
{
- summon->GetMotionMaster()->Clear();
- summon->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, summon->GetFollowAngle());
+ case SUMMON_CATEGORY_PET:
+ return true;
+ case SUMMON_CATEGORY_WILD:
+ case SUMMON_CATEGORY_ALLY:
+ case SUMMON_CATEGORY_UNK:
+ if (properties->GetFlags().HasFlag(SummonPropertiesFlags::JoinSummonerSpawnGroup))
+ return true;
+ switch (SummonTitle(properties->Title))
+ {
+ case SummonTitle::Pet:
+ case SummonTitle::Guardian:
+ case SummonTitle::Runeblade:
+ case SummonTitle::Minion:
+ case SummonTitle::Companion:
+ return true;
+ default:
+ return false;
+ }
+ default:
+ return false;
+ }
+}
+void CreatureAI::JustAppeared()
+{
+ if (TempSummon* summon = me->ToTempSummon())
+ {
+ // Only apply this to specific types of summons
+ if (!summon->GetVehicle() && ShouldFollowOnSpawn(summon->m_Properties))
+ {
+ if (Unit* owner = summon->GetCharmerOrOwner())
+ {
+ summon->GetMotionMaster()->Clear();
+ summon->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, summon->GetFollowAngle());
+ }
+ }
}
}