mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 13:46:24 +00:00
fix(Core/Group): CF Faction Assign & Leader Instance Faction (#21118)
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
@@ -114,7 +114,17 @@ public:
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
if (!players.IsEmpty())
|
||||
if (Player* pPlayer = players.begin()->GetSource())
|
||||
TeamIdInInstance = pPlayer->GetTeamId();
|
||||
{
|
||||
if (Group* group = pPlayer->GetGroup())
|
||||
{
|
||||
if (Player* gLeader = ObjectAccessor::FindPlayer(group->GetLeaderGUID()))
|
||||
TeamIdInInstance = Player::TeamIdForRace(gLeader->getRace());
|
||||
else
|
||||
TeamIdInInstance = pPlayer->GetTeamId();
|
||||
}
|
||||
else
|
||||
TeamIdInInstance = pPlayer->GetTeamId();
|
||||
}
|
||||
}
|
||||
|
||||
switch (creature->GetEntry())
|
||||
@@ -271,9 +281,25 @@ public:
|
||||
|
||||
// EVENT STUFF BELOW:
|
||||
|
||||
void OnPlayerEnter(Player* plr) override
|
||||
void OnPlayerEnter(Player* player) override
|
||||
{
|
||||
if (DoNeedCleanup(plr))
|
||||
if (TeamIdInInstance == TEAM_NEUTRAL)
|
||||
{
|
||||
if (Group* group = player->GetGroup())
|
||||
{
|
||||
if (Player* gLeader = ObjectAccessor::FindPlayer(group->GetLeaderGUID()))
|
||||
TeamIdInInstance = Player::TeamIdForRace(gLeader->getRace());
|
||||
else
|
||||
TeamIdInInstance = player->GetTeamId();
|
||||
}
|
||||
else
|
||||
TeamIdInInstance = player->GetTeamId();
|
||||
}
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
|
||||
player->SetFaction((TeamIdInInstance == TEAM_HORDE) ? 1610 : 1);
|
||||
|
||||
if (DoNeedCleanup(player))
|
||||
{
|
||||
InstanceCleanup();
|
||||
}
|
||||
@@ -281,6 +307,12 @@ public:
|
||||
events.RescheduleEvent(EVENT_CHECK_PLAYERS, CLEANUP_CHECK_INTERVAL);
|
||||
}
|
||||
|
||||
void OnPlayerLeave(Player* player) override
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
|
||||
player->SetFactionForRace(player->getRace());
|
||||
}
|
||||
|
||||
bool DoNeedCleanup(Player* ignoredPlayer = nullptr)
|
||||
{
|
||||
uint8 aliveCount = 0;
|
||||
|
||||
@@ -1203,8 +1203,24 @@ public:
|
||||
if (Player* plr = itr->GetSource())
|
||||
if (!plr->IsGameMaster())
|
||||
{
|
||||
TeamIdInInstance = plr->GetTeamId();
|
||||
break;
|
||||
if (Group* group = plr->GetGroup())
|
||||
{
|
||||
if (Player* gLeader = ObjectAccessor::FindPlayer(group->GetLeaderGUID()))
|
||||
{
|
||||
TeamIdInInstance = Player::TeamIdForRace(gLeader->getRace());
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
TeamIdInInstance = plr->GetTeamId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TeamIdInInstance = plr->GetTeamId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Creature* c = instance->GetCreature(TeamIdInInstance == TEAM_ALLIANCE ? NPC_VarianGUID : NPC_GarroshGUID))
|
||||
@@ -1397,6 +1413,22 @@ public:
|
||||
|
||||
void OnPlayerEnter(Player* plr) override
|
||||
{
|
||||
if (TeamIdInInstance == TEAM_NEUTRAL)
|
||||
{
|
||||
if (Group* group = plr->GetGroup())
|
||||
{
|
||||
if (Player* gLeader = ObjectAccessor::FindPlayer(group->GetLeaderGUID()))
|
||||
TeamIdInInstance = Player::TeamIdForRace(gLeader->getRace());
|
||||
else
|
||||
TeamIdInInstance = plr->GetTeamId();
|
||||
}
|
||||
else
|
||||
TeamIdInInstance = plr->GetTeamId();
|
||||
}
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
|
||||
plr->SetFaction((TeamIdInInstance == TEAM_HORDE) ? 1610 : 1);
|
||||
|
||||
if (instance->IsHeroic())
|
||||
{
|
||||
plr->SendUpdateWorldState(UPDATE_STATE_UI_SHOW, 1);
|
||||
@@ -1416,6 +1448,12 @@ public:
|
||||
events.RescheduleEvent(EVENT_CHECK_PLAYERS, 5s);
|
||||
}
|
||||
|
||||
void OnPlayerLeave(Player* player) override
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
|
||||
player->SetFactionForRace(player->getRace());
|
||||
}
|
||||
|
||||
bool DoNeedCleanup(Player* ignoredPlayer = nullptr)
|
||||
{
|
||||
uint8 aliveCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user