mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[7399] Rewrited BattleGround starting code - moved it to battleground class.
Fixed message color for premature finish warnings. Fixed .debug bg command won't allow 1v0 arenas now, only battlegrounds 1v0. Added battleground announcer message removed in [7384]. Patch is tested, everything worked for me. You must execute attached sql file! Signed-off-by: Triply <triply@getmangos.com>
This commit is contained in:
parent
67f307d5f7
commit
1ee2320484
29 changed files with 469 additions and 425 deletions
|
|
@ -88,6 +88,16 @@ BattleGround::BattleGround()
|
|||
|
||||
m_PrematureCountDown = false;
|
||||
m_PrematureCountDown = 0;
|
||||
|
||||
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()
|
||||
|
|
@ -169,6 +179,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)
|
||||
|
|
@ -219,6 +234,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()))
|
||||
{
|
||||
|
|
@ -240,13 +259,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;
|
||||
}
|
||||
|
|
@ -254,6 +273,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
|
||||
|
|
@ -267,6 +368,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)
|
||||
|
|
@ -1365,31 +1467,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 = GetMangosString(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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue