Battlefield/Wintergrasp:

* Use correct spells on losing and winning factions
* Enums renaming, lowerCamelCase wherever applicable
* Rename some methods and class attributes for them to sound more English and less Engrish or even Frenglish (\o/)
* Use correct spells when trying to build mechanical units at the Workshops.
This commit is contained in:
Warpten
2012-08-20 13:50:49 -04:00
committed by Kandera
parent d31902d858
commit 094f98d3a9
10 changed files with 1389 additions and 1425 deletions
+195 -202
View File
@@ -32,12 +32,11 @@
#include "CreatureTextMgr.h"
#include "GroupMgr.h"
Battlefield::Battlefield()
{
m_Timer = 0;
m_enable = true;
m_BattlefieldActive = false;
m_IsEnabled = true;
m_isActive = false;
m_DefenderTeam = TEAM_NEUTRAL;
m_TypeId = 0;
@@ -51,7 +50,7 @@ Battlefield::Battlefield()
m_TimeForAcceptInvite = 20;
m_uiKickDontAcceptTimer = 1000;
m_uiKickAfkTimer = 1000;
m_uiKickAfkPlayersTimer = 1000;
m_LastResurectTimer = 30 * IN_MILLISECONDS;
m_StartGroupingTimer = 0;
@@ -63,50 +62,49 @@ Battlefield::~Battlefield()
{
}
void Battlefield::HandlePlayerEnterZone(Player *player, uint32 /*zone */ )
// Called when a player enters the zone
void Battlefield::HandlePlayerEnterZone(Player* player, uint32 /*zone*/)
{
//If battle is start,
// if it not fully > invite player to join the war
// if it fully > announce to player that BF is full and kick after few second if he dont leave
// If battle is started,
// If not full of players > invite player to join the war
// If full of players > announce to player that BF is full and kick him after a few second if he desn't leave
if (IsWarTime())
{
if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer) //Not fully
{
if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer) // Vacant spaces
InvitePlayerToWar(player);
}
else //Full
else // No more vacant places
{
//TODO:Send packet for announce it to player
// TODO: Send a packet to announce it to player
m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + 10;
InvitePlayerToQueue(player);
}
}
else
{
//If time left is <15 minutes invite player to join queue
// If time left is < 15 minutes invite player to join queue
if (m_Timer <= m_StartGroupingTimer)
InvitePlayerToQueue(player);
}
//Add player in list of player in zone
// Add player in the list of player in zone
m_players[player->GetTeamId()].insert(player->GetGUID());
OnPlayerEnterZone(player); //for scripting
OnPlayerEnterZone(player);
}
//Called when a player leave the zone
void Battlefield::HandlePlayerLeaveZone(Player *player, uint32 /*zone */ )
// Called when a player leave the zone
void Battlefield::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/)
{
if (IsWarTime())
{
//if player is in war list
// If the player is participating to the battle
if (m_PlayersInWar[player->GetTeamId()].find(player->GetGUID()) != m_PlayersInWar[player->GetTeamId()].end())
{
m_PlayersInWar[player->GetTeamId()].erase(player->GetGUID());
player->GetSession()->SendBfLeaveMessage(m_BattleId);
if (Group* group = player->GetGroup()) // remove from raid group if player is member
if (Group* group = player->GetGroup()) // Remove the player from the raid group
group->RemoveMember(player->GetGUID());
OnPlayerLeaveWar(player); //For scripting
OnPlayerLeaveWar(player);
}
}
@@ -118,55 +116,54 @@ void Battlefield::HandlePlayerLeaveZone(Player *player, uint32 /*zone */ )
m_players[player->GetTeamId()].erase(player->GetGUID());
SendRemoveWorldStates(player);
RemovePlayerFromResurrectQueue(player->GetGUID());
OnPlayerLeaveZone(player); //For scripting
OnPlayerLeaveZone(player);
}
bool Battlefield::Update(uint32 diff)
{
//When global timer is end
if (m_Timer <= diff)
{
//Here end of battle by timer
// Battlefield ends on time
if (IsWarTime())
EndBattle(true);
//Start of battle
else
else // Time to start a new battle!
StartBattle();
}
else
m_Timer -= diff;
//Some times before battle start invite player to queue
// Invite players a few minutes before the battle's beginning
if (!m_StartGrouping && m_Timer <= m_StartGroupingTimer)
{
m_StartGrouping = true;
InvitePlayerInZoneToQueue();
OnStartGrouping(); // for scripting
InvitePlayersInZoneToQueue();
OnStartGrouping();
}
bool objective_changed = false;
if (IsWarTime())
{
if (m_uiKickAfkTimer <= diff)
if (m_uiKickAfkPlayersTimer <= diff)
{
m_uiKickAfkTimer = 1000;
KickAfk();
m_uiKickAfkPlayersTimer = 1000;
KickAfkPlayers();
}
else
m_uiKickAfkTimer -= diff;
m_uiKickAfkPlayersTimer -= diff;
//Here kick player witch dont have accept invitation to join the war when time is end (time of windows)
// Kick players who chose not to accept invitation to the battle
if (m_uiKickDontAcceptTimer <= diff)
{
for (int team = 0; team < 2; team++)
for (PlayerTimerMap::iterator itr = m_InvitedPlayers[team].begin(); itr != m_InvitedPlayers[team].end(); itr++)
if ((*itr).second <= time(NULL))
KickPlayerFromBf((*itr).first);
InvitePlayerInZoneToWar();
KickPlayerFromBattlefield((*itr).first);
InvitePlayersInZoneToWar();
for (int team = 0; team < 2; team++)
for (PlayerTimerMap::iterator itr = m_PlayersWillBeKick[team].begin(); itr != m_PlayersWillBeKick[team].end(); itr++)
if ((*itr).second <= time(NULL))
KickPlayerFromBf((*itr).first);
KickPlayerFromBattlefield((*itr).first);
m_uiKickDontAcceptTimer = 1000;
}
@@ -181,9 +178,9 @@ bool Battlefield::Update(uint32 diff)
if (m_LastResurectTimer <= diff)
{
for (uint8 i = 0; i < m_GraveYardList.size(); i++)
if (GetGraveYardById(i))
m_GraveYardList[i]->Resurrect();
for (uint8 i = 0; i < m_GraveyardList.size(); i++)
if (GetGraveyardById(i))
m_GraveyardList[i]->Resurrect();
m_LastResurectTimer = RESURRECTION_INTERVAL;
}
else
@@ -192,7 +189,7 @@ bool Battlefield::Update(uint32 diff)
return objective_changed;
}
void Battlefield::InvitePlayerInZoneToQueue()
void Battlefield::InvitePlayersInZoneToQueue()
{
for (uint8 team = 0; team < 2; ++team)
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
@@ -200,16 +197,16 @@ void Battlefield::InvitePlayerInZoneToQueue()
InvitePlayerToQueue(player);
}
void Battlefield::InvitePlayerToQueue(Player *player)
void Battlefield::InvitePlayerToQueue(Player* player)
{
if (m_PlayersInQueue[player->GetTeamId()].count(player->GetGUID()))
return;
if (m_PlayersInQueue[player->GetTeam()].size() <= m_MinPlayer || m_PlayersInQueue[player->GetTeam() == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE].size() >= m_MinPlayer)
if (m_PlayersInQueue[player->GetTeam()].size() <= m_MinPlayer || m_PlayersInQueue[GetOtherTeam(player->GetTeamId())].size() >= m_MinPlayer)
player->GetSession()->SendBfInvitePlayerToQueue(m_BattleId);
}
void Battlefield::InvitePlayerInQueueToWar()
void Battlefield::InvitePlayersInQueueToWar()
{
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
{
@@ -229,7 +226,7 @@ void Battlefield::InvitePlayerInQueueToWar()
}
}
void Battlefield::InvitePlayerInZoneToWar()
void Battlefield::InvitePlayersInZoneToWar()
{
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
@@ -240,16 +237,13 @@ void Battlefield::InvitePlayerInZoneToWar()
continue;
if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer)
InvitePlayerToWar(player);
else
{
//full
else // Battlefield is full of players
m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + 10;
}
}
}
}
void Battlefield::InvitePlayerToWar(Player *player)
void Battlefield::InvitePlayerToWar(Player* player)
{
if (!player)
return;
@@ -264,13 +258,15 @@ void Battlefield::InvitePlayerToWar(Player *player)
return;
}
// If the player does not match minimal level requirements for the battlefield, kick him
if (player->getLevel() < m_MinLevel)
{
if (m_PlayersWillBeKick[player->GetTeamId()].count(player->GetGUID()) == 0)
m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + 10;
return;
}
//Check if player is not already in war
// Check if player is not already in war
if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID()))
return;
@@ -287,16 +283,16 @@ void Battlefield::InitStalker(uint32 entry, float x, float y, float z, float o)
sLog->outError("Battlefield::InitStalker: could not spawn Stalker (Creature entry %u), zone messeges will be un-available", entry);
}
void Battlefield::KickAfk()
void Battlefield::KickAfkPlayers()
{
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = sObjectAccessor->FindPlayer(*itr))
if (player->isAFK())
KickPlayerFromBf(*itr);
KickPlayerFromBattlefield(*itr);
}
void Battlefield::KickPlayerFromBf(uint64 guid)
void Battlefield::KickPlayerFromBattlefield(uint64 guid)
{
if (Player* player = sObjectAccessor->FindPlayer(guid))
if (player->GetZoneId() == GetZoneId())
@@ -305,7 +301,7 @@ void Battlefield::KickPlayerFromBf(uint64 guid)
void Battlefield::StartBattle()
{
if (m_BattlefieldActive)
if (m_isActive)
return;
for (int team = 0; team < BG_TEAMS_COUNT; team++)
@@ -315,41 +311,41 @@ void Battlefield::StartBattle()
}
m_Timer = m_BattleTime;
m_BattlefieldActive = true;
m_isActive = true;
InvitePlayerInZoneToWar();
InvitePlayerInQueueToWar();
InvitePlayersInZoneToWar();
InvitePlayersInQueueToWar();
PlaySoundToAll(BF_START);
DoPlaySoundToAll(BF_START);
OnBattleStart();
}
void Battlefield::EndBattle(bool endbytimer)
void Battlefield::EndBattle(bool endByTimer)
{
if (!m_BattlefieldActive)
if (!m_isActive)
return;
m_BattlefieldActive = false;
m_isActive = false;
m_StartGrouping = false;
if (!endbytimer)
if (!endByTimer)
SetDefenderTeam(GetAttackerTeam());
if (GetDefenderTeam() == TEAM_ALLIANCE)
PlaySoundToAll(BF_ALLIANCE_WINS); // alliance wins sound
DoPlaySoundToAll(BF_ALLIANCE_WINS);
else
PlaySoundToAll(BF_HORDE_WINS); // horde wins sound
DoPlaySoundToAll(BF_HORDE_WINS);
OnBattleEnd(endbytimer);
OnBattleEnd(endByTimer);
// reset bf timer
// Reset battlefield timer
m_Timer = m_NoWarBattleTime;
SendInitWorldStatesToAll();
}
void Battlefield::PlaySoundToAll(uint32 SoundID)
void Battlefield::DoPlaySoundToAll(uint32 SoundID)
{
WorldPacket data;
data.Initialize(SMSG_PLAY_SOUND, 4);
@@ -357,34 +353,33 @@ void Battlefield::PlaySoundToAll(uint32 SoundID)
for (int team = 0; team < BG_TEAMS_COUNT; team++)
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
{
if (Player* player = sObjectAccessor->FindPlayer(*itr))
player->GetSession()->SendPacket(&data);
}
}
bool Battlefield::HasPlayer(Player *player) const
bool Battlefield::HasPlayer(Player* player) const
{
return m_players[player->GetTeamId()].find(player->GetGUID()) != m_players[player->GetTeamId()].end();
}
// Called in WorldSession::HandleBfQueueInviteResponse
void Battlefield::PlayerAcceptInviteToQueue(Player *player)
void Battlefield::PlayerAcceptInviteToQueue(Player* player)
{
// Add player in queueVenez
// Add player in queue
m_PlayersInQueue[player->GetTeamId()].insert(player->GetGUID());
// Send notification
player->GetSession()->SendBfQueueInviteResponce(m_BattleId, m_ZoneId);
player->GetSession()->SendBfQueueInviteResponse(m_BattleId, m_ZoneId);
}
// Called in WorldSession::HandleBfExitRequest
void Battlefield::AskToLeaveQueue(Player *player)
void Battlefield::AskToLeaveQueue(Player* player)
{
// Remove player from queue
m_PlayersInQueue[player->GetTeamId()].erase(player->GetGUID());
}
// Called in WorldSession::HandleBfEntryInviteResponse
void Battlefield::PlayerAcceptInviteToWar(Player *player)
void Battlefield::PlayerAcceptInviteToWar(Player* player)
{
if (!IsWarTime())
return;
@@ -394,7 +389,7 @@ void Battlefield::PlayerAcceptInviteToWar(Player *player)
player->GetSession()->SendBfEntered(m_BattleId);
m_PlayersInWar[player->GetTeamId()].insert(player->GetGUID());
m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
//Remove player AFK
if (player->isAFK())
player->ToggleAFK();
@@ -407,14 +402,14 @@ void Battlefield::TeamCastSpell(TeamId team, int32 spellId)
if (spellId > 0)
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = sObjectAccessor->FindPlayer(*itr))
player->CastSpell(player, (uint32) spellId, true);
player->CastSpell(player, uint32(spellId), true);
else
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = sObjectAccessor->FindPlayer(*itr))
player->RemoveAuraFromStack((uint32) - spellId);
player->RemoveAuraFromStack(uint32(-spellId));
}
void Battlefield::BroadcastPacketZone(WorldPacket & data) const
void Battlefield::BroadcastPacketToZone(WorldPacket& data) const
{
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
@@ -422,7 +417,7 @@ void Battlefield::BroadcastPacketZone(WorldPacket & data) const
player->GetSession()->SendPacket(&data);
}
void Battlefield::BroadcastPacketQueue(WorldPacket & data) const
void Battlefield::BroadcastPacketToQueue(WorldPacket& data) const
{
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
for (GuidSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
@@ -430,7 +425,7 @@ void Battlefield::BroadcastPacketQueue(WorldPacket & data) const
player->GetSession()->SendPacket(&data);
}
void Battlefield::BroadcastPacketWar(WorldPacket & data) const
void Battlefield::BroadcastPacketToWar(WorldPacket& data) const
{
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
@@ -477,14 +472,13 @@ void Battlefield::SendWarningToAllInZone(uint32 entry)
WorldPacket data = BuildWarningAnnPacket(msg);
BroadcastPacketWar(data);
}*/
void Battlefield::SendWarningToPlayer(Player *player, uint32 entry)
{
if (!player)
return;
if (Unit* unit = sObjectAccessor->FindUnit(StalkerGuid))
if (Creature* stalker = unit->ToCreature())
sCreatureTextMgr->SendChat(stalker, (uint8)entry, player->GetGUID());
void Battlefield::SendWarningToPlayer(Player* player, uint32 entry)
{
if (player)
if (Unit* unit = sObjectAccessor->FindUnit(StalkerGuid))
if (Creature* stalker = unit->ToCreature())
sCreatureTextMgr->SendChat(stalker, (uint8)entry, player->GetGUID());
}
void Battlefield::SendUpdateWorldState(uint32 field, uint32 value)
@@ -500,38 +494,37 @@ void Battlefield::RegisterZone(uint32 zoneId)
sBattlefieldMgr->AddZone(zoneId, this);
}
void Battlefield::HideNpc(Creature *p_Creature)
void Battlefield::HideNpc(Creature* creature)
{
p_Creature->CombatStop();
p_Creature->SetReactState(REACT_PASSIVE);
p_Creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
p_Creature->SetPhaseMask(2, true);
p_Creature->DisappearAndDie();
p_Creature->SetVisible(false);
creature->CombatStop();
creature->SetReactState(REACT_PASSIVE);
creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
creature->SetPhaseMask(2, true);
creature->DisappearAndDie();
creature->SetVisible(false);
}
void Battlefield::ShowNpc(Creature *p_Creature, bool p_Aggressive)
void Battlefield::ShowNpc(Creature* creature, bool aggressive)
{
p_Creature->SetPhaseMask(1, true);
p_Creature->SetVisible(true);
p_Creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
if (!p_Creature->isAlive())
p_Creature->Respawn(true);
if (p_Aggressive)
p_Creature->SetReactState(REACT_AGGRESSIVE);
creature->SetPhaseMask(1, true);
creature->SetVisible(true);
creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
if (!creature->isAlive())
creature->Respawn(true);
if (aggressive)
creature->SetReactState(REACT_AGGRESSIVE);
else
{
p_Creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
p_Creature->SetReactState(REACT_PASSIVE);
creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
creature->SetReactState(REACT_PASSIVE);
}
}
//*****************************************************
//*******************Group System**********************
//*****************************************************
Group *Battlefield::GetFreeBfRaid(TeamId TeamId)
// ****************************************************
// ******************* Group System *******************
// ****************************************************
Group* Battlefield::GetFreeBfRaid(TeamId TeamId)
{
//if found free group we return it
for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
if (!group->IsFull())
@@ -540,7 +533,7 @@ Group *Battlefield::GetFreeBfRaid(TeamId TeamId)
return NULL;
}
Group *Battlefield::GetGroupPlayer(uint64 guid, TeamId TeamId)
Group* Battlefield::GetGroupPlayer(uint64 guid, TeamId TeamId)
{
for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
@@ -550,7 +543,7 @@ Group *Battlefield::GetGroupPlayer(uint64 guid, TeamId TeamId)
return NULL;
}
bool Battlefield::AddOrSetPlayerToCorrectBfGroup(Player *player)
bool Battlefield::AddOrSetPlayerToCorrectBfGroup(Player* player)
{
if (!player->IsInWorld())
return false;
@@ -583,97 +576,97 @@ bool Battlefield::AddOrSetPlayerToCorrectBfGroup(Player *player)
//*****************************************************
//***************Spirit Guide System*******************
//*****************************************************
//--------------------
//-Battlefield Method-
//--------------------
BfGraveYard *Battlefield::GetGraveYardById(uint32 id)
BfGraveyard* Battlefield::GetGraveyardById(uint32 id)
{
if (id < m_GraveYardList.size())
if (id < m_GraveyardList.size())
{
if (m_GraveYardList[id])
return m_GraveYardList[id];
if (m_GraveyardList[id])
return m_GraveyardList[id];
else
sLog->outError("Battlefield::GetGraveYardById Id:%u not existed", id);
sLog->outError("Battlefield::GetGraveyardById Id:%u not existed", id);
}
else
sLog->outError("Battlefield::GetGraveYardById Id:%u cant be found", id);
sLog->outError("Battlefield::GetGraveyardById Id:%u cant be found", id);
return NULL;
}
WorldSafeLocsEntry const *Battlefield::GetClosestGraveYard(Player *player)
WorldSafeLocsEntry const * Battlefield::GetClosestGraveYard(Player* player)
{
BfGraveYard* closestGY = NULL;
BfGraveyard* closestGY = NULL;
float maxdist = -1;
for (uint8 i = 0; i < m_GraveYardList.size(); i++)
for (uint8 i = 0; i < m_GraveyardList.size(); i++)
{
if (m_GraveYardList[i])
if (m_GraveyardList[i])
{
if (m_GraveYardList[i]->GetControlTeamId() != player->GetTeamId())
if (m_GraveyardList[i]->GetControlTeamId() != player->GetTeamId())
continue;
float dist = m_GraveYardList[i]->GetDistance(player);
float dist = m_GraveyardList[i]->GetDistance(player);
if (dist < maxdist || maxdist < 0)
{
closestGY = m_GraveYardList[i];
closestGY = m_GraveyardList[i];
maxdist = dist;
}
}
}
if (closestGY)
return sWorldSafeLocsStore.LookupEntry(closestGY->GetGraveYardId());
return sWorldSafeLocsStore.LookupEntry(closestGY->GetGraveyardId());
return NULL;
}
void Battlefield::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid)
void Battlefield::AddPlayerToResurrectQueue(uint64 npcGuid, uint64 playerGuid)
{
for (uint8 i = 0; i < m_GraveYardList.size(); i++)
for (uint8 i = 0; i < m_GraveyardList.size(); i++)
{
if (!m_GraveYardList[i])
if (!m_GraveyardList[i])
continue;
if (m_GraveYardList[i]->HasNpc(npc_guid))
if (m_GraveyardList[i]->HasNpc(npcGuid))
{
m_GraveYardList[i]->AddPlayer(player_guid);
m_GraveyardList[i]->AddPlayer(playerGuid);
break;
}
}
}
void Battlefield::RemovePlayerFromResurrectQueue(uint64 player_guid)
void Battlefield::RemovePlayerFromResurrectQueue(uint64 playerGuid)
{
for (uint8 i = 0; i < m_GraveYardList.size(); i++)
for (uint8 i = 0; i < m_GraveyardList.size(); i++)
{
if (!m_GraveYardList[i])
if (!m_GraveyardList[i])
continue;
if (m_GraveYardList[i]->HasPlayer(player_guid))
if (m_GraveyardList[i]->HasPlayer(playerGuid))
{
m_GraveYardList[i]->RemovePlayer(player_guid);
m_GraveyardList[i]->RemovePlayer(playerGuid);
break;
}
}
}
void Battlefield::SendAreaSpiritHealerQueryOpcode(Player *pl, const uint64 &guid)
void Battlefield::SendAreaSpiritHealerQueryOpcode(Player* player, const uint64 &guid)
{
sLog->outError("SendAreaSpiritHealerQueryOpcode");
WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12);
uint32 time = m_LastResurectTimer; // resurrect every 30 seconds
data << guid << time;
ASSERT(pl && pl->GetSession());
pl->GetSession()->SendPacket(&data);
ASSERT(player && player->GetSession());
player->GetSession()->SendPacket(&data);
}
//--------------------
//-BfGraveYard Method-
//--------------------
BfGraveYard::BfGraveYard(Battlefield *Bf)
// ----------------------
// - BfGraveyard Method -
// ----------------------
BfGraveyard::BfGraveyard(Battlefield* battlefield)
{
m_Bf = Bf;
m_Bf = battlefield;
m_GraveyardId = 0;
m_ControlTeam = TEAM_NEUTRAL;
m_SpiritGuide[0] = NULL;
@@ -681,17 +674,17 @@ BfGraveYard::BfGraveYard(Battlefield *Bf)
m_ResurrectQueue.clear();
}
void BfGraveYard::Initialize(TeamId startcontrol, uint32 gy)
void BfGraveyard::Initialize(TeamId startControl, uint32 graveyardId)
{
m_ControlTeam = startcontrol;
m_GraveyardId = gy;
m_ControlTeam = startControl;
m_GraveyardId = graveyardId;
}
void BfGraveYard::SetSpirit(Creature* spirit, TeamId team)
void BfGraveyard::SetSpirit(Creature* spirit, TeamId team)
{
if (!spirit)
{
sLog->outError("<Error - Wintergrasp>: Invalid Spirit.");
sLog->outError("BfGraveyard::SetSpirit: Invalid Spirit.");
return;
}
@@ -699,32 +692,32 @@ void BfGraveYard::SetSpirit(Creature* spirit, TeamId team)
spirit->SetReactState(REACT_PASSIVE);
}
float BfGraveYard::GetDistance(Player *player)
float BfGraveyard::GetDistance(Player* player)
{
const WorldSafeLocsEntry* ws = sWorldSafeLocsStore.LookupEntry(m_GraveyardId);
return player->GetDistance2d(ws->x, ws->y);
const WorldSafeLocsEntry* safeLoc = sWorldSafeLocsStore.LookupEntry(m_GraveyardId);
return player->GetDistance2d(safeLoc->x, safeLoc->y);
}
void BfGraveYard::AddPlayer(uint64 player_guid)
void BfGraveyard::AddPlayer(uint64 playerGuid)
{
if (!m_ResurrectQueue.count(player_guid))
if (!m_ResurrectQueue.count(playerGuid))
{
m_ResurrectQueue.insert(player_guid);
m_ResurrectQueue.insert(playerGuid);
if (Player* player = sObjectAccessor->FindPlayer(player_guid))
if (Player* player = sObjectAccessor->FindPlayer(playerGuid))
player->CastSpell(player, SPELL_WAITING_FOR_RESURRECT, true);
}
}
void BfGraveYard::RemovePlayer(uint64 player_guid)
void BfGraveyard::RemovePlayer(uint64 playerGuid)
{
m_ResurrectQueue.erase(m_ResurrectQueue.find(player_guid));
m_ResurrectQueue.erase(m_ResurrectQueue.find(playerGuid));
if (Player* player = sObjectAccessor->FindPlayer(player_guid))
if (Player* player = sObjectAccessor->FindPlayer(playerGuid))
player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT);
}
void BfGraveYard::Resurrect()
void BfGraveyard::Resurrect()
{
if (m_ResurrectQueue.empty())
return;
@@ -736,7 +729,7 @@ void BfGraveYard::Resurrect()
if (!player)
continue;
// Check player isinworld and player is on good graveyard
// Check if the player is in world and on the good graveyard
if (player->IsInWorld())
if (Unit* spirit = sObjectAccessor->FindUnit(m_SpiritGuide[m_ControlTeam]))
spirit->CastSpell(spirit, SPELL_SPIRIT_HEAL, true);
@@ -754,7 +747,7 @@ void BfGraveYard::Resurrect()
}
// For changing graveyard control
void BfGraveYard::ChangeControl(TeamId team)
void BfGraveyard::GiveControlTo(TeamId team)
{
// Guide switching
// Note: Visiblity changes are made by phasing
@@ -768,52 +761,51 @@ void BfGraveYard::ChangeControl(TeamId team)
RelocateDeadPlayers();
}
void BfGraveYard::RelocateDeadPlayers()
void BfGraveyard::RelocateDeadPlayers()
{
WorldSafeLocsEntry const* ClosestGrave = NULL;
WorldSafeLocsEntry const* closestGrave = NULL;
for (GuidSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
{
Player* player = sObjectAccessor->FindPlayer(*itr);
if (!player)
continue;
if (ClosestGrave)
player->TeleportTo(player->GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation());
if (closestGrave)
player->TeleportTo(player->GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation());
else
{
ClosestGrave = m_Bf->GetClosestGraveYard(player);
if (ClosestGrave)
player->TeleportTo(player->GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation());
closestGrave = m_Bf->GetClosestGraveYard(player);
if (closestGrave)
player->TeleportTo(player->GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation());
}
}
}
//***************End Spirit Guide system***************
// *******************************************************
// *************** End Spirit Guide system ***************
// *******************************************************
// ********************** Misc ***************************
// *******************************************************
//*****************************************************
//**********************Misc***************************
//*****************************************************
//Method for spawn creature on map
Creature *Battlefield::SpawnCreature(uint32 entry, Position pos, TeamId team)
Creature* Battlefield::SpawnCreature(uint32 entry, Position pos, TeamId team)
{
return SpawnCreature(entry, pos.m_positionX, pos.m_positionY, pos.m_positionZ, pos.m_orientation, team);
}
Creature *Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId team)
Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId team)
{
//Get map object
Map* map = const_cast < Map * >(sMapMgr->CreateBaseMap(m_MapId));
if (!map)
{
sLog->outError("Can't create creature entry: %u map not found", entry);
sLog->outError("Battlefield::SpawnCreature: Can't create creature entry: %u map not found", entry);
return 0;
}
//Create creature
Creature* creature = new Creature;
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, team, x, y, z, o))
{
sLog->outError("Can't create creature entry: %u", entry);
sLog->outError("Battlefield::SpawnCreature: Can't create creature entry: %u", entry);
delete creature;
return NULL;
}
@@ -823,7 +815,7 @@ Creature *Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
if (!cinfo)
{
sLog->outErrorDb("Battleground::AddCreature: entry %u does not exist.", entry);
sLog->outErrorDb("Battlefield::SpawnCreature: entry %u does not exist.", entry);
return NULL;
}
// force using DB speeds -- do we really need this?
@@ -838,10 +830,10 @@ Creature *Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
}
// Method for spawning gameobject on map
GameObject *Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z, float o)
GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z, float o)
{
// Get map object
Map* map = const_cast < Map * >(sMapMgr->CreateBaseMap(571));
Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(571)); // *vomits*
if (!map)
return 0;
@@ -849,23 +841,24 @@ GameObject *Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z
GameObject* go = new GameObject;
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, PHASEMASK_NORMAL, x, y, z, o, 0, 0, 0, 0, 100, GO_STATE_READY))
{
sLog->outErrorDb("Gameobject template %u not found in database! Battleground not created!", entry);
sLog->outError("Cannot create gameobject template %u! Battleground not created!", entry);
sLog->outErrorDb("Battlefield::SpawnGameObject: Gameobject template %u not found in database! Battlefield not created!", entry);
sLog->outError("Battlefield::SpawnGameObject: Cannot create gameobject template %u! Battlefield not created!", entry);
delete go;
return NULL;
}
// Add in the world
// Add to world
map->AddToMap(go);
go->setActive(true);
return go;
}
//*****************************************************
//*******************CapturePoint**********************
//*****************************************************
// *******************************************************
// ******************* CapturePoint **********************
// *******************************************************
BfCapturePoint::BfCapturePoint(Battlefield *Bf):m_Bf(Bf), m_capturePoint(NULL)
BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePoint(NULL)
{
m_team = TEAM_NEUTRAL;
m_value = 0;
@@ -877,28 +870,28 @@ BfCapturePoint::BfCapturePoint(Battlefield *Bf):m_Bf(Bf), m_capturePoint(NULL)
m_maxSpeed = 0;
}
bool BfCapturePoint::HandlePlayerEnter(Player *player)
bool BfCapturePoint::HandlePlayerEnter(Player* player)
{
if (m_capturePoint)
{
player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32) ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f));
player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, uint32(ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)));
player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct);
}
return m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second;
}
GuidSet::iterator BfCapturePoint::HandlePlayerLeave(Player* plr)
GuidSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player)
{
if (m_capturePoint)
plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 0);
player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 0);
GuidSet::iterator current = m_activePlayers[plr->GetTeamId()].find(plr->GetGUID());
GuidSet::iterator current = m_activePlayers[player->GetTeamId()].find(player->GetGUID());
if (current == m_activePlayers[plr->GetTeamId()].end())
if (current == m_activePlayers[player->GetTeamId()].end())
return current; // return end()
m_activePlayers[plr->GetTeamId()].erase(current++);
m_activePlayers[player->GetTeamId()].erase(current++);
return current;
}
@@ -974,10 +967,10 @@ bool BfCapturePoint::Update(uint32 diff)
{
for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();)
{
if (Player* plr = sObjectAccessor->FindPlayer(*itr))
if (Player* player = sObjectAccessor->FindPlayer(*itr))
{
if (!m_capturePoint->IsWithinDistInMap(plr, radius) || !plr->IsOutdoorPvPActive())
itr = HandlePlayerLeave(plr);
if (!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
itr = HandlePlayerLeave(player);
else
++itr;
}
@@ -1111,7 +1104,7 @@ void BfCapturePoint::SendObjectiveComplete(uint32 id, uint64 guid)
player->KilledMonsterCredit(id, guid);
}
bool BfCapturePoint::IsInsideObjective(Player *player) const
bool BfCapturePoint::IsInsideObjective(Player* player) const
{
return m_activePlayers[player->GetTeamId()].find(player->GetGUID()) != m_activePlayers[player->GetTeamId()].end();
}
+272 -251
View File
@@ -68,342 +68,363 @@ class Creature;
class Unit;
class Battlefield;
class BfGraveYard;
class BfGraveyard;
typedef std::set < uint64 > GuidSet;
typedef std::vector < BfGraveYard * >GraveYardVect;
typedef std::map < uint64, uint32 > PlayerTimerMap;
typedef std::set<uint64> GuidSet;
typedef std::vector<BfGraveyard*> GraveyardVect;
typedef std::map<uint64, uint32> PlayerTimerMap;
class BfCapturePoint
{
public:
BfCapturePoint(Battlefield * bf);
public:
BfCapturePoint(Battlefield* bf);
virtual void FillInitialWorldStates(WorldPacket & /*data */ ) {}
virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
// send world state update to all players present
void SendUpdateWorldState(uint32 field, uint32 value);
// Send world state update to all players present
void SendUpdateWorldState(uint32 field, uint32 value);
// send kill notify to players in the controlling faction
void SendObjectiveComplete(uint32 id, uint64 guid);
// Send kill notify to players in the controlling faction
void SendObjectiveComplete(uint32 id, uint64 guid);
// used when player is activated/inactivated in the area
virtual bool HandlePlayerEnter(Player* player);
virtual GuidSet::iterator HandlePlayerLeave(Player* player);
//virtual void HandlePlayerActivityChanged(Player * player);
// Used when player is activated/inactivated in the area
virtual bool HandlePlayerEnter(Player* player);
virtual GuidSet::iterator HandlePlayerLeave(Player* player);
//virtual void HandlePlayerActivityChanged(Player* player);
// checks if player is in range of a capture credit marker
bool IsInsideObjective(Player * player) const;
// Checks if player is in range of a capture credit marker
bool IsInsideObjective(Player* player) const;
// returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update.
virtual bool Update(uint32 diff);
virtual void ChangeTeam(TeamId /*oldTeam */ ) {}
virtual void SendChangePhase();
// Returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update.
virtual bool Update(uint32 diff);
virtual void ChangeTeam(TeamId /*oldTeam*/) {}
virtual void SendChangePhase();
bool SetCapturePointData(GameObject* capturePoint);
GameObject* GetCapturePointGo() { return m_capturePoint; }
bool SetCapturePointData(GameObject* capturePoint);
GameObject* GetCapturePointGo() { return m_capturePoint; }
TeamId GetTeamId() {return m_team;}
protected:
bool DelCapturePoint();
TeamId GetTeamId() { return m_team; }
protected:
bool DelCapturePoint();
// active players in the area of the objective, 0 - alliance, 1 - horde
GuidSet m_activePlayers[2];
// active Players in the area of the objective, 0 - alliance, 1 - horde
GuidSet m_activePlayers[2];
// total shift needed to capture the objective
float m_maxValue;
float m_minValue;
// Total shift needed to capture the objective
float m_maxValue;
float m_minValue;
// maximum speed of capture
float m_maxSpeed;
// Maximum speed of capture
float m_maxSpeed;
// the status of the objective
float m_value;
TeamId m_team;
// The status of the objective
float m_value;
TeamId m_team;
// objective states
BattlefieldObjectiveStates m_OldState;
BattlefieldObjectiveStates m_State;
// Objective states
BattlefieldObjectiveStates m_OldState;
BattlefieldObjectiveStates m_State;
// neutral value on capture bar
uint32 m_neutralValuePct;
// Neutral value on capture bar
uint32 m_neutralValuePct;
// pointer to the Battlefield this objective belongs to
Battlefield *m_Bf;
uint32 m_capturePointEntry;
GameObject *m_capturePoint;
// Pointer to the Battlefield this objective belongs to
Battlefield* m_Bf;
// Capture point entry
uint32 m_capturePointEntry;
// Gameobject related to that capture point
GameObject* m_capturePoint;
};
class BfGraveYard
class BfGraveyard
{
public:
BfGraveYard(Battlefield *Bf);
public:
BfGraveyard(Battlefield* Bf);
// method for change who control the graveyard
void ChangeControl(TeamId team);
TeamId GetControlTeamId() { return m_ControlTeam; }
// Method to changing who controls the graveyard
void GiveControlTo(TeamId team);
TeamId GetControlTeamId() { return m_ControlTeam; }
// use for found the nearest graveyard
float GetDistance(Player * player);
void Initialize(TeamId startcontrol, uint32 gy);
void SetSpirit(Creature* spirit, TeamId team);
void AddPlayer(uint64 player_guid);
void RemovePlayer(uint64 player_guid);
// Find the nearest graveyard to a player
float GetDistance(Player* player);
void Resurrect();
void RelocateDeadPlayers();
// Initialize the graveyard
void Initialize(TeamId startcontrol, uint32 gy);
bool HasNpc(uint64 guid)
{
// npcs could not be loaded in the map yet.
if (!m_SpiritGuide[0] || !m_SpiritGuide[1])
return false;
// Set spirit service for the graveyard
void SetSpirit(Creature* spirit, TeamId team);
if (!sObjectAccessor->FindUnit(m_SpiritGuide[0]) ||
!sObjectAccessor->FindUnit(m_SpiritGuide[1]))
return false;
// Add a player to the graveyard
void AddPlayer(uint64 player_guid);
return (m_SpiritGuide[0] == guid || m_SpiritGuide[1] == guid);
}
bool HasPlayer(uint64 guid) { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); }
uint32 GetGraveYardId() { return m_GraveyardId; }
// Remove a player from the graveyard
void RemovePlayer(uint64 player_guid);
protected:
// Resurrect players
void Resurrect();
TeamId m_ControlTeam;
uint32 m_GraveyardId;
uint64 m_SpiritGuide[2];
GuidSet m_ResurrectQueue;
Battlefield *m_Bf;
// Move players waiting to that graveyard on the nearest one
void RelocateDeadPlayers();
// Check if this graveyard has a spirit guide
bool HasNpc(uint64 guid)
{
if (!m_SpiritGuide[0] || !m_SpiritGuide[1])
return false;
if (!sObjectAccessor->FindUnit(m_SpiritGuide[0]) ||
!sObjectAccessor->FindUnit(m_SpiritGuide[1]))
return false;
return (m_SpiritGuide[0] == guid || m_SpiritGuide[1] == guid);
}
// Check if a player is in this graveyard's ressurect queue
bool HasPlayer(uint64 guid) { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); }
// Get the graveyard's ID.
uint32 GetGraveyardId() { return m_GraveyardId; }
protected:
TeamId m_ControlTeam;
uint32 m_GraveyardId;
uint64 m_SpiritGuide[2];
GuidSet m_ResurrectQueue;
Battlefield* m_Bf;
};
class Battlefield : public ZoneScript
{
friend class BattlefieldMgr;
public:
/// Constructor
Battlefield();
/// Destructor
virtual ~Battlefield();
public:
/// Constructor
Battlefield();
/// Destructor
virtual ~Battlefield();
/// typedef of map witch store capturepoint and the associate gameobject entry
typedef std::map < uint32 /*lowguid */ , BfCapturePoint * >BfCapturePointMap;
/// typedef of map witch store capturepoint and the associate gameobject entry
typedef std::map<uint32 /*lowguid */, BfCapturePoint*> BfCapturePointMap;
/// Call this to init the Battlefield
virtual bool SetupBattlefield() { return true; }
/// Call this to init the Battlefield
virtual bool SetupBattlefield() { return true; }
/// Generate packet which contain all worldstatedata of area
virtual void FillInitialWorldStates(WorldPacket & /*data */ ) {}
/// Generate packet which contain all worldstatedata of area
virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
/// Update data of a worldstate to all players present in zone
void SendUpdateWorldState(uint32 field, uint32 value);
/// Update data of a worldstate to all players present in zone
void SendUpdateWorldState(uint32 field, uint32 value);
/**
* \brief Called every time for update bf data and time
* -Update timer for start/end battle
* -Invite player in zone to queue x minutes before start (x = m_StartGroupingTimer)
* -Kick Afk players
* \param diff : time ellapsed since last call (in ms)
*/
virtual bool Update(uint32 diff);
/**
* \brief Called every time for update bf data and time
* - Update timer for start/end battle
* - Invite player in zone to queue m_StartGroupingTimer minutes before start
* - Kick Afk players
* \param diff : time ellapsed since last call (in ms)
*/
virtual bool Update(uint32 diff);
/// Invite all player in zone, to join the queue, called x minutes before battle start in Update()
void InvitePlayerInZoneToQueue();
/// Invite all player in queue to join battle on battle start
void InvitePlayerInQueueToWar();
/// Invite all player in zone to join battle on battle start
void InvitePlayerInZoneToWar();
/// Invite all players in zone to join the queue, called x minutes before battle start in Update()
void InvitePlayersInZoneToQueue();
/// Invite all players in queue to join battle on battle start
void InvitePlayersInQueueToWar();
/// Invite all players in zone to join battle on battle start
void InvitePlayersInZoneToWar();
/// Called when a Unit is kill in battlefield zone
virtual void HandleKill(Player * /*killer */ , Unit * /*killed */ ) {};
/// Called when a Unit is kill in battlefield zone
virtual void HandleKill(Player* /*killer*/, Unit* /*killed*/) {};
uint32 GetTypeId() { return m_TypeId; }
uint32 GetZoneId() { return m_ZoneId; }
uint32 GetTypeId() { return m_TypeId; }
uint32 GetZoneId() { return m_ZoneId; }
void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2 = 0);
void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2 = 0);
/// Return true if battle is start, false if battle is not started
bool IsWarTime() { return m_BattlefieldActive; }
/// Return true if battle is start, false if battle is not started
bool IsWarTime() { return m_isActive; }
/// Enable or Disable battlefield
void SetEnable(bool enable) { m_enable = enable; }
/// Return if battlefield is enable
bool GetEnable() { return m_enable; }
/// Enable or Disable battlefield
void ToggleBattlefield(bool enable) { m_IsEnabled = enable; }
/// Return if battlefield is enable
bool IsEnabled() { return m_IsEnabled; }
/**
* \brief Kick player from battlefield and teleport him to kick-point location
* \param guid : guid of player who must be kick
*/
void KickPlayerFromBf(uint64 guid);
/**
* \brief Kick player from battlefield and teleport him to kick-point location
* \param guid : guid of player who must be kick
*/
void KickPlayerFromBattlefield(uint64 guid);
/// Called when player (player) enter in zone
void HandlePlayerEnterZone(Player * player, uint32 zone);
/// Called when player (player) leave the zone
void HandlePlayerLeaveZone(Player * player, uint32 zone);
/// Called when player (player) enter in zone
void HandlePlayerEnterZone(Player* player, uint32 zone);
/// Called when player (player) leave the zone
void HandlePlayerLeaveZone(Player* player, uint32 zone);
// All-purpose data storage 64 bit
virtual uint64 GetData64(uint32 DataId) { return m_Data64[DataId]; }
virtual void SetData64(uint32 DataId, uint64 Value) { m_Data64[DataId] = Value; }
// All-purpose data storage 64 bit
virtual uint64 GetData64(uint32 dataId) { return m_Data64[dataId]; }
virtual void SetData64(uint32 dataId, uint64 value) { m_Data64[dataId] = value; }
// All-purpose data storage 32 bit
virtual uint32 GetData(uint32 DataId) { return m_Data32[DataId]; }
virtual void SetData(uint32 DataId, uint32 Value) { m_Data32[DataId] = Value; }
// All-purpose data storage 32 bit
virtual uint32 GetData(uint32 dataId) { return m_Data32[dataId]; }
virtual void SetData(uint32 dataId, uint32 value) { m_Data32[dataId] = value; }
virtual void UpdateData(uint32 index, int32 pad) { m_Data32[index] += pad; }
// Battlefield - generic methods
TeamId GetDefenderTeam() { return m_DefenderTeam; }
TeamId GetAttackerTeam() { return TeamId(1 - m_DefenderTeam); }
void SetDefenderTeam(TeamId team) { m_DefenderTeam = team; }
// Battlefield - generic methods
TeamId GetDefenderTeam() { return m_DefenderTeam; }
TeamId GetAttackerTeam() { return TeamId(1 - m_DefenderTeam); }
TeamId GetOtherTeam(TeamId team) { return (team == TEAM_HORDE ? TEAM_ALLIANCE : TEAM_HORDE); }
void SetDefenderTeam(TeamId team) { m_DefenderTeam = team; }
// Group methods
/**
* \brief Find a not full battlefield group, if there is no, create one
* \param TeamId : Id of player team for who we search a group (player->GetTeamId())
*/
Group *GetFreeBfRaid(TeamId TeamId);
/// Return battlefield group where player is.
Group *GetGroupPlayer(uint64 guid, TeamId TeamId);
/// Force player to join a battlefield group
bool AddOrSetPlayerToCorrectBfGroup(Player * player);
// Group methods
/**
* \brief Find a not full battlefield group, if there is no, create one
* \param TeamId : Id of player team for who we search a group (player->GetTeamId())
*/
Group* GetFreeBfRaid(TeamId TeamId);
/// Return battlefield group where player is.
Group* GetGroupPlayer(uint64 guid, TeamId TeamId);
/// Force player to join a battlefield group
bool AddOrSetPlayerToCorrectBfGroup(Player* player);
// Graveyard methods
// Find which graveyard the player must be teleported to to be resurrected by spiritguide
WorldSafeLocsEntry const *GetClosestGraveYard(Player * player);
// Graveyard methods
// Find which graveyard the player must be teleported to to be resurrected by spiritguide
WorldSafeLocsEntry const * GetClosestGraveYard(Player* player);
virtual void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid);
void RemovePlayerFromResurrectQueue(uint64 player_guid);
void SetGraveyardNumber(uint32 number) { m_GraveYardList.resize(number); }
BfGraveYard *GetGraveYardById(uint32 id);
virtual void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid);
void RemovePlayerFromResurrectQueue(uint64 player_guid);
void SetGraveyardNumber(uint32 number) { m_GraveyardList.resize(number); }
BfGraveyard* GetGraveyardById(uint32 id);
// Misc methods
Creature *SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId team);
Creature *SpawnCreature(uint32 entry, Position pos, TeamId team);
GameObject *SpawnGameObject(uint32 entry, float x, float y, float z, float o);
// Misc methods
Creature* SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId team);
Creature* SpawnCreature(uint32 entry, Position pos, TeamId team);
GameObject* SpawnGameObject(uint32 entry, float x, float y, float z, float o);
// Script-methods
// Script-methods
/// Called on start
virtual void OnBattleStart() {};
/// Called at the end of battle
virtual void OnBattleEnd(bool /*endbytimer */ ) {};
/// Called x minutes before battle start when player in zone are invite to join queue
virtual void OnStartGrouping() {};
/// Called when a player accept to join the battle
virtual void OnPlayerJoinWar(Player * /*player */ ) {};
/// Called when a player leave the battle
virtual void OnPlayerLeaveWar(Player * /*player */ ) {};
/// Called when a player leave battlefield zone
virtual void OnPlayerLeaveZone(Player * /*player */ ) {};
/// Called when a player enter in battlefield zone
virtual void OnPlayerEnterZone(Player * /*player */ ) {};
/// Called on start
virtual void OnBattleStart() {};
/// Called at the end of battle
virtual void OnBattleEnd(bool /*endByTimer*/) {};
/// Called x minutes before battle start when player in zone are invite to join queue
virtual void OnStartGrouping() {};
/// Called when a player accept to join the battle
virtual void OnPlayerJoinWar(Player* /*player*/) {};
/// Called when a player leave the battle
virtual void OnPlayerLeaveWar(Player* /*player*/) {};
/// Called when a player leave battlefield zone
virtual void OnPlayerLeaveZone(Player* /*player*/) {};
/// Called when a player enter in battlefield zone
virtual void OnPlayerEnterZone(Player* /*player*/) {};
WorldPacket BuildWarningAnnPacket(std::string msg);
void SendWarningToAllInZone(uint32 entry);
//void SendWarningToAllInWar(int32 entry, ...); -- UNUSED
void SendWarningToPlayer(Player * player, uint32 entry);
WorldPacket BuildWarningAnnPacket(std::string msg);
void SendWarningToAllInZone(uint32 entry);
//void SendWarningToAllInWar(int32 entry, ...); -- UNUSED
void SendWarningToPlayer(Player* player, uint32 entry);
void PlayerAcceptInviteToQueue(Player * player);
void PlayerAcceptInviteToWar(Player * player);
uint32 GetBattleId() { return m_BattleId; }
void AskToLeaveQueue(Player * player);
void PlayerAcceptInviteToQueue(Player* player);
void PlayerAcceptInviteToWar(Player* player);
uint32 GetBattleId() { return m_BattleId; }
void AskToLeaveQueue(Player* player);
virtual void DoCompleteOrIncrementAchievement(uint32 /*achievement */ , Player * /*player */ , uint8 /*incrementNumber = 1 */ ) {};
virtual void DoCompleteOrIncrementAchievement(uint32 /*achievement*/, Player* /*player*/, uint8 /*incrementNumber = 1*/) {};
/// Send all worldstate data to all player in zone.
virtual void SendInitWorldStatesToAll() {};
/// Send all worldstate data to all player in zone.
virtual void SendInitWorldStatesToAll() {};
/// Return if we can use mount in battlefield
bool CanFlyIn() { return !m_BattlefieldActive; } // Used for check if we can use flying mount or not
void SendAreaSpiritHealerQueryOpcode(Player * pl, const uint64 & guid);
/// Return if we can use mount in battlefield
bool CanFlyIn() { return !m_isActive; }
void StartBattle();
void EndBattle(bool endbytimer);
void SendAreaSpiritHealerQueryOpcode(Player* player, const uint64 & guid);
void HideNpc(Creature * p_Creature);
void ShowNpc(Creature * p_Creature, bool p_Aggressive);
void StartBattle();
void EndBattle(bool endByTimer);
GraveYardVect GetGraveYardVect() { return m_GraveYardList; }
void HideNpc(Creature* creature);
void ShowNpc(Creature* creature, bool aggressive);
uint32 GetTimer() { return m_Timer; }
void SetTimer(uint32 timer) { m_Timer = timer; }
GraveyardVect GetGraveyardVector() { return m_GraveyardList; }
void PlaySoundToAll(uint32 SoundID);
uint32 GetTimer() { return m_Timer; }
void SetTimer(uint32 timer) { m_Timer = timer; }
void InvitePlayerToQueue(Player * player);
void InvitePlayerToWar(Player * player);
void DoPlaySoundToAll(uint32 SoundID);
void InitStalker(uint32 entry, float x, float y, float z, float o);
void InvitePlayerToQueue(Player* player);
void InvitePlayerToWar(Player* player);
protected:
uint64 StalkerGuid;
uint32 m_Timer; // Global timer for event
bool m_enable;
bool m_BattlefieldActive;
TeamId m_DefenderTeam;
void InitStalker(uint32 entry, float x, float y, float z, float o);
// the map of the objectives belonging to this outdoorpvp
BfCapturePointMap m_capturePoints;
protected:
uint64 StalkerGuid;
uint32 m_Timer; // Global timer for event
bool m_IsEnabled;
bool m_isActive;
TeamId m_DefenderTeam;
// the set of player
GuidSet m_players[BG_TEAMS_COUNT]; // Players in zone
GuidSet m_PlayersInQueue[BG_TEAMS_COUNT]; // Players in the queue
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]; // Players in WG combat
PlayerTimerMap m_InvitedPlayers[BG_TEAMS_COUNT];
PlayerTimerMap m_PlayersWillBeKick[BG_TEAMS_COUNT];
// Map of the objectives belonging to this OutdoorPvP
BfCapturePointMap m_capturePoints;
//Variables that must exist for each battlefield
uint32 m_TypeId; // See enum BattlefieldTypes
uint32 m_BattleId; // BattleID (for packet)
uint32 m_ZoneId; // ZoneID of Wintergrasp = 4197
uint32 m_MapId; // MapId where is Battlefield
uint32 m_MaxPlayer; // Maximum number of player that participated to Battlefield
uint32 m_MinPlayer; // Minimum number of player for Battlefield start
uint32 m_MinLevel; // Required level to participate at Battlefield
uint32 m_BattleTime; // Length of a battle
uint32 m_NoWarBattleTime; // Time between two battles
uint32 m_RestartAfterCrash; // Delay to restart Wintergrasp if the server crashed during a running battle.
uint32 m_TimeForAcceptInvite;
uint32 m_uiKickDontAcceptTimer;
WorldLocation KickPosition; // Position where player is teleport if they switch to afk during battle or if they dont accept invitation
// Players info maps
GuidSet m_players[BG_TEAMS_COUNT]; // Players in zone
GuidSet m_PlayersInQueue[BG_TEAMS_COUNT]; // Players in the queue
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]; // Players in WG combat
PlayerTimerMap m_InvitedPlayers[BG_TEAMS_COUNT];
PlayerTimerMap m_PlayersWillBeKick[BG_TEAMS_COUNT];
uint32 m_uiKickAfkTimer; // Timer for check Afk in war
// Variables that must exist for each battlefield
uint32 m_TypeId; // See enum BattlefieldTypes
uint32 m_BattleId; // BattleID (for packet)
uint32 m_ZoneId; // ZoneID of Wintergrasp = 4197
uint32 m_MapId; // MapId where is Battlefield
uint32 m_MaxPlayer; // Maximum number of player that participated to Battlefield
uint32 m_MinPlayer; // Minimum number of player for Battlefield start
uint32 m_MinLevel; // Required level to participate at Battlefield
uint32 m_BattleTime; // Length of a battle
uint32 m_NoWarBattleTime; // Time between two battles
uint32 m_RestartAfterCrash; // Delay to restart Wintergrasp if the server crashed during a running battle.
uint32 m_TimeForAcceptInvite;
uint32 m_uiKickDontAcceptTimer;
WorldLocation KickPosition; // Position where players are teleported if they switch to afk during the battle or if they don't accept invitation
//Graveyard variables
GraveYardVect m_GraveYardList; // Vector witch contain the different GY of the battle
uint32 m_LastResurectTimer; // Timer for resurect player every 30 sec
uint32 m_uiKickAfkPlayersTimer; // Timer for check Afk in war
uint32 m_StartGroupingTimer; // Timer for invite players in area 15 minute before start battle
bool m_StartGrouping; // bool for know if all players in area has been invited
// Graveyard variables
GraveyardVect m_GraveyardList; // Vector witch contain the different GY of the battle
uint32 m_LastResurectTimer; // Timer for resurect player every 30 sec
GuidSet m_Groups[BG_TEAMS_COUNT]; // Contain different raid group
uint32 m_StartGroupingTimer; // Timer for invite players in area 15 minute before start battle
bool m_StartGrouping; // bool for know if all players in area has been invited
std::vector < uint64 > m_Data64;
std::vector < uint32 > m_Data32;
GuidSet m_Groups[BG_TEAMS_COUNT]; // Contain different raid group
void KickAfk();
// use for switch off all worldstate for client
virtual void SendRemoveWorldStates(Player * /*player */ ) {}
std::vector<uint64> m_Data64;
std::vector<uint32> m_Data32;
// use for send a packet for all player list
void BroadcastPacketZone(WorldPacket & data) const;
void BroadcastPacketQueue(WorldPacket & data) const;
void BroadcastPacketWar(WorldPacket & data) const;
void KickAfkPlayers();
//CapturePoint system
void AddCapturePoint(BfCapturePoint * cp) { m_capturePoints[cp->GetCapturePointGo()->GetEntry()] = cp; }
// use for switch off all worldstate for client
virtual void SendRemoveWorldStates(Player* /*player*/) {}
BfCapturePoint *GetCapturePoint(uint32 lowguid) const
{
Battlefield::BfCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid);
if (itr != m_capturePoints.end())
return itr->second;
return NULL;
}
// use for send a packet for all player list
void BroadcastPacketToZone(WorldPacket& data) const;
void BroadcastPacketToQueue(WorldPacket& data) const;
void BroadcastPacketToWar(WorldPacket& data) const;
void RegisterZone(uint32 zoneid);
bool HasPlayer(Player * player) const;
void TeamCastSpell(TeamId team, int32 spellId);
// CapturePoint system
void AddCapturePoint(BfCapturePoint* cp) { m_capturePoints[cp->GetCapturePointGo()->GetEntry()] = cp; }
BfCapturePoint* GetCapturePoint(uint32 lowguid) const
{
Battlefield::BfCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid);
if (itr != m_capturePoints.end())
return itr->second;
return NULL;
}
void RegisterZone(uint32 zoneid);
bool HasPlayer(Player* player) const;
void TeamCastSpell(TeamId team, int32 spellId);
};
#endif
@@ -60,7 +60,7 @@ void WorldSession::SendBfInvitePlayerToQueue(uint32 BattleId)
//Param2:(ZoneId) the zone where the battle is (4197 for wg)
//Param3:(CanQueue) if able to queue
//Param4:(Full) on log in is full
void WorldSession::SendBfQueueInviteResponce(uint32 BattleId,uint32 ZoneId, bool CanQueue, bool Full)
void WorldSession::SendBfQueueInviteResponse(uint32 BattleId,uint32 ZoneId, bool CanQueue, bool Full)
{
WorldPacket data(SMSG_BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE, 11);
data << uint32(BattleId);
@@ -132,7 +132,7 @@ void WorldSession::HandleBfEntryInviteResponse(WorldPacket & recv_data)
else
{
if (_player->GetZoneId() == Bf->GetZoneId())
Bf->KickPlayerFromBf(_player->GetGUID());
Bf->KickPlayerFromBattlefield(_player->GetGUID());
}
}
@@ -77,10 +77,9 @@ void BattlefieldMgr::HandlePlayerEnterZone(Player * player, uint32 zoneid)
if (itr == m_BattlefieldMap.end())
return;
if (itr->second->HasPlayer(player))
return;
if (itr->second->GetEnable() == false)
if (itr->second->HasPlayer(player) || !itr->second->IsEnabled())
return;
itr->second->HandlePlayerEnterZone(player, zoneid);
sLog->outDebug(LOG_FILTER_BATTLEFIELD, "Player %u entered outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId());
}
@@ -106,7 +105,7 @@ Battlefield *BattlefieldMgr::GetBattlefieldToZoneId(uint32 zoneid)
// no handle for this zone, return
return NULL;
}
if (itr->second->GetEnable() == false)
if (!itr->second->IsEnabled())
return NULL;
return itr->second;
}
@@ -127,7 +126,7 @@ void BattlefieldMgr::Update(uint32 diff)
if (m_UpdateTimer > BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL)
{
for (BattlefieldSet::iterator itr = m_BattlefieldSet.begin(); itr != m_BattlefieldSet.end(); ++itr)
if ((*itr)->GetEnable())
if ((*itr)->IsEnabled())
(*itr)->Update(m_UpdateTimer);
m_UpdateTimer = 0;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-5
View File
@@ -821,11 +821,6 @@ class ObjectMgr
return &_creatureQuestRelations;
}
QuestRelations* GetCreatureQuestInvolvedRelation()
{
return &_creatureQuestInvolvedRelations;
}
QuestRelationBounds GetCreatureQuestRelationBounds(uint32 creature_entry)
{
return _creatureQuestRelations.equal_range(creature_entry);
+1 -1
View File
@@ -800,7 +800,7 @@ class WorldSession
// Battlefield
void SendBfInvitePlayerToWar(uint32 BattleId,uint32 ZoneId,uint32 time);
void SendBfInvitePlayerToQueue(uint32 BattleId);
void SendBfQueueInviteResponce(uint32 BattleId,uint32 ZoneId, bool CanQueue = true, bool Full = false);
void SendBfQueueInviteResponse(uint32 BattleId,uint32 ZoneId, bool CanQueue = true, bool Full = false);
void SendBfEntered(uint32 BattleId);
void SendBfLeaveMessage(uint32 BattleId, BFLeaveReason reason = BF_LEAVE_REASON_EXITED);
void HandleBfQueueInviteResponse(WorldPacket &recv_data);