bool BattlefieldTB::SetupBattlefield() { m_TypeId = BATTLEFIELD_TB; //View enum BattlefieldTypes m_BattleId = BATTLEFIELD_BATTLEID_TB; m_ZoneId = 5095; // Tol Barad _MapId = 732; // Map X m_MaxPlayer = sWorld->getIntConfig(CONFIG_TOL_BARAD_PLR_MAX); m_enable = sWorld->getBoolConfig(CONFIG_TOL_BARAD_ENABLE); m_MinPlayer = sWorld->getIntConfig(CONFIG_TOL_BARAD_PLR_MIN); m_MinLevel = sWorld->getIntConfig(CONFIG_TOL_BARAD_PLR_MIN_LVL); m_BattleTime = sWorld->getIntConfig(CONFIG_TOL_BARAD_BATTLETIME)*60*1000; // Time of battle (in ms) m_NoWarBattleTime = sWorld->getIntConfig(CONFIG_TOL_BARAD_NOBATTLETIME)*60*1000; // Time between to battle (in ms) m_TimeForAcceptInvite = 20; // in second m_StartGroupingTimer = 15*60*1000; // in ms m_StartGrouping=false; KickPositionA.Relocate(-363.897f, 1047.931f, 22, 0); KickPositionA.m_mapId = _MapId; KickPositionH.Relocate(-609.336f, 1392.194f, 21.5f, 0); KickPositionH.m_mapId = _MapId; RegisterZone(m_ZoneId); m_Data32.resize(BATTLEFIELD_TB_DATA_MAX); m_saveTimer = 60000; // Init GraveYards SetGraveyardNumber(BATTLEFIELD_TB_GY_MAX); //Load from db if(( sWorld->getWorldState(5387) == 0 ) && (sWorld->getWorldState(5384) == 0) && (sWorld->getWorldState(TBClockWorldState[0]) == 0 )) { sWorld->setWorldState(5387, false); sWorld->setWorldState(5384, urand(0, 1)); sWorld->setWorldState(TBClockWorldState[0], m_NoWarBattleTime); } m_WarTime = sWorld->getWorldState(5387); m_DefenderTeam = (TeamId)sWorld->getWorldState(5384); m_Timer = sWorld->getWorldState(TBClockWorldState[0]); if (m_WarTime) { m_WarTime = false; m_Timer = 10 * 60 * 1000; } for (uint8 i=0; i<BATTLEFIELD_TB_GY_MAX; i++) { BfGraveYardTB* gy = new BfGraveYardTB(this); if (TBGraveYard[i].startcontrol == TEAM_NEUTRAL) { // In no war time Gy is control by defender gy->Init(45079, 45066, TBGraveYard[i].x, TBGraveYard[i].y, TBGraveYard[i].z, TBGraveYard[i].o, m_DefenderTeam, TBGraveYard[i].guid); } else gy->Init(45079, 45066, TBGraveYard[i].x, TBGraveYard[i].y, TBGraveYard[i].z, TBGraveYard[i].o, TBGraveYard[i].startcontrol, TBGraveYard[i].guid); gy->SetTextId(TBGraveYard[i].textid); m_GraveYardList[i] = gy; } // Pop des gameobject et creature du TBWorkShop for (uint8 i = 0; i<TB_MAX_WORKSHOP; i++) { BfTBWorkShopData* ws = new BfTBWorkShopData(this); // Create new object // Init:setup variable ws->Init(TBCapturePointDataBase[i].worldstate, TBCapturePointDataBase[i].type, TBCapturePointDataBase[i].nameid); // Spawn associate gameobject on this point (Horde/Alliance flags) for (int g = 0; g<TBCapturePointDataBase[i].nbgob; g++) { ws->AddGameObject(TBCapturePointDataBase[i].GameObjectData[g]); } // Create PvPCapturePoint if (TBCapturePointDataBase[i].type < BATTLEFIELD_TB_FORT_MAX) { ws->ChangeControl(GetAttackerTeam(), true); // Update control of this point m_Data32[BATTLEFIELD_TB_DATA_CAPTURED_FORT_ATT]++; m_Data32[BATTLEFIELD_TB_DATA_CAPTURED_FORT_DEF]--; // Create Object BfCapturePointTB* TBWorkShop = new BfCapturePointTB(this, GetAttackerTeam()); // Spawn gameobject associate (see in OnGameObjectCreate, of OutdoorPvP for see association) if (TBWorkShop->SetCapturePointData(TBCapturePointDataBase[i].CapturePoint.entryh, 732, TBCapturePointDataBase[i].CapturePoint.x, TBCapturePointDataBase[i].CapturePoint.y, TBCapturePointDataBase[i].CapturePoint.z, 0)) { TBWorkShop->LinkToWorkShop(ws); // Link our point to the capture point (for faction changement) AddCapturePoint(TBWorkShop); // Add this capture point to list for update this (view in Update() of OutdoorPvP) } } else { m_Data32[BATTLEFIELD_TB_DATA_CAPTURED_FORT_ATT]--; m_Data32[BATTLEFIELD_TB_DATA_CAPTURED_FORT_DEF]++; ws->ChangeControl(GetDefenderTeam(), true); // Update control of this point (Keep TBWorkShop= to deffender team) } WorkShopList.insert(ws); } // Spawning npc in keep for (uint8 i = 0; i<TB_MAX_KEEP_NPC; i++) { // Horde npc if (Creature* creature = SpawnCreature(TBKeepNPC[i].entryh, TBKeepNPC[i].x, TBKeepNPC[i].y, TBKeepNPC[i].z, TBKeepNPC[i].o, TEAM_HORDE)) KeepCreature[TEAM_HORDE].insert(creature->GetGUID()); // Alliance npc if (Creature* creature = SpawnCreature(TBKeepNPC[i].entrya, TBKeepNPC[i].x, TBKeepNPC[i].y, TBKeepNPC[i].z, TBKeepNPC[i].o, TEAM_ALLIANCE)) KeepCreature[TEAM_ALLIANCE].insert(creature->GetGUID()); } // 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); // Spawning battle npcs for (uint8 i = 0; i<TB_MAX_KEEP_NPC; i++) { // Horde npc if (Creature* creature = SpawnCreature(TBWarNPC[i].entryh, TBWarNPC[i].x, TBWarNPC[i].y, TBWarNPC[i].z, TBWarNPC[i].o, TEAM_HORDE)) WarCreature[TEAM_HORDE].insert(creature->GetGUID()); // Alliance npc if (Creature* creature = SpawnCreature(TBWarNPC[i].entrya, TBWarNPC[i].x, TBWarNPC[i].y, TBWarNPC[i].z, TBWarNPC[i].o, TEAM_ALLIANCE)) WarCreature[TEAM_ALLIANCE].insert(creature->GetGUID()); } // Hide 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); 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); //Spawning Buiding for (uint8 i = 0; i<TB_MAX_OBJ; i++) { GameObject* go = SpawnGameObject(TBGameObjectBuillding[i].entry, TBGameObjectBuillding[i].x, TBGameObjectBuillding[i].y, TBGameObjectBuillding[i].z, TBGameObjectBuillding[i].o); if (go) { BfTBGameObjectBuilding* b = new BfTBGameObjectBuilding(this); b->Init(go, TBGameObjectBuillding[i].type, TBGameObjectBuillding[i].WorldState, TBGameObjectBuillding[i].nameid); BuildingsInZone.insert(b); } } return true; }
bool BattlefieldTB::SetupBattlefield() { m_TypeId = BATTLEFIELD_TB; m_BattleId = BATTLEFIELD_BATTLEID_TB; m_ZoneId = BATTLEFIELD_TB_ZONEID; m_MapId = BATTLEFIELD_TB_MAPID; m_MaxPlayer = sWorld->getIntConfig(CONFIG_TOL_BARAD_PLR_MAX); m_IsEnabled = sWorld->getBoolConfig(CONFIG_TOL_BARAD_ENABLE); m_MinPlayer = sWorld->getIntConfig(CONFIG_TOL_BARAD_PLR_MIN); m_MinLevel = sWorld->getIntConfig(CONFIG_TOL_BARAD_PLR_MIN_LVL); m_BattleTime = sWorld->getIntConfig(CONFIG_TOL_BARAD_BATTLETIME) * MINUTE * IN_MILLISECONDS; m_NoWarBattleTime = sWorld->getIntConfig(CONFIG_TOL_BARAD_NOBATTLETIME) * MINUTE * IN_MILLISECONDS; m_RestartAfterCrash = sWorld->getIntConfig(CONFIG_TOL_BARAD_RESTART_AFTER_CRASH) * MINUTE * IN_MILLISECONDS; m_TimeForAcceptInvite = 20; m_StartGroupingTimer = 15 * MINUTE * IN_MILLISECONDS; m_StartGrouping = false; KickPosition.Relocate(-630.460f, 1184.504f, 95.766f, 0); KickPosition.m_mapId = m_MapId; RegisterZone(m_ZoneId); m_Data32.resize(BATTLEFIELD_TB_DATA_MAX); m_Data32[BATTLEFIELD_TB_DATA_CAPTURED] = 0; m_saveTimer = 60000; SetGraveyardNumber(BATTLEFIELD_TB_GY_MAX); if ((sWorld->getWorldState(WS_TB_NEXT_BATTLE_TIMER_ENABLED) == 0) && (sWorld->getWorldState(WS_TB_HORDE_DEFENCE) == 0) && (sWorld->getWorldState(ClockBTWorldState[0]) == 0)) { sWorld->setWorldState(WS_TB_NEXT_BATTLE_TIMER_ENABLED, uint64(false)); sWorld->setWorldState(WS_TB_HORDE_DEFENCE, uint64(urand(0, 1))); sWorld->setWorldState(ClockBTWorldState[0], uint64(m_NoWarBattleTime)); } if (sWorld->getWorldState(WS_TB_UNK) == 0) sWorld->setWorldState(WS_TB_UNK, urand(1, 3)); if (sWorld->getWorldState(WS_TB_UNK_2) == 0) sWorld->setWorldState(WS_TB_UNK_2, time(NULL) + 86400); m_isActive = bool(sWorld->getWorldState(WS_TB_NEXT_BATTLE_TIMER_ENABLED)); m_DefenderTeam = (TeamId)sWorld->getWorldState(WS_TB_HORDE_DEFENCE); m_Timer = sWorld->getWorldState(ClockBTWorldState[0]); if (m_isActive) { m_isActive = false; m_Timer = m_RestartAfterCrash; } for (uint8 i = 0; i < BATTLEFIELD_TB_GY_MAX; i++) { BfGraveyardTB* graveyard = new BfGraveyardTB(this); graveyard->Initialize(TBGraveYard[i].entryh, TBGraveYard[i].entrya, TBGraveYard[i].x, TBGraveYard[i].y, TBGraveYard[i].z, TBGraveYard[i].o, m_DefenderTeam, TBGraveYard[i].gyid); m_GraveyardList[i] = graveyard; } for (uint8 i = 0; i < TB_MAX_WORKSHOP; i++) { BfTBWorkShopData* workshop = new BfTBWorkShopData(this); workshop->Init(TBWorkShopDataBase[i].worldstate, TBWorkShopDataBase[i].type, TBWorkShopDataBase[i].nameid); workshop->ChangeControl(GetDefenderTeam(),true); BfCapturePointTB* point = new BfCapturePointTB(this, GetDefenderTeam()); point->SetCapturePointData(GetDefenderTeam() == TEAM_ALLIANCE ? TBWorkShopDataBase[i].CapturePoint.entrya : TBWorkShopDataBase[i].CapturePoint.entryh, BATTLEFIELD_TB_MAPID, TBWorkShopDataBase[i].CapturePoint.x, TBWorkShopDataBase[i].CapturePoint.y, TBWorkShopDataBase[i].CapturePoint.z, 0); point->LinkToWorkShop(workshop); AddCapturePoint(point); CapturePoints.insert(point); WorkShopList.insert(workshop); } for (uint8 i = 0; i < TB_MAX_DESTROY_MACHINE_NPC; i++) { if (Creature* creature = SpawnCreature(TBDestroyMachineNPC[i].entrya, TBDestroyMachineNPC[i].x, TBDestroyMachineNPC[i].y, TBDestroyMachineNPC[i].z, TBDestroyMachineNPC[i].o, GetAttackerTeam())) { HideNpc(creature); Vehicles.insert(creature->GetGUID()); } } for (uint8 i = 0; i < TB_MAX_OBJ; i++) { GameObject* go = SpawnGameObject(TBGameObjectBuillding[i].entry, BATTLEFIELD_TB_MAPID, TBGameObjectBuillding[i].x, TBGameObjectBuillding[i].y, TBGameObjectBuillding[i].z, TBGameObjectBuillding[i].o); BfTBGameObjectBuilding* b = new BfTBGameObjectBuilding(this); b->Init(go,TBGameObjectBuillding[i].type,TBGameObjectBuillding[i].WorldState,TBGameObjectBuillding[i].nameid); b->m_State = BATTLEFIELD_TB_OBJECTSTATE_ALLIANCE_INTACT - (GetDefenderTeam() * 3); BuildingsInZone.insert(b); } for (uint8 i = 0; i < 4; i++) { if (Creature* creature = SpawnCreature(QuestGivers[i].entrya, QuestGivers[i].x, QuestGivers[i].y, QuestGivers[i].z, QuestGivers[i].o, TEAM_ALLIANCE)) { HideNpc(creature); creature->setFaction(TolBaradFaction[TEAM_ALLIANCE]); questgiversA.insert(creature->GetGUID()); } } for (uint8 i = 0; i < 4; i++) { if (Creature* creature = SpawnCreature(QuestGivers[i].entryh, QuestGivers[i].x, QuestGivers[i].y, QuestGivers[i].z, QuestGivers[i].o, TEAM_HORDE)) { HideNpc(creature); creature->setFaction(TolBaradFaction[TEAM_HORDE]); questgiversH.insert(creature->GetGUID()); } } { int i = 0; GuidSet questgivers = (GetDefenderTeam() == TEAM_ALLIANCE ? questgiversA : questgiversH); for (GuidSet::const_iterator itr = questgivers.begin(); itr != questgivers.end(); ++itr) { if (Unit* unit = sObjectAccessor->FindUnit((*itr))) { if (Creature* creature = unit->ToCreature()) { if (!i || i == sWorld->getWorldState(WS_TB_UNK)) if (!m_isActive) ShowNpc(creature, true); i++; } } } } for (uint8 i = 0; i < 23; i++) { if (Creature* creature = SpawnCreature(AllianceSpawnNPC[i].entrya, AllianceSpawnNPC[i].x, AllianceSpawnNPC[i].y, AllianceSpawnNPC[i].z, AllianceSpawnNPC[i].o, TEAM_ALLIANCE)) { creature->setFaction(TolBaradFaction[TEAM_ALLIANCE]); npcAlliance.insert(creature->GetGUID()); } } for (uint8 i = 0; i < 23; i++) { if (Creature* creature = SpawnCreature(HordeSpawnNPC[i].entrya, HordeSpawnNPC[i].x, HordeSpawnNPC[i].y, HordeSpawnNPC[i].z, HordeSpawnNPC[i].o, TEAM_HORDE)) { creature->setFaction(TolBaradFaction[TEAM_HORDE]); npcHorde.insert(creature->GetGUID()); } } for (uint8 i = 0; i < 130; i++) { if (Creature* creature = SpawnCreature(TbOldNpcStructure[i].entrya, TbOldNpcStructure[i].x, TbOldNpcStructure[i].y, TbOldNpcStructure[i].z, TbOldNpcStructure[i].o, TEAM_NEUTRAL)) { creature->SetRespawnRadius(15.0f); creature->SetDefaultMovementType(RANDOM_MOTION_TYPE); creature->GetMotionMaster()->Initialize(); npcOld.insert(creature->GetGUID()); } } for (uint8 i = 0; i < 4; i++) { if (GameObject* go = SpawnGameObject(TBGameobjectsDoor[i].entrya, BATTLEFIELD_TB_MAPID, TBGameobjectsDoor[i].x, TBGameobjectsDoor[i].y, TBGameobjectsDoor[i].z, TBGameobjectsDoor[i].o)) { go->ToGameObject()->SetLootState(GO_READY); go->ToGameObject()->UseDoorOrButton(); goDoors.insert(go); } } return true; }