diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-06-24 23:31:53 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2025-06-24 23:31:53 +0200 |
commit | fd26363940c13a4581eb43554fd5d1caf2c00fbd (patch) | |
tree | b76ae40dce9faf791a2b4725dc81027e8920260e /src | |
parent | 39c06d40e26ca7c1651e266cde16e031066610f5 (diff) |
Core/Commands: Enable setting linked aggro and formation movement with .npc add formation and fix swapped saved dist/angle values
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/Commands/cs_npc.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 9577bac25ba..1bd81181d8a 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -1338,7 +1338,7 @@ public: return true; } - static bool HandleNpcAddFormationCommand(ChatHandler* handler, ObjectGuid::LowType leaderGUID) + static bool HandleNpcAddFormationCommand(ChatHandler* handler, ObjectGuid::LowType leaderGUID, Optional<bool> linkedAggro, Optional<bool> formationMovement) { Creature* creature = handler->getSelectedCreature(); @@ -1361,17 +1361,22 @@ public: Player* chr = handler->GetSession()->GetPlayer(); - float followAngle = (creature->GetAbsoluteAngle(chr) - chr->GetOrientation()) * 180.0f / float(M_PI); - float followDist = std::sqrt(std::pow(chr->GetPositionX() - creature->GetPositionX(), 2.f) + std::pow(chr->GetPositionY() - creature->GetPositionY(), 2.f)); + float followAngle = creature->GetRelativeAngle(chr) * 180.0f / float(M_PI); + float followDist = chr->GetExactDist2d(creature); uint32 groupAI = 0; + if (linkedAggro == true) + groupAI |= FLAG_MEMBERS_ASSIST_MEMBER; + if (formationMovement == true) + groupAI |= FLAG_IDLE_IN_FORMATION; + sFormationMgr->AddFormationMember(lowguid, followAngle, followDist, leaderGUID, groupAI); creature->SearchFormation(); WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_FORMATION); stmt->setUInt64(0, leaderGUID); stmt->setUInt64(1, lowguid); - stmt->setFloat (2, followAngle); - stmt->setFloat (3, followDist); + stmt->setFloat (2, followDist); + stmt->setFloat (3, followAngle); stmt->setUInt32(4, groupAI); WorldDatabase.Execute(stmt); |