void BattlefieldTB::TowerDestroyed(TBTowerId tbTowerId) { if (!IsWarTime()) return; // Add 5 minute bonus time m_Timer += m_BonusTime; SendUpdateWorldState(TB_WS_TIME_BATTLE_END, uint32(time(NULL) + (m_Timer / 1000))); SendWarning(TBTowers[tbTowerId].textDamaged); SetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED, GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED) + 1); SendUpdateWorldState(uint32(TB_WS_TOWERS_DESTROYED), int32(GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED))); SendUpdateWorldState(uint32(TBTowers[tbTowerId].wsDamaged[GetDefenderTeam()]), int32(0)); SendUpdateWorldState(uint32(TBTowers[tbTowerId].wsDestroyed), int32(1)); // Attack bonus buff for (ObjectGuid const& guid : m_PlayersInWar[GetAttackerTeam()]) if (Player* player = ObjectAccessor::FindPlayer(guid)) player->CastCustomSpell(SPELL_TOWER_ATTACK_BONUS, SPELLVALUE_AURA_STACK, GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED), player, TRIGGERED_FULL_MASK); // Honor reward TeamCastSpell(GetAttackerTeam(), SPELL_REWARD_TOWER_DESTROYED); }
// Called when a tower is damaged, used for honor reward calcul void BattlefieldWG::UpdateDamagedTowerCount(TeamId team) { if (team == GetAttackerTeam()) UpdateData(BATTLEFIELD_WG_DATA_DAMAGED_TOWER_ATT, 1); else UpdateData(BATTLEFIELD_WG_DATA_DAMAGED_TOWER_DEF, 1); }
// Method sending worldsate to player WorldPacket BattlefieldWG::BuildInitWorldStates() { WorldPacket data(SMSG_INIT_WORLD_STATES, (4 + 4 + 4 + 2 + (BuildingsInZone.size() * 8) + (WorkShopList.size() * 8))); data << uint32(_MapId); data << uint32(m_ZoneId); data << uint32(0); data << uint16(4 + 2 + 4 + BuildingsInZone.size() + WorkShopList.size()); data << uint32(BATTLEFIELD_WG_WORLD_STATE_ATTACKER) << uint32(GetAttackerTeam()); data << uint32(BATTLEFIELD_WG_WORLD_STATE_DEFENDER) << uint32(GetDefenderTeam()); data << uint32(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) << uint32(IsWarTime()? 0 : 1); data << uint32(3710) << uint32(IsWarTime()? 1 : 0); for (uint32 i = 0; i < 2; ++i) data << ClockWorldState[i] << uint32(time(NULL) + (m_Timer / 1000)); data << uint32(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_H) << uint32(GetData(BATTLEFIELD_WG_DATA_VEHICLE_H)); data << uint32(BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_H) << GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H); data << uint32(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_A) << uint32(GetData(BATTLEFIELD_WG_DATA_VEHICLE_A)); data << uint32(BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_A) << GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_A); for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr) { data << (*itr)->m_WorldState << (*itr)->m_State; } for (WorkShop::const_iterator itr = WorkShopList.begin(); itr != WorkShopList.end(); ++itr) { data << (*itr)->m_WorldState << (*itr)->m_State; } return data; }
void BattlefieldTB::AddBrokenTower(TeamId team) { m_BattleTime += 5 * MINUTE * IN_MILLISECONDS; m_Data32[BATTLEFIELD_TB_DATA_CAPTURED]++; if (team == GetDefenderTeam()) { for (GuidSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer((*itr))) player->RemoveAuraFromStack(SPELL_TB_TOL_BARAD_TOWER_BONUS); for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer((*itr))) player->CastSpell(player, SPELL_TB_TOL_BARAD_TOWER_BONUS, true); if (m_Data32[BATTLEFIELD_TB_DATA_CAPTURED] == 3) { if (int32(m_Timer - 600000) < 0) m_Timer = 0; else m_Timer -= 600000; SendInitWorldStatesToAll(); } } }
void BattlefieldTB::OnBattleEnd(bool endByTimer) { if (!endByTimer) // Attackers win (but now they are defenders already) SendWarning(GetDefenderTeam() == TEAM_ALLIANCE ? TB_TEXT_FORTRESS_CAPTURE_ALLIANCE : TB_TEXT_FORTRESS_CAPTURE_HORDE); else // Defenders win SendWarning(GetDefenderTeam() == TEAM_ALLIANCE ? TB_TEXT_FORTRESS_DEFEND_ALLIANCE : TB_TEXT_FORTRESS_DEFEND_HORDE); // UpdateNPCsAndGameObjects() must be called 1 minute after battle ends m_updateObjectsTimer = 1 * MINUTE * IN_MILLISECONDS; updatedNPCAndObjects = false; // Complete quest TeamCastSpell(GetDefenderTeam(), GetDefenderTeam() == TEAM_ALLIANCE ? SPELL_VICTORY_ALLIANCE : SPELL_VICTORY_HORDE); // Rewards TeamCastSpell(GetDefenderTeam(), GetDefenderTeam() == TEAM_ALLIANCE ? SPELL_REWARD_VICTORY_ALLIANCE : SPELL_REWARD_VICTORY_HORDE); for (uint32 i = 0; i < GetData(BATTLEFIELD_TB_DATA_TOWERS_INTACT); i++) // Unsure, for each intact tower or only once for having any tower intact? TeamCastSpell(GetDefenderTeam(), SPELL_REWARD_TOWER_INTACT); TeamCastSpell(GetAttackerTeam(), SPELL_REWARD_DEFEAT); for (uint8 team = 0; team < 2; ++team) { for (ObjectGuid const& guid : m_PlayersInWar[team]) if (Player* player = ObjectAccessor::FindPlayer(guid)) RemoveAurasFromPlayer(player); m_PlayersInWar[team].clear(); } // Reset time warning vars warnedFiveMinutes = false; warnedTwoMinutes = false; warnedOneMinute = false; };
// Method sending worldsate to player WorldPacket BattlefieldWG::BuildInitWorldStates() { WorldPacket data(SMSG_INIT_WORLD_STATES, (4 + 4 + 4 + 2 + (BuildingsInZone.size() * 8) + (WorkshopsList.size() * 8))); data << uint32(m_MapId); data << uint32(m_ZoneId); data << uint32(0); data << uint16(4 + 2 + 4 + BuildingsInZone.size() + WorkshopsList.size()); data << uint32(BATTLEFIELD_WG_WORLD_STATE_ATTACKER) << uint32(GetAttackerTeam()); data << uint32(BATTLEFIELD_WG_WORLD_STATE_DEFENDER) << uint32(GetDefenderTeam()); data << uint32(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) << uint32(IsWarTime()? 0 : 1); // Note: cleanup these two, their names look awkward data << uint32(BATTLEFIELD_WG_WORLD_STATE_SHOW_WORLDSTATE) << uint32(IsWarTime()? 1 : 0); for (uint32 i = 0; i < 2; ++i) data << ClockWorldState[i] << uint32(time(NULL) + (m_Timer / 1000)); data << uint32(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_H) << uint32(GetData(BATTLEFIELD_WG_DATA_VEHICLE_H)); data << uint32(BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_H) << GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H); data << uint32(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_A) << uint32(GetData(BATTLEFIELD_WG_DATA_VEHICLE_A)); data << uint32(BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_A) << GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_A); for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr) data << (*itr)->m_WorldState << (*itr)->m_State; for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr) if (*itr) data << WorkshopsData[(*itr)->workshopId].worldstate << (*itr)->state; return data; }
// Method sending worldsate to player WorldPacket BattlefieldTB::BuildInitWorldStates() { WorldPacket data(SMSG_INIT_WORLD_STATES, (4+4+4+2+(BuildingsInZone.size()*8)+(WorkShopList.size()*8))); data << uint32(_MapId); data << uint32(m_ZoneId); data << uint32(0); data << uint16(4+2+4+BuildingsInZone.size()+WorkShopList.size()); data << uint32(5385) << uint32(IsWarTime() ? 0 : GetAttackerTeam()); // Alliance Controlled data << uint32(5384) << uint32(IsWarTime() ? 0 : GetDefenderTeam()); // Horde Controlled // data << uint32(5547) << uint32(IsWarTime() ? GetAttackerTeam() : 0); // Horde is Attacking // data << uint32(5546) << uint32(IsWarTime() ? GetAttackerTeam() : 0); // Alliance is Attacking data << uint32(5349) << uint32(IsWarTime() ? BATTLEFIELD_TB_DATA_CAPTURED_FORT_ATT : 0); // Captured count data << uint32(5346) << uint32(IsWarTime() ? 1 : 0); // Time remaining data << uint32(5387) << uint32(IsWarTime() ? 0 : 1); // Next Battle for (uint32 i = 0; i < 2; ++i) data << TBClockWorldState[i] << uint32(time(NULL)+(m_Timer / 1000)); for (TBGameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr) { data << (*itr)->m_WorldState << (*itr)->m_State; } for (TBWorkShop::const_iterator itr = WorkShopList.begin(); itr != WorkShopList.end(); ++itr) { data << (*itr)->m_WorldState << (*itr)->m_State; } return data; }
void BattlefieldTB::AddBrokenTower(TeamId team) { m_BattleTime += 5*60*1000; // Increase battle time by 5 mins. m_Data32[BATTLEFIELD_TB_DATA_BROKEN_TOWER_DEF]++; // Destroy an attack tower if (team == GetDefenderTeam()) { // Remove buff stack for (GuidSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer((*itr))) player->RemoveAuraFromStack(SPELL_TOWER_BONUS); // Add buff stack for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer((*itr))) { player->CastSpell(player, SPELL_TOWER_BONUS, true); //DoCompleteOrIncrementAchievement(ACHIEVEMENTS_TB_TOWER_DESTROY, player); TODO } if (m_Data32[BATTLEFIELD_TB_DATA_BROKEN_TOWER_DEF] == 3) { if (int32(m_Timer-600000)<0) m_Timer = 0; else m_Timer -= 600000; SendInitWorldStatesToAll(); } } }
void BattlefieldWG::OnPlayerJoinWar(Player* player) { RemoveAurasFromPlayer(player); player->CastSpell(player, SPELL_RECRUIT, true); if (player->GetZoneId() != m_ZoneId) { if (player->GetTeamId() == GetDefenderTeam()) player->TeleportTo(571, 5345, 2842, 410, 3.14f); else { if (player->GetTeamId() == TEAM_HORDE) player->TeleportTo(571, 5025.857422f, 3674.628906f, 362.737122f, 4.135169f); else player->TeleportTo(571, 5101.284f, 2186.564f, 373.549f, 3.812f); } } UpdateTenacity(); if (player->GetTeamId() == GetAttackerTeam()) { if (GetData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT) < 3) player->SetAuraStack(SPELL_TOWER_CONTROL, player, 3 - GetData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT)); } else { if (GetData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT) > 0) player->SetAuraStack(SPELL_TOWER_CONTROL, player, GetData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT)); } SendInitWorldStatesTo(player); }
void BattlefieldTB::OnPlayerJoinWar(Player* player) { player->RemoveAurasDueToSpell(SPELL_VETERAN); player->RemoveAurasDueToSpell(SPELL_SPIRITUAL_IMMUNITY_TB); player->RemoveAurasDueToSpell(SPELL_TOWER_BONUS); if (player->GetZoneId() != m_ZoneId) if (player->GetTeamId() == GetDefenderTeam()) { player->TeleportTo(732, -1244.58f, 981.233f, 155.426f, 0); player->CastSpell(player, SPELL_SLOW_FALL_TB, true); } else player->TeleportTo(732, -827.212646f, 1187.948608f, 112.81f, 3.092834f); if (player->GetTeamId() == GetAttackerTeam()) { player->CastSpell(player, SPELL_VETERAN, true); if (3-m_Data32[BATTLEFIELD_TB_DATA_BROKEN_TOWER_DEF]>0) player->SetAuraStack(SPELL_TOWER_BONUS, player, 3-m_Data32[BATTLEFIELD_TB_DATA_BROKEN_TOWER_DEF]); } else { if (m_Data32[BATTLEFIELD_TB_DATA_BROKEN_TOWER_DEF]>0) player->SetAuraStack(SPELL_TOWER_BONUS, player, m_Data32[BATTLEFIELD_TB_DATA_BROKEN_TOWER_DEF]); } SendInitWorldStatesTo(player); }
void BattlefieldTB::OnDamaged() { for(uint8 team = 0; team < 2; team++) for (GuidSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) if (Player *plr = sObjectMgr->GetPlayerByLowGUID((*itr))) if (plr->GetTeam() == GetAttackerTeam()) plr->CastSpell(plr, SPELL_TB_TOL_BARAD_TOWER_DAMAGED, true); }
void BattlefieldTB::OnBattleStart() { // Rebuild all wall /*for (TBGameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr) if ((*itr)) (*itr)->Rebuild();*/ m_Data32[BATTLEFIELD_TB_DATA_BROKEN_TOWER_DEF] = 0; m_Data32[BATTLEFIELD_TB_DATA_CAPTURED_FORT_DEF] = 3; m_Data32[BATTLEFIELD_TB_DATA_CAPTURED_FORT_ATT] = 0; // Update graveyard (in no war time all graveyard is to deffender, in war time, depend of base) for (TBWorkShop::const_iterator itr = WorkShopList.begin(); itr != WorkShopList.end(); ++itr) { if ((*itr)) (*itr)->UpdateGraveYardAndWorkshop(); } //Hide keep npc for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr) if (Unit* unit = ObjectAccessor::FindUnit((*itr))) if (Creature* creature = unit->ToCreature()) HideNpc(creature); for (GuidSet::const_iterator itr = KeepCreature[GetDefenderTeam()].begin(); itr != KeepCreature[GetDefenderTeam()].end(); ++itr) if (Unit* unit = ObjectAccessor::FindUnit((*itr))) if (Creature* creature = unit->ToCreature()) HideNpc(creature); //Show battle npcs for (GuidSet::const_iterator itr = WarCreature[GetDefenderTeam()].begin(); itr != WarCreature[GetDefenderTeam()].end(); ++itr) if (Unit* unit = ObjectAccessor::FindUnit((*itr))) if (Creature* creature = unit->ToCreature()) HideNpc(creature); //Show battle npcs for (GuidSet::const_iterator itr = WarCreature[GetAttackerTeam()].begin(); itr != WarCreature[GetAttackerTeam()].end(); ++itr) if (Unit* unit = ObjectAccessor::FindUnit((*itr))) if (Creature* creature = unit->ToCreature()) HideNpc(creature); //Warnin message SendWarningToAllInZone(BATTLEFIELD_TB_TEXT_START); }
void BattlefieldTB::OnPlayerJoinWar(Player* player) { RemoveAurasFromPlayer(player); player->SetPvP(true); // Bonus damage buff for attackers if (player->GetTeamId() == GetAttackerTeam() && GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED) > 0) player->CastCustomSpell(SPELL_TOWER_ATTACK_BONUS, SPELLVALUE_AURA_STACK, GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED), player, TRIGGERED_FULL_MASK); }
// Called when a tower is broke void BattlefieldWG::AddBrokenTower(TeamId team) { // Destroy an attack tower if (team == GetAttackerTeam()) { // Update counter m_Data32[BATTLEFIELD_WG_DATA_DAMAGED_TOWER_ATT]--; m_Data32[BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT]++; // Remove buff stack for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->RemoveAuraFromStack(SPELL_TOWER_CONTROL); // Add buff stack for (GuidSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) { player->CastSpell(player, SPELL_TOWER_CONTROL, true); IncrementQuest(player, WGQuest[player->GetTeamId()][3], true); DoCompleteOrIncrementAchievement(ACHIEVEMENTS_WG_TOWER_DESTROY, player); } // If the threw south tower is destroy if (m_Data32[BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT] == 3) { // Remove 10 minutes to battle time if (int32(m_Timer - 600000) < 0) { m_Timer = 0; } else { m_Timer -= 600000; } SendInitWorldStatesToAll(); } } else { m_Data32[BATTLEFIELD_WG_DATA_DAMAGED_TOWER_DEF]--; m_Data32[BATTLEFIELD_WG_DATA_BROKEN_TOWER_DEF]++; } }
// Called when a tower is damaged, used for honor reward calcul void BattlefieldWG::AddDamagedTower(TeamId team) { if (team == GetAttackerTeam()) { m_Data32[BATTLEFIELD_WG_DATA_DAMAGED_TOWER_ATT]++; } else { m_Data32[BATTLEFIELD_WG_DATA_DAMAGED_TOWER_DEF]++; } }
void BattlefieldWG::BrokenWallOrTower(TeamId team) { if (team == GetDefenderTeam()) { for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) IncrementQuest(player, WGQuest[player->GetTeamId()][2], true); } } }
// Called when a tower is broke void BattlefieldWG::UpdatedDestroyedTowerCount(TeamId team) { // Destroy an attack tower if (team == GetAttackerTeam()) { // Update counter UpdateData(BATTLEFIELD_WG_DATA_DAMAGED_TOWER_ATT, -1); UpdateData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT, 1); // Remove buff stack on attackers for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr) if (Player* player = sObjectAccessor->FindPlayer(*itr)) player->RemoveAuraFromStack(SPELL_TOWER_CONTROL); // Add buff stack to defenders for (GuidSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr) if (Player* player = sObjectAccessor->FindPlayer(*itr)) { player->CastSpell(player, SPELL_TOWER_CONTROL, true); DoCompleteOrIncrementAchievement(ACHIEVEMENTS_WG_TOWER_DESTROY, player); } // If all three south towers are destroyed (ie. all attack towers), remove ten minutes from battle time if (GetData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT) == 3) { if (int32(m_Timer - 600000) < 0) m_Timer = 0; else m_Timer -= 600000; SendInitWorldStatesToAll(); } } else { UpdateData(BATTLEFIELD_WG_DATA_DAMAGED_TOWER_DEF, -1); UpdateData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_DEF, 1); } }
void BattlefieldTB::OnDestroyed() { for (uint8 team = 0; team < 2; team++) { for (GuidSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) if (Player *plr = sObjectMgr->GetPlayerByLowGUID((*itr))) if (plr->GetTeam() == GetAttackerTeam()) { plr->CastSpell(plr, SPELL_TB_TOL_BARAD_TOWER_DESTROYED, true); plr->CastSpell(plr, SPELL_TB_TOL_BARAD_TOWER_BONUS, true); } } m_Data32[BATTLEFIELD_TB_DATA_CAPTURED]++; }
void BattlefieldTB::TowerDamaged(TBTowerId tbTowerId) { if (!IsWarTime()) return; SendWarning(TBTowers[tbTowerId].textDamaged); SetData(BATTLEFIELD_TB_DATA_TOWERS_INTACT, GetData(BATTLEFIELD_TB_DATA_TOWERS_INTACT) - 1); SendUpdateWorldState(uint32(TBTowers[tbTowerId].wsIntact[GetDefenderTeam()]), int32(0)); SendUpdateWorldState(uint32(TBTowers[tbTowerId].wsDamaged[GetDefenderTeam()]), int32(1)); TeamCastSpell(GetAttackerTeam(), SPELL_REWARD_TOWER_DAMAGED); }
bool BattlefieldTB::Update(uint32 diff) { bool m_return = Battlefield::Update(diff); if (m_saveTimer <= diff) { sWorld->setWorldState(5387, m_WarTime); if (IsWarTime()) { sWorld->setWorldState(5546, GetAttackerTeam()); sWorld->setWorldState(5547, GetAttackerTeam()); } else sWorld->setWorldState(5384, m_DefenderTeam); sWorld->setWorldState(TBClockWorldState[0], m_Timer ); m_saveTimer = 60 * IN_MILLISECONDS; } else m_saveTimer -= diff; for (GuidSet::const_iterator itr = m_PlayersIsSpellImu.begin(); itr != m_PlayersIsSpellImu.end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer((*itr))) { if (player->HasAura(SPELL_SPIRITUAL_IMMUNITY_TB)) { const WorldSafeLocsEntry* graveyard = GetClosestGraveYard(player); if (graveyard) { if (player->GetDistance2d(graveyard->x, graveyard->y) > 6.0f) { player->RemoveAurasDueToSpell(SPELL_SPIRITUAL_IMMUNITY_TB); m_PlayersIsSpellImu.erase(player->GetGUID()); } } } } return m_return; }
void BattlefieldTB::UpdateCapturedBaseCount() { uint32 numCapturedBases = 0; // How many bases attacker has captured for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) if (itr->second->GetTeamId() == GetAttackerTeam()) numCapturedBases += 1; SetData(BATTLEFIELD_TB_DATA_BUILDINGS_CAPTURED, numCapturedBases); SendUpdateWorldState(TB_WS_BUILDINGS_CAPTURED, uint32(numCapturedBases)); // Check if attackers won if (numCapturedBases == TB_BASE_COUNT) EndBattle(false); }
void BattlefieldTB::SendInitWorldStatesToAll() { // Save sWorld->setWorldState(TB_WS_STATE_BATTLE, uint32(IsWarTime() ? 1 : 0)); sWorld->setWorldState(TB_WS_ALLIANCE_CONTROLS_SHOW, uint32(!IsWarTime() && GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0)); sWorld->setWorldState(TB_WS_HORDE_CONTROLS_SHOW, uint32(!IsWarTime() && GetDefenderTeam() == TEAM_HORDE ? 1 : 0)); sWorld->setWorldState(TB_WS_ALLIANCE_ATTACKING_SHOW, uint32(IsWarTime() && GetAttackerTeam() == TEAM_ALLIANCE ? 1 : 0)); sWorld->setWorldState(TB_WS_HORDE_ATTACKING_SHOW, uint32(IsWarTime() && GetAttackerTeam() == TEAM_HORDE ? 1 : 0)); sWorld->setWorldState(TB_WS_TIME_NEXT_BATTLE, uint32(!IsWarTime() ? m_Timer : 0)); sWorld->setWorldState(TB_WS_TIME_NEXT_BATTLE_SHOW, uint32(!IsWarTime() ? 1 : 0)); // Tol Barad for (uint8 team = 0; team < BG_TEAMS_COUNT; team++) for (ObjectGuid const& guid : m_players[team]) if (Player* player = ObjectAccessor::FindPlayer(guid)) SendInitWorldStatesTo(player); // Tol Barad Peninsula Map::PlayerList const& players = m_Map->GetPlayers(); for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) if (Player* player = itr->GetSource()->ToPlayer()) if (player->GetZoneId() == 5389) // ZONE_TOL_BARAD_PENINSULA player->SendInitWorldStates(5389, player->GetAreaId()); }
void Battlefield::EndBattle(bool endByTimer) { if (!m_isActive) return; m_isActive = false; m_StartGrouping = false; if (!endByTimer) SetDefenderTeam(GetAttackerTeam()); OnBattleEnd(endByTimer); // Reset battlefield timer m_Timer = m_NoWarBattleTime; SendInitWorldStatesToAll(); }
void Battlefield::EndBattle(bool endbytimer) { m_WarTime = false; m_StartGrouping = false; if (!endbytimer) SetDefenderTeam(GetAttackerTeam()); if (GetDefenderTeam() == TEAM_ALLIANCE) PlaySoundToAll(BF_ALLIANCE_WINS); // alliance wins sound else PlaySoundToAll(BF_HORDE_WINS); // horde wins sound OnBattleEnd(endbytimer); //reset battlefield timer m_Timer = m_NoWarBattleTime; SendInitWorldStatesToAll(); }
void BattlefieldWG::OnPlayerJoinWar(Player* player) { player->RemoveAurasDueToSpell(SPELL_RECRUIT); player->RemoveAurasDueToSpell(SPELL_CORPORAL); player->RemoveAurasDueToSpell(SPELL_LIEUTENANT); player->RemoveAurasDueToSpell(SPELL_TOWER_CONTROL); player->RemoveAurasDueToSpell(SPELL_SPIRITUAL_IMMUNITY); player->RemoveAurasDueToSpell(SPELL_TENACITY); player->RemoveAurasDueToSpell(SPELL_ESSENCE_OF_WINTERGRASP); player->CastSpell(player, SPELL_RECRUIT, true); if (player->GetZoneId() != m_ZoneId) { if (player->GetTeamId() == GetDefenderTeam()) { player->TeleportTo(571, 5345, 2842, 410, 3.14f); } else { if (player->GetTeamId() == TEAM_HORDE) player->TeleportTo(571, 5025.857422f, 3674.628906f, 362.737122f, 4.135169f); else player->TeleportTo(571, 5101.284f, 2186.564f, 373.549f, 3.812f); } } UpdateTenacity(); if (player->GetTeamId() == GetAttackerTeam()) { if (3 - m_Data32[BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT] > 0) player->SetAuraStack(SPELL_TOWER_CONTROL, player, 3 - m_Data32[BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT]); } else { if (m_Data32[BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT] > 0) player->SetAuraStack(SPELL_TOWER_CONTROL, player, m_Data32[BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT]); } SendInitWorldStatesTo(player); }
void BattlefieldWG::FillInitialWorldStates(WorldStateBuilder& builder) { builder.AppendState(BATTLEFIELD_WG_WORLD_STATE_ATTACKER, GetAttackerTeam()); builder.AppendState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER, GetDefenderTeam()); builder.AppendState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, IsWarTime() ? 0 : 1); // Note: cleanup these two, their names look awkward builder.AppendState(BATTLEFIELD_WG_WORLD_STATE_SHOW_WORLDSTATE, IsWarTime() ? 1 : 0); for (uint32 i = 0; i < 2; ++i) builder.AppendState(ClockWorldState[i], uint32(time(NULL) + (m_Timer / 1000))); builder.AppendState(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_H, GetData(BATTLEFIELD_WG_DATA_VEHICLE_H)); builder.AppendState(BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_H, GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H)); builder.AppendState(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_A, GetData(BATTLEFIELD_WG_DATA_VEHICLE_A)); builder.AppendState(BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_A, GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_A)); for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr) builder.AppendState((*itr)->m_WorldState, (*itr)->m_State); for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr) if (*itr) builder.AppendState(WorkshopsData[(*itr)->workshopId].worldstate, (*itr)->state); }
void BattlefieldWG::FillInitialWorldStates(WorldPacket& data) { data << uint32(BATTLEFIELD_WG_WORLD_STATE_ATTACKER) << uint32(GetAttackerTeam()); data << uint32(BATTLEFIELD_WG_WORLD_STATE_DEFENDER) << uint32(GetDefenderTeam()); data << uint32(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) << uint32(IsWarTime() ? 0 : 1); // Note: cleanup these two, their names look awkward data << uint32(BATTLEFIELD_WG_WORLD_STATE_SHOW_WORLDSTATE) << uint32(IsWarTime() ? 1 : 0); for (uint32 i = 0; i < 2; ++i) data << ClockWorldState[i] << uint32(time(NULL) + (m_Timer / 1000)); data << uint32(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_H) << uint32(GetData(BATTLEFIELD_WG_DATA_VEHICLE_H)); data << uint32(BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_H) << GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H); data << uint32(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_A) << uint32(GetData(BATTLEFIELD_WG_DATA_VEHICLE_A)); data << uint32(BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_A) << GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_A); for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr) data << (*itr)->m_WorldState << (*itr)->m_State; for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr) if (*itr) data << WorkshopsData[(*itr)->workshopId].worldstate << (*itr)->state; }
void Battlefield::EndBattle(bool endByTimer) { if (!m_isActive) return; m_isActive = false; m_StartGrouping = false; if (!endByTimer) SetDefenderTeam(GetAttackerTeam()); if (GetDefenderTeam() == TEAM_ALLIANCE) DoPlaySoundToAll(BF_ALLIANCE_WINS); else DoPlaySoundToAll(BF_HORDE_WINS); OnBattleEnd(endByTimer); // Reset battlefield timer m_Timer = m_NoWarBattleTime; SendInitWorldStatesToAll(); }
bool BattlefieldWG::SetupBattlefield() { m_TypeId = BATTLEFIELD_WG; // See enum BattlefieldTypes m_BattleId = BATTLEFIELD_BATTLEID_WG; m_ZoneId = BATTLEFIELD_WG_ZONEID; m_MapId = BATTLEFIELD_WG_MAPID; m_Map = sMapMgr->FindMap(m_MapId, 0); InitStalker(BATTLEFIELD_WG_NPC_STALKER, WintergraspStalkerPos[0], WintergraspStalkerPos[1], WintergraspStalkerPos[2], WintergraspStalkerPos[3]); m_MaxPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MAX); m_IsEnabled = sWorld->getBoolConfig(CONFIG_WINTERGRASP_ENABLE); m_MinPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MIN); m_MinLevel = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MIN_LVL); m_BattleTime = sWorld->getIntConfig(CONFIG_WINTERGRASP_BATTLETIME) * MINUTE * IN_MILLISECONDS; m_NoWarBattleTime = sWorld->getIntConfig(CONFIG_WINTERGRASP_NOBATTLETIME) * MINUTE * IN_MILLISECONDS; m_RestartAfterCrash = sWorld->getIntConfig(CONFIG_WINTERGRASP_RESTART_AFTER_CRASH) * MINUTE * IN_MILLISECONDS; m_TimeForAcceptInvite = 20; m_StartGroupingTimer = 15 * MINUTE * IN_MILLISECONDS; m_StartGrouping = false; m_tenacityStack = 0; KickPosition.Relocate(5728.117f, 2714.346f, 697.733f, 0); KickPosition.m_mapId = m_MapId; RegisterZone(m_ZoneId); m_Data32.resize(BATTLEFIELD_WG_DATA_MAX); m_saveTimer = 60000; // Init GraveYards SetGraveyardNumber(BATTLEFIELD_WG_GRAVEYARD_MAX); // Load from db if ((sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) == 0) && (sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER) == 0) && (sWorld->getWorldState(ClockWorldState[0]) == 0)) { sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, uint64(false)); sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER, uint64(urand(0, 1))); sWorld->setWorldState(ClockWorldState[0], uint64(m_NoWarBattleTime)); } m_isActive = bool(sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE)); m_DefenderTeam = TeamId(sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER)); m_Timer = sWorld->getWorldState(ClockWorldState[0]); if (m_isActive) { m_isActive = false; m_Timer = m_RestartAfterCrash; } for (uint8 i = 0; i < BATTLEFIELD_WG_GRAVEYARD_MAX; i++) { BfGraveyardWG* graveyard = new BfGraveyardWG(this); // When between games, the graveyard is controlled by the defending team if (WGGraveYard[i].startcontrol == TEAM_NEUTRAL) graveyard->Initialize(m_DefenderTeam, WGGraveYard[i].gyid); else graveyard->Initialize(WGGraveYard[i].startcontrol, WGGraveYard[i].gyid); graveyard->SetTextId(WGGraveYard[i].textid); m_GraveyardList[i] = graveyard; } // Spawn workshop creatures and gameobjects for (uint8 i = 0; i < WG_MAX_WORKSHOP; i++) { WGWorkshop* workshop = new WGWorkshop(this, i); if (i < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST) workshop->GiveControlTo(GetAttackerTeam(), true); else workshop->GiveControlTo(GetDefenderTeam(), true); // Note: Capture point is added once the gameobject is created. WorkshopsList.insert(workshop); } // Spawn NPCs in the defender's keep, both Horde and Alliance for (uint8 i = 0; i < WG_MAX_KEEP_NPC; i++) { // Horde npc if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryHorde, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_HORDE)) KeepCreature[TEAM_HORDE].insert(creature->GetGUID()); // Alliance npc if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryAlliance, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_ALLIANCE)) KeepCreature[TEAM_ALLIANCE].insert(creature->GetGUID()); } // Hide NPCs from the Attacker's team in the keep for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr) if (Creature* creature = GetCreature(*itr)) HideNpc(creature); // Spawn Horde NPCs outside the keep for (uint8 i = 0; i < WG_OUTSIDE_ALLIANCE_NPC; i++) if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryHorde, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_HORDE)) OutsideCreature[TEAM_HORDE].insert(creature->GetGUID()); // Spawn Alliance NPCs outside the keep for (uint8 i = WG_OUTSIDE_ALLIANCE_NPC; i < WG_MAX_OUTSIDE_NPC; i++) if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryAlliance, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_ALLIANCE)) OutsideCreature[TEAM_ALLIANCE].insert(creature->GetGUID()); // Hide units outside the keep that are defenders for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr) if (Creature* creature = GetCreature(*itr)) HideNpc(creature); // Spawn turrets and hide them per default for (uint8 i = 0; i < WG_MAX_TURRET; i++) { Position towerCannonPos = WGTurret[i].GetPosition(); if (Creature* creature = SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE)) { CanonList.insert(creature->GetGUID()); HideNpc(creature); } } // Spawn all gameobjects for (uint8 i = 0; i < WG_MAX_OBJ; i++) { if (GameObject* go = SpawnGameObject(WGGameObjectBuilding[i].entry, WGGameObjectBuilding[i].x, WGGameObjectBuilding[i].y, WGGameObjectBuilding[i].z, WGGameObjectBuilding[i].o)) { BfWGGameObjectBuilding* b = new BfWGGameObjectBuilding(this); b->Init(go, WGGameObjectBuilding[i].type, WGGameObjectBuilding[i].WorldState, WGGameObjectBuilding[i].nameId); if (!IsEnabled() && go->GetEntry() == GO_WINTERGRASP_VAULT_GATE) go->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED); BuildingsInZone.insert(b); } } // Spawning portal defender for (uint8 i = 0; i < WG_MAX_TELEPORTER; i++) { if (GameObject* go = SpawnGameObject(WGPortalDefenderData[i].entry, WGPortalDefenderData[i].x, WGPortalDefenderData[i].y, WGPortalDefenderData[i].z, WGPortalDefenderData[i].o)) { DefenderPortalList.insert(go->GetGUID()); go->SetFaction(WintergraspFaction[GetDefenderTeam()]); } } UpdateCounterVehicle(true); return true; }
void BattlefieldWG::OnGameObjectCreate(GameObject* go) { uint8 workshopId = 0; switch (go->GetEntry()) { case GO_WINTERGRASP_FACTORY_BANNER_NE: workshopId = BATTLEFIELD_WG_WORKSHOP_NE; break; case GO_WINTERGRASP_FACTORY_BANNER_NW: workshopId = BATTLEFIELD_WG_WORKSHOP_NW; break; case GO_WINTERGRASP_FACTORY_BANNER_SE: workshopId = BATTLEFIELD_WG_WORKSHOP_SE; break; case GO_WINTERGRASP_FACTORY_BANNER_SW: workshopId = BATTLEFIELD_WG_WORKSHOP_SW; break; default: return; } for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr) { if (WGWorkshop* workshop = (*itr)) { if (workshop->workshopId == workshopId) { WintergraspCapturePoint* capturePoint = new WintergraspCapturePoint(this, GetAttackerTeam()); capturePoint->SetCapturePointData(go); capturePoint->LinkToWorkshop(workshop); AddCapturePoint(capturePoint); break; } } } }