void BattleGroundSA::Update(uint32 diff) { BattleGround::Update(diff); TotalTime += diff; if (status == BG_SA_WARMUP || status == BG_SA_SECOND_WARMUP) { if (TotalTime >= BG_SA_WARMUPLENGTH) { TotalTime = 0; ToggleTimer(); status = (status == BG_SA_WARMUP) ? BG_SA_ROUND_ONE : BG_SA_ROUND_TWO; } if (TotalTime >= BG_SA_BOAT_START) StartShips(); return; } else if (GetStatus() == STATUS_IN_PROGRESS) { if (status == BG_SA_ROUND_ONE) { if (TotalTime >= BG_SA_ROUNDLENGTH) { RoundScores[0].time = BG_SA_ROUNDLENGTH; TotalTime = 0; status = BG_SA_SECOND_WARMUP; attackers = (attackers == TEAM_ALLIANCE) ? TEAM_HORDE : TEAM_ALLIANCE; RoundScores[0].winner = attackers; status = BG_SA_SECOND_WARMUP; ToggleTimer(); ResetObjs(); return; } } else if (status == BG_SA_ROUND_TWO) { if (TotalTime >= BG_SA_ROUNDLENGTH) { RoundScores[1].time = BG_SA_ROUNDLENGTH; RoundScores[1].winner = (attackers == TEAM_ALLIANCE) ? TEAM_HORDE : TEAM_ALLIANCE; if (RoundScores[0].time == RoundScores[1].time) EndBattleGround(NULL); else if (RoundScores[0].time < RoundScores[1].time) EndBattleGround(RoundScores[0].winner == TEAM_ALLIANCE ? ALLIANCE : HORDE); else EndBattleGround(RoundScores[1].winner == TEAM_ALLIANCE ? ALLIANCE : HORDE); return; } } if (status == BG_SA_ROUND_ONE || status == BG_SA_ROUND_TWO) SendTime(); } }
void BattleGroundSA::Update(uint32 diff) { BattleGround::Update(diff); if (GetStatus() == STATUS_WAIT_JOIN && !shipsStarted) if (Phase == SA_ROUND_ONE) // Round one not started yet if (shipsTimer <= diff) StartShips(); else shipsTimer -= diff; if (GetStatus() == STATUS_IN_PROGRESS) // Battleground already in progress { if (Round_timer >= BG_SA_ROUNDLENGTH) { if(Phase == SA_ROUND_ONE) // Timeout of second round { PlaySoundToAll(BG_SA_SOUND_GYD_VICTORY); SendMessageToAll(defender == ALLIANCE ? LANG_BG_SA_ALLIANCE_TIMEOUT_END_1ROUND : LANG_BG_SA_HORDE_TIMEOUT_END_1ROUND, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL); RoundScores[0].winner = GetDefender(); RoundScores[0].time = Round_timer; ResetBattle(0, defender); } else // Timeout of second round { SendMessageToAll(defender == ALLIANCE ? LANG_BG_SA_ALLIANCE_TIMEOUT_END_2ROUND : LANG_BG_SA_HORDE_TIMEOUT_END_2ROUND, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL); RoundScores[1].winner = GetDefender(); RoundScores[1].time = Round_timer; EndBattleGround(TEAM_NONE); return; } } else Round_timer += diff; for (int gyd = 0; gyd < BG_SA_GRY_MAX; ++gyd) { // 3 sec delay to spawn new banner instead previous despawned one if (m_BannerTimers[gyd].timer) { if (m_BannerTimers[gyd].timer > diff) m_BannerTimers[gyd].timer -= diff; else { m_BannerTimers[gyd].timer = 0; _CreateBanner(gyd, m_BannerTimers[gyd].type, m_BannerTimers[gyd].teamIndex, false); } } // 1-minute to occupy a node from contested state if (m_GydTimers[gyd]) { if (m_GydTimers[gyd] > diff) m_GydTimers[gyd] -= diff; else { m_GydTimers[gyd] = 0; // Change from contested to occupied ! uint8 teamIndex = m_Gyd[gyd]-1; m_prevGyd[gyd] = m_Gyd[gyd]; m_Gyd[gyd] += 2; // create new occupied banner _CreateBanner(gyd, BG_SA_GARVE_TYPE_OCCUPIED, teamIndex, true); //_SendNodeUpdate(node); _GydOccupied(gyd,(teamIndex == 0) ? ALLIANCE:HORDE); // Message to chatlog RewardHonorToTeam(85, (teamIndex == 0) ? ALLIANCE:HORDE); RewardXpToTeam(0, 0.6f, (teamIndex == 0) ? ALLIANCE:HORDE); RewardReputationToTeam((teamIndex == 0) ? 1050:1085, 65, (teamIndex == 0) ? ALLIANCE:HORDE); switch(gyd) { case 0: SpawnEvent(SA_EVENT_ADD_VECH_W, 0, true);break; case 1: SpawnEvent(SA_EVENT_ADD_VECH_E, 0, true);break; } if (teamIndex == 0) { // SendMessage2ToAll(LANG_BG_SA_AH_SEIZES_GRAVEYARD,CHAT_MSG_BG_SYSTEM_ALLIANCE,NULL,LANG_BG_ALLY,_GydName(gyd)); PlaySoundToAll(BG_SA_SOUND_GYD_CAPTURED_ALLIANCE); SendWarningToAllSA(gyd, STATUS_CONQUESTED, ALLIANCE); } else { // SendMessage2ToAll(LANG_BG_SA_AH_SEIZES_GRAVEYARD,CHAT_MSG_BG_SYSTEM_HORDE,NULL,LANG_BG_HORDE,_GydName(gyd)); PlaySoundToAll(BG_SA_SOUND_GYD_CAPTURED_HORDE); SendWarningToAllSA(gyd, STATUS_CONQUESTED, HORDE); } } } } UpdateTimer(); } if (GetStatus() == STATUS_WAIT_JOIN && Phase == SA_ROUND_TWO) // Round two, not yet started { if (!shipsStarted) if (shipsTimer <= diff) { SendMessageToAll(LANG_BG_SA_START_ONE_MINUTE, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL); StartShips(); } else shipsTimer -= diff; if (TimeST2Round < diff) { Phase = 2; OpenDoorEvent(SA_EVENT_OP_DOOR, 0); SpawnEvent(SA_EVENT_ADD_NPC, 0, true); ToggleTimer(); SetStatus(STATUS_IN_PROGRESS); // Start round two PlaySoundToAll(SOUND_BG_START); SendMessageToAll(LANG_BG_SA_HAS_BEGUN, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL); SendWarningToAll(LANG_BG_SA_HAS_BEGUN); } else TimeST2Round -= diff; } }
void BattleGroundSA::Update(uint32 diff) { BattleGround::Update(diff); if (GetStatus() == STATUS_WAIT_JOIN && !shipsStarted) if (Phase == SA_ROUND_ONE) // Round one not started yet { if (shipsTimer <= diff) StartShips(); else shipsTimer -= diff; } if (GetStatus() == STATUS_IN_PROGRESS) // Battleground already in progress { if (Round_timer >= BG_SA_ROUNDLENGTH) { if (Phase == SA_ROUND_ONE) // Timeout of first round { PlaySoundToAll(BG_SA_SOUND_GYD_VICTORY); SendMessageToAll(defender == ALLIANCE ? LANG_BG_SA_ALLIANCE_TIMEOUT_END_1ROUND : LANG_BG_SA_HORDE_TIMEOUT_END_1ROUND, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL); SendWarningToAll(LANG_BG_SA_END_1ROUND); RoundScores[0].winner = GetDefender(); RoundScores[0].time = BG_SA_ROUNDLENGTH; for (BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) { Player* plr = sObjectMgr.GetPlayer(itr->first); if (plr) plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, BG_SA_END_OF_ROUND); } ResetBattle(0, defender); } else // Timeout of second round { SendMessageToAll(defender == ALLIANCE ? LANG_BG_SA_ALLIANCE_TIMEOUT_END_2ROUND : LANG_BG_SA_HORDE_TIMEOUT_END_2ROUND, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL); RoundScores[1].winner = GetDefender(); for (BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) { Player* plr = sObjectMgr.GetPlayer(itr->first); if (plr) plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, BG_SA_END_OF_ROUND); } if (RoundScores[0].winner == GetDefender()) EndBattleGround(GetDefender()); else EndBattleGround(TEAM_NONE); return; } } else Round_timer += diff; for (int gyd = 0; gyd < BG_SA_GRY_MAX; ++gyd) { // 3 sec delay to spawn new banner instead previous despawned one if (m_BannerTimers[gyd].timer) { if (m_BannerTimers[gyd].timer > diff) m_BannerTimers[gyd].timer -= diff; else { m_BannerTimers[gyd].timer = 0; _CreateBanner(gyd, m_BannerTimers[gyd].type, m_BannerTimers[gyd].teamIndex, false); } } } UpdateTimer(); } if (GetStatus() == STATUS_WAIT_JOIN && Phase == SA_ROUND_TWO) // Round two, not yet started { if (!shipsStarted) { if (shipsTimer <= diff) { SendMessageToAll(LANG_BG_SA_START_ONE_MINUTE, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL); StartShips(); } else shipsTimer -= diff; } if (TimeST2Round < diff) { Phase = SA_ROUND_TWO; SpawnEvent(SA_EVENT_ADD_NPC, 0, true); SpawnEvent(SA_EVENT_ADD_BOMB_B, (GetDefender() == ALLIANCE ? BG_SA_GRAVE_STATUS_HORDE_OCCUPIED : BG_SA_GRAVE_STATUS_ALLY_OCCUPIED), true); ToggleTimer(); SetStatus(STATUS_IN_PROGRESS); // Start round two PlaySoundToAll(SOUND_BG_START); SendWarningToAll(LANG_BG_SA_HAS_BEGUN); for (BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) { Player* plr = sObjectMgr.GetPlayer(itr->first); if (plr) { plr->RemoveAurasDueToSpell(SPELL_PREPARATION); if(plr->GetTeam()!=GetDefender()) { plr->GetAchievementMgr().StartTimedAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET,BG_SA_STORM_THE_BEACH_TIMER1); plr->GetAchievementMgr().StartTimedAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET,BG_SA_STORM_THE_BEACH_TIMER2); } } } } else TimeST2Round -= diff; } }
void BattlegroundSA::Update(uint32 diff) { if (InitSecondRound) { if (UpdateWaitTimer < diff) { if (!SignaledRoundTwo) { SignaledRoundTwo = true; InitSecondRound = false; SendMessageToAll(LANG_BG_SA_ROUND_TWO_ONE_MINUTE, CHAT_MSG_BG_SYSTEM_NEUTRAL); } }else { UpdateWaitTimer -= diff; return; } } Battleground::Update(diff); TotalTime += diff; if (status == BG_SA_WARMUP ) { BG_SA_ENDROUNDTIME = BG_SA_ROUNDLENGTH; if (TotalTime >= BG_SA_WARMUPLENGTH) { TotalTime = 0; ToggleTimer(); DemolisherStartState(false); status = BG_SA_ROUND_ONE; } if (TotalTime >= BG_SA_BOAT_START) StartShips(); return; } else if (status == BG_SA_SECOND_WARMUP) { if (RoundScores[0].time<BG_SA_ROUNDLENGTH) BG_SA_ENDROUNDTIME = RoundScores[0].time; else BG_SA_ENDROUNDTIME = BG_SA_ROUNDLENGTH; if (TotalTime >= 60000) { SendWarningToAll(LANG_BG_SA_HAS_BEGUN); TotalTime = 0; ToggleTimer(); DemolisherStartState(false); status = BG_SA_ROUND_TWO; } if (TotalTime >= 30000) { if (!SignaledRoundTwoHalfMin) { SignaledRoundTwoHalfMin = true; SendMessageToAll(LANG_BG_SA_ROUND_TWO_START_HALF_MINUTE, CHAT_MSG_BG_SYSTEM_NEUTRAL); } } StartShips(); return; } else if (GetStatus() == STATUS_IN_PROGRESS) { if (status == BG_SA_ROUND_ONE) { if (TotalTime >= BG_SA_ROUNDLENGTH) { RoundScores[0].winner = attackers; RoundScores[0].time = BG_SA_ROUNDLENGTH; TotalTime = 0; status = BG_SA_SECOND_WARMUP; attackers = (attackers == TEAM_ALLIANCE) ? TEAM_HORDE : TEAM_ALLIANCE; UpdateWaitTimer = 5000; SignaledRoundTwo = false; SignaledRoundTwoHalfMin = false; InitSecondRound = true; ToggleTimer(); ResetObjs(); return; } } else if (status == BG_SA_ROUND_TWO) { if (TotalTime >= BG_SA_ENDROUNDTIME) { RoundScores[1].time = BG_SA_ROUNDLENGTH; RoundScores[1].winner = (attackers == TEAM_ALLIANCE) ? TEAM_HORDE : TEAM_ALLIANCE; if (RoundScores[0].time == RoundScores[1].time) EndBattleground(NULL); else if (RoundScores[0].time < RoundScores[1].time) EndBattleground(RoundScores[0].winner == TEAM_ALLIANCE ? ALLIANCE : HORDE); else EndBattleground(RoundScores[1].winner == TEAM_ALLIANCE ? ALLIANCE : HORDE); return; } } if (status == BG_SA_ROUND_ONE || status == BG_SA_ROUND_TWO) { SendTime(); UpdateDemolisherSpawns(); } } }
void BattlegroundSA::PostUpdateImpl(uint32 diff) { if (InitSecondRound) { if (UpdateWaitTimer < diff) { if (!SignaledRoundTwo) { SignaledRoundTwo = true; InitSecondRound = false; SendMessageToAll(LANG_BG_SA_ROUND_TWO_ONE_MINUTE, CHAT_MSG_BG_SYSTEM_NEUTRAL); } } else { UpdateWaitTimer -= diff; return; } } TotalTime += diff; if (Status == BG_SA_WARMUP ) { EndRoundTimer = BG_SA_ROUNDLENGTH; if (TotalTime >= BG_SA_WARMUPLENGTH) { TotalTime = 0; ToggleTimer(); DemolisherStartState(false); Status = BG_SA_ROUND_ONE; StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, (Attackers == TEAM_ALLIANCE)? 23748 : 21702); } if (TotalTime >= BG_SA_BOAT_START) StartShips(); return; } else if (Status == BG_SA_SECOND_WARMUP) { if (RoundScores[0].time<BG_SA_ROUNDLENGTH) EndRoundTimer = RoundScores[0].time; else EndRoundTimer = BG_SA_ROUNDLENGTH; if (TotalTime >= 60000) { SendWarningToAll(LANG_BG_SA_HAS_BEGUN); TotalTime = 0; ToggleTimer(); DemolisherStartState(false); Status = BG_SA_ROUND_TWO; StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, (Attackers == TEAM_ALLIANCE) ? 23748 : 21702); // status was set to STATUS_WAIT_JOIN manually for Preparation, set it back now SetStatus(STATUS_IN_PROGRESS); for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) if (Player* p = ObjectAccessor::FindPlayer(itr->first)) p->RemoveAurasDueToSpell(SPELL_PREPARATION); } if (TotalTime >= 30000) { if (!SignaledRoundTwoHalfMin) { SignaledRoundTwoHalfMin = true; SendMessageToAll(LANG_BG_SA_ROUND_TWO_START_HALF_MINUTE, CHAT_MSG_BG_SYSTEM_NEUTRAL); } } StartShips(); return; } else if (GetStatus() == STATUS_IN_PROGRESS) { if (Status == BG_SA_ROUND_ONE) { if (TotalTime >= BG_SA_ROUNDLENGTH) { for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(itr->first)) player->CastSpell(player, 52459, true); RoundScores[0].winner = Attackers; RoundScores[0].time = BG_SA_ROUNDLENGTH; TotalTime = 0; Status = BG_SA_SECOND_WARMUP; Attackers = (Attackers == TEAM_ALLIANCE) ? TEAM_HORDE : TEAM_ALLIANCE; UpdateWaitTimer = 5000; SignaledRoundTwo = false; SignaledRoundTwoHalfMin = false; InitSecondRound = true; ToggleTimer(); ResetObjs(); return; } } else if (Status == BG_SA_ROUND_TWO) { if (TotalTime >= EndRoundTimer) { for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(itr->first)) player->CastSpell(player, 52459, true); RoundScores[1].time = BG_SA_ROUNDLENGTH; RoundScores[1].winner = (Attackers == TEAM_ALLIANCE) ? TEAM_HORDE : TEAM_ALLIANCE; if (RoundScores[0].time == RoundScores[1].time) EndBattleground(0); else if (RoundScores[0].time < RoundScores[1].time) EndBattleground(RoundScores[0].winner == TEAM_ALLIANCE ? ALLIANCE : HORDE); else EndBattleground(RoundScores[1].winner == TEAM_ALLIANCE ? ALLIANCE : HORDE); return; } } if (Status == BG_SA_ROUND_ONE || Status == BG_SA_ROUND_TWO) { SendTime(); UpdateDemolisherSpawns(); } } }
void BattlegroundSA::PostUpdateImpl(uint32 diff) { if (InitSecondRound) { if (UpdateWaitTimer < diff) { if (!SignaledRoundTwo) { SignaledRoundTwo = true; InitSecondRound = false; SendMessageToAll(LANG_BG_SA_ROUND_TWO_ONE_MINUTE, CHAT_MSG_BG_SYSTEM_NEUTRAL); } }else { UpdateWaitTimer -= diff; return; } } TotalTime += diff; if (Status == BG_SA_WARMUP ) { EndRoundTimer = BG_SA_ROUNDLENGTH; if (TotalTime >= BG_SA_WARMUPLENGTH) { TotalTime = 0; ToggleTimer(); DemolisherStartState(false); Status = BG_SA_ROUND_ONE; StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, (Attackers == TEAM_ALLIANCE)?23748:21702); } if (TotalTime >= BG_SA_BOAT_START) StartShips(); return; } else if (Status == BG_SA_SECOND_WARMUP) { if (RoundScores[0].time<BG_SA_ROUNDLENGTH) EndRoundTimer = RoundScores[0].time; else EndRoundTimer = BG_SA_ROUNDLENGTH; if (TotalTime >= 60000) { SendWarningToAll(LANG_BG_SA_HAS_BEGUN); TotalTime = 0; ToggleTimer(); DemolisherStartState(false); Status = BG_SA_ROUND_TWO; StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, (Attackers == TEAM_ALLIANCE)?23748:21702); } if (TotalTime >= 30000) { if (!SignaledRoundTwoHalfMin) { SignaledRoundTwoHalfMin = true; SendMessageToAll(LANG_BG_SA_ROUND_TWO_START_HALF_MINUTE, CHAT_MSG_BG_SYSTEM_NEUTRAL); } } StartShips(); return; } else if (GetStatus() == STATUS_IN_PROGRESS) { if (Status == BG_SA_ROUND_ONE) { if (TotalTime >= BG_SA_ROUNDLENGTH) { RoundScores[0].winner = Attackers; RoundScores[0].time = BG_SA_ROUNDLENGTH; TotalTime = 0; Status = BG_SA_SECOND_WARMUP; Attackers = (Attackers == TEAM_ALLIANCE) ? TEAM_HORDE : TEAM_ALLIANCE; UpdateWaitTimer = 5000; SignaledRoundTwo = false; SignaledRoundTwoHalfMin = false; InitSecondRound = true; ToggleTimer(); ResetObjs(); return; } } else if (Status == BG_SA_ROUND_TWO) { if (TotalTime >= EndRoundTimer) { RoundScores[1].time = BG_SA_ROUNDLENGTH; RoundScores[1].winner = (Attackers == TEAM_ALLIANCE) ? TEAM_HORDE : TEAM_ALLIANCE; if (RoundScores[0].time == RoundScores[1].time) EndBattleground(0); else if (RoundScores[0].time < RoundScores[1].time) EndBattleground(RoundScores[0].winner == TEAM_ALLIANCE ? ALLIANCE : HORDE); else EndBattleground(RoundScores[1].winner == TEAM_ALLIANCE ? ALLIANCE : HORDE); return; } } if (Status == BG_SA_ROUND_ONE || Status == BG_SA_ROUND_TWO) { SendTime(); UpdateDemolisherSpawns(); } } }