@@ -368,6 +368,7 @@ void CLuaBattlefield::addGroups(const sol::table& groups, bool hasMultipleArenas
368368 // The entities to be added to the battlefield
369369 std::set<uint32> entities;
370370 std::set<uint32> spawnedEntities;
371+ std::set<uint32> explicitPartyEntities;
371372
372373 std::vector<BattlefieldGroup> battlefieldGroups;
373374 for (const auto & entry : groups)
@@ -490,6 +491,8 @@ void CLuaBattlefield::addGroups(const sol::table& groups, bool hasMultipleArenas
490491 {
491492 party->AddMember (PMob);
492493 }
494+
495+ explicitPartyEntities.insert (entity->id );
493496 }
494497 }
495498
@@ -586,7 +589,8 @@ void CLuaBattlefield::addGroups(const sol::table& groups, bool hasMultipleArenas
586589
587590 for (const auto & modifier : mobMods.get <sol::table>())
588591 {
589- PMob->setMobMod (modifier.first .as <uint16>(), modifier.second .as <uint16>());
592+ const auto mobMod = modifier.first .as <uint16>();
593+ PMob->setMobMod (mobMod, modifier.second .as <uint16>());
590594 }
591595 PMob->saveMobModifiers ();
592596 }
@@ -680,6 +684,37 @@ void CLuaBattlefield::addGroups(const sol::table& groups, bool hasMultipleArenas
680684 m_PLuaBattlefield->addGroup (group);
681685 }
682686
687+ // Rebuild party links after all the battlefield groups have their modifiers applied
688+ // This avoids ordering bugs when SUPERLINK/SUBLINK or other link-affecting state
689+ // are assigned after the zone-load party pass.
690+ for (uint32 entityID : entities)
691+ {
692+ if (explicitPartyEntities.find (entityID) != explicitPartyEntities.end ())
693+ {
694+ continue ;
695+ }
696+
697+ auto * PMob = dynamic_cast <CMobEntity*>(zoneutils::GetEntity (entityID, TYPE_MOB));
698+ if (PMob != nullptr && PMob->PParty != nullptr )
699+ {
700+ PMob->PParty ->RemoveMember (PMob);
701+ }
702+ }
703+
704+ for (uint32 entityID : entities)
705+ {
706+ if (explicitPartyEntities.find (entityID) != explicitPartyEntities.end ())
707+ {
708+ continue ;
709+ }
710+
711+ CBaseEntity* entity = zoneutils::GetEntity (entityID, TYPE_MOB);
712+ if (entity != nullptr )
713+ {
714+ m_PLuaBattlefield->GetZone ()->FindPartyForMob (entity);
715+ }
716+ }
717+
683718 if (m_PLuaBattlefield->GetArmouryCrate () != 0 )
684719 {
685720 if (auto * entity = dynamic_cast <CNpcEntity*>(zoneutils::GetEntity (m_PLuaBattlefield->GetArmouryCrate (), TYPE_NPC)))
0 commit comments