void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node) { // TODO implement quest 7101, 7081 TeamIndex teamIdx = GetTeamIndex(player->GetTeam()); DEBUG_LOG("BattleGroundAV: player assaults node %i", node); if (m_Nodes[node].Owner == TeamIndex(teamIdx) || TeamIndex(teamIdx) == m_Nodes[node].TotalOwner) return; AssaultNode(node, teamIdx); // update nodeinfo variables UpdateNodeWorldState(node); // send mapicon PopulateNode(node); if (IsTower(node)) { SendYell2ToAll(LANG_BG_AV_TOWER_ASSAULTED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), ( teamIdx == TEAM_INDEX_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE); UpdatePlayerScore(player, SCORE_TOWERS_ASSAULTED, 1); } else { SendYell2ToAll(LANG_BG_AV_GRAVE_ASSAULTED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), ( teamIdx == TEAM_INDEX_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE); // update the statistic for the assaulting player UpdatePlayerScore(player, SCORE_GRAVEYARDS_ASSAULTED, 1); } PlaySoundToAll((teamIdx == TEAM_INDEX_ALLIANCE) ? BG_AV_SOUND_ALLIANCE_ASSAULTS : BG_AV_SOUND_HORDE_ASSAULTS); }
void BattleGroundAV::DefendNode(BG_AV_Nodes node, TeamIndex teamIdx) { MANGOS_ASSERT(m_Nodes[node].TotalOwner == TeamIndex(teamIdx)); MANGOS_ASSERT(m_Nodes[node].Owner != TeamIndex(teamIdx)); MANGOS_ASSERT(m_Nodes[node].State != POINT_CONTROLLED); m_Nodes[node].PrevOwner = m_Nodes[node].Owner; m_Nodes[node].Owner = TeamIndex(teamIdx); m_Nodes[node].PrevState = m_Nodes[node].State; m_Nodes[node].State = POINT_CONTROLLED; m_Nodes[node].Timer = 0; }
void BattleGroundAV::AssaultNode(BG_AV_Nodes node, TeamIndex teamIdx) { MANGOS_ASSERT(m_Nodes[node].TotalOwner != TeamIndex(teamIdx)); MANGOS_ASSERT(m_Nodes[node].Owner != TeamIndex(teamIdx)); // only assault an assaulted node if no totalowner exists: MANGOS_ASSERT(m_Nodes[node].State != POINT_ASSAULTED || m_Nodes[node].TotalOwner == TEAM_INDEX_NEUTRAL); // the timer gets another time, if the previous owner was 0 == Neutral m_Nodes[node].Timer = (m_Nodes[node].PrevOwner != TEAM_INDEX_NEUTRAL) ? BG_AV_CAPTIME : BG_AV_SNOWFALL_FIRSTCAP; m_Nodes[node].PrevOwner = m_Nodes[node].Owner; m_Nodes[node].Owner = TeamIndex(teamIdx); m_Nodes[node].PrevState = m_Nodes[node].State; m_Nodes[node].State = POINT_ASSAULTED; }
void BattleGroundAV::EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node) { MANGOS_ASSERT(GetStatus() == STATUS_IN_PROGRESS); TeamIndex teamIdx = GetTeamIndex(player->GetTeam()); if (m_Nodes[node].Owner == TeamIndex(teamIdx) || m_Nodes[node].State != POINT_ASSAULTED) return; if (m_Nodes[node].TotalOwner == TEAM_INDEX_NEUTRAL) // initial snowfall capture { // until snowfall doesn't belong to anyone it is better handled in assault - code (best would be to have a special function // for neutral nodes.. but doing this just for snowfall will be a bit to much i think MANGOS_ASSERT(node == BG_AV_NODES_SNOWFALL_GRAVE); // currently the only neutral grave EventPlayerAssaultsPoint(player, node); return; } DEBUG_LOG("BattleGroundAV: player defends node: %i", node); if (m_Nodes[node].PrevOwner != TeamIndex(teamIdx)) { sLog.outError("BattleGroundAV: player defends point which doesn't belong to his team %i", node); return; } DefendNode(node, teamIdx); // set the right variables for nodeinfo PopulateNode(node); // spawn node-creatures (defender for example) UpdateNodeWorldState(node); // send new mapicon to the player if (IsTower(node)) { SendYell2ToAll(LANG_BG_AV_TOWER_DEFENDED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), (teamIdx == TEAM_INDEX_ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE); UpdatePlayerScore(player, SCORE_TOWERS_DEFENDED, 1); PlaySoundToAll(BG_AV_SOUND_BOTH_TOWER_DEFEND); } else { SendYell2ToAll(LANG_BG_AV_GRAVE_DEFENDED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), (teamIdx == TEAM_INDEX_ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE); UpdatePlayerScore(player, SCORE_GRAVEYARDS_DEFENDED, 1); player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, 1, 65); // update the statistic for the defending player PlaySoundToAll((teamIdx == TEAM_INDEX_ALLIANCE) ? BG_AV_SOUND_ALLIANCE_GOOD : BG_AV_SOUND_HORDE_GOOD); } }
void BattleGroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node) { DEBUG_LOG("BattleGroundAV: player destroyed point node %i", node); MANGOS_ASSERT(m_Nodes[node].Owner != TEAM_INDEX_NEUTRAL) TeamIndex ownerTeamIdx = TeamIndex(m_Nodes[node].Owner); Team ownerTeam = ownerTeamIdx == TEAM_INDEX_ALLIANCE ? ALLIANCE : HORDE; // despawn banner DestroyNode(node); PopulateNode(node); UpdateNodeWorldState(node); if (IsTower(node)) { uint8 tmp = node - BG_AV_NODES_DUNBALDAR_SOUTH; // despawn marshal (one of those guys protecting the boss) SpawnEvent(BG_AV_MARSHAL_A_SOUTH + tmp, 0, false); UpdateScore(GetOtherTeamIndex(ownerTeamIdx), (-1) * BG_AV_RES_TOWER); RewardReputationToTeam((ownerTeam == ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, m_RepTowerDestruction, ownerTeam); RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_TOWER), ownerTeam); RewardXpToTeam(0, 0.91f, ownerTeam); SendYell2ToAll(LANG_BG_AV_TOWER_TAKEN, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), (ownerTeam == ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE); } else { SendYell2ToAll(LANG_BG_AV_GRAVE_TAKEN, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), (ownerTeam == ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE); } }
void BattleGroundAV::Update(uint32 diff) { BattleGround::Update(diff); if (GetStatus() != STATUS_IN_PROGRESS) return; // add points from mine owning, and look if the neutral team can reclaim the mine for (uint8 mine = 0; mine < BG_AV_MAX_MINES; ++mine) { if (m_Mine_Owner[mine] != TEAM_INDEX_NEUTRAL) { m_Mine_Timer[mine] -= diff; if (m_Mine_Timer[mine] <= 0) { UpdateScore(TeamIndex(m_Mine_Owner[mine]), WORLD_STATE_ADD); m_Mine_Timer[mine] = BG_AV_MINE_TICK_TIMER; } if (m_Mine_Reclaim_Timer[mine] > diff) m_Mine_Reclaim_Timer[mine] -= diff; else ChangeMineOwner(mine, TEAM_INDEX_NEUTRAL); } } // looks for all timers of the nodes and destroy the building (for graveyards the building wont get destroyed, it goes just to the other team for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) { if (m_Nodes[i].State == POINT_ASSAULTED) { if (m_Nodes[i].Timer > diff) m_Nodes[i].Timer -= diff; else EventPlayerDestroyedPoint(i); } } }
void BattleGroundIC::Update(uint32 diff) { BattleGround::Update(diff); if (GetStatus() != STATUS_IN_PROGRESS) return; if (!doorsClosed) { if (closeFortressDoorsTimer <= diff) { // correct visual of closed gates is at "damaged" flag for (int i = BG_IC_GO_T_ALLIANCE_GATE_1; i <= BG_IC_GO_T_HORDE_GATE_3; ++i) GetBGObject(i)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); for (int i = BG_IC_GO_T_ALLIANCE_WEST; i <= BG_IC_GO_T_HORDE_FRONT; ++i) DelObject(i); doorsClosed = true; } else closeFortressDoorsTimer -= diff; } for (int node = 0; node < BG_IC_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_IC_NODE_TYPE_OCCUPIED, teamIndex, true); _SendNodeUpdate(node); // Message to chatlog if (teamIndex == TEAM_INDEX_ALLIANCE) { SendMessage2ToAll(LANG_BG_IC_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_ALLIANCE,NULL,LANG_BG_ALLY,_GetNodeNameId(node)); PlaySoundToAll(BG_IC_SOUND_NODE_CAPTURED_ALLIANCE); } else { SendMessage2ToAll(LANG_BG_IC_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_HORDE,NULL,LANG_BG_HORDE,_GetNodeNameId(node)); PlaySoundToAll(BG_IC_SOUND_NODE_CAPTURED_HORDE); } // gunship starting if (node == BG_IC_NODE_HANGAR) (teamIndex == TEAM_INDEX_ALLIANCE ? gunshipAlliance : gunshipHorde)->BuildStartMovePacket(GetBgMap()); } } } // add a point every 45 secs to quarry/refinery owner for (uint8 node = BG_IC_NODE_QUARRY; node <= BG_IC_NODE_REFINERY; node++) { if (m_Nodes[node] >= BG_IC_NODE_TYPE_OCCUPIED) { if (m_resource_Timer[node] <= diff) { UpdateScore(TeamIndex(m_Nodes[node] - BG_IC_NODE_TYPE_OCCUPIED) , 1); RewardHonorToTeam(GetBonusHonorFromKill(1), (m_Nodes[node] - BG_IC_NODE_TYPE_OCCUPIED == 0 ? ALLIANCE : HORDE)); m_resource_Timer[node] = BG_IC_RESOURCE_TICK_TIMER; } else m_resource_Timer[node] -= diff; } } HandleBuffs(); }