From a8e4653a4658c96a441603928d14087ed4fe7f3f Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Mon, 18 Aug 2025 19:48:05 -0400 Subject: [PATCH] Core/Commands: Enable setting linked aggro and formation movement with .npc add formation and fix swapped saved dist/angle values Port From (https://github.com/TrinityCore/TrinityCore/commit/fd26363940c13a4581eb43554fd5d1caf2c00fbd) --- Source/Game/Chat/Commands/NPCCommands.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Source/Game/Chat/Commands/NPCCommands.cs b/Source/Game/Chat/Commands/NPCCommands.cs index 8180e0f4b..ddb09fa4c 100644 --- a/Source/Game/Chat/Commands/NPCCommands.cs +++ b/Source/Game/Chat/Commands/NPCCommands.cs @@ -773,7 +773,7 @@ namespace Game.Chat } [Command("formation", RBACPermissions.CommandNpcAddFormation)] - static bool HandleNpcAddFormationCommand(CommandHandler handler, ulong leaderGUID) + static bool HandleNpcAddFormationCommand(CommandHandler handler, ulong leaderGUID, bool? linkedAggro, bool? formationMovement) { Creature creature = handler.GetSelectedCreature(); if (creature == null || creature.GetSpawnId() == 0) @@ -793,18 +793,23 @@ namespace Game.Chat return false; Player chr = handler.GetSession().GetPlayer(); - float followAngle = (creature.GetAbsoluteAngle(chr) - chr.GetOrientation()) * 180.0f / MathF.PI; - float followDist = MathF.Sqrt(MathF.Pow(chr.GetPositionX() - creature.GetPositionX(), 2f) + MathF.Pow(chr.GetPositionY() - creature.GetPositionY(), 2f)); - uint groupAI = 0; - FormationMgr.AddFormationMember(lowguid, followAngle, followDist, leaderGUID, groupAI); + float followAngle = creature.GetRelativeAngle(chr) * 180.0f / MathF.PI; + float followDist = chr.GetExactDist2d(creature); + GroupAIFlags groupAI = 0; + if (linkedAggro == true) + groupAI |= GroupAIFlags.MembersAssistMember; + if (formationMovement == true) + groupAI |= GroupAIFlags.IdleInFormation; + + FormationMgr.AddFormationMember(lowguid, followAngle, followDist, leaderGUID, (uint)groupAI); creature.SearchFormation(); PreparedStatement stmt = WorldDatabase.GetPreparedStatement(WorldStatements.INS_CREATURE_FORMATION); stmt.AddValue(0, leaderGUID); stmt.AddValue(1, lowguid); - stmt.AddValue(2, followAngle); - stmt.AddValue(3, followDist); - stmt.AddValue(4, groupAI); + stmt.AddValue(2, followDist); + stmt.AddValue(3, followAngle); + stmt.AddValue(4, (uint)groupAI); DB.World.Execute(stmt);