void BattlefieldTB::ProcessEvent(WorldObject* obj, uint32 eventId) { if (!IsWarTime()) return; if (eventId == EVENT_COUNT_CAPTURED_BASE) { UpdateCapturedBaseCount(); return; } if (!obj) return; GameObject* go = obj->ToGameObject(); if (!go) return; TBTowerId towerId; switch (go->GetEntry()) { case GO_WEST_SPIRE: towerId = TB_TOWER_WEST_SPIRE; break; case GO_EAST_SPIRE: towerId = TB_TOWER_EAST_SPIRE; break; case GO_SOUTH_SPIRE: towerId = TB_TOWER_SOUTH_SPIRE; break; default: return; } if (go->GetDestructibleState() == GO_DESTRUCTIBLE_DAMAGED) TowerDamaged(towerId); else if (go->GetDestructibleState() == GO_DESTRUCTIBLE_DESTROYED) TowerDestroyed(towerId); }
// 62 fields, [7]-[68] void BattlefieldTB::FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& packet) { packet.Worldstates.emplace_back(uint32(TB_WS_ALLIANCE_ATTACKING_SHOW), int32(IsWarTime() && GetAttackerTeam() == TEAM_ALLIANCE ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TB_WS_HORDE_ATTACKING_SHOW), int32(IsWarTime() && GetAttackerTeam() == TEAM_HORDE ? 1 : 0)); // Not sure if TB //packet.Worldstates.emplace_back(uint32(TB_WS_9_UNKNOWN), int32(1)); packet.Worldstates.emplace_back(uint32(TB_WS_SOUTH_DAMAGED_NEUTRAL), int32(0)); packet.Worldstates.emplace_back(uint32(TB_WS_SOUTH_INTACT_NEUTRAL), int32(0)); packet.Worldstates.emplace_back(uint32(TB_WS_PROGRESS_SHOW), int32(0)); // Buildings/bases for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) { uint8 i = TB_BASE_COUNT; switch (itr->second->GetCapturePointEntry()) { case GO_CAPTURE_POINT_NORTH_A_DEFENDING: case GO_CAPTURE_POINT_NORTH_H_DEFENDING: i = TB_BASE_IRONCLAD_GARRISON; break; case GO_CAPTURE_POINT_EAST_A_DEFENDING: case GO_CAPTURE_POINT_EAST_H_DEFENDING: i = TB_BASE_SLAGWORKS; break; case GO_CAPTURE_POINT_WEST_A_DEFENDING: case GO_CAPTURE_POINT_WEST_H_DEFENDING: i = TB_BASE_WARDENS_VIGIL; break; default: continue; } TeamId team = TEAM_NEUTRAL; bool controlled = false; bool capturing = false; switch (itr->second->GetObjectiveState()) { case BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE: case BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE: controlled = true; team = itr->second->GetTeamId(); break; case BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE: case BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE: team = TEAM_ALLIANCE; capturing = true; break; case BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE: case BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE: team = TEAM_HORDE; capturing = true; break; default: team = TEAM_NEUTRAL; break; } packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsControlled[TEAM_ALLIANCE]), int32(team == TEAM_ALLIANCE && controlled ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsCapturing[TEAM_ALLIANCE]), int32(team == TEAM_ALLIANCE && capturing ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsNeutral), int32(team == TEAM_NEUTRAL ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsCapturing[TEAM_HORDE]), int32(team == TEAM_HORDE && capturing ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsControlled[TEAM_HORDE]), int32(team == TEAM_HORDE && controlled ? 1 : 0)); } packet.Worldstates.emplace_back(uint32(TB_WS_TOWERS_DESTROYED_SHOW), int32(GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED))); packet.Worldstates.emplace_back(uint32(TB_WS_BUILDINGS_CAPTURED_SHOW), int32(IsWarTime() ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TB_WS_BUILDINGS_CAPTURED), int32(GetData(BATTLEFIELD_TB_DATA_BUILDINGS_CAPTURED))); packet.Worldstates.emplace_back(uint32(TB_WS_TOWERS_DESTROYED), int32(0)); packet.Worldstates.emplace_back(uint32(TB_WS_TIME_BATTLE_END_SHOW), int32(IsWarTime() ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TB_WS_STATE_BATTLE), int32(IsWarTime() ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TB_WS_STATE_PREPARATIONS), int32(GetState() == BATTLEFIELD_WARMUP ? 1 : 0)); // Not sure if TB //packet.Worldstates.emplace_back(uint32(TB_WS_35_UNKNOWN), int32(0)); //packet.Worldstates.emplace_back(uint32(TB_WS_36_UNKNOWN), int32(0)); //packet.Worldstates.emplace_back(uint32(TB_WS_37_UNKNOWN), int32(0)); // Unused tower icons packet.Worldstates.emplace_back(uint32(TB_WS_WEST_DAMAGED_NEUTRAL), int32(0)); packet.Worldstates.emplace_back(uint32(TB_WS_WEST_INTACT_NEUTRAL), int32(0)); packet.Worldstates.emplace_back(uint32(TB_WS_EAST_DAMAGED_NEUTRAL), int32(0)); packet.Worldstates.emplace_back(uint32(TB_WS_EAST_INTACT_NEUTRAL), int32(0)); // Towers/spires for (uint8 i = 0; i < TB_TOWERS_COUNT; i++) { // Find gameobject for (ObjectGuid guid : Towers) { GameObject* tower = GetGameObject(guid); if (!tower || tower->GetEntry() != TBTowers[i].entry) continue; TeamId team = GetDefenderTeam(); // 0-false -> alliance; 1-true -> horde bool intact = tower->GetDestructibleState() == GO_DESTRUCTIBLE_INTACT; bool damaged = tower->GetDestructibleState() == GO_DESTRUCTIBLE_DAMAGED; bool destroyed = tower->GetDestructibleState() == GO_DESTRUCTIBLE_DESTROYED; packet.Worldstates.emplace_back(uint32(TBTowers[i].wsIntact[TEAM_ALLIANCE]), int32(!team && intact ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TBTowers[i].wsDamaged[TEAM_ALLIANCE]), int32(!team && damaged ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TBTowers[i].wsDestroyed), int32(destroyed ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TBTowers[i].wsDamaged[TEAM_HORDE]), int32(team && damaged ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TBTowers[i].wsIntact[TEAM_HORDE]), int32(team && intact ? 1 : 0)); } } packet.Worldstates.emplace_back(uint32(TB_WS_TIME_NEXT_BATTLE_SHOW), int32(!IsWarTime() ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TB_WS_ALLIANCE_CONTROLS_SHOW), int32(!IsWarTime() && GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TB_WS_HORDE_CONTROLS_SHOW), int32(!IsWarTime() && GetDefenderTeam() == TEAM_HORDE ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TB_WS_TIME_BATTLE_END), int32(IsWarTime() ? time(NULL) + (m_Timer / 1000) : 0)); packet.Worldstates.emplace_back(uint32(TB_WS_TIME_NEXT_BATTLE), int32(!IsWarTime() ? time(NULL) + (m_Timer / 1000) : 0)); // Not sure if TB //packet.Worldstates.emplace_back(uint32(TB_WS_65_UNKNOWN), int32(0)); //packet.Worldstates.emplace_back(uint32(TB_WS_66_UNKNOWN), int32(0)); packet.Worldstates.emplace_back(uint32(TB_WS_KEEP_ALLIANCE), int32(GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0)); packet.Worldstates.emplace_back(uint32(TB_WS_KEEP_HORDE), int32(GetDefenderTeam() == TEAM_HORDE ? 1 : 0)); }