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 BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player) { if (GetStatus() != STATUS_IN_PROGRESS) { return; } BattleGroundAVTeamIndex teamIdx = GetAVTeamIndexByTeamId(player->GetTeam()); MANGOS_ASSERT(teamIdx != BG_AV_TEAM_NEUTRAL); uint32 reputation = 0; // reputation for the whole team (other reputation must be done in db) // TODO add events (including quest not available anymore, next quest availabe, go/npc de/spawning) sLog.outError("BattleGroundAV: Quest %i completed", questid); switch (questid) { case BG_AV_QUEST_A_SCRAPS1: case BG_AV_QUEST_A_SCRAPS2: case BG_AV_QUEST_H_SCRAPS1: case BG_AV_QUEST_H_SCRAPS2: m_Team_QuestStatus[teamIdx][0] += 20; reputation = 1; if (m_Team_QuestStatus[teamIdx][0] == 500 || m_Team_QuestStatus[teamIdx][0] == 1000 || m_Team_QuestStatus[teamIdx][0] == 1500) // 25,50,75 turn ins { DEBUG_LOG("BattleGroundAV: Quest %i completed starting with unit upgrading..", questid); for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i) if (m_Nodes[i].Owner == teamIdx && m_Nodes[i].State == POINT_CONTROLLED) { PopulateNode(i); } } break; case BG_AV_QUEST_A_COMMANDER1: case BG_AV_QUEST_H_COMMANDER1: m_Team_QuestStatus[teamIdx][1]++; reputation = 1; if (m_Team_QuestStatus[teamIdx][1] == 120) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); } break; case BG_AV_QUEST_A_COMMANDER2: case BG_AV_QUEST_H_COMMANDER2: m_Team_QuestStatus[teamIdx][2]++; reputation = 2; if (m_Team_QuestStatus[teamIdx][2] == 60) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); } break; case BG_AV_QUEST_A_COMMANDER3: case BG_AV_QUEST_H_COMMANDER3: m_Team_QuestStatus[teamIdx][3]++; reputation = 5; if (m_Team_QuestStatus[teamIdx][1] == 30) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); } break; case BG_AV_QUEST_A_BOSS1: case BG_AV_QUEST_H_BOSS1: m_Team_QuestStatus[teamIdx][4] += 4; // there are 2 quests where you can turn in 5 or 1 item.. ( + 4 cause +1 will be done some lines below) reputation = 4; case BG_AV_QUEST_A_BOSS2: case BG_AV_QUEST_H_BOSS2: m_Team_QuestStatus[teamIdx][4]++; reputation += 1; if (m_Team_QuestStatus[teamIdx][4] >= 200) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); } break; case BG_AV_QUEST_A_NEAR_MINE: case BG_AV_QUEST_H_NEAR_MINE: m_Team_QuestStatus[teamIdx][5]++; reputation = 2; if (m_Team_QuestStatus[teamIdx][5] == 28) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); if (m_Team_QuestStatus[teamIdx][6] == 7) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid); } } break; case BG_AV_QUEST_A_OTHER_MINE: case BG_AV_QUEST_H_OTHER_MINE: m_Team_QuestStatus[teamIdx][6]++; reputation = 3; if (m_Team_QuestStatus[teamIdx][6] == 7) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); if (m_Team_QuestStatus[teamIdx][5] == 20) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid); } } break; case BG_AV_QUEST_A_RIDER_HIDE: case BG_AV_QUEST_H_RIDER_HIDE: m_Team_QuestStatus[teamIdx][7]++; reputation = 1; if (m_Team_QuestStatus[teamIdx][7] == 25) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); if (m_Team_QuestStatus[teamIdx][8] == 25) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid); } } break; case BG_AV_QUEST_A_RIDER_TAME: case BG_AV_QUEST_H_RIDER_TAME: m_Team_QuestStatus[teamIdx][8]++; reputation = 1; if (m_Team_QuestStatus[teamIdx][8] == 25) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); if (m_Team_QuestStatus[teamIdx][7] == 25) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid); } } break; default: DEBUG_LOG("BattleGroundAV: Quest %i completed but is not interesting for us", questid); return; break; } if (reputation) { RewardReputationToTeam((player->GetTeam() == ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, reputation, player->GetTeam()); } }
void BattleGroundAB::Update(uint32 diff) { BattleGround::Update(diff); if (GetStatus() == STATUS_IN_PROGRESS) { int team_points[BG_TEAMS_COUNT] = { 0, 0 }; for (uint8 node = 0; node < BG_AB_NODES_MAX; ++node) { // 3 sec delay to spawn new banner instead previous despawned one if (m_BannerTimers[node].timer) { if (m_BannerTimers[node].timer > diff) m_BannerTimers[node].timer -= diff; else { m_BannerTimers[node].timer = 0; _CreateBanner(node, m_BannerTimers[node].type, m_BannerTimers[node].teamIndex, false); } } // 1-minute to occupy a node from contested state if (m_NodeTimers[node]) { if (m_NodeTimers[node] > diff) m_NodeTimers[node] -= diff; else { m_NodeTimers[node] = 0; // Change from contested to occupied ! uint8 teamIndex = m_Nodes[node] - 1; m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] += 2; // create new occupied banner _CreateBanner(node, BG_AB_NODE_TYPE_OCCUPIED, teamIndex, true); _SendNodeUpdate(node); _NodeOccupied(node, (teamIndex == 0) ? ALLIANCE : HORDE); // Message to chatlog if (teamIndex == 0) { SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_ALLY, _GetNodeNameId(node)); PlaySoundToAll(BG_AB_SOUND_NODE_CAPTURED_ALLIANCE); } else { SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_HORDE, _GetNodeNameId(node)); PlaySoundToAll(BG_AB_SOUND_NODE_CAPTURED_HORDE); } } } for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) if (m_Nodes[node] == team + BG_AB_NODE_TYPE_OCCUPIED) ++team_points[team]; } // Accumulate points for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) { int points = team_points[team]; if (!points) continue; m_lastTick[team] += diff; if (m_lastTick[team] > BG_AB_TickIntervals[points]) { m_lastTick[team] -= BG_AB_TickIntervals[points]; m_TeamScores[team] += BG_AB_TickPoints[points]; m_honorScoreTicks[team] += BG_AB_TickPoints[points]; m_ReputationScoreTics[team] += BG_AB_TickPoints[points]; if (m_ReputationScoreTics[team] >= m_ReputationTics) { (team == BG_TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE); m_ReputationScoreTics[team] -= m_ReputationTics; } if (m_honorScoreTicks[team] >= m_honorTicks) { RewardHonorToTeam(GetBonusHonorFromKill(1), (team == BG_TEAM_ALLIANCE) ? ALLIANCE : HORDE); m_honorScoreTicks[team] -= m_honorTicks; } if (!m_IsInformedNearVictory && m_TeamScores[team] > BG_AB_WARNING_NEAR_VICTORY_SCORE) { if (team == BG_TEAM_ALLIANCE) SendMessageToAll(LANG_BG_AB_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); else SendMessageToAll(LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); PlaySoundToAll(BG_AB_SOUND_NEAR_VICTORY); m_IsInformedNearVictory = true; } if (m_TeamScores[team] > BG_AB_MAX_TEAM_SCORE) m_TeamScores[team] = BG_AB_MAX_TEAM_SCORE; if (team == BG_TEAM_ALLIANCE) UpdateWorldState(BG_AB_OP_RESOURCES_ALLY, m_TeamScores[team]); if (team == BG_TEAM_HORDE) UpdateWorldState(BG_AB_OP_RESOURCES_HORDE, m_TeamScores[team]); // update achievement flags // we increased m_TeamScores[team] so we just need to check if it is 500 more than other teams resources // horde will be a bit disadvantaged, but we can assume that points aren't updated for both team in same Update() call uint8 otherTeam = (team + 1) % BG_TEAMS_COUNT; if (m_TeamScores[team] > m_TeamScores[otherTeam] + 500) m_TeamScores500Disadvantage[otherTeam] = true; } } // Test win condition if (m_TeamScores[BG_TEAM_ALLIANCE] >= BG_AB_MAX_TEAM_SCORE) EndBattleGround(ALLIANCE); if (m_TeamScores[BG_TEAM_HORDE] >= BG_AB_MAX_TEAM_SCORE) EndBattleGround(HORDE); } }
int main(int argc, char* argv[]) #endif { int retval; int ii; int jj; #ifdef SYNA_TOOL_BOX int this_arg = 0; #else int this_arg = 1; #endif int found = 0; int readings = 1; int reading;; int cartesian = 0; int patience = PATIENCE; int report_type; int report_size; int rx_num; int tx_num; char *report_data_8; short *report_data_16; int *report_data_32; unsigned int *report_data_u32; struct stat st; #ifndef SYNA_TOOL_BOX if (argc == 1) { usage(argv[0]); error_exit(EINVAL); } #endif for (ii = 0; ii < NUMBER_OF_INPUTS_TO_SCAN; ii++) { memset(input_detect, 0x00, MAX_STRING_LEN); snprintf(input_detect, MAX_STRING_LEN, "%s%d/%s", INPUT_PATH, (unsigned int)ii, DETECT_FILENAME); retval = stat(input_detect, &st); if (retval == 0) { snprintf(mySensor, MAX_STRING_LEN, "%s%d", INPUT_PATH, (unsigned int)ii); found = 1; break; } } if (!found) { printf("ERROR: input driver not found\n"); error_exit(ENODEV); } while (this_arg < argc) { if (!strcmp((const char *)argv[this_arg], "-n")) { this_arg++; readings = (unsigned int)strtoul(argv[this_arg], NULL, 0); } else if (!strcmp((const char *)argv[this_arg], "-c")) { cartesian = 1; } else { report_type = strtoul(argv[this_arg], NULL, 0); } this_arg++; } if (cartesian) { rx_num = GetRxElectrodes(); tx_num = GetTxElectrodes(); } switch (report_type) { case F54_16BIT_IMAGE: case F54_RAW_16BIT_IMAGE: case F54_SENSOR_SPEED: case F54_ADC_RANGE: case F54_ABS_CAP: case F54_ABS_DELTA: break; default: DoPreparation(1); break; } for (reading = 0; reading < readings; reading++) { patience = PATIENCE; SetReportType(report_type); GetReport(1); do { if (GetStatus() != STATUS_BUSY) break; usleep(1000); } while (--patience > 0); report_size = ReadReportSize(); if (report_size == 0) { printf("ERROR: unable to read report\n"); DoReset(1); error_exit(EINVAL); } if (!data_buffer) { data_buffer = malloc(report_size); if (!data_buffer) { printf("ERROR: failed to allocate report data buffer\n"); DoReset(1); error_exit(ENOMEM); } } ReadBlockData((char *)&data_buffer[0], report_size); printf("Reading %d\r\n", reading + 1); switch (report_type) { case F54_8BIT_IMAGE: report_data_8 = (char *)data_buffer; for (ii = 0; ii < report_size; ii++) { printf("%03d: %d\r\n", ii, *report_data_8); report_data_8++; } break; case F54_16BIT_IMAGE: case F54_RAW_16BIT_IMAGE: case F54_TRUE_BASELINE: case F54_FULL_RAW_CAP: case F54_FULL_RAW_CAP_RX_COUPLING_COMP: case F54_SENSOR_SPEED: report_data_16 = (short *)data_buffer; if (cartesian) { printf(" "); for (ii = 0; ii < rx_num; ii++) printf(" %2d", ii); printf("\r\n"); for (ii = 0; ii < tx_num; ii++) { printf("%2d ", ii); for (jj = 0; jj < rx_num; jj++) { printf(" %5d", *report_data_16); report_data_16++; } printf("\r\n"); } } else { for (ii = 0; ii < report_size; ii += 2) { printf("%03d: %d\r\n", ii / 2, *report_data_16); report_data_16++; } } break; case F54_HIGH_RESISTANCE: case F54_FULL_RAW_CAP_MIN_MAX: report_data_16 = (short *)data_buffer; for (ii = 0; ii < report_size; ii += 2) { printf("%03d: %d\r\n", ii / 2, *report_data_16); report_data_16++; } break; case F54_ABS_CAP: report_data_u32 = (unsigned int *)data_buffer; if (cartesian) { printf("Rx "); for (ii = 0; ii < rx_num; ii++) printf(" %2d", ii); printf("\r\n"); printf(" "); for (ii = 0; ii < rx_num; ii++) { printf(" %5u", *report_data_u32); report_data_u32++; } printf("\r\n"); printf("Tx "); for (ii = 0; ii < tx_num; ii++) printf(" %2d", ii); printf("\r\n"); printf(" "); for (ii = 0; ii < tx_num; ii++) { printf(" %5u", *report_data_u32); report_data_u32++; } printf("\r\n"); } else { for (ii = 0; ii < report_size; ii += 4) { printf("%03d: %u\r\n", ii / 4, *report_data_u32); report_data_u32++; } } break; case F54_ABS_DELTA: report_data_32 = (int *)data_buffer; if (cartesian) { printf("Rx "); for (ii = 0; ii < rx_num; ii++) printf(" %2d", ii); printf("\r\n"); printf(" "); for (ii = 0; ii < rx_num; ii++) { printf(" %5d", *report_data_32); report_data_32++; } printf("\r\n"); printf("Tx "); for (ii = 0; ii < tx_num; ii++) printf(" %2d", ii); printf("\r\n"); printf(" "); for (ii = 0; ii < tx_num; ii++) { printf(" %5d", *report_data_32); report_data_32++; } printf("\r\n"); } else { for (ii = 0; ii < report_size; ii += 4) { printf("%03d: %d\r\n", ii / 4, *report_data_32); report_data_32++; } } break; default: for (ii = 0; ii < report_size; ii++) printf("%03d: 0x%02x\r\n", ii, data_buffer[ii]); break; } } switch (report_type) { case F54_16BIT_IMAGE: case F54_RAW_16BIT_IMAGE: case F54_SENSOR_SPEED: case F54_ADC_RANGE: case F54_ABS_CAP: case F54_ABS_DELTA: ResumeTouch(1); break; default: DoReset(1); break; } if (data_buffer) free(data_buffer); return 0; }
void BattleGroundWS::EventPlayerDroppedFlag(Player* source) { if (GetStatus() != STATUS_IN_PROGRESS) { // if not running, do not cast things at the dropper player (prevent spawning the "dropped" flag), neither send unnecessary messages // just take off the aura if (source->GetTeam() == ALLIANCE) { if (!IsHordeFlagPickedUp()) return; if (GetHordeFlagCarrierGuid() == source->GetObjectGuid()) { ClearHordeFlagCarrier(); source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); } } else { if (!IsAllianceFlagPickedUp()) return; if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid()) { ClearAllianceFlagCarrier(); source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); } } return; } bool set = false; if (source->GetTeam() == ALLIANCE) { if (!IsHordeFlagPickedUp()) return; if (GetHordeFlagCarrierGuid() == source->GetObjectGuid()) { ClearHordeFlagCarrier(); source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); m_FlagState[TEAM_INDEX_HORDE] = BG_WS_FLAG_STATE_ON_GROUND; source->CastSpell(source, BG_WS_SPELL_WARSONG_FLAG_DROPPED, true); set = true; } } else { if (!IsAllianceFlagPickedUp()) return; if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid()) { ClearAllianceFlagCarrier(); source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); m_FlagState[TEAM_INDEX_ALLIANCE] = BG_WS_FLAG_STATE_ON_GROUND; source->CastSpell(source, BG_WS_SPELL_SILVERWING_FLAG_DROPPED, true); set = true; } } if (set) { UpdateFlagState(source->GetTeam(), 1); if (source->GetTeam() == ALLIANCE) { SendMessageToAll(LANG_BG_WS_DROPPED_HF, CHAT_MSG_BG_SYSTEM_HORDE, source); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, uint32(-1)); } else { SendMessageToAll(LANG_BG_WS_DROPPED_AF, CHAT_MSG_BG_SYSTEM_ALLIANCE, source); UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, uint32(-1)); } m_FlagsDropTimer[GetOtherTeamIndex(GetTeamIndexByTeamId(source->GetTeam()))] = BG_WS_FLAG_DROP_TIME; } }
void BattlegroundEY::EventTeamCapturedPoint(Player* Source, uint32 Point) { if (GetStatus() != STATUS_IN_PROGRESS) return; uint32 Team = Source->GetTeam(); SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType, RESPAWN_ONE_DAY); SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 1, RESPAWN_ONE_DAY); SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 2, RESPAWN_ONE_DAY); if (Team == ALLIANCE) { m_TeamPointsCount[BG_TEAM_ALLIANCE]++; SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance, RESPAWN_IMMEDIATELY); SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 1, RESPAWN_IMMEDIATELY); SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 2, RESPAWN_IMMEDIATELY); } else { m_TeamPointsCount[BG_TEAM_HORDE]++; SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde, RESPAWN_IMMEDIATELY); SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 1, RESPAWN_IMMEDIATELY); SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 2, RESPAWN_IMMEDIATELY); } //buff isn't respawned m_PointOwnedByTeam[Point] = Team; m_PointState[Point] = EY_POINT_UNDER_CONTROL; if (Team == ALLIANCE) SendMessageToAll(m_CapturingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); else SendMessageToAll(m_CapturingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, Source); if (m_BgCreatures[Point]) DelCreature(Point); WorldSafeLocsEntry const* sg = NULL; sg = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[Point].GraveYardId); if (!sg || !AddSpiritGuide(Point, sg->x, sg->y, sg->z, 3.124139f, Team)) sLog->outError("BatteGroundEY: Failed to spawn spirit guide! point: %u, team: %u, graveyard_id: %u", Point, Team, m_CapturingPointTypes[Point].GraveYardId); // SpawnBGCreature(Point, RESPAWN_IMMEDIATELY); UpdatePointsIcons(Team, Point); UpdatePointsCount(Team); if (Point >= EY_POINTS_MAX) return; Creature* trigger = GetBGCreature(Point + 6);//0-5 spirit guides if (!trigger) trigger = AddCreature(WORLD_TRIGGER, Point+6, Team, BG_EY_TriggerPositions[Point][0], BG_EY_TriggerPositions[Point][1], BG_EY_TriggerPositions[Point][2], BG_EY_TriggerPositions[Point][3]); //add bonus honor aura trigger creature when node is accupied //cast bonus aura (+50% honor in 25yards) //aura should only apply to players who have accupied the node, set correct faction for trigger if (trigger) { trigger->setFaction(Team == ALLIANCE ? 84 : 83); trigger->CastSpell(trigger, SPELL_HONORABLE_DEFENDER_25Y, false); } }
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 (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; }
/* Invoked if a player used a banner as a gameobject */ void BattlegroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* /*target_obj*/) { if (GetStatus() != STATUS_IN_PROGRESS) return; uint8 node = BG_AB_NODE_STABLES; GameObject* obj = GetBgMap()->GetGameObject(BgObjects[node*8+7]); while ((node < BG_AB_DYNAMIC_NODES_COUNT) && ((!obj) || (!source->IsWithinDistInMap(obj, 10)))) { ++node; obj = GetBgMap()->GetGameObject(BgObjects[node*8+BG_AB_OBJECT_AURA_CONTESTED]); } if (node == BG_AB_DYNAMIC_NODES_COUNT) { // this means our player isn't close to any of banners - maybe cheater ?? return; } BattlegroundTeamId teamIndex = GetTeamIndexByTeamId(source->GetTeam()); // Check if player really could use this banner, not cheated if (!(m_Nodes[node] == 0 || teamIndex == m_Nodes[node]%2)) return; source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); uint32 sound = 0; // If node is neutral, change to contested if (m_Nodes[node] == BG_AB_NODE_TYPE_NEUTRAL) { UpdatePlayerScore(source, SCORE_BASES_ASSAULTED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + 1; // burn current neutral banner _DelBanner(node, BG_AB_NODE_TYPE_NEUTRAL, 0); // create new contested banner _CreateBanner(node, BG_AB_NODE_TYPE_CONTESTED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; // FIXME: team and node names not localized if (teamIndex == 0) SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node), LANG_BG_AB_ALLY); else SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node), LANG_BG_AB_HORDE); sound = BG_AB_SOUND_NODE_CLAIMED; } // If node is contested else if ((m_Nodes[node] == BG_AB_NODE_STATUS_ALLY_CONTESTED) || (m_Nodes[node] == BG_AB_NODE_STATUS_HORDE_CONTESTED)) { // If last state is NOT occupied, change node to enemy-contested if (m_prevNodes[node] < BG_AB_NODE_TYPE_OCCUPIED) { UpdatePlayerScore(source, SCORE_BASES_ASSAULTED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + BG_AB_NODE_TYPE_CONTESTED; // burn current contested banner _DelBanner(node, BG_AB_NODE_TYPE_CONTESTED, !teamIndex); // create new contested banner _CreateBanner(node, BG_AB_NODE_TYPE_CONTESTED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; // FIXME: node names not localized if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } // If contested, change back to occupied else { UpdatePlayerScore(source, SCORE_BASES_DEFENDED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + BG_AB_NODE_TYPE_OCCUPIED; // burn current contested banner _DelBanner(node, BG_AB_NODE_TYPE_CONTESTED, !teamIndex); // create new occupied banner _CreateBanner(node, BG_AB_NODE_TYPE_OCCUPIED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = 0; _NodeOccupied(node, (teamIndex == BG_TEAM_ALLIANCE) ? ALLIANCE:HORDE); // FIXME: node names not localized if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } sound = (teamIndex == BG_TEAM_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE; } // If node is occupied, change to enemy-contested else { UpdatePlayerScore(source, SCORE_BASES_ASSAULTED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + BG_AB_NODE_TYPE_CONTESTED; // burn current occupied banner _DelBanner(node, BG_AB_NODE_TYPE_OCCUPIED, !teamIndex); // create new contested banner _CreateBanner(node, BG_AB_NODE_TYPE_CONTESTED, teamIndex, true); _SendNodeUpdate(node); _NodeDeOccupied(node); m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; // FIXME: node names not localized if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); sound = (teamIndex == BG_TEAM_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE; } // If node is occupied again, send "X has taken the Y" msg. if (m_Nodes[node] >= BG_AB_NODE_TYPE_OCCUPIED) { // FIXME: team and node names not localized if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_AB_ALLY, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_AB_HORDE, _GetNodeNameId(node)); } PlaySoundToAll(sound); }
void EVA::clbkPreStep (double simt, double SimDT, double mjd) { char EVAName[256]=""; char CSMName[256]=""; char MSName[256]=""; strcpy(EVAName,GetName()); double VessCount; int i=0; VessCount=oapiGetVesselCount(); hMaster=oapiGetVesselByIndex(i); while (i<VessCount)i++;{ oapiGetObjectName(hMaster,MSName,256); strcpy(CSMName,MSName);strcat(CSMName,"-EVA"); if (strcmp(CSMName,EVAName)==0) { i=int(VessCount); } } sprintf(oapiDebugString(), "EVA Cable Attached to %s", MSName); VESSELSTATUS csmV; VESSELSTATUS evaV; VESSEL *csmvessel; VECTOR3 rdist = {0,0,0}; VECTOR3 posr = {0,0,0}; VECTOR3 rvel = {0,0,0}; VECTOR3 RelRot = {0,0,0}; double dist = 0.0; double Vel = 0.0; if (hMaster) { csmvessel = oapiGetVesselInterface(hMaster); oapiGetRelativePos (GetHandle() ,hMaster, &posr); oapiGetRelativeVel (GetHandle() ,hMaster , &rvel); GetStatus(evaV); csmvessel->GetStatus(csmV); GlobalRot (posr, RelRot); dist = sqrt(posr.x * posr.x + posr.y * posr.y + posr.z * posr.z); Vel = sqrt(rvel.x * rvel.x + rvel.y * rvel.y + rvel.z * rvel.z); if (dist >= 25) { rvel = evaV.rvel-csmV.rvel; rvel.x = -rvel.x; rvel.y = -rvel.y; rvel.z = -rvel.z; GetStatus(evaV); csmvessel->GetStatus(csmV); evaV.rvel = csmV.rvel + rvel; DefSetState(&evaV); } if (GoDock1){ sprintf(oapiDebugString(), "EVA Back CSM Mode Relative Distance M/s %f", dist); if (dist <= 0.55 && dist>=0.50 ){ GoDock1 =false; oapiSetFocusObject(hMaster); oapiDeleteVessel(GetHandle()); } } } }
void BattlegroundBFG::PostUpdateImpl(uint32 diff) { if (GetStatus() != STATUS_IN_PROGRESS) return; if (GetStatus() == STATUS_IN_PROGRESS) { int team_points[BG_TEAMS_COUNT] = { 0, 0 }; for (int node = 0; node < GILNEAS_BG_DYNAMIC_NODES_COUNT; ++node) { // 3 sec delay to spawn new a banner. if (m_BannerTimers[node].timer) { if (m_BannerTimers[node].timer > diff) m_BannerTimers[node].timer -= diff; else { m_BannerTimers[node].timer = 0; _CreateBanner(node, m_BannerTimers[node].type, m_BannerTimers[node].teamIndex, false); } } // 1-minute cap timer on each node from a contested state. if (m_NodeTimers[node]) { if (m_NodeTimers[node] > diff) m_NodeTimers[node] -= diff; else { m_NodeTimers[node] = 0; // Change from contested to occupied ! uint8 teamIndex = m_Nodes[node] - 1; m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] += 2; // burn current contested banner _DelBanner(node, GILNEAS_BG_NODE_TYPE_CONTESTED, teamIndex); // create new occupied banner _CreateBanner(node, GILNEAS_BG_NODE_TYPE_OCCUPIED, teamIndex, true); _SendNodeUpdate(node); _NodeOccupied(node, (teamIndex == 0) ? ALLIANCE : HORDE); // Message to chatlog if (teamIndex == 0) { // FIXME: need to fix Locales for team and nodes names. SendMessage2ToAll(LANG_BG_BG_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_BG_ALLY, _GetNodeNameId(node)); PlaySoundToAll(GILNEAS_BG_SOUND_NODE_CAPTURED_ALLIANCE); } else { // FIXME: team and node names not localized SendMessage2ToAll(LANG_BG_BG_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_BG_HORDE, _GetNodeNameId(node)); PlaySoundToAll(GILNEAS_BG_SOUND_NODE_CAPTURED_HORDE); } } } for (int team = 0; team < BG_TEAMS_COUNT; ++team) if (m_Nodes[node] == team + GILNEAS_BG_NODE_TYPE_OCCUPIED) ++team_points[team]; } // Accumulate points for (int team = 0; team < BG_TEAMS_COUNT; ++team) { int points = team_points[team]; if (!points) continue; m_lastTick[team] += diff; if (m_lastTick[team] > GILNEAS_BG_TickIntervals[points]) { m_lastTick[team] -= GILNEAS_BG_TickIntervals[points]; m_TeamScores[team] += GILNEAS_BG_TickPoints[points]; m_HonorScoreTicks[team] += GILNEAS_BG_TickPoints[points]; m_ReputationScoreTicks[team] += GILNEAS_BG_TickPoints[points]; if (m_ReputationScoreTicks[team] >= m_ReputationTicks) { //(team == BG_TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE); m_ReputationScoreTicks[team] -= m_ReputationTicks; } if (m_HonorScoreTicks[team] >= m_HonorTicks) { RewardHonorToTeam(GetBonusHonorFromKill(1), (team == BG_TEAM_ALLIANCE) ? ALLIANCE : HORDE); //BG=BFG m_HonorScoreTicks[team] -= m_HonorTicks; } if (!m_IsInformedNearVictory && m_TeamScores[team] > GILNEAS_BG_WARNING_NEAR_VICTORY_SCORE) //BG=BFG { if (team == BG_TEAM_ALLIANCE) SendMessageToAll(LANG_BG_AB_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); else SendMessageToAll(LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); PlaySoundToAll(GILNEAS_BG_SOUND_NEAR_VICTORY); m_IsInformedNearVictory = true; } if (m_TeamScores[team] > GILNEAS_BG_MAX_TEAM_SCORE) m_TeamScores[team] = GILNEAS_BG_MAX_TEAM_SCORE; if (team == BG_TEAM_ALLIANCE) UpdateWorldState(GILNEAS_BG_OP_RESOURCES_ALLY, m_TeamScores[team]); if (team == BG_TEAM_HORDE) UpdateWorldState(GILNEAS_BG_OP_RESOURCES_HORDE, m_TeamScores[team]); // update achievement flags // we increased m_TeamScores[team] so we just need to check if it is 500 more than other teams resources uint8 otherTeam = (team + 1) % BG_TEAMS_COUNT; if (m_TeamScores[team] > m_TeamScores[otherTeam] + 500) m_TeamScores500Disadvantage[otherTeam] = true; } } // Test win condition if (m_TeamScores[BG_TEAM_ALLIANCE] >= GILNEAS_BG_MAX_TEAM_SCORE) EndBattleground(ALLIANCE); if (m_TeamScores[BG_TEAM_HORDE] >= GILNEAS_BG_MAX_TEAM_SCORE) EndBattleground(HORDE); } }
void GlooxCLEntry::SetAuthRequested (bool auth) { AuthRequested_ = auth; emit statusChanged (GetStatus (QString ()), QString ()); emit groupsChanged (Groups ()); }
/* * Process private IOCTL messages (typically from scctrl) */ int sc_ioctl(int card, scs_ioctl *data) { int status; RspMessage *rcvmsg; char *spid; char *dn; char switchtype; char speed; rcvmsg = kmalloc(sizeof(RspMessage), GFP_KERNEL); if (!rcvmsg) return -ENOMEM; switch(data->command) { case SCIOCRESET: /* Perform a hard reset of the adapter */ { pr_debug("%s: SCIOCRESET: ioctl received\n", sc_adapter[card]->devicename); sc_adapter[card]->StartOnReset = 0; kfree(rcvmsg); return reset(card); } case SCIOCLOAD: { char *srec; srec = kmalloc(SCIOC_SRECSIZE, GFP_KERNEL); if (!srec) { kfree(rcvmsg); return -ENOMEM; } pr_debug("%s: SCIOLOAD: ioctl received\n", sc_adapter[card]->devicename); if(sc_adapter[card]->EngineUp) { pr_debug("%s: SCIOCLOAD: command failed, LoadProc while engine running.\n", sc_adapter[card]->devicename); kfree(rcvmsg); kfree(srec); return -1; } /* * Get the SRec from user space */ if (copy_from_user(srec, data->dataptr, SCIOC_SRECSIZE)) { kfree(rcvmsg); kfree(srec); return -EFAULT; } status = send_and_receive(card, CMPID, cmReqType2, cmReqClass0, cmReqLoadProc, 0, SCIOC_SRECSIZE, srec, rcvmsg, SAR_TIMEOUT); kfree(rcvmsg); kfree(srec); if(status) { pr_debug("%s: SCIOCLOAD: command failed, status = %d\n", sc_adapter[card]->devicename, status); return -1; } else { pr_debug("%s: SCIOCLOAD: command successful\n", sc_adapter[card]->devicename); return 0; } } case SCIOCSTART: { kfree(rcvmsg); pr_debug("%s: SCIOSTART: ioctl received\n", sc_adapter[card]->devicename); if(sc_adapter[card]->EngineUp) { pr_debug("%s: SCIOCSTART: command failed, engine already running.\n", sc_adapter[card]->devicename); return -1; } sc_adapter[card]->StartOnReset = 1; startproc(card); return 0; } case SCIOCSETSWITCH: { pr_debug("%s: SCIOSETSWITCH: ioctl received\n", sc_adapter[card]->devicename); /* * Get the switch type from user space */ if (copy_from_user(&switchtype, data->dataptr, sizeof(char))) { kfree(rcvmsg); return -EFAULT; } pr_debug("%s: SCIOCSETSWITCH: setting switch type to %d\n", sc_adapter[card]->devicename, switchtype); status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallSetSwitchType, 0, sizeof(char),&switchtype, rcvmsg, SAR_TIMEOUT); if(!status && !(rcvmsg->rsp_status)) { pr_debug("%s: SCIOCSETSWITCH: command successful\n", sc_adapter[card]->devicename); kfree(rcvmsg); return 0; } else { pr_debug("%s: SCIOCSETSWITCH: command failed (status = %d)\n", sc_adapter[card]->devicename, status); kfree(rcvmsg); return status; } } case SCIOCGETSWITCH: { pr_debug("%s: SCIOGETSWITCH: ioctl received\n", sc_adapter[card]->devicename); /* * Get the switch type from the board */ status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetSwitchType, 0, 0, NULL, rcvmsg, SAR_TIMEOUT); if (!status && !(rcvmsg->rsp_status)) { pr_debug("%s: SCIOCGETSWITCH: command successful\n", sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETSWITCH: command failed (status = %d)\n", sc_adapter[card]->devicename, status); kfree(rcvmsg); return status; } switchtype = rcvmsg->msg_data.byte_array[0]; /* * Package the switch type and send to user space */ if (copy_to_user(data->dataptr, &switchtype, sizeof(char))) { kfree(rcvmsg); return -EFAULT; } kfree(rcvmsg); return 0; } case SCIOCGETSPID: { pr_debug("%s: SCIOGETSPID: ioctl received\n", sc_adapter[card]->devicename); spid = kmalloc(SCIOC_SPIDSIZE, GFP_KERNEL); if (!spid) { kfree(rcvmsg); return -ENOMEM; } /* * Get the spid from the board */ status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetSPID, data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); if (!status) { pr_debug("%s: SCIOCGETSPID: command successful\n", sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETSPID: command failed (status = %d)\n", sc_adapter[card]->devicename, status); kfree(spid); kfree(rcvmsg); return status; } strcpy(spid, rcvmsg->msg_data.byte_array); /* * Package the switch type and send to user space */ if (copy_to_user(data->dataptr, spid, SCIOC_SPIDSIZE)) { kfree(spid); kfree(rcvmsg); return -EFAULT; } kfree(spid); kfree(rcvmsg); return 0; } case SCIOCSETSPID: { pr_debug("%s: DCBIOSETSPID: ioctl received\n", sc_adapter[card]->devicename); spid = kmalloc(SCIOC_SPIDSIZE, GFP_KERNEL); if(!spid) { kfree(rcvmsg); return -ENOMEM; } /* * Get the spid from user space */ if (copy_from_user(spid, data->dataptr, SCIOC_SPIDSIZE)) { kfree(rcvmsg); return -EFAULT; } pr_debug("%s: SCIOCSETSPID: setting channel %d spid to %s\n", sc_adapter[card]->devicename, data->channel, spid); status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallSetSPID, data->channel, strlen(spid), spid, rcvmsg, SAR_TIMEOUT); if(!status && !(rcvmsg->rsp_status)) { pr_debug("%s: SCIOCSETSPID: command successful\n", sc_adapter[card]->devicename); kfree(rcvmsg); kfree(spid); return 0; } else { pr_debug("%s: SCIOCSETSPID: command failed (status = %d)\n", sc_adapter[card]->devicename, status); kfree(rcvmsg); kfree(spid); return status; } } case SCIOCGETDN: { pr_debug("%s: SCIOGETDN: ioctl received\n", sc_adapter[card]->devicename); /* * Get the dn from the board */ status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); if (!status) { pr_debug("%s: SCIOCGETDN: command successful\n", sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETDN: command failed (status = %d)\n", sc_adapter[card]->devicename, status); kfree(rcvmsg); return status; } dn = kmalloc(SCIOC_DNSIZE, GFP_KERNEL); if (!dn) { kfree(rcvmsg); return -ENOMEM; } strcpy(dn, rcvmsg->msg_data.byte_array); kfree(rcvmsg); /* * Package the dn and send to user space */ if (copy_to_user(data->dataptr, dn, SCIOC_DNSIZE)) { kfree(dn); return -EFAULT; } kfree(dn); return 0; } case SCIOCSETDN: { pr_debug("%s: SCIOSETDN: ioctl received\n", sc_adapter[card]->devicename); dn = kmalloc(SCIOC_DNSIZE, GFP_KERNEL); if (!dn) { kfree(rcvmsg); return -ENOMEM; } /* * Get the spid from user space */ if (copy_from_user(dn, data->dataptr, SCIOC_DNSIZE)) { kfree(rcvmsg); kfree(dn); return -EFAULT; } pr_debug("%s: SCIOCSETDN: setting channel %d dn to %s\n", sc_adapter[card]->devicename, data->channel, dn); status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallSetMyNumber, data->channel, strlen(dn),dn,rcvmsg, SAR_TIMEOUT); if(!status && !(rcvmsg->rsp_status)) { pr_debug("%s: SCIOCSETDN: command successful\n", sc_adapter[card]->devicename); kfree(rcvmsg); kfree(dn); return 0; } else { pr_debug("%s: SCIOCSETDN: command failed (status = %d)\n", sc_adapter[card]->devicename, status); kfree(rcvmsg); kfree(dn); return status; } } case SCIOCTRACE: pr_debug("%s: SCIOTRACE: ioctl received\n", sc_adapter[card]->devicename); /* sc_adapter[card]->trace = !sc_adapter[card]->trace; pr_debug("%s: SCIOCTRACE: tracing turned %s\n", sc_adapter[card]->devicename, sc_adapter[card]->trace ? "ON" : "OFF"); */ break; case SCIOCSTAT: { boardInfo *bi; pr_debug("%s: SCIOSTAT: ioctl received\n", sc_adapter[card]->devicename); bi = kmalloc (sizeof(boardInfo), GFP_KERNEL); if (!bi) { kfree(rcvmsg); return -ENOMEM; } kfree(rcvmsg); GetStatus(card, bi); if (copy_to_user(data->dataptr, bi, sizeof(boardInfo))) { kfree(bi); return -EFAULT; } kfree(bi); return 0; } case SCIOCGETSPEED: { pr_debug("%s: SCIOGETSPEED: ioctl received\n", sc_adapter[card]->devicename); /* * Get the speed from the board */ status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetCallType, data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); if (!status && !(rcvmsg->rsp_status)) { pr_debug("%s: SCIOCGETSPEED: command successful\n", sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETSPEED: command failed (status = %d)\n", sc_adapter[card]->devicename, status); kfree(rcvmsg); return status; } speed = rcvmsg->msg_data.byte_array[0]; kfree(rcvmsg); /* * Package the switch type and send to user space */ if (copy_to_user(data->dataptr, &speed, sizeof(char))) return -EFAULT; return 0; } case SCIOCSETSPEED: pr_debug("%s: SCIOCSETSPEED: ioctl received\n", sc_adapter[card]->devicename); break; case SCIOCLOOPTST: pr_debug("%s: SCIOCLOOPTST: ioctl received\n", sc_adapter[card]->devicename); break; default: kfree(rcvmsg); return -1; } kfree(rcvmsg); return 0; }
DWORD GetRuntimeStatus ( LPCWSTR subscriptionName) { DWORD dwEventSourceCount, dwRetVal = ERROR_SUCCESS; std::vector<BYTE> buffer; std::vector<BYTE> eventSourceBuffer; PEC_VARIANT vStatus, vProperty, vEventSource; EC_OBJECT_ARRAY_PROPERTY_HANDLE hArray =NULL; EC_HANDLE hSubscription; RUNTIME_STATUS runtimeStatus; //Open the subscription for query hSubscription = EcOpenSubscription(subscriptionName, EC_READ_ACCESS, EC_OPEN_EXISTING); if (!hSubscription) { return GetLastError(); } dwRetVal = GetProperty(hSubscription, EcSubscriptionEventSources, 0,buffer, vProperty); if ( ERROR_SUCCESS != dwRetVal ) goto Cleanup; //Ensure that we have obtained handle to the Array Property if ( vProperty->Type != EcVarTypeNull && vProperty->Type!= EcVarObjectArrayPropertyHandle) { dwRetVal = ERROR_INVALID_DATA; goto Cleanup; } hArray = (vProperty->Type == EcVarTypeNull) ? NULL: vProperty->PropertyHandleVal ; if( !hArray) { dwRetVal = ERROR_INVALID_DATA; goto Cleanup; } // Get the EventSources array size (number of elements) if ( !EcGetObjectArraySize(hArray, &dwEventSourceCount ) ) { dwRetVal = GetLastError(); goto Cleanup; } for ( DWORD i = 0; i < dwEventSourceCount ; i++) { dwRetVal = GetArrayProperty( hArray, EcSubscriptionEventSourceAddress, i, 0, eventSourceBuffer, vEventSource); if (ERROR_SUCCESS != dwRetVal) { goto Cleanup; } if (vEventSource->Type != EcVarTypeNull && vEventSource->Type != EcVarTypeString) { dwRetVal = ERROR_INVALID_DATA; goto Cleanup; } LPCWSTR eventSource = (vEventSource->Type == EcVarTypeNull) ? NULL: vEventSource->StringVal; if (!eventSource) continue; dwRetVal = GetStatus( subscriptionName, eventSource, EcSubscriptionRunTimeStatusActive, 0, buffer, vStatus); if( ERROR_SUCCESS != dwRetVal ) goto Cleanup; if( vStatus->Type != EcVarTypeUInt32 ) { dwRetVal = ERROR_INVALID_DATA; goto Cleanup; } switch (vStatus->UInt32Val) { case EcRuntimeStatusActiveStatusActive: runtimeStatus.ActiveStatus = L"Active"; break; case EcRuntimeStatusActiveStatusDisabled: runtimeStatus.ActiveStatus = L"Disabled"; break; case EcRuntimeStatusActiveStatusInactive: runtimeStatus.ActiveStatus = L"Inactive"; break; case EcRuntimeStatusActiveStatusTrying: runtimeStatus.ActiveStatus = L"Trying"; break; default: runtimeStatus.ActiveStatus = L"Unknown Status"; break; } //Get Subscription Last Error dwRetVal = GetStatus( subscriptionName, eventSource, EcSubscriptionRunTimeStatusLastError , 0, buffer, vStatus); if( ERROR_SUCCESS != dwRetVal) { goto Cleanup; } if ( vStatus->Type != EcVarTypeUInt32 ) { dwRetVal = ERROR_INVALID_DATA; goto Cleanup; } runtimeStatus.LastError = vStatus->UInt32Val; //Obtain the associated Error Message dwRetVal = GetStatus( subscriptionName, eventSource, EcSubscriptionRunTimeStatusLastErrorMessage , 0, buffer, vStatus); if( ERROR_SUCCESS != dwRetVal) { goto Cleanup; } if ( vStatus->Type != EcVarTypeNull && vStatus->Type!= EcVarTypeString) { dwRetVal = ERROR_INVALID_DATA; goto Cleanup; } if( vStatus->Type != EcVarTypeNull) { runtimeStatus.LastErrorMessage = vStatus->StringVal; } else { runtimeStatus.LastErrorMessage = L""; } //Obtain the Next Retry Time dwRetVal = GetStatus( subscriptionName, eventSource, EcSubscriptionRunTimeStatusNextRetryTime, 0, buffer, vStatus); if( ERROR_SUCCESS != dwRetVal) { goto Cleanup; } if ( vStatus->Type != EcVarTypeNull && vStatus->Type!= EcVarTypeDateTime) { dwRetVal = ERROR_INVALID_DATA; goto Cleanup; } if( vStatus->Type != EcVarTypeNull) { runtimeStatus.NextRetryTime = ConvertEcDateTime(vStatus->DateTimeVal); } else { runtimeStatus.NextRetryTime = L""; } wprintf(L"\nEventSource[%u]\n", i); wprintf(L" Address: %s\n", eventSource); wprintf(L" Runtime Status: %s\n", runtimeStatus.ActiveStatus.c_str()); wprintf(L" Last Error: %u\n", runtimeStatus.LastError); if( 0 != runtimeStatus.LastError ) { wprintf(L" Last Error Message: %s\n", runtimeStatus.LastErrorMessage.c_str()); } else { wprintf(L" Last Error Message: No Error\n"); } wprintf(L" Next Retry Time: %s\n", runtimeStatus.NextRetryTime.c_str()); } Cleanup: if(hArray) EcClose(hArray); EcClose(hSubscription); return dwRetVal; }
inline int body() { if( NT_SUCCESS( status ) ) { ExAcquireFastMutex(); SetFlags(); ExReleaseFastMutex(); WarmPollPeriod = HtRegGetDword(); if( WarmPollPeriod < 5 ) { WarmPollPeriod = 5; } else { if( WarmPollPeriod > 20 ) { WarmPollPeriod = 20; } } { if (nondet()) { // We've got it. Now get a pointer to it. polling = 1; if(nondet()) { //--------------------------------------------- { LARGE_INTEGER timeOut1; NTSTATUS status; UCHAR deviceStatus; PCHAR devId; BOOLEAN requestRescan; const ULONG pollingFailureThreshold = 10; //pick an arbitrary but reasonable number do { if( PowerStateIsAC ) { } else { } status = KeWaitForSingleObject(); if( nondet() ) { break; } if( !PowerStateIsAC ) { goto loc_continue; } if( STATUS_TIMEOUT == status ) { if( nondet() ) { // try to acquire port if( HtTryAllocatePort() ) { requestRescan = FALSE; // check for something connected deviceStatus = GetStatus(); if( nondet()) { } else { // we might have something connected // try a device ID to confirm devId = P4ReadRawIeee1284DeviceId(); if( devId ) { PCHAR mfg, mdl, cls, des, aid, cid; // RawIeee1284 string includes 2 bytes of length data at beginning HTPnpFindDeviceIdKeys(); if( mfg && mdl ) { requestRescan = TRUE; } } else { } if( requestRescan ) { } else { if(nondet() ) { } } } HtFreePort( ); if( requestRescan ) { IoInvalidateDeviceRelations(); } } else { } } else { } } loc_continue: { int ddd; ddd = ddd; } } while( TRUE ); } //--------------------------------------------- polling = 0; } else { polling = 0; // error } } else { } } } // Failsafe polling = 1; while (1) { HTPnpFindDeviceIdKeys(); } }
UserStatus::RankContainer User::GetRank() { return GetStatus().rank; }
// // Remove the unit device ID from the list // BOOL CNdasLogicalDevice::RemoveUnitDevice(CNdasUnitDevice& unitDevice) { ximeta::CAutoLock autolock(this); DWORD ldSequence = unitDevice.GetLDSequence(); _ASSERTE(ldSequence < m_logicalDeviceGroup.nUnitDevices); if (ldSequence >= m_logicalDeviceGroup.nUnitDevices) { DBGPRT_ERR(_FT("Invalid sequence (%d) of the unit device.\n"), ldSequence); return FALSE; } _ASSERTE(&unitDevice == m_pUnitDevices[ldSequence]); if (&unitDevice != m_pUnitDevices[ldSequence]) { DBGPRT_ERR(_FT("Unit device in sequence (%d) is not occupied.\n"), ldSequence); return FALSE; } m_pUnitDevices[ldSequence]->Release(); m_pUnitDevices[ldSequence] = NULL; // // Workaround for Fault-tolerant Mode // -> Even if the logical device is incomplete, // Mounted Logical Device Location should be intact // if it is mounted // if (NDAS_LOGICALDEVICE_STATUS_MOUNT_PENDING == GetStatus() || NDAS_LOGICALDEVICE_STATUS_MOUNTED == GetStatus() || NDAS_LOGICALDEVICE_STATUS_UNMOUNT_PENDING == GetStatus()) { --m_nUnitDeviceInstances; return TRUE; } if (IsComplete()) { CNdasLogicalDeviceManager* pLdm = pGetNdasLogicalDeviceManager(); pLdm->UnregisterNdasScsiLocation(m_NdasScsiLocation); } --m_nUnitDeviceInstances; // // Deallocation NDAS SCSI Location when the fist unit device is removed // if (0 == ldSequence) { cpDeallocateNdasScsiLocation(); } // // Publish Event // CNdasEventPublisher* pEventPublisher = pGetNdasEventPublisher(); (VOID) pEventPublisher->LogicalDeviceRelationChanged(m_logicalDeviceId); // // Set Device Error // SetLastDeviceError(NDAS_LOGICALDEVICE_ERROR_MISSING_MEMBER); return TRUE; }
float User::GetBalanceRank() { return 1.0 + 0.1 * float( GetStatus().rank - UserStatus::RANK_1 ) / float( UserStatus::RANK_7 - UserStatus::RANK_1 ); }
void BattlegroundWS::Update (uint32 diff) { Battleground::Update(diff); if (GetStatus() == STATUS_IN_PROGRESS) { if (GetStartTime() >= 25 * MINUTE * IN_MILLISECONDS) { if (GetTeamScore(ALLIANCE) == 0) { if (GetTeamScore(HORDE) == 0) // No one scored - result is tie EndBattleground (NULL); else // Horde has more points and thus wins EndBattleground(HORDE); } else if (GetTeamScore(HORDE) == 0) EndBattleground(ALLIANCE); // Alliance has > 0, Horde has 0, alliance wins else if (GetTeamScore(HORDE) == GetTeamScore(ALLIANCE)) // Team score equal, winner is team that scored the last flag EndBattleground(m_LastFlagCaptureTeam); else if (GetTeamScore(HORDE) > GetTeamScore(ALLIANCE)) // Last but not least, check who has the higher score EndBattleground(HORDE); else EndBattleground(ALLIANCE); } else if (GetStartTime() > uint32(m_minutesElapsed * MINUTE * IN_MILLISECONDS)) { ++m_minutesElapsed; UpdateWorldState(BG_WS_STATE_TIMER, 25 - m_minutesElapsed); } if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_WAIT_RESPAWN) { m_FlagsTimer[BG_TEAM_ALLIANCE] -= diff; if (m_FlagsTimer[BG_TEAM_ALLIANCE] < 0) { m_FlagsTimer[BG_TEAM_ALLIANCE] = 0; RespawnFlag(ALLIANCE, true); } } if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND) { m_FlagsDropTimer[BG_TEAM_ALLIANCE] -= diff; if (m_FlagsDropTimer[BG_TEAM_ALLIANCE] < 0) { m_FlagsDropTimer[BG_TEAM_ALLIANCE] = 0; RespawnFlagAfterDrop(ALLIANCE); m_BothFlagsKept = false; } } if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_WAIT_RESPAWN) { m_FlagsTimer[BG_TEAM_HORDE] -= diff; if (m_FlagsTimer[BG_TEAM_HORDE] < 0) { m_FlagsTimer[BG_TEAM_HORDE] = 0; RespawnFlag(HORDE, true); } } if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND) { m_FlagsDropTimer[BG_TEAM_HORDE] -= diff; if (m_FlagsDropTimer[BG_TEAM_HORDE] < 0) { m_FlagsDropTimer[BG_TEAM_HORDE] = 0; RespawnFlagAfterDrop(HORDE); m_BothFlagsKept = false; } } if (m_BothFlagsKept) { m_FlagSpellForceTimer += diff; if (m_FlagDebuffState == 0 && m_FlagSpellForceTimer >= 600000) //10 minutes { if (Player * plr = sObjectMgr->GetPlayer(m_FlagKeepers[0])) plr->CastSpell(plr, WS_SPELL_FOCUSED_ASSAULT, true); if (Player * plr = sObjectMgr->GetPlayer(m_FlagKeepers[1])) plr->CastSpell(plr, WS_SPELL_FOCUSED_ASSAULT, true); m_FlagDebuffState = 1; } else if (m_FlagDebuffState == 1 && m_FlagSpellForceTimer >= 900000) //15 minutes { if (Player * plr = sObjectMgr->GetPlayer(m_FlagKeepers[0])) { plr->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); plr->CastSpell(plr, WS_SPELL_BRUTAL_ASSAULT, true); } if (Player * plr = sObjectMgr->GetPlayer(m_FlagKeepers[1])) { plr->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); plr->CastSpell(plr, WS_SPELL_BRUTAL_ASSAULT, true); } m_FlagDebuffState = 2; } } else { m_FlagSpellForceTimer = 0; //reset timer. m_FlagDebuffState = 0; } } }
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]) 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); 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; } } }
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(); } } }
void BattleGroundSA::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/) { // this is wrong way to implement these things. On official it done by gameobject spell cast. if (GetStatus() != STATUS_IN_PROGRESS) return; }
void BattlegroundWS::EventPlayerCapturedFlag(Player* Source) { if (GetStatus() != STATUS_IN_PROGRESS) return; uint32 winner = 0; Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); if (Source->GetBGTeam() == ALLIANCE) { if (!IsHordeFlagPickedup()) return; SetHordeFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time // horde flag in base (but not respawned yet) _flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_WAIT_RESPAWN; // Drop Horde Flag from Player Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); if (_flagDebuffState == 1) Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); if (_flagDebuffState == 2) Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); if (GetTeamScore(TEAM_ALLIANCE) < BG_WS_MAX_TEAM_SCORE) AddPoint(ALLIANCE, 1); PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE); RewardReputationToTeam(890, m_ReputationCapture, ALLIANCE); } else { if (!IsAllianceFlagPickedup()) return; SetAllianceFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time // alliance flag in base (but not respawned yet) _flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_WAIT_RESPAWN; // Drop Alliance Flag from Player Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); if (_flagDebuffState == 1) Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); if (_flagDebuffState == 2) Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); if (GetTeamScore(TEAM_HORDE) < BG_WS_MAX_TEAM_SCORE) AddPoint(HORDE, 1); PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE); RewardReputationToTeam(889, m_ReputationCapture, HORDE); } //for flag capture is reward 2 honorable kills RewardHonorToTeam(GetBonusHonorFromKill(2), Source->GetBGTeam()); SpawnBGObject(BG_WS_OBJECT_H_FLAG, BG_WS_FLAG_RESPAWN_TIME); SpawnBGObject(BG_WS_OBJECT_A_FLAG, BG_WS_FLAG_RESPAWN_TIME); if (Source->GetBGTeam() == ALLIANCE) SendMessageToAll(LANG_BG_WS_CAPTURED_HF, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); else SendMessageToAll(LANG_BG_WS_CAPTURED_AF, CHAT_MSG_BG_SYSTEM_HORDE, Source); UpdateFlagState(Source->GetBGTeam(), 1); // flag state none UpdateTeamScore(Source->GetBGTeamId()); // only flag capture should be updated UpdatePlayerScore(Source, SCORE_FLAG_CAPTURES, 1); // +1 flag captures // update last flag capture to be used if teamscore is equal SetLastFlagCapture(Source->GetBGTeam()); if (GetTeamScore(TEAM_ALLIANCE) == BG_WS_MAX_TEAM_SCORE) winner = ALLIANCE; if (GetTeamScore(TEAM_HORDE) == BG_WS_MAX_TEAM_SCORE) winner = HORDE; if (winner) { UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 0); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 0); UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, 1); UpdateWorldState(BG_WS_FLAG_STATE_HORDE, 1); UpdateWorldState(BG_WS_STATE_TIMER_ACTIVE, 0); RewardHonorToTeam(BG_WSG_Honor[m_HonorMode][BG_WSG_WIN], winner); EndBattleground(winner); } else { _flagsTimer[GetTeamIndexByTeamId(Source->GetBGTeam()) ? 0 : 1] = BG_WS_FLAG_RESPAWN_TIME; } }
void BattleGroundWS::EventPlayerCapturedFlag(Player* source) { if (GetStatus() != STATUS_IN_PROGRESS) return; source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); if (source->GetTeam() == ALLIANCE) { if (!IsHordeFlagPickedUp()) return; ClearHordeFlagCarrier(); // must be before aura remove to prevent 2 events (drop+capture) at the same time // horde flag in base (but not respawned yet) m_FlagState[TEAM_INDEX_HORDE] = BG_WS_FLAG_STATE_WAIT_RESPAWN; // Drop Horde Flag from Player source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); if (m_TeamScores[TEAM_INDEX_ALLIANCE] < BG_WS_MAX_TEAM_SCORE) m_TeamScores[TEAM_INDEX_ALLIANCE] += 1; PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE); RewardReputationToTeam(890, m_ReputationCapture, ALLIANCE); } else { if (!IsAllianceFlagPickedUp()) return; ClearAllianceFlagCarrier(); // must be before aura remove to prevent 2 events (drop+capture) at the same time // alliance flag in base (but not respawned yet) m_FlagState[TEAM_INDEX_ALLIANCE] = BG_WS_FLAG_STATE_WAIT_RESPAWN; // Drop Alliance Flag from Player source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); if (m_TeamScores[TEAM_INDEX_HORDE] < BG_WS_MAX_TEAM_SCORE) m_TeamScores[TEAM_INDEX_HORDE] += 1; PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE); RewardReputationToTeam(889, m_ReputationCapture, HORDE); } // for flag capture is reward distributed according level range RewardHonorToTeam(BG_WSG_FlagCapturedHonor[GetBracketId()], source->GetTeam()); // despawn flags SpawnEvent(WS_EVENT_FLAG_A, 0, false); SpawnEvent(WS_EVENT_FLAG_H, 0, false); if (source->GetTeam() == ALLIANCE) SendMessageToAll(LANG_BG_WS_CAPTURED_HF, CHAT_MSG_BG_SYSTEM_ALLIANCE, source); else SendMessageToAll(LANG_BG_WS_CAPTURED_AF, CHAT_MSG_BG_SYSTEM_HORDE, source); UpdateFlagState(source->GetTeam(), 1); // flag state none UpdateTeamScore(source->GetTeam()); // only flag capture should be updated UpdatePlayerScore(source, SCORE_FLAG_CAPTURES, 1); // +1 flag captures Team winner = TEAM_NONE; if (m_TeamScores[TEAM_INDEX_ALLIANCE] == BG_WS_MAX_TEAM_SCORE) winner = ALLIANCE; else if (m_TeamScores[TEAM_INDEX_HORDE] == BG_WS_MAX_TEAM_SCORE) winner = HORDE; if (winner) { UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 0); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 0); UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, 1); UpdateWorldState(BG_WS_FLAG_STATE_HORDE, 1); EndBattleGround(winner); } else { m_FlagsTimer[GetOtherTeamIndex(GetTeamIndexByTeamId(source->GetTeam()))] = BG_WS_FLAG_RESPAWN_TIME; } }
void BattlegroundWS::EventPlayerDroppedFlag(Player* Source) { if (GetStatus() != STATUS_IN_PROGRESS) { // if not running, do not cast things at the dropper player (prevent spawning the "dropped" flag), neither send unnecessary messages // just take off the aura if (Source->GetBGTeam() == ALLIANCE) { if (!IsHordeFlagPickedup()) return; if (GetFlagPickerGUID(TEAM_HORDE) == Source->GetGUID()) { SetHordeFlagPicker(0); Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); } } else { if (!IsAllianceFlagPickedup()) return; if (GetFlagPickerGUID(TEAM_ALLIANCE) == Source->GetGUID()) { SetAllianceFlagPicker(0); Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); } } return; } bool set = false; if (Source->GetBGTeam() == ALLIANCE) { if (!IsHordeFlagPickedup()) return; if (GetFlagPickerGUID(TEAM_HORDE) == Source->GetGUID()) { SetHordeFlagPicker(0); Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); if (_flagDebuffState == 1) Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); if (_flagDebuffState == 2) Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); _flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_GROUND; Source->CastSpell(Source, BG_WS_SPELL_WARSONG_FLAG_DROPPED, true); set = true; } } else { if (!IsAllianceFlagPickedup()) return; if (GetFlagPickerGUID(TEAM_ALLIANCE) == Source->GetGUID()) { SetAllianceFlagPicker(0); Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); if (_flagDebuffState == 1) Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); if (_flagDebuffState == 2) Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); _flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_GROUND; Source->CastSpell(Source, BG_WS_SPELL_SILVERWING_FLAG_DROPPED, true); set = true; } } if (set) { Source->CastSpell(Source, SPELL_RECENTLY_DROPPED_FLAG, true); UpdateFlagState(Source->GetBGTeam(), 1); if (Source->GetBGTeam() == ALLIANCE) { SendMessageToAll(LANG_BG_WS_DROPPED_HF, CHAT_MSG_BG_SYSTEM_HORDE, Source); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, uint32(-1)); } else { SendMessageToAll(LANG_BG_WS_DROPPED_AF, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, uint32(-1)); } _flagsDropTimer[GetTeamIndexByTeamId(Source->GetBGTeam()) ? 0 : 1] = BG_WS_FLAG_DROP_TIME; } }
void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) return; int32 message_id = 0; ChatMsg type; uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event1; // alliance flag picked up from base if (source->GetTeam() == HORDE && GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE && event == WS_EVENT_FLAG_A) { message_id = LANG_BG_WS_PICKEDUP_AF; type = CHAT_MSG_BG_SYSTEM_HORDE; PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP); SpawnEvent(WS_EVENT_FLAG_A, 0, false); SetAllianceFlagCarrier(source->GetObjectGuid()); m_FlagState[TEAM_INDEX_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER; // update world state to show correct flag carrier UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER); UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 1); source->CastSpell(source, BG_WS_SPELL_SILVERWING_FLAG, true); } // horde flag picked up from base if (source->GetTeam() == ALLIANCE && GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE && event == WS_EVENT_FLAG_H) { message_id = LANG_BG_WS_PICKEDUP_HF; type = CHAT_MSG_BG_SYSTEM_ALLIANCE; PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP); SpawnEvent(WS_EVENT_FLAG_H, 0, false); SetHordeFlagCarrier(source->GetObjectGuid()); m_FlagState[TEAM_INDEX_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER; // update world state to show correct flag carrier UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 1); source->CastSpell(source, BG_WS_SPELL_WARSONG_FLAG, true); } // Alliance flag on ground(not in base) (returned or picked up again from ground!) if (GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && source->IsWithinDistInMap(target_obj, 10)) { if (source->GetTeam() == ALLIANCE) { message_id = LANG_BG_WS_RETURNED_AF; type = CHAT_MSG_BG_SYSTEM_ALLIANCE; UpdateFlagState(HORDE, BG_WS_FLAG_STATE_WAIT_RESPAWN); RespawnFlag(ALLIANCE, false); PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED); UpdatePlayerScore(source, SCORE_FLAG_RETURNS, 1); } else { message_id = LANG_BG_WS_PICKEDUP_AF; type = CHAT_MSG_BG_SYSTEM_HORDE; PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP); SpawnEvent(WS_EVENT_FLAG_A, 0, false); SetAllianceFlagCarrier(source->GetObjectGuid()); source->CastSpell(source, BG_WS_SPELL_SILVERWING_FLAG, true); m_FlagState[TEAM_INDEX_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER; UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER); UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 1); } // called in HandleGameObjectUseOpcode: // target_obj->Delete(); } // Horde flag on ground(not in base) (returned or picked up again) if (GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && source->IsWithinDistInMap(target_obj, 10)) { if (source->GetTeam() == HORDE) { message_id = LANG_BG_WS_RETURNED_HF; type = CHAT_MSG_BG_SYSTEM_HORDE; UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_WAIT_RESPAWN); RespawnFlag(HORDE, false); PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED); UpdatePlayerScore(source, SCORE_FLAG_RETURNS, 1); } else { message_id = LANG_BG_WS_PICKEDUP_HF; type = CHAT_MSG_BG_SYSTEM_ALLIANCE; PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP); SpawnEvent(WS_EVENT_FLAG_H, 0, false); SetHordeFlagCarrier(source->GetObjectGuid()); source->CastSpell(source, BG_WS_SPELL_WARSONG_FLAG, true); m_FlagState[TEAM_INDEX_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER; UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 1); } // called in HandleGameObjectUseOpcode: // target_obj->Delete(); } if (!message_id) return; SendMessageToAll(message_id, type, source); source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); }
void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) return; int32 message_id = 0; ChatMsg type = CHAT_MSG_BG_SYSTEM_NEUTRAL; //alliance flag picked up from base if (Source->GetBGTeam() == HORDE && GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE && BgObjects[BG_WS_OBJECT_A_FLAG] == target_obj->GetGUID()) { message_id = LANG_BG_WS_PICKEDUP_AF; type = CHAT_MSG_BG_SYSTEM_HORDE; PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP); SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_ONE_DAY); SetAllianceFlagPicker(Source->GetGUID()); _flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER; //update world state to show correct flag carrier UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER); UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 1); Source->CastSpell(Source, BG_WS_SPELL_SILVERWING_FLAG, true); Source->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_SPELL_TARGET, BG_WS_SPELL_SILVERWING_FLAG_PICKED); if (_flagState[1] == BG_WS_FLAG_STATE_ON_PLAYER) _bothFlagsKept = true; } //horde flag picked up from base if (Source->GetBGTeam() == ALLIANCE && GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE && BgObjects[BG_WS_OBJECT_H_FLAG] == target_obj->GetGUID()) { message_id = LANG_BG_WS_PICKEDUP_HF; type = CHAT_MSG_BG_SYSTEM_ALLIANCE; PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP); SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_ONE_DAY); SetHordeFlagPicker(Source->GetGUID()); _flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER; //update world state to show correct flag carrier UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 1); Source->CastSpell(Source, BG_WS_SPELL_WARSONG_FLAG, true); Source->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_SPELL_TARGET, BG_WS_SPELL_WARSONG_FLAG_PICKED); if (_flagState[0] == BG_WS_FLAG_STATE_ON_PLAYER) _bothFlagsKept = true; } //Alliance flag on ground(not in base) (returned or picked up again from ground!) if (GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && target_obj->GetGOInfo()->entry == BG_OBJECT_A_FLAG_GROUND_WS_ENTRY) { if (Source->GetBGTeam() == ALLIANCE) { message_id = LANG_BG_WS_RETURNED_AF; type = CHAT_MSG_BG_SYSTEM_ALLIANCE; UpdateFlagState(HORDE, BG_WS_FLAG_STATE_WAIT_RESPAWN); RespawnFlag(ALLIANCE, false); SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_IMMEDIATELY); PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED); UpdatePlayerScore(Source, SCORE_FLAG_RETURNS, 1); _bothFlagsKept = false; } else { message_id = LANG_BG_WS_PICKEDUP_AF; type = CHAT_MSG_BG_SYSTEM_HORDE; PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP); SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_ONE_DAY); SetAllianceFlagPicker(Source->GetGUID()); Source->CastSpell(Source, BG_WS_SPELL_SILVERWING_FLAG, true); _flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER; UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER); if (_flagDebuffState == 1) Source->CastSpell(Source, WS_SPELL_FOCUSED_ASSAULT, true); if (_flagDebuffState == 2) Source->CastSpell(Source, WS_SPELL_BRUTAL_ASSAULT, true); UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 1); } //called in HandleGameObjectUseOpcode: //target_obj->Delete(); } //Horde flag on ground(not in base) (returned or picked up again) if (GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && target_obj->GetGOInfo()->entry == BG_OBJECT_H_FLAG_GROUND_WS_ENTRY) { if (Source->GetBGTeam() == HORDE) { message_id = LANG_BG_WS_RETURNED_HF; type = CHAT_MSG_BG_SYSTEM_HORDE; UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_WAIT_RESPAWN); RespawnFlag(HORDE, false); SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_IMMEDIATELY); PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED); UpdatePlayerScore(Source, SCORE_FLAG_RETURNS, 1); _bothFlagsKept = false; } else { message_id = LANG_BG_WS_PICKEDUP_HF; type = CHAT_MSG_BG_SYSTEM_ALLIANCE; PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP); SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_ONE_DAY); SetHordeFlagPicker(Source->GetGUID()); Source->CastSpell(Source, BG_WS_SPELL_WARSONG_FLAG, true); _flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER; UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER); if (_flagDebuffState == 1) Source->CastSpell(Source, WS_SPELL_FOCUSED_ASSAULT, true); if (_flagDebuffState == 2) Source->CastSpell(Source, WS_SPELL_BRUTAL_ASSAULT, true); UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 1); } //called in HandleGameObjectUseOpcode: //target_obj->Delete(); } if (!message_id) return; SendMessageToAll(message_id, type, Source); Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); }
/* Invoked if a player used a banner as a gameobject */ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) return; uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event1; if (event >= BG_AB_NODES_MAX) // not a node return; BG_AB_Nodes node = BG_AB_Nodes(event); BattleGroundTeamIndex teamIndex = GetTeamIndexByTeamId(source->GetTeam()); // Check if player really could use this banner, not cheated if (!(m_Nodes[node] == 0 || teamIndex == m_Nodes[node] % 2)) return; source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); uint32 sound = 0; // TODO in the following code we should restructure a bit to avoid // duplication (or maybe write functions?) // If node is neutral, change to contested if (m_Nodes[node] == BG_AB_NODE_TYPE_NEUTRAL) { UpdatePlayerScore(source, SCORE_BASES_ASSAULTED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + 1; // create new contested banner _CreateBanner(node, BG_AB_NODE_TYPE_CONTESTED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; if (teamIndex == 0) SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node), LANG_BG_ALLY); else SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node), LANG_BG_HORDE); sound = BG_AB_SOUND_NODE_CLAIMED; } // If node is contested else if ((m_Nodes[node] == BG_AB_NODE_STATUS_ALLY_CONTESTED) || (m_Nodes[node] == BG_AB_NODE_STATUS_HORDE_CONTESTED)) { // If last state is NOT occupied, change node to enemy-contested if (m_prevNodes[node] < BG_AB_NODE_TYPE_OCCUPIED) { UpdatePlayerScore(source, SCORE_BASES_ASSAULTED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + BG_AB_NODE_TYPE_CONTESTED; // create new contested banner _CreateBanner(node, BG_AB_NODE_TYPE_CONTESTED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } // If contested, change back to occupied else { UpdatePlayerScore(source, SCORE_BASES_DEFENDED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + BG_AB_NODE_TYPE_OCCUPIED; // create new occupied banner _CreateBanner(node, BG_AB_NODE_TYPE_OCCUPIED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = 0; _NodeOccupied(node, (teamIndex == BG_TEAM_ALLIANCE) ? ALLIANCE : HORDE); if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } sound = (teamIndex == BG_TEAM_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE; } // If node is occupied, change to enemy-contested else { UpdatePlayerScore(source, SCORE_BASES_ASSAULTED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + BG_AB_NODE_TYPE_CONTESTED; // create new contested banner _CreateBanner(node, BG_AB_NODE_TYPE_CONTESTED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); sound = (teamIndex == BG_TEAM_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE; } // If node is occupied again, send "X has taken the Y" msg. if (m_Nodes[node] >= BG_AB_NODE_TYPE_OCCUPIED) { if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_ALLY, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_HORDE, _GetNodeNameId(node)); } PlaySoundToAll(sound); }
void BattlegroundWS::PostUpdateImpl(uint32 diff) { if (GetStatus() == STATUS_IN_PROGRESS) { if (GetStartTime() >= 27*MINUTE*IN_MILLISECONDS) { if (GetTeamScore(TEAM_ALLIANCE) == 0) { if (GetTeamScore(TEAM_HORDE) == 0) // No one scored - result is tie EndBattleground(WINNER_NONE); else // Horde has more points and thus wins EndBattleground(HORDE); } else if (GetTeamScore(TEAM_HORDE) == 0) EndBattleground(ALLIANCE); // Alliance has > 0, Horde has 0, alliance wins else if (GetTeamScore(TEAM_HORDE) == GetTeamScore(TEAM_ALLIANCE)) // Team score equal, winner is team that scored the last flag EndBattleground(_lastFlagCaptureTeam); else if (GetTeamScore(TEAM_HORDE) > GetTeamScore(TEAM_ALLIANCE)) // Last but not least, check who has the higher score EndBattleground(HORDE); else EndBattleground(ALLIANCE); } // first update needed after 1 minute of game already in progress else if (GetStartTime() > uint32(_minutesElapsed * MINUTE * IN_MILLISECONDS) + 3 * MINUTE * IN_MILLISECONDS) { ++_minutesElapsed; UpdateWorldState(BG_WS_STATE_TIMER, 25 - _minutesElapsed); } if (_flagState[TEAM_ALLIANCE] == BG_WS_FLAG_STATE_WAIT_RESPAWN) { _flagsTimer[TEAM_ALLIANCE] -= diff; if (_flagsTimer[TEAM_ALLIANCE] < 0) { _flagsTimer[TEAM_ALLIANCE] = 0; RespawnFlag(ALLIANCE, true); } } if (_flagState[TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND) { _flagsDropTimer[TEAM_ALLIANCE] -= diff; if (_flagsDropTimer[TEAM_ALLIANCE] < 0) { _flagsDropTimer[TEAM_ALLIANCE] = 0; RespawnFlagAfterDrop(ALLIANCE); _bothFlagsKept = false; } } if (_flagState[TEAM_HORDE] == BG_WS_FLAG_STATE_WAIT_RESPAWN) { _flagsTimer[TEAM_HORDE] -= diff; if (_flagsTimer[TEAM_HORDE] < 0) { _flagsTimer[TEAM_HORDE] = 0; RespawnFlag(HORDE, true); } } if (_flagState[TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND) { _flagsDropTimer[TEAM_HORDE] -= diff; if (_flagsDropTimer[TEAM_HORDE] < 0) { _flagsDropTimer[TEAM_HORDE] = 0; RespawnFlagAfterDrop(HORDE); _bothFlagsKept = false; } } if (_bothFlagsKept) { _flagSpellForceTimer += diff; if (_flagDebuffState == 0 && _flagSpellForceTimer >= 10*MINUTE*IN_MILLISECONDS) //10 minutes { if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[0])) player->CastSpell(player, WS_SPELL_FOCUSED_ASSAULT, true); if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[1])) player->CastSpell(player, WS_SPELL_FOCUSED_ASSAULT, true); _flagDebuffState = 1; } else if (_flagDebuffState == 1 && _flagSpellForceTimer >= 900000) //15 minutes { if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[0])) { player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); player->CastSpell(player, WS_SPELL_BRUTAL_ASSAULT, true); } if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[1])) { player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); player->CastSpell(player, WS_SPELL_BRUTAL_ASSAULT, true); } _flagDebuffState = 2; } } else { if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[0])) { player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); player->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); } if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[1])) { player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); player->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); } _flagSpellForceTimer = 0; //reset timer. _flagDebuffState = 0; } } }
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 BattleGroundWS::Update(time_t diff) { BattleGround::Update(diff); // after bg start we get there (once) if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize()) { ModifyStartDelayTime(diff); if (!(m_Events & 0x01)) { m_Events |= 0x01; // setup here, only when at least one player has ported to the map if (!SetupBattleGround()) { EndNow(); return; } // for (uint32 i = WS_SPIRIT_MAIN_ALLIANCE; i <= WS_SPIRIT_MAIN_HORDE; i++) // SpawnBGCreature(i, RESPAWN_IMMEDIATELY); for (uint32 i = BG_WS_OBJECT_DOOR_A_1; i <= BG_WS_OBJECT_DOOR_H_4; i++) { SpawnBGObject(i, RESPAWN_IMMEDIATELY); DoorClose(i); } for (uint32 i = BG_WS_OBJECT_A_FLAG; i <= BG_WS_OBJECT_BERSERKBUFF_2; i++) SpawnBGObject(i, RESPAWN_ONE_DAY); SetStartDelayTime(START_DELAY0); } // After 1 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04)) { m_Events |= 0x04; SendMessageToAll(GetNeoString(LANG_BG_WS_ONE_MINUTE)); } // After 1,5 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08)) { m_Events |= 0x08; SendMessageToAll(GetNeoString(LANG_BG_WS_HALF_MINUTE)); } // After 2 minutes, gates OPEN ! x) else if (GetStartDelayTime() < 0 && !(m_Events & 0x10)) { m_Events |= 0x10; for (uint32 i = BG_WS_OBJECT_DOOR_A_1; i <= BG_WS_OBJECT_DOOR_A_4; i++) DoorOpen(i); for (uint32 i = BG_WS_OBJECT_DOOR_H_1; i <= BG_WS_OBJECT_DOOR_H_2; i++) DoorOpen(i); SpawnBGObject(BG_WS_OBJECT_DOOR_A_5, RESPAWN_ONE_DAY); SpawnBGObject(BG_WS_OBJECT_DOOR_A_6, RESPAWN_ONE_DAY); SpawnBGObject(BG_WS_OBJECT_DOOR_H_3, RESPAWN_ONE_DAY); SpawnBGObject(BG_WS_OBJECT_DOOR_H_4, RESPAWN_ONE_DAY); for (uint32 i = BG_WS_OBJECT_A_FLAG; i <= BG_WS_OBJECT_BERSERKBUFF_2; i++) SpawnBGObject(i, RESPAWN_IMMEDIATELY); SendMessageToAll(GetNeoString(LANG_BG_WS_BEGIN)); PlaySoundToAll(SOUND_BG_START); if (sWorld.getConfig(CONFIG_BG_START_MUSIC)) PlaySoundToAll(SOUND_BG_START_L70ETC); //MUSIC - Custom config SetStatus(STATUS_IN_PROGRESS); for (BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) if (Player* plr = objmgr.GetPlayer(itr->first)) plr->RemoveAurasDueToSpell(SPELL_PREPARATION); } } else if (GetStatus() == STATUS_IN_PROGRESS) { if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_WAIT_RESPAWN) { m_FlagsTimer[BG_TEAM_ALLIANCE] -= diff; if (m_FlagsTimer[BG_TEAM_ALLIANCE] < 0) { m_FlagsTimer[BG_TEAM_ALLIANCE] = 0; RespawnFlag(ALLIANCE, true); } } if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND) { m_FlagsDropTimer[BG_TEAM_ALLIANCE] -= diff; if (m_FlagsDropTimer[BG_TEAM_ALLIANCE] < 0) { m_FlagsDropTimer[BG_TEAM_ALLIANCE] = 0; RespawnFlagAfterDrop(ALLIANCE); m_BothFlagsKept = false; } } if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_WAIT_RESPAWN) { m_FlagsTimer[BG_TEAM_HORDE] -= diff; if (m_FlagsTimer[BG_TEAM_HORDE] < 0) { m_FlagsTimer[BG_TEAM_HORDE] = 0; RespawnFlag(HORDE, true); } } if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND) { m_FlagsDropTimer[BG_TEAM_HORDE] -= diff; if (m_FlagsDropTimer[BG_TEAM_HORDE] < 0) { m_FlagsDropTimer[BG_TEAM_HORDE] = 0; RespawnFlagAfterDrop(HORDE); m_BothFlagsKept = false; } } if (m_BothFlagsKept) { m_FlagSpellForceTimer += diff; if (m_FlagDebuffState == 0 && m_FlagSpellForceTimer >= 600000) //10 minutes { if (Player * plr = objmgr.GetPlayer(m_FlagKeepers[0])) plr->CastSpell(plr,WS_SPELL_FOCUSED_ASSAULT,true); if (Player * plr = objmgr.GetPlayer(m_FlagKeepers[1])) plr->CastSpell(plr,WS_SPELL_FOCUSED_ASSAULT,true); m_FlagDebuffState = 1; } else if (m_FlagDebuffState == 1 && m_FlagSpellForceTimer >= 900000) //15 minutes { if (Player * plr = objmgr.GetPlayer(m_FlagKeepers[0])) { plr->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); plr->CastSpell(plr,WS_SPELL_BRUTAL_ASSAULT,true); } if (Player * plr = objmgr.GetPlayer(m_FlagKeepers[1])) { plr->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); plr->CastSpell(plr,WS_SPELL_BRUTAL_ASSAULT,true); } m_FlagDebuffState = 2; } } else { m_FlagSpellForceTimer = 0; //reset timer. m_FlagDebuffState = 0; } } }