aboutsummaryrefslogtreecommitdiff
path: root/src/game/BattleGround.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/BattleGround.cpp')
-rw-r--r--src/game/BattleGround.cpp120
1 files changed, 111 insertions, 9 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 46c6bbf76aa..29843eb425e 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -92,6 +92,16 @@ BattleGround::BattleGround()
m_PrematureCountDown = 0;
m_HonorMode = BG_NORMAL;
+
+ m_StartDelayTimes[BG_STARTING_EVENT_FIRST] = BG_START_DELAY_2M;
+ m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_1M;
+ m_StartDelayTimes[BG_STARTING_EVENT_THIRD] = BG_START_DELAY_30S;
+ m_StartDelayTimes[BG_STARTING_EVENT_FOURTH] = BG_START_DELAY_NONE;
+ //we must set to some default existing values
+ m_StartMessageIds[BG_STARTING_EVENT_FIRST] = LANG_BG_WS_START_TWO_MINUTES;
+ m_StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_BG_WS_START_ONE_MINUTE;
+ m_StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_BG_WS_START_HALF_MINUTE;
+ m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_WS_HAS_BEGUN;
}
BattleGround::~BattleGround()
@@ -173,6 +183,11 @@ void BattleGround::Update(uint32 diff)
}
}
+ //TODO: move this system to spell system and ressurect players correclt there!
+ /*********************************************************/
+ /*** BATTLEGROUND RESSURECTION SYSTEM ***/
+ /*********************************************************/
+
//this should be handled by spell system:
m_LastResurrectTime += diff;
if (m_LastResurrectTime >= RESURRECTION_INTERVAL)
@@ -223,6 +238,10 @@ void BattleGround::Update(uint32 diff)
m_ResurrectQueue.clear();
}
+ /*********************************************************/
+ /*** BATTLEGROUND BALLANCE SYSTEM ***/
+ /*********************************************************/
+
// if less then minimum players are in on one side, then start premature finish timer
if(GetStatus() == STATUS_IN_PROGRESS && !isArena() && sBattleGroundMgr.GetPrematureFinishTime() && (GetPlayersCountByTeam(ALLIANCE) < GetMinPlayersPerTeam() || GetPlayersCountByTeam(HORDE) < GetMinPlayersPerTeam()))
{
@@ -244,13 +263,13 @@ void BattleGround::Update(uint32 diff)
if( newtime > (MINUTE * IN_MILISECONDS) )
{
if( newtime / (MINUTE * IN_MILISECONDS) != m_PrematureCountDownTimer / (MINUTE * IN_MILISECONDS) )
- PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING, (uint32)(m_PrematureCountDownTimer / (MINUTE * IN_MILISECONDS)));
+ PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING, CHAT_MSG_SYSTEM, (uint32)(m_PrematureCountDownTimer / (MINUTE * IN_MILISECONDS)));
}
else
{
//announce every 15 seconds
if( newtime / (15 * IN_MILISECONDS) != m_PrematureCountDownTimer / (15 * IN_MILISECONDS) )
- PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS, (uint32)(m_PrematureCountDownTimer / IN_MILISECONDS));
+ PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS, CHAT_MSG_SYSTEM, (uint32)(m_PrematureCountDownTimer / IN_MILISECONDS));
}
m_PrematureCountDownTimer = newtime;
}
@@ -258,6 +277,88 @@ void BattleGround::Update(uint32 diff)
else if (m_PrematureCountDown)
m_PrematureCountDown = false;
+ /*********************************************************/
+ /*** BATTLEGROUND STARTING SYSTEM ***/
+ /*********************************************************/
+
+ if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize())
+ {
+ ModifyStartDelayTime(diff);
+
+ if (!(m_Events & BG_STARTING_EVENT_1))
+ {
+ m_Events |= BG_STARTING_EVENT_1;
+
+ // setup here, only when at least one player has ported to the map
+ if(!SetupBattleGround())
+ {
+ EndNow();
+ return;
+ }
+
+ StartingEventCloseDoors();
+ SetStartDelayTime(m_StartDelayTimes[BG_STARTING_EVENT_FIRST]);
+ //first start warning - 2 or 1 minute
+ SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_FIRST], CHAT_MSG_BG_SYSTEM_NEUTRAL);
+ }
+ // After 1 minute or 30 seconds, warning is signalled
+ else if (GetStartDelayTime() <= m_StartDelayTimes[BG_STARTING_EVENT_SECOND] && !(m_Events & BG_STARTING_EVENT_2))
+ {
+ m_Events |= BG_STARTING_EVENT_2;
+ SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_SECOND], CHAT_MSG_BG_SYSTEM_NEUTRAL);
+ }
+ // After 30 or 15 seconds, warning is signalled
+ else if (GetStartDelayTime() <= m_StartDelayTimes[BG_STARTING_EVENT_THIRD] && !(m_Events & BG_STARTING_EVENT_3))
+ {
+ m_Events |= BG_STARTING_EVENT_3;
+ SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_THIRD], CHAT_MSG_BG_SYSTEM_NEUTRAL);
+ }
+ // delay expired (atfer 2 or 1 minute)
+ else if (GetStartDelayTime() <= 0 && !(m_Events & BG_STARTING_EVENT_4))
+ {
+ m_Events |= BG_STARTING_EVENT_4;
+
+ StartingEventOpenDoors();
+
+ SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_FOURTH], CHAT_MSG_BG_SYSTEM_NEUTRAL);
+ SetStatus(STATUS_IN_PROGRESS);
+ SetStartDelayTime(m_StartDelayTimes[BG_STARTING_EVENT_FOURTH]);
+
+ //remove preparation
+ if( isArena() )
+ {
+ //TODO : add arena sound (PlaySoundToAll(SOUND_ARENA_START);
+
+ for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
+ if(Player *plr = objmgr.GetPlayer(itr->first))
+ plr->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
+
+ if(!GetPlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE))
+ EndBattleGround(HORDE);
+ else if(GetPlayersCountByTeam(ALLIANCE) && !GetPlayersCountByTeam(HORDE))
+ EndBattleGround(ALLIANCE);
+ }
+ else
+ {
+
+ PlaySoundToAll(SOUND_BG_START);
+
+ for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
+ if(Player* plr = objmgr.GetPlayer(itr->first))
+ plr->RemoveAurasDueToSpell(SPELL_PREPARATION);
+ //Announce BG starting:
+ if( sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE) )
+ {
+ sWorld.SendWorldText(LANG_BG_STARTED_ANNOUNCE_WORLD, GetName(), GetMinLevel(), GetMaxLevel());
+ }
+ }
+ }
+ }
+
+ /*********************************************************/
+ /*** BATTLEGROUND ENDING SYSTEM ***/
+ /*********************************************************/
+
if(GetStatus() == STATUS_WAIT_LEAVE)
{
// remove all players from battleground after 2 minutes
@@ -271,6 +372,7 @@ void BattleGround::Update(uint32 diff)
// do not change any battleground's private variables
}
}
+
}
void BattleGround::SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O)
@@ -1407,31 +1509,31 @@ bool BattleGround::AddSpiritGuide(uint32 type, float x, float y, float z, float
return true;
}
-void BattleGround::SendMessageToAll(char const* text)
+void BattleGround::SendMessageToAll(char const* text, uint8 type)
{
WorldPacket data;
- ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, NULL, 0, text, NULL);
+ ChatHandler::FillMessageData(&data, NULL, type, LANG_UNIVERSAL, NULL, 0, text, NULL);
SendPacketToAll(&data);
}
-void BattleGround::SendMessageToAll(int32 entry)
+void BattleGround::SendMessageToAll(int32 entry, uint8 type)
{
char const* text = GetTrinityString(entry);
WorldPacket data;
- ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, NULL, 0, text, NULL);
+ ChatHandler::FillMessageData(&data, NULL, type, LANG_UNIVERSAL, NULL, 0, text, NULL);
SendPacketToAll(&data);
}
//copied from void ChatHandler::PSendSysMessage(int32 entry, ...)
-void BattleGround::PSendMessageToAll(int32 entry, ...)
+void BattleGround::PSendMessageToAll(int32 entry, uint8 type, ...)
{
const char *format = GetMangosString(entry);
va_list ap;
char str [2048];
- va_start(ap, entry);
+ va_start(ap, type);
vsnprintf(str,2048,format, ap );
va_end(ap);
- SendMessageToAll(str);
+ SendMessageToAll(str, type);
}
void BattleGround::EndNow()