void BattleGroundBE::Update(uint32 diff) { BattleGround::Update(diff); // after bg start we get there if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize()) { ModifyStartDelayTime(diff); if (!(m_Events & 0x01)) { m_Events |= 0x01; // setup here, only when at least one player has ported to the map if(!SetupBattleGround()) { EndNow(); return; } for(uint32 i = BG_BE_OBJECT_DOOR_1; i <= BG_BE_OBJECT_DOOR_4; i++) SpawnBGObject(i, RESPAWN_IMMEDIATELY); for(uint32 i = BG_BE_OBJECT_BUFF_1; i <= BG_BE_OBJECT_BUFF_2; i++) SpawnBGObject(i, RESPAWN_ONE_DAY); SetStartDelayTime(START_DELAY1); SendMessageToAll(LANG_ARENA_ONE_MINUTE); } // After 30 seconds, warning is signalled else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x04)) { m_Events |= 0x04; SendMessageToAll(LANG_ARENA_THIRTY_SECONDS); } // After 15 seconds, warning is signalled else if (GetStartDelayTime() <= START_DELAY3 && !(m_Events & 0x08)) { m_Events |= 0x08; SendMessageToAll(LANG_ARENA_FIFTEEN_SECONDS); } // delay expired (1 minute) else if (GetStartDelayTime() <= 0 && !(m_Events & 0x10)) { m_Events |= 0x10; for(uint32 i = BG_BE_OBJECT_DOOR_1; i <= BG_BE_OBJECT_DOOR_2; i++) DoorOpen(i); for(uint32 i = BG_BE_OBJECT_BUFF_1; i <= BG_BE_OBJECT_BUFF_2; i++) SpawnBGObject(i, 60); SendMessageToAll(LANG_ARENA_BEGUN); SetStatus(STATUS_IN_PROGRESS); SetStartDelayTime(0); 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); } } /*if(GetStatus() == STATUS_IN_PROGRESS) { // update something }*/ }
void BattleGroundEY::Update(uint32 diff) { BattleGround::Update(diff); // after bg start we get there (once) if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize()) { ModifyStartDelayTime(diff); if(!(m_Events & 0x01)) { m_Events |= 0x01; // setup here, only when at least one player has ported to the map if(!SetupBattleGround()) { EndNow(); return; } SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_IMMEDIATELY); SpawnBGObject(BG_EY_OBJECT_DOOR_H, RESPAWN_IMMEDIATELY); // SpawnBGCreature(EY_SPIRIT_MAIN_ALLIANCE, RESPAWN_IMMEDIATELY); // SpawnBGCreature(EY_SPIRIT_MAIN_HORDE, RESPAWN_IMMEDIATELY); for(uint32 i = BG_EY_OBJECT_A_BANNER_FEL_REALVER_CENTER; i < BG_EY_OBJECT_MAX; ++i) SpawnBGObject(i, RESPAWN_ONE_DAY); SetStartDelayTime(START_DELAY0); } // After 1 minute, warning is signalled else if(GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04)) { m_Events |= 0x04; SendMessageToAll(GetMangosString(LANG_BG_EY_ONE_MINUTE)); } // After 1,5 minute, warning is signalled else if(GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08)) { m_Events |= 0x08; SendMessageToAll(GetMangosString(LANG_BG_EY_HALF_MINUTE)); } // After 2 minutes, gates OPEN ! x) else if(GetStartDelayTime() < 0 && !(m_Events & 0x10)) { m_Events |= 0x10; SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_ONE_DAY); SpawnBGObject(BG_EY_OBJECT_DOOR_H, RESPAWN_ONE_DAY); for(uint32 i = BG_EY_OBJECT_N_BANNER_FEL_REALVER_CENTER; i <= BG_EY_OBJECT_FLAG_NETHERSTORM; ++i) SpawnBGObject(i, RESPAWN_IMMEDIATELY); for(uint32 i = 0; i < EY_POINTS_MAX; ++i) { //randomly spawn buff uint8 buff = urand(0, 2); SpawnBGObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REALVER + buff + i * 3, RESPAWN_IMMEDIATELY); } SendMessageToAll(GetMangosString(LANG_BG_EY_BEGIN)); PlaySoundToAll(SOUND_BG_START); SetStatus(STATUS_IN_PROGRESS); for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) if(Player *plr = objmgr.GetPlayer(itr->first)) plr->RemoveAurasDueToSpell(SPELL_PREPARATION); } } else if(GetStatus() == STATUS_IN_PROGRESS) { m_PointAddingTimer -= diff; if(m_PointAddingTimer <= 0) { m_PointAddingTimer = BG_EY_FPOINTS_TICK_TIME; if (m_TeamPointsCount[BG_TEAM_ALLIANCE] > 0) AddPoints(ALLIANCE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_ALLIANCE] - 1]); if (m_TeamPointsCount[BG_TEAM_HORDE] > 0) AddPoints(HORDE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_HORDE] - 1]); } if(m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN || m_FlagState == BG_EY_FLAG_STATE_ON_GROUND) { m_FlagsTimer -= diff; if(m_FlagsTimer < 0) { m_FlagsTimer = 0; if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN) RespawnFlag(true); else RespawnFlagAfterDrop(); } } m_TowerCapCheckTimer -= diff; if(m_TowerCapCheckTimer <= 0) { //check if player joined point /*I used this order of calls, because although we will check if one player is in gameobject's distance 2 times but we can count of players on current point in CheckSomeoneLeftPoint */ CheckSomeoneJoinedPoint(); //check if player left point CheckSomeoneLeftPoint(); UpdatePointStatuses(); m_TowerCapCheckTimer = BG_EY_FPOINTS_TICK_TIME; } } }
void BattleGroundAB::Update(time_t diff) { BattleGround::Update(diff); if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize() ) { ModifyStartDelayTime(diff); if (!(m_Events & 0x01) ) { m_Events |= 0x01; // setup here, only when at least one player has ported to the map if (!SetupBattleGround()) { EndNow(); return; } sLog.outDebug("Arathi Basin: entering state STATUS_WAIT_JOIN ..."); // despawn banners, auras and buffs for (int obj = BG_AB_OBJECT_BANNER_NEUTRAL; obj < BG_AB_DYNAMIC_NODES_COUNT * 8; ++obj) SpawnBGObject(obj, RESPAWN_ONE_DAY); for (int i = 0; i < BG_AB_DYNAMIC_NODES_COUNT * 3; ++i) SpawnBGObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + i, RESPAWN_ONE_DAY); // Starting doors SpawnBGObject(BG_AB_OBJECT_GATE_A, RESPAWN_IMMEDIATELY); SpawnBGObject(BG_AB_OBJECT_GATE_H, RESPAWN_IMMEDIATELY); DoorClose(BG_AB_OBJECT_GATE_A); DoorClose(BG_AB_OBJECT_GATE_H); // Starting base spirit guides _NodeOccupied(BG_AB_SPIRIT_ALIANCE,ALLIANCE); _NodeOccupied(BG_AB_SPIRIT_HORDE,HORDE); SetStartDelayTime(START_DELAY0); } // After 1 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04) ) { m_Events |= 0x04; SendMessageToAll(GetNeoString(LANG_BG_AB_ONEMINTOSTART)); } // After 1,5 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08) ) { m_Events |= 0x08; SendMessageToAll(GetNeoString(LANG_BG_AB_HALFMINTOSTART)); } // After 2 minutes, gates OPEN ! x) else if (GetStartDelayTime() < 0 && !(m_Events & 0x10) ) { m_Events |= 0x10; SendMessageToAll(GetNeoString(LANG_BG_AB_STARTED)); // spawn neutral banners for (int banner = BG_AB_OBJECT_BANNER_NEUTRAL, i = 0; i < 5; banner += 8, ++i) SpawnBGObject(banner, RESPAWN_IMMEDIATELY); for (int i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i) { //randomly select buff to spawn uint8 buff = urand(0, 2); SpawnBGObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + buff + i * 3, RESPAWN_IMMEDIATELY); } DoorOpen(BG_AB_OBJECT_GATE_A); DoorOpen(BG_AB_OBJECT_GATE_H); PlaySoundToAll(SOUND_BG_START); if (sWorld.getConfig(CONFIG_BG_START_MUSIC)) PlaySoundToAll(SOUND_BG_START_L70ETC); //MUSIC SetStatus(STATUS_IN_PROGRESS); for (BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) if (Player* plr = objmgr.GetPlayer(itr->first)) plr->RemoveAurasDueToSpell(SPELL_PREPARATION); } } else if (GetStatus() == STATUS_IN_PROGRESS ) { int team_points[2] = { 0, 0 }; for (int node = 0; node < BG_AB_DYNAMIC_NODES_COUNT; ++node) { // 3 sec delay to spawn new banner instead previous despawned one if (m_BannerTimers[node].timer ) { if (m_BannerTimers[node].timer > diff ) m_BannerTimers[node].timer -= diff; else { m_BannerTimers[node].timer = 0; _CreateBanner(node, m_BannerTimers[node].type, m_BannerTimers[node].teamIndex, false); } } // 1-minute to occupy a node from contested state if (m_NodeTimers[node] ) { if (m_NodeTimers[node] > diff ) m_NodeTimers[node] -= diff; else { m_NodeTimers[node] = 0; // Change from contested to occupied ! uint8 teamIndex = m_Nodes[node]-1; m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] += 2; // burn current contested banner _DelBanner(node, BG_AB_NODE_TYPE_CONTESTED, teamIndex); // create new occupied banner _CreateBanner(node, BG_AB_NODE_TYPE_OCCUPIED, teamIndex, true); _SendNodeUpdate(node); _NodeOccupied(node,(teamIndex == 0) ? ALLIANCE:HORDE); // Message to chatlog char buf[256]; uint8 type = (teamIndex == 0) ? CHAT_MSG_BG_SYSTEM_ALLIANCE : CHAT_MSG_BG_SYSTEM_HORDE; sprintf(buf, GetNeoString(LANG_BG_AB_NODE_TAKEN), (teamIndex == 0) ? GetNeoString(LANG_BG_AB_ALLY) : GetNeoString(LANG_BG_AB_HORDE), _GetNodeName(node)); WorldPacket data; ChatHandler::FillMessageData(&data, NULL, type, LANG_UNIVERSAL, NULL, 0, buf, NULL); SendPacketToAll(&data); PlaySoundToAll((teamIndex == 0) ? SOUND_NODE_CAPTURED_ALLIANCE : SOUND_NODE_CAPTURED_HORDE); } } for (int team = 0; team < 2; ++team) if (m_Nodes[node] == team + BG_AB_NODE_TYPE_OCCUPIED ) ++team_points[team]; } // Accumulate points for (int team = 0; team < 2; ++team) { int points = team_points[team]; if (!points ) continue; m_lastTick[team] += diff; if (m_lastTick[team] > BG_AB_TickIntervals[points] ) { m_lastTick[team] -= BG_AB_TickIntervals[points]; m_TeamScores[team] += BG_AB_TickPoints[points]; m_score[team] = m_TeamScores[team]; m_HonorScoreTics[team] += BG_AB_TickPoints[points]; m_ReputationScoreTics[team] += BG_AB_TickPoints[points]; if (m_ReputationScoreTics[team] >= BG_AB_ReputationScoreTicks[m_HonorMode] ) { (team == BG_TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE); m_ReputationScoreTics[team] -= BG_AB_ReputationScoreTicks[m_HonorMode]; } if (m_HonorScoreTics[team] >= BG_AB_HonorScoreTicks[m_HonorMode] ) { (team == BG_TEAM_ALLIANCE) ? RewardHonorToTeam(20, ALLIANCE) : RewardHonorToTeam(20, HORDE); m_HonorScoreTics[team] -= BG_AB_HonorScoreTicks[m_HonorMode]; } if (!m_IsInformedNearVictory && m_TeamScores[team] > 1800 ) { if (team == BG_TEAM_ALLIANCE ) SendMessageToAll(GetNeoString(LANG_BG_AB_A_NEAR_VICTORY)); else SendMessageToAll(GetNeoString(LANG_BG_AB_H_NEAR_VICTORY)); PlaySoundToAll(SOUND_NEAR_VICTORY); m_IsInformedNearVictory = true; } if (m_TeamScores[team] > 2000 ) m_TeamScores[team] = 2000; if (team == BG_TEAM_ALLIANCE ) UpdateWorldState(BG_AB_OP_RESOURCES_ALLY, m_TeamScores[team]); if (team == BG_TEAM_HORDE ) UpdateWorldState(BG_AB_OP_RESOURCES_HORDE, m_TeamScores[team]); } } // Test win condition if (m_TeamScores[BG_TEAM_ALLIANCE] >= 2000 ) EndBattleGround(ALLIANCE); if (m_TeamScores[BG_TEAM_HORDE] >= 2000 ) EndBattleGround(HORDE); } }
void BattleGroundWS::Update(uint32 diff) { BattleGround::Update(diff); // after bg start we get there (once) if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize()) { ModifyStartDelayTime(diff); if (!(m_Events & 0x01)) { m_Events |= 0x01; // setup here, only when at least one player has ported to the map if (!SetupBattleGround()) { EndNow(); return; } // for (uint32 i = WS_SPIRIT_MAIN_ALLIANCE; i <= WS_SPIRIT_MAIN_HORDE; i++) // SpawnBGCreature(i, RESPAWN_IMMEDIATELY); for (uint32 i = BG_WS_OBJECT_DOOR_A_1; i <= BG_WS_OBJECT_DOOR_H_4; i++) { SpawnBGObject(i, RESPAWN_IMMEDIATELY); DoorClose(i); } for (uint32 i = BG_WS_OBJECT_A_FLAG; i <= BG_WS_OBJECT_BERSERKBUFF_2; i++) SpawnBGObject(i, RESPAWN_ONE_DAY); SetStartDelayTime(START_DELAY0); } // After 1 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04)) { m_Events |= 0x04; SendMessageToAll(GetTrinityString(LANG_BG_WS_ONE_MINUTE)); } // After 1,5 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08)) { m_Events |= 0x08; SendMessageToAll(GetTrinityString(LANG_BG_WS_HALF_MINUTE)); } // After 2 minutes, gates OPEN ! x) else if (GetStartDelayTime() < 0 && !(m_Events & 0x10)) { m_Events |= 0x10; for (uint32 i = BG_WS_OBJECT_DOOR_A_1; i <= BG_WS_OBJECT_DOOR_A_4; i++) DoorOpen(i); for (uint32 i = BG_WS_OBJECT_DOOR_H_1; i <= BG_WS_OBJECT_DOOR_H_2; i++) DoorOpen(i); SpawnBGObject(BG_WS_OBJECT_DOOR_A_5, RESPAWN_ONE_DAY); SpawnBGObject(BG_WS_OBJECT_DOOR_A_6, RESPAWN_ONE_DAY); SpawnBGObject(BG_WS_OBJECT_DOOR_H_3, RESPAWN_ONE_DAY); SpawnBGObject(BG_WS_OBJECT_DOOR_H_4, RESPAWN_ONE_DAY); for (uint32 i = BG_WS_OBJECT_A_FLAG; i <= BG_WS_OBJECT_BERSERKBUFF_2; i++) SpawnBGObject(i, RESPAWN_IMMEDIATELY); SendMessageToAll(GetTrinityString(LANG_BG_WS_BEGIN)); PlaySoundToAll(SOUND_BG_START); if (sWorld.getConfig(CONFIG_BG_START_MUSIC)) PlaySoundToAll(SOUND_BG_START_L70ETC); //MUSIC - Custom config SetStatus(STATUS_IN_PROGRESS); for (BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) if (Player* plr = sObjectMgr.GetPlayer(itr->first)) plr->RemoveAurasDueToSpell(SPELL_PREPARATION); } } else if (GetStatus() == STATUS_IN_PROGRESS) { if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_WAIT_RESPAWN) { m_FlagsTimer[BG_TEAM_ALLIANCE] -= diff; if (m_FlagsTimer[BG_TEAM_ALLIANCE] < 0) { m_FlagsTimer[BG_TEAM_ALLIANCE] = 0; RespawnFlag(ALLIANCE, true); } } if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND) { m_FlagsDropTimer[BG_TEAM_ALLIANCE] -= diff; if (m_FlagsDropTimer[BG_TEAM_ALLIANCE] < 0) { m_FlagsDropTimer[BG_TEAM_ALLIANCE] = 0; RespawnFlagAfterDrop(ALLIANCE); m_BothFlagsKept = false; } } if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_WAIT_RESPAWN) { m_FlagsTimer[BG_TEAM_HORDE] -= diff; if (m_FlagsTimer[BG_TEAM_HORDE] < 0) { m_FlagsTimer[BG_TEAM_HORDE] = 0; RespawnFlag(HORDE, true); } } if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND) { m_FlagsDropTimer[BG_TEAM_HORDE] -= diff; if (m_FlagsDropTimer[BG_TEAM_HORDE] < 0) { m_FlagsDropTimer[BG_TEAM_HORDE] = 0; RespawnFlagAfterDrop(HORDE); m_BothFlagsKept = false; } } if (m_BothFlagsKept) { m_FlagSpellForceTimer += diff; if (m_FlagDebuffState == 0 && m_FlagSpellForceTimer >= 600000) //10 minutes { if (Player * plr = sObjectMgr.GetPlayer(m_FlagKeepers[0])) plr->CastSpell(plr,WS_SPELL_FOCUSED_ASSAULT,true); if (Player * plr = sObjectMgr.GetPlayer(m_FlagKeepers[1])) plr->CastSpell(plr,WS_SPELL_FOCUSED_ASSAULT,true); m_FlagDebuffState = 1; } else if (m_FlagDebuffState == 1 && m_FlagSpellForceTimer >= 900000) //15 minutes { if (Player * plr = sObjectMgr.GetPlayer(m_FlagKeepers[0])) { plr->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); plr->CastSpell(plr,WS_SPELL_BRUTAL_ASSAULT,true); } if (Player * plr = sObjectMgr.GetPlayer(m_FlagKeepers[1])) { plr->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); plr->CastSpell(plr,WS_SPELL_BRUTAL_ASSAULT,true); } m_FlagDebuffState = 2; } } else { m_FlagSpellForceTimer = 0; //reset timer. m_FlagDebuffState = 0; } } }
void BattleGroundAV::Update(uint32 diff) { BattleGround::Update(diff); if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize()) { ModifyStartDelayTime(diff); if (!(m_Events & 0x01)) { m_Events |= 0x01; if(!SetupBattleGround()) { EndNow(); return; } sLog.outDebug("Alterac Valley: entering state STATUS_WAIT_JOIN ..."); SetStartDelayTime(START_DELAY0); } // After 1 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04)) { m_Events |= 0x04; SendMessageToAll(GetMangosString(LANG_BG_AV_START_ONE_MINUTE)); } // After 1,5 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08)) { m_Events |= 0x08; SendMessageToAll(GetMangosString(LANG_BG_AV_START_HALF_MINUTE)); } // After 2 minutes, gates OPEN ! x) else if (GetStartDelayTime() <= 0 && !(m_Events & 0x10)) { UpdateWorldState(BG_AV_SHOW_H_SCORE, 1); UpdateWorldState(BG_AV_SHOW_A_SCORE, 1); m_Events |= 0x10; SendMessageToAll(GetMangosString(LANG_BG_AV_HAS_BEGUN)); PlaySoundToAll(SOUND_BG_START); SetStatus(STATUS_IN_PROGRESS); OpenDoorEvent(BG_EVENT_DOOR); for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) if(Player* plr = sObjectMgr.GetPlayer(itr->first)) plr->RemoveAurasDueToSpell(SPELL_PREPARATION); } } if (GetStatus() != STATUS_IN_PROGRESS) return; // add points from mine owning, and look if the neutral team can reclaim the mine for(uint8 mine = 0; mine < BG_AV_MAX_MINES; mine++) { if (m_Mine_Owner[mine] == BG_TEAM_ALLIANCE || m_Mine_Owner[mine] == BG_TEAM_HORDE) { m_Mine_Timer[mine] -=diff; if (m_Mine_Timer[mine] <= 0) { UpdateScore(BattleGroundTeamId(m_Mine_Owner[mine]), 1); m_Mine_Timer[mine] = BG_AV_MINE_TICK_TIMER; } if (m_Mine_Reclaim_Timer[mine] > diff) m_Mine_Reclaim_Timer[mine] -= diff; else ChangeMineOwner(mine, BG_AV_NEUTRAL_TEAM); } } // looks for all timers of the nodes and destroy the building (for graveyards the building wont get destroyed, it goes just to the other team for(BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) { if (m_Nodes[i].State == POINT_ASSAULTED) { if (m_Nodes[i].Timer > diff) m_Nodes[i].Timer -= diff; else EventPlayerDestroyedPoint(i); } } }
void BattleGroundWS::Update(uint32 diff) { BattleGround::Update(diff); // after bg start we get there (once) if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize()) { ModifyStartDelayTime(diff); if (!(m_Events & 0x01)) { m_Events |= 0x01; // setup here, only when at least one player has ported to the map if (!SetupBattleGround()) { EndNow(); return; } SetStartDelayTime(START_DELAY0); } // After 1 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04)) { m_Events |= 0x04; SendMessageToAll(GetMangosString(LANG_BG_WS_ONE_MINUTE)); } // After 1,5 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08)) { m_Events |= 0x08; SendMessageToAll(GetMangosString(LANG_BG_WS_HALF_MINUTE)); } // After 2 minutes, gates OPEN ! x) else if (GetStartDelayTime() < 0 && !(m_Events & 0x10)) { m_Events |= 0x10; // TODO implement timer to despawn doors after a short while OpenDoorEvent(BG_EVENT_DOOR); SpawnEvent(WS_EVENT_SPIRITGUIDES_SPAWN, 0, true); SpawnEvent(WS_EVENT_FLAG_A, 0, true); SpawnEvent(WS_EVENT_FLAG_H, 0, true); SendMessageToAll(GetMangosString(LANG_BG_WS_BEGIN)); PlaySoundToAll(SOUND_BG_START); SetStatus(STATUS_IN_PROGRESS); } } else if (GetStatus() == STATUS_IN_PROGRESS) { if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_WAIT_RESPAWN) { m_FlagsTimer[BG_TEAM_ALLIANCE] -= diff; if (m_FlagsTimer[BG_TEAM_ALLIANCE] < 0) { m_FlagsTimer[BG_TEAM_ALLIANCE] = 0; RespawnFlag(ALLIANCE, true); } } if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND) { m_FlagsDropTimer[BG_TEAM_ALLIANCE] -= diff; if (m_FlagsDropTimer[BG_TEAM_ALLIANCE] < 0) { m_FlagsDropTimer[BG_TEAM_ALLIANCE] = 0; RespawnFlagAfterDrop(ALLIANCE); } } if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_WAIT_RESPAWN) { m_FlagsTimer[BG_TEAM_HORDE] -= diff; if (m_FlagsTimer[BG_TEAM_HORDE] < 0) { m_FlagsTimer[BG_TEAM_HORDE] = 0; RespawnFlag(HORDE, true); } } if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND) { m_FlagsDropTimer[BG_TEAM_HORDE] -= diff; if (m_FlagsDropTimer[BG_TEAM_HORDE] < 0) { m_FlagsDropTimer[BG_TEAM_HORDE] = 0; RespawnFlagAfterDrop(HORDE); } } } }
void BattleGround::Update(uint32 diff) { if (!GetPlayersSize()) { // BG is empty // if there are no players invited, delete BG // this will delete arena or bg object, where any player entered // [[ but if you use battleground object again (more battles possible to be played on 1 instance) // then this condition should be removed and code: // if (!GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE)) // this->AddToFreeBGObjectsQueue(); // not yet implemented // should be used instead of current // ]] // BattleGround Template instance cannot be updated, because it would be deleted if (!GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE)) delete this; return; } // remove offline players from bg after 5 minutes if (!m_OfflineQueue.empty()) { BattleGroundPlayerMap::iterator itr = m_Players.find(*(m_OfflineQueue.begin())); if (itr != m_Players.end()) { if (itr->second.OfflineRemoveTime <= sWorld.GetGameTime()) { RemovePlayerAtLeave(itr->first, true, true);// remove player from BG m_OfflineQueue.pop_front(); // remove from offline queue // do not use itr for anything, because it is erased in RemovePlayerAtLeave() } } } /*********************************************************/ /*** BATTLEGROUND BALLANCE SYSTEM ***/ /*********************************************************/ // if less then minimum players are in on one side, then start premature finish timer if (GetStatus() == STATUS_IN_PROGRESS && sBattleGroundMgr.GetPrematureFinishTime() && (GetPlayersCountByTeam(ALLIANCE) < GetMinPlayersPerTeam() || GetPlayersCountByTeam(HORDE) < GetMinPlayersPerTeam())) { if (!m_PrematureCountDown) { m_PrematureCountDown = true; m_PrematureCountDownTimer = sBattleGroundMgr.GetPrematureFinishTime(); } else if (m_PrematureCountDownTimer < diff) { // time's up! Team winner = TEAM_NONE; if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam()) winner = ALLIANCE; else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam()) winner = HORDE; EndBattleGround(winner); m_PrematureCountDown = false; } else if (!sBattleGroundMgr.isTesting()) { uint32 newtime = m_PrematureCountDownTimer - diff; // announce every minute if (newtime > (MINUTE * IN_MILLISECONDS)) { if (newtime / (MINUTE * IN_MILLISECONDS) != m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS)) PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING, CHAT_MSG_SYSTEM, NULL, (uint32)(m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS))); } else { // announce every 15 seconds if (newtime / (15 * IN_MILLISECONDS) != m_PrematureCountDownTimer / (15 * IN_MILLISECONDS)) PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS, CHAT_MSG_SYSTEM, NULL, (uint32)(m_PrematureCountDownTimer / IN_MILLISECONDS)); } m_PrematureCountDownTimer = newtime; } } 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, only if defined if (m_StartMessageIds[BG_STARTING_EVENT_FIRST]) 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]); { PlaySoundToAll(SOUND_BG_START); // Announce BG starting if (sWorld.getConfig(CONFIG_BOOL_BATTLEGROUND_QUEUE_ANNOUNCER_START)) { 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 m_EndTime -= diff; if (m_EndTime <= 0) { m_EndTime = 0; BattleGroundPlayerMap::iterator itr, next; for (itr = m_Players.begin(); itr != m_Players.end(); itr = next) { next = itr; ++next; // itr is erased here! RemovePlayerAtLeave(itr->first, true, true);// remove player from BG // do not change any battleground's private variables } } } // update start time m_StartTime += diff; }