void BattlegroundIC::EventPlayerClickedOnFlag(Player* player, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) return; // All the node points are iterated to find the clicked one for (uint8 i = 0; i < MAX_NODE_TYPES; ++i) { if (nodePoint[i].gameobject_entry == target_obj->GetEntry()) { // THIS SHOULD NEEVEER HAPPEN if (nodePoint[i].faction == player->GetTeamId()) return; uint32 nextBanner = GetNextBanner(&nodePoint[i], player->GetTeamId(), false); // we set the new settings of the nodePoint nodePoint[i].faction = player->GetTeamId(); nodePoint[i].last_entry = nodePoint[i].gameobject_entry; nodePoint[i].gameobject_entry = nextBanner; // this is just needed if the next banner is grey if (nodePoint[i].banners[BANNER_A_CONTESTED] == nextBanner || nodePoint[i].banners[BANNER_H_CONTESTED] == nextBanner) { nodePoint[i].timer = BANNER_STATE_CHANGE_TIME; // 1 minute for last change (real faction banner) nodePoint[i].needChange = true; RealocatePlayers(nodePoint[i].nodeType); // if we are here means that the point has been lost, or it is the first capture if (nodePoint[i].nodeType != NODE_TYPE_REFINERY && nodePoint[i].nodeType != NODE_TYPE_QUARRY) if (BgCreatures[BG_IC_NPC_SPIRIT_GUIDE_1+(nodePoint[i].nodeType)-2]) DelCreature(BG_IC_NPC_SPIRIT_GUIDE_1+(nodePoint[i].nodeType)-2); UpdatePlayerScore(player, SCORE_BASES_ASSAULTED, 1); SendMessage2ToAll(LANG_BG_IC_TEAM_ASSAULTED_NODE_1, CHAT_MSG_BG_SYSTEM_NEUTRAL, player, nodePoint[i].string); SendMessage2ToAll(LANG_BG_IC_TEAM_ASSAULTED_NODE_2, CHAT_MSG_BG_SYSTEM_NEUTRAL, player, nodePoint[i].string, (player->GetTeamId() == TEAM_ALLIANCE ? LANG_BG_IC_ALLIANCE : LANG_BG_IC_HORDE)); HandleContestedNodes(&nodePoint[i]); } else if (nextBanner == nodePoint[i].banners[BANNER_A_CONTROLLED] || nextBanner == nodePoint[i].banners[BANNER_H_CONTROLLED]) // if we are going to spawn the definitve faction banner, we dont need the timer anymore { nodePoint[i].timer = BANNER_STATE_CHANGE_TIME; nodePoint[i].needChange = false; SendMessage2ToAll(LANG_BG_IC_TEAM_DEFENDED_NODE, CHAT_MSG_BG_SYSTEM_NEUTRAL, player, nodePoint[i].string); HandleCapturedNodes(&nodePoint[i], true); UpdatePlayerScore(player, SCORE_BASES_DEFENDED, 1); } GameObject* banner = GetBGObject(nodePoint[i].gameobject_type); if (!banner) // this should never happen return; float cords[4] = {banner->GetPositionX(), banner->GetPositionY(), banner->GetPositionZ(), banner->GetOrientation() }; DelObject(nodePoint[i].gameobject_type); AddObject(nodePoint[i].gameobject_type, nodePoint[i].gameobject_entry, cords[0], cords[1], cords[2], cords[3], 0, 0, 0, 0, RESPAWN_ONE_DAY); GetBGObject(nodePoint[i].gameobject_type)->SetUInt32Value(GAMEOBJECT_FACTION, nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_Factions[1] : BG_IC_Factions[0]); if (nodePoint[i].nodeType == NODE_TYPE_WORKSHOP) { DelObject(BG_IC_GO_SEAFORIUM_BOMBS_1); DelObject(BG_IC_GO_SEAFORIUM_BOMBS_2); } UpdateNodeWorldState(&nodePoint[i]); // we dont need iterating if we are here // If the needChange bool was set true, we will handle the rest in the Update Map function. return; } } }
void BattlegroundIC::PostUpdateImpl(uint32 diff) { if (GetStatus() != STATUS_IN_PROGRESS) return; if (!doorsClosed) { if (closeFortressDoorsTimer <= diff) { GetBGObject(BG_IC_GO_DOODAD_ND_HUMAN_GATE_CLOSEDFX_DOOR01)->RemoveFromWorld(); GetBGObject(BG_IC_GO_DOODAD_ND_WINTERORC_WALL_GATEFX_DOOR01)->RemoveFromWorld(); GetBGObject(BG_IC_GO_DOODAD_ND_HUMAN_GATE_CLOSEDFX_DOOR02)->RemoveFromWorld(); GetBGObject(BG_IC_GO_DOODAD_ND_WINTERORC_WALL_GATEFX_DOOR02)->RemoveFromWorld(); GetBGObject(BG_IC_GO_DOODAD_ND_HUMAN_GATE_CLOSEDFX_DOOR03)->RemoveFromWorld(); GetBGObject(BG_IC_GO_DOODAD_ND_WINTERORC_WALL_GATEFX_DOOR03)->RemoveFromWorld(); GetBGObject(BG_IC_GO_ALLIANCE_GATE_1)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); GetBGObject(BG_IC_GO_HORDE_GATE_1)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); GetBGObject(BG_IC_GO_ALLIANCE_GATE_2)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); GetBGObject(BG_IC_GO_HORDE_GATE_2)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); GetBGObject(BG_IC_GO_ALLIANCE_GATE_3)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); GetBGObject(BG_IC_GO_HORDE_GATE_3)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); doorsClosed = true; } else closeFortressDoorsTimer -= diff; } for (uint8 i = NODE_TYPE_REFINERY; i < MAX_NODE_TYPES; ++i) { if (nodePoint[i].nodeType == NODE_TYPE_DOCKS) { if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A || nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H) { if (nodePoint[i].timer <= diff) { // we need to confirm this, i am not sure if this every 3 minutes for (uint8 j = 0; j < MAX_CATAPULTS_SPAWNS_PER_FACTION; ++j) { uint8 type = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_A : BG_IC_NPC_CATAPULT_1_H)+j; if (Creature* catapult = GetBGCreature(type)) if (!catapult->IsAlive()) { // Check if creature respawn time is properly saved RespawnMap::iterator itr = respawnMap.find(catapult->GetGUIDLow()); if (itr == respawnMap.end() || time(NULL) < itr->second) continue; catapult->Relocate(BG_IC_DocksVehiclesCatapults[j].GetPositionX(), BG_IC_DocksVehiclesCatapults[j].GetPositionY(), BG_IC_DocksVehiclesCatapults[j].GetPositionZ(), BG_IC_DocksVehiclesCatapults[j].GetOrientation()); catapult->Respawn(true); respawnMap.erase(itr); } } // we need to confirm this is blizzlike, not sure if it is every 3 minutes for (uint8 j = 0; j < MAX_GLAIVE_THROWERS_SPAWNS_PER_FACTION; ++j) { uint8 type = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_A : BG_IC_NPC_GLAIVE_THROWER_1_H)+j; if (Creature* glaiveThrower = GetBGCreature(type)) if (!glaiveThrower->IsAlive()) { // Check if creature respawn time is properly saved RespawnMap::iterator itr = respawnMap.find(glaiveThrower->GetGUIDLow()); if (itr == respawnMap.end() || time(NULL) < itr->second) continue; glaiveThrower->Relocate(BG_IC_DocksVehiclesGlaives[j].GetPositionX(), BG_IC_DocksVehiclesGlaives[j].GetPositionY(), BG_IC_DocksVehiclesGlaives[j].GetPositionZ(), BG_IC_DocksVehiclesGlaives[j].GetOrientation()); glaiveThrower->Respawn(true); respawnMap.erase(itr); } } docksTimer = DOCKS_UPDATE_TIME; } else nodePoint[i].timer -= diff; } } if (nodePoint[i].nodeType == NODE_TYPE_WORKSHOP) { if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A || nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H) { if (siegeEngineWorkshopTimer <= diff) { uint8 siegeType = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_A : BG_IC_NPC_SIEGE_ENGINE_H); if (Creature* siege = GetBGCreature(siegeType)) // this always should be true if (!siege->IsAlive()) { // Check if creature respawn time is properly saved RespawnMap::iterator itr = respawnMap.find(siege->GetGUIDLow()); if (itr == respawnMap.end() || time(NULL) < itr->second) continue; siege->Relocate(BG_IC_WorkshopVehicles[4].GetPositionX(), BG_IC_WorkshopVehicles[4].GetPositionY(), BG_IC_WorkshopVehicles[4].GetPositionZ(), BG_IC_WorkshopVehicles[4].GetOrientation()); siege->Respawn(true); respawnMap.erase(itr); } // we need to confirm this, i am not sure if this every 3 minutes for (uint8 u = 0; u < MAX_DEMOLISHERS_SPAWNS_PER_FACTION; ++u) { uint8 type = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_A : BG_IC_NPC_DEMOLISHER_1_H)+u; if (Creature* demolisher = GetBGCreature(type)) if (!demolisher->IsAlive()) { // Check if creature respawn time is properly saved RespawnMap::iterator itr = respawnMap.find(demolisher->GetGUIDLow()); if (itr == respawnMap.end() || time(NULL) < itr->second) continue; demolisher->Relocate(BG_IC_WorkshopVehicles[u].GetPositionX(), BG_IC_WorkshopVehicles[u].GetPositionY(), BG_IC_WorkshopVehicles[u].GetPositionZ(), BG_IC_WorkshopVehicles[u].GetOrientation()); demolisher->Respawn(true); respawnMap.erase(itr); } } siegeEngineWorkshopTimer = WORKSHOP_UPDATE_TIME; } else siegeEngineWorkshopTimer -= diff; } } // the point is waiting for a change on its banner if (nodePoint[i].needChange) { if (nodePoint[i].timer <= diff) { uint32 nextBanner = GetNextBanner(&nodePoint[i], nodePoint[i].faction, true); nodePoint[i].last_entry = nodePoint[i].gameobject_entry; nodePoint[i].gameobject_entry = nextBanner; // nodePoint[i].faction = the faction should be the same one... GameObject* banner = GetBGObject(nodePoint[i].gameobject_type); if (!banner) // this should never happen return; float cords[4] = {banner->GetPositionX(), banner->GetPositionY(), banner->GetPositionZ(), banner->GetOrientation() }; DelObject(nodePoint[i].gameobject_type); AddObject(nodePoint[i].gameobject_type, nodePoint[i].gameobject_entry, cords[0], cords[1], cords[2], cords[3], 0, 0, 0, 0, RESPAWN_ONE_DAY); GetBGObject(nodePoint[i].gameobject_type)->SetUInt32Value(GAMEOBJECT_FACTION, nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_Factions[1] : BG_IC_Factions[0]); UpdateNodeWorldState(&nodePoint[i]); HandleCapturedNodes(&nodePoint[i], false); SendMessage2ToAll(LANG_BG_IC_TEAM_HAS_TAKEN_NODE, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL, (nodePoint[i].faction == TEAM_ALLIANCE ? LANG_BG_IC_ALLIANCE : LANG_BG_IC_HORDE), nodePoint[i].string); nodePoint[i].needChange = false; nodePoint[i].timer = BANNER_STATE_CHANGE_TIME; } else nodePoint[i].timer -= diff; } } if (resourceTimer <= diff) { for (uint8 i = 0; i < NODE_TYPE_DOCKS; ++i) { if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A || nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H) { factionReinforcements[nodePoint[i].faction] += 1; RewardHonorToTeam(RESOURCE_HONOR_AMOUNT, nodePoint[i].faction); UpdateWorldState((nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_ALLIANCE_RENFORT : BG_IC_HORDE_RENFORT), factionReinforcements[nodePoint[i].faction]); } } resourceTimer = IC_RESOURCE_TIME; } else resourceTimer -= diff; }
void BattlegroundIC::PostUpdateImpl(uint32 diff) { if (GetStatus() != STATUS_IN_PROGRESS) return; if (!doorsClosed) { if (closeFortressDoorsTimer <= diff) { GetBGObject(BG_IC_GO_DOODAD_ND_HUMAN_GATE_CLOSEDFX_DOOR01)->RemoveFromWorld(); GetBGObject(BG_IC_GO_DOODAD_ND_WINTERORC_WALL_GATEFX_DOOR01)->RemoveFromWorld(); GetBGObject(BG_IC_GO_ALLIANCE_GATE_3)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); // Alliance door GetBGObject(BG_IC_GO_HORDE_GATE_1)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); // Horde door doorsClosed = true; } else closeFortressDoorsTimer -= diff; } for (uint8 i = NODE_TYPE_REFINERY; i < MAX_NODE_TYPES; ++i) { if (nodePoint[i].nodeType == NODE_TYPE_DOCKS) { if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A || nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H) { if (docksTimer <= diff) { // we need to confirm this, i am not sure if this every 3 minutes for (uint8 u = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_A : BG_IC_NPC_CATAPULT_1_H); u < (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_4_A : BG_IC_NPC_CATAPULT_4_H); ++u) { if (Creature* catapult = GetBGCreature(u)) { if (!catapult->isAlive()) catapult->Respawn(true); } } // we need to confirm this is blizzlike, not sure if it is every 3 minutes for (uint8 u = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_A : BG_IC_NPC_GLAIVE_THROWER_1_H); u < (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_2_A : BG_IC_NPC_GLAIVE_THROWER_2_H); ++u) { if (Creature* glaiveThrower = GetBGCreature(u)) { if (!glaiveThrower->isAlive()) glaiveThrower->Respawn(true); } } docksTimer = DOCKS_UPDATE_TIME; } else docksTimer -= diff; } } if (nodePoint[i].nodeType == NODE_TYPE_WORKSHOP) { if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A || nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H) { if (siegeEngineWorkshopTimer <= diff) { uint8 siegeType = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_A : BG_IC_NPC_SIEGE_ENGINE_H); if (Creature* siege = GetBGCreature(siegeType)) // this always should be true { if (siege->isAlive()) { if (siege->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_UNK_14|UNIT_FLAG_IMMUNE_TO_PC)) // following sniffs the vehicle always has UNIT_FLAG_UNK_14 siege->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_IMMUNE_TO_PC); else siege->SetHealth(siege->GetMaxHealth()); } else siege->Respawn(true); } // we need to confirm if it is every 3 minutes for (uint8 u = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_A : BG_IC_NPC_DEMOLISHER_1_H); u < (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_4_A : BG_IC_NPC_DEMOLISHER_4_H); ++u) { if (Creature* demolisher = GetBGCreature(u)) { if (!demolisher->isAlive()) demolisher->Respawn(true); } } siegeEngineWorkshopTimer = WORKSHOP_UPDATE_TIME; } else siegeEngineWorkshopTimer -= diff; } } // the point is waiting for a change on its banner if (nodePoint[i].needChange) { if (nodePoint[i].timer <= diff) { uint32 nextBanner = GetNextBanner(&nodePoint[i], nodePoint[i].faction, true); nodePoint[i].last_entry = nodePoint[i].gameobject_entry; nodePoint[i].gameobject_entry = nextBanner; // nodePoint[i].faction = the faction should be the same one... GameObject* banner = GetBGObject(nodePoint[i].gameobject_type); if (!banner) // this should never happen return; float cords[4] = {banner->GetPositionX(), banner->GetPositionY(), banner->GetPositionZ(), banner->GetOrientation() }; DelObject(nodePoint[i].gameobject_type); AddObject(nodePoint[i].gameobject_type, nodePoint[i].gameobject_entry, cords[0], cords[1], cords[2], cords[3], 0, 0, 0, 0, RESPAWN_ONE_DAY); GetBGObject(nodePoint[i].gameobject_type)->SetUInt32Value(GAMEOBJECT_FACTION, nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_Factions[1] : BG_IC_Factions[0]); UpdateNodeWorldState(&nodePoint[i]); HandleCapturedNodes(&nodePoint[i], false); SendMessage2ToAll(LANG_BG_IC_TEAM_HAS_TAKEN_NODE, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL, (nodePoint[i].faction == TEAM_ALLIANCE ? LANG_BG_IC_ALLIANCE : LANG_BG_IC_HORDE), nodePoint[i].string); nodePoint[i].needChange = false; nodePoint[i].timer = BANNER_STATE_CHANGE_TIME; } else nodePoint[i].timer -= diff; } } if (resourceTimer <= diff) { for (uint8 i = 0; i < NODE_TYPE_DOCKS; ++i) { if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A || nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H) { factionReinforcements[nodePoint[i].faction] += 1; RewardHonorToTeam(RESOURCE_HONOR_AMOUNT, nodePoint[i].faction == TEAM_ALLIANCE ? ALLIANCE : HORDE); UpdateWorldState((nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_ALLIANCE_RENFORT : BG_IC_HORDE_RENFORT), factionReinforcements[nodePoint[i].faction]); } } resourceTimer = IC_RESOURCE_TIME; } else resourceTimer -= diff; }
void BattlegroundIC::EventPlayerClickedOnFlag(Player* player, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) return; // All the node points are iterated to find the clicked one for (uint8 i = 0; i < MAX_NODE_TYPES; ++i) { if (nodePoint[i].gameobject_entry == target_obj->GetEntry()) { // THIS SHOULD NEEVEER HAPPEN if (nodePoint[i].faction == player->GetTeamId()) return; uint32 nextBanner = GetNextBanner(&nodePoint[i], player->GetTeamId(), false); // we set the new settings of the nodePoint nodePoint[i].faction = player->GetTeamId(); nodePoint[i].last_entry = nodePoint[i].gameobject_entry; nodePoint[i].gameobject_entry = nextBanner; // this is just needed if the next banner is grey if (nodePoint[i].banners[BANNER_A_CONTESTED] == nextBanner || nodePoint[i].banners[BANNER_H_CONTESTED] == nextBanner) { nodePoint[i].timer = BANNER_STATE_CHANGE_TIME; // 1 minute for last change (real faction banner) nodePoint[i].needChange = true; RelocateDeadPlayers(BgCreatures[BG_IC_NPC_SPIRIT_GUIDE_1 + nodePoint[i].nodeType - 2]); // if we are here means that the point has been lost, or it is the first capture if (nodePoint[i].nodeType != NODE_TYPE_REFINERY && nodePoint[i].nodeType != NODE_TYPE_QUARRY) if (!BgCreatures[BG_IC_NPC_SPIRIT_GUIDE_1 + (nodePoint[i].nodeType) - 2].IsEmpty()) DelCreature(BG_IC_NPC_SPIRIT_GUIDE_1 + (nodePoint[i].nodeType) - 2); UpdatePlayerScore(player, SCORE_BASES_ASSAULTED, 1); if (nodePoint[i].faction == TEAM_ALLIANCE) SendBroadcastText(ICNodes[i].TextAssaulted, CHAT_MSG_BG_SYSTEM_ALLIANCE, player); else SendBroadcastText(ICNodes[i].TextAssaulted, CHAT_MSG_BG_SYSTEM_HORDE, player); HandleContestedNodes(&nodePoint[i]); } else if (nextBanner == nodePoint[i].banners[BANNER_A_CONTROLLED] || nextBanner == nodePoint[i].banners[BANNER_H_CONTROLLED]) // if we are going to spawn the definitve faction banner, we dont need the timer anymore { nodePoint[i].timer = BANNER_STATE_CHANGE_TIME; nodePoint[i].needChange = false; if (nodePoint[i].faction == TEAM_ALLIANCE) SendBroadcastText(ICNodes[i].TextDefended, CHAT_MSG_BG_SYSTEM_ALLIANCE, player); else SendBroadcastText(ICNodes[i].TextDefended, CHAT_MSG_BG_SYSTEM_HORDE, player); HandleCapturedNodes(&nodePoint[i], true); UpdatePlayerScore(player, SCORE_BASES_DEFENDED, 1); } GameObject* banner = GetBGObject(nodePoint[i].gameobject_type); if (!banner) // this should never happen return; float cords[4] = {banner->GetPositionX(), banner->GetPositionY(), banner->GetPositionZ(), banner->GetOrientation() }; DelObject(nodePoint[i].gameobject_type); if (!AddObject(nodePoint[i].gameobject_type, nodePoint[i].gameobject_entry, cords[0], cords[1], cords[2], cords[3], 0, 0, 0, 0, RESPAWN_ONE_DAY)) { TC_LOG_ERROR("bg.battleground", "Isle of Conquest: There was an error spawning a banner (type: %u, entry: %u). Isle of Conquest BG cancelled.", nodePoint[i].gameobject_type, nodePoint[i].gameobject_entry); EndBattleground(0); } GetBGObject(nodePoint[i].gameobject_type)->SetUInt32Value(GAMEOBJECT_FACTION, nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_Factions[1] : BG_IC_Factions[0]); UpdateNodeWorldState(&nodePoint[i]); // we dont need iterating if we are here // If the needChange bool was set true, we will handle the rest in the Update Map function. return; } } }