mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +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:
@@ -184,6 +184,9 @@ public:
|
||||
//Called when a player successfully enters the instance.
|
||||
virtual void OnPlayerEnter(Player* /*player*/) {}
|
||||
|
||||
//Called when a player successfully leaves the instance.
|
||||
virtual void OnPlayerLeave(Player* /*player*/) {}
|
||||
|
||||
virtual void OnPlayerAreaUpdate(Player* /*player*/, uint32 /*oldArea*/, uint32 /*newArea*/) {}
|
||||
|
||||
//Called when a player enters/leaves water bodies.
|
||||
|
||||
@@ -3048,6 +3048,9 @@ void InstanceMap::RemovePlayerFromMap(Player* player, bool remove)
|
||||
// If remove == true - player already deleted.
|
||||
if (!remove)
|
||||
player->SetPendingBind(0, 0);
|
||||
|
||||
if (instance_data)
|
||||
instance_data->OnPlayerLeave(player);
|
||||
}
|
||||
|
||||
void InstanceMap::AfterPlayerUnlinkFromMap()
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "Player.h"
|
||||
#include "ScriptedCreature.h"
|
||||
#include "forge_of_souls.h"
|
||||
#include "Group.h"
|
||||
|
||||
BossBoundaryData const boundaries =
|
||||
{
|
||||
@@ -69,8 +70,24 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void OnPlayerEnter(Player* /*plr*/) override
|
||||
void OnPlayerEnter(Player* player) override
|
||||
{
|
||||
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);
|
||||
|
||||
// this will happen only after crash and loading the instance from db
|
||||
if (m_auiEncounter[0] == DONE && m_auiEncounter[1] == DONE && (!NPC_LeaderSecondGUID || !instance->GetCreature(NPC_LeaderSecondGUID)))
|
||||
{
|
||||
@@ -79,6 +96,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void OnPlayerLeave(Player* player) override
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
|
||||
player->SetFactionForRace(player->getRace());
|
||||
}
|
||||
|
||||
void OnCreatureCreate(Creature* creature) override
|
||||
{
|
||||
if (teamIdInInstance == TEAM_NEUTRAL)
|
||||
@@ -86,7 +109,17 @@ public:
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
if (!players.IsEmpty())
|
||||
if (Player* player = players.begin()->GetSource())
|
||||
teamIdInInstance = player->GetTeamId();
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
switch (creature->GetEntry())
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "Transport.h"
|
||||
#include "halls_of_reflection.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "Group.h"
|
||||
|
||||
class UtherBatteredHiltEvent : public BasicEvent
|
||||
{
|
||||
@@ -213,6 +214,31 @@ public:
|
||||
return (instance->HavePlayers() && WaveNumber) || IsDuringLKFight; // during LK fight npcs are active and will unset this variable
|
||||
}
|
||||
|
||||
void OnPlayerEnter(Player* player) override
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void OnPlayerLeave(Player* player) override
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
|
||||
player->SetFactionForRace(player->getRace());
|
||||
}
|
||||
|
||||
void OnCreatureCreate(Creature* creature) override
|
||||
{
|
||||
if (TeamIdInInstance == TEAM_NEUTRAL)
|
||||
@@ -223,8 +249,24 @@ public:
|
||||
if (Player* p = itr->GetSource())
|
||||
if (!p->IsGameMaster())
|
||||
{
|
||||
TeamIdInInstance = p->GetTeamId();
|
||||
break;
|
||||
if (Group* group = p->GetGroup())
|
||||
{
|
||||
if (Player* gLeader = ObjectAccessor::FindPlayer(group->GetLeaderGUID()))
|
||||
{
|
||||
TeamIdInInstance = Player::TeamIdForRace(gLeader->getRace());
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
TeamIdInInstance = p->GetTeamId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TeamIdInInstance = p->GetTeamId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "Player.h"
|
||||
#include "ScriptedCreature.h"
|
||||
#include "pit_of_saron.h"
|
||||
#include "Group.h"
|
||||
|
||||
class instance_pit_of_saron : public InstanceMapScript
|
||||
{
|
||||
@@ -75,13 +76,35 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void OnPlayerEnter(Player* /*plr*/) override
|
||||
void OnPlayerEnter(Player* player) override
|
||||
{
|
||||
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);
|
||||
|
||||
instance->LoadGrid(LeaderIntroPos.GetPositionX(), LeaderIntroPos.GetPositionY());
|
||||
if (Creature* c = instance->GetCreature(GetGuidData(DATA_LEADER_FIRST_GUID)))
|
||||
c->AI()->SetData(DATA_START_INTRO, 0);
|
||||
}
|
||||
|
||||
void OnPlayerLeave(Player* player) override
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
|
||||
player->SetFactionForRace(player->getRace());
|
||||
}
|
||||
|
||||
uint32 GetCreatureEntry(ObjectGuid::LowType /*guidLow*/, CreatureData const* data) override
|
||||
{
|
||||
if (teamIdInInstance == TEAM_NEUTRAL)
|
||||
@@ -89,7 +112,17 @@ public:
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
if (!players.IsEmpty())
|
||||
if (Player* player = players.begin()->GetSource())
|
||||
teamIdInInstance = player->GetTeamId();
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
uint32 entry = data->id1;
|
||||
@@ -115,7 +148,17 @@ public:
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
if (!players.IsEmpty())
|
||||
if (Player* player = players.begin()->GetSource())
|
||||
teamIdInInstance = player->GetTeamId();
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
switch (creature->GetEntry())
|
||||
|
||||
@@ -262,7 +262,20 @@ public:
|
||||
void OnPlayerEnter(Player* player) override
|
||||
{
|
||||
if (TeamIdInInstance == TEAM_NEUTRAL)
|
||||
TeamIdInInstance = player->GetTeamId();
|
||||
{
|
||||
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);
|
||||
|
||||
// for professor putricide hc
|
||||
DoRemoveAurasDueToSpellOnPlayers(SPELL_GAS_VARIABLE);
|
||||
@@ -293,6 +306,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void OnPlayerLeave(Player* player) override
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
|
||||
player->SetFactionForRace(player->getRace());
|
||||
}
|
||||
|
||||
void OnCreatureCreate(Creature* creature) override
|
||||
{
|
||||
if (TeamIdInInstance == TEAM_NEUTRAL)
|
||||
@@ -300,7 +319,17 @@ public:
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
if (!players.IsEmpty())
|
||||
if (Player* player = players.begin()->GetSource())
|
||||
TeamIdInInstance = player->GetTeamId();
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// apply ICC buff to pets/summons
|
||||
@@ -537,6 +566,7 @@ public:
|
||||
}
|
||||
|
||||
InstanceScript::OnCreatureCreate(creature);
|
||||
|
||||
}
|
||||
|
||||
void OnCreatureRemove(Creature* creature) override
|
||||
@@ -554,7 +584,17 @@ public:
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
if (!players.IsEmpty())
|
||||
if (Player* player = players.begin()->GetSource())
|
||||
TeamIdInInstance = player->GetTeamId();
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
uint32 entry = data->id1;
|
||||
@@ -599,7 +639,17 @@ public:
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
if (!players.IsEmpty())
|
||||
if (Player* player = players.begin()->GetSource())
|
||||
TeamIdInInstance = player->GetTeamId();
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
switch (entry)
|
||||
@@ -703,7 +753,17 @@ public:
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
if (!players.IsEmpty())
|
||||
if (Player* player = players.begin()->GetSource())
|
||||
TeamIdInInstance = player->GetTeamId();
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
switch (go->GetEntry())
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "ScriptedCreature.h"
|
||||
#include "nexus.h"
|
||||
#include "Player.h"
|
||||
#include "Group.h"
|
||||
|
||||
DoorData const doorData[] =
|
||||
{
|
||||
@@ -48,15 +49,29 @@ public:
|
||||
SetHeaders(DataHeader);
|
||||
SetBossNumber(MAX_ENCOUNTERS);
|
||||
LoadDoorData(doorData);
|
||||
|
||||
TeamIdInInstance = TEAM_NEUTRAL;
|
||||
}
|
||||
|
||||
void OnCreatureCreate(Creature* creature) override
|
||||
{
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
TeamId TeamIdInInstance = TEAM_NEUTRAL;
|
||||
if (!players.IsEmpty())
|
||||
if (Player* pPlayer = players.begin()->GetSource())
|
||||
TeamIdInInstance = pPlayer->GetTeamId();
|
||||
if (TeamIdInInstance == TEAM_NEUTRAL)
|
||||
{
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
if (!players.IsEmpty())
|
||||
if (Player* pPlayer = players.begin()->GetSource())
|
||||
{
|
||||
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())
|
||||
{
|
||||
@@ -88,6 +103,31 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void OnPlayerEnter(Player* player) override
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void OnPlayerLeave(Player* player) override
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
|
||||
player->SetFactionForRace(player->getRace());
|
||||
}
|
||||
|
||||
void OnGameObjectCreate(GameObject* gameObject) override
|
||||
{
|
||||
switch (gameObject->GetEntry())
|
||||
@@ -154,6 +194,8 @@ public:
|
||||
(*i)->RemoveGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
|
||||
return true;
|
||||
}
|
||||
protected:
|
||||
TeamId TeamIdInInstance;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "InstanceMapScript.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "shattered_halls.h"
|
||||
#include "Group.h"
|
||||
|
||||
ObjectData const creatureData[] =
|
||||
{
|
||||
@@ -66,8 +67,26 @@ public:
|
||||
void OnPlayerEnter(Player* player) override
|
||||
{
|
||||
if (TeamIdInInstance == TEAM_NEUTRAL)
|
||||
TeamIdInInstance = player->GetTeamId();
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void OnPlayerLeave(Player* player) override
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
|
||||
player->SetFactionForRace(player->getRace());
|
||||
}
|
||||
|
||||
void OnCreatureCreate(Creature* creature) override
|
||||
@@ -77,7 +96,17 @@ public:
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
if (!players.IsEmpty())
|
||||
if (Player* player = players.begin()->GetSource())
|
||||
TeamIdInInstance = player->GetTeamId();
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
switch (creature->GetEntry())
|
||||
|
||||
Reference in New Issue
Block a user