bool OPvPCapturePointEP::HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid) { std::map<uint64,uint32>::iterator itr = m_CreatureTypes.find(guid); if (itr != m_CreatureTypes.end()) { Creature * cr = m_PvP->GetMap()->GetCreature(guid); if (!cr) return true; if (itr->second == EP_PWT_FLIGHTMASTER) { uint32 src = EP_TAXI_NODE[0]; uint32 dst = EP_TAXI_NODE[gossipid+1]; std::vector<uint32> nodes; nodes.resize(2); nodes[0] = src; nodes[1] = dst; plr->PlayerTalkClass->CloseGossip(); plr->ActivateTaxiPathTo(nodes, 0, cr); // leave the opvp, seems like moveinlineofsight isn't called when entering a taxi HandlePlayerLeave(plr); } return true; } return false; }
bool OPvPCapturePointEP_PWT::HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid) { std::map<uint64,uint32>::iterator itr = m_CreatureTypes.find(guid); if(itr != m_CreatureTypes.end()) { Creature * cr = HashMapHolder<Creature>::Find(guid); if(!cr) return true; if(itr->second == EP_PWT_FLIGHTMASTER) { uint32 src = EP_PWT_Taxi; uint32 dst = 0; switch(gossipid) { case 0: dst = EP_NPT_Taxi; break; case 1: dst = EP_EWT_Taxi; break; default: dst = EP_CGT_Taxi; break; } std::vector<uint32> nodes; nodes.resize(2); nodes[0] = src; nodes[1] = dst; plr->PlayerTalkClass->CloseGossip(); plr->ActivateTaxiPathTo(nodes, cr); // leave the opvp, seems like moveinlineofsight isn't called when entering a taxi HandlePlayerLeave(plr); } return true; } return false; }
bool OPvPCapturePoint::Update(uint32 diff) { if (!m_capturePoint) return false; float radius = (float)m_capturePoint->GetGOInfo()->controlZone.radius; for (uint32 team = 0; team < 2; ++team) { for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) { ObjectGuid playerGuid = *itr; ++itr; if (Player* player = ObjectAccessor::FindPlayer(playerGuid)) if (!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) HandlePlayerLeave(player); } } std::list<Player*> players; Trinity::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius); Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(m_capturePoint, players, checker); Cell::VisitWorldObjects(m_capturePoint, searcher, radius); for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr) { Player* const player = *itr; if (player->IsOutdoorPvPActive()) { if (m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second) HandlePlayerEnter(*itr); } } // get the difference of numbers float fact_diff = ((float)m_activePlayers[0].size() - (float)m_activePlayers[1].size()) * diff / OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL; if (!fact_diff) return false; uint32 Challenger = 0; float maxDiff = m_maxSpeed * diff; if (fact_diff < 0) { // horde is in majority, but it's already horde-controlled -> no change if (m_State == OBJECTIVESTATE_HORDE && m_value <= -m_maxValue) return false; if (fact_diff < -maxDiff) fact_diff = -maxDiff; Challenger = HORDE; } else { // ally is in majority, but it's already ally-controlled -> no change if (m_State == OBJECTIVESTATE_ALLIANCE && m_value >= m_maxValue) return false; if (fact_diff > maxDiff) fact_diff = maxDiff; Challenger = ALLIANCE; } float oldValue = m_value; TeamId oldTeam = m_team; m_OldState = m_State; m_value += fact_diff; if (m_value < -m_minValue) // red { if (m_value < -m_maxValue) m_value = -m_maxValue; m_State = OBJECTIVESTATE_HORDE; m_team = TEAM_HORDE; } else if (m_value > m_minValue) // blue { if (m_value > m_maxValue) m_value = m_maxValue; m_State = OBJECTIVESTATE_ALLIANCE; m_team = TEAM_ALLIANCE; } else if (oldValue * m_value <= 0) // grey, go through mid point { // if challenger is ally, then n->a challenge if (Challenger == ALLIANCE) m_State = OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE; // if challenger is horde, then n->h challenge else if (Challenger == HORDE) m_State = OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE; m_team = TEAM_NEUTRAL; } else // grey, did not go through mid point { // old phase and current are on the same side, so one team challenges the other if (Challenger == ALLIANCE && (m_OldState == OBJECTIVESTATE_HORDE || m_OldState == OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE)) m_State = OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE; else if (Challenger == HORDE && (m_OldState == OBJECTIVESTATE_ALLIANCE || m_OldState == OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE)) m_State = OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE; m_team = TEAM_NEUTRAL; } if (m_value != oldValue) SendChangePhase(); if (m_OldState != m_State) { //TC_LOG_ERROR("outdoorpvp", "%u->%u", m_OldState, m_State); if (oldTeam != m_team) ChangeTeam(oldTeam); ChangeState(); return true; } return false; }
bool BfCapturePoint::Update(uint32 diff) { if (!m_capturePointGUID) return false; if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID)) { float radius = capturePoint->GetGOInfo()->capturePoint.radius; for (uint8 team = 0; team < 2; ++team) { for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) { if (!capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) itr = HandlePlayerLeave(player); else ++itr; } else ++itr; } } std::list<Player*> players; Trinity::AnyPlayerInObjectRangeCheck checker(capturePoint, radius); Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(capturePoint, players, checker); capturePoint->VisitNearbyWorldObject(radius, searcher); for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr) if ((*itr)->IsOutdoorPvPActive()) if (m_activePlayers[(*itr)->GetTeamId()].insert((*itr)->GetGUID()).second) HandlePlayerEnter(*itr); } // get the difference of numbers float fact_diff = ((float) m_activePlayers[0].size() - (float) m_activePlayers[1].size()) * diff / BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL; if (G3D::fuzzyEq(fact_diff, 0.0f)) return false; uint32 Challenger = 0; float maxDiff = m_maxSpeed * diff; if (fact_diff < 0) { // horde is in majority, but it's already horde-controlled -> no change if (m_State == BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE && m_value <= -m_maxValue) return false; if (fact_diff < -maxDiff) fact_diff = -maxDiff; Challenger = HORDE; } else { // ally is in majority, but it's already ally-controlled -> no change if (m_State == BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE && m_value >= m_maxValue) return false; if (fact_diff > maxDiff) fact_diff = maxDiff; Challenger = ALLIANCE; } float oldValue = m_value; TeamId oldTeam = m_team; m_OldState = m_State; m_value += fact_diff; if (m_value < -m_minValue) // red { if (m_value < -m_maxValue) m_value = -m_maxValue; m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE; m_team = TEAM_HORDE; } else if (m_value > m_minValue) // blue { if (m_value > m_maxValue) m_value = m_maxValue; m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE; m_team = TEAM_ALLIANCE; } else if (oldValue * m_value <= 0) // grey, go through mid point { // if challenger is ally, then n->a challenge if (Challenger == ALLIANCE) m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE; // if challenger is horde, then n->h challenge else if (Challenger == HORDE) m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE; m_team = TEAM_NEUTRAL; } else // grey, did not go through mid point { // old phase and current are on the same side, so one team challenges the other if (Challenger == ALLIANCE && (m_OldState == BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE || m_OldState == BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE)) m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE; else if (Challenger == HORDE && (m_OldState == BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE || m_OldState == BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE)) m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE; m_team = TEAM_NEUTRAL; } if (G3D::fuzzyNe(m_value, oldValue)) SendChangePhase(); if (m_OldState != m_State) { //TC_LOG_ERROR("bg.battlefield", "%u->%u", m_OldState, m_State); if (oldTeam != m_team) ChangeTeam(oldTeam); return true; } return false; }
bool OPvPCapturePoint::Update(uint32 diff) { if(!m_capturePoint) return false; float radius = m_capturePoint->GetGOInfo()->capturePoint.radius; for (uint32 team = 0; team < 2; ++team) { for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) { Player *player = *itr; ++itr; if(!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) HandlePlayerLeave(player); } } std::list<Player*> players; std::list<Unit *> targets; CellPair p(MaNGOS::ComputeCellPair(m_capturePoint->GetPositionX(), m_capturePoint->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); { MaNGOS::AnyUnitInObjectRangeCheck u_check(m_capturePoint, radius); MaNGOS::UnitListSearcher<MaNGOS::AnyUnitInObjectRangeCheck> searcher(targets, u_check); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); cell.Visit(p, world_unit_searcher, *m_capturePoint->GetMap()); cell.Visit(p, grid_unit_searcher, *m_capturePoint->GetMap()); } for( std::list<Unit *>::iterator itr = targets.begin(); itr != targets.end(); ++itr ) if( (*itr)->GetTypeId() == TYPEID_PLAYER ) players.push_back((Player*)(*itr)); for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr) { if((*itr)->IsOutdoorPvPActive()) { if(m_activePlayers[(*itr)->GetTeamId()].insert(*itr).second) HandlePlayerEnter(*itr); } } // get the difference of numbers float fact_diff = ((float)m_activePlayers[0].size() - (float)m_activePlayers[1].size()) * diff / OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL; if(!fact_diff) return false; uint32 Challenger = 0; float maxDiff = m_maxSpeed * diff; if(fact_diff < 0) { // horde is in majority, but it's already horde-controlled -> no change if(m_State == OBJECTIVESTATE_HORDE && m_value <= -m_maxValue) return false; if(fact_diff < -maxDiff) fact_diff = -maxDiff; Challenger = HORDE; } else { // ally is in majority, but it's already ally-controlled -> no change if(m_State == OBJECTIVESTATE_ALLIANCE && m_value >= m_maxValue) return false; if(fact_diff > maxDiff) fact_diff = maxDiff; Challenger = ALLIANCE; } float oldValue = m_value; TeamId oldTeam = m_team; m_OldState = m_State; m_value += fact_diff; if(m_value < -m_minValue) // red { if(m_value < -m_maxValue) m_value = -m_maxValue; m_State = OBJECTIVESTATE_HORDE; m_team = TEAM_HORDE; } else if(m_value > m_minValue) // blue { if(m_value > m_maxValue) m_value = m_maxValue; m_State = OBJECTIVESTATE_ALLIANCE; m_team = TEAM_ALLIANCE; } else if(oldValue * m_value <= 0) // grey, go through mid point { // if challenger is ally, then n->a challenge if(Challenger == ALLIANCE) m_State = OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE; // if challenger is horde, then n->h challenge else if(Challenger == HORDE) m_State = OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE; m_team = TEAM_NEUTRAL; } else // grey, did not go through mid point { // old phase and current are on the same side, so one team challenges the other if(Challenger == ALLIANCE && (m_OldState == OBJECTIVESTATE_HORDE || m_OldState == OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE)) m_State = OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE; else if(Challenger == HORDE && (m_OldState == OBJECTIVESTATE_ALLIANCE || m_OldState == OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE)) m_State = OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE; m_team = TEAM_NEUTRAL; } if(m_value != oldValue) SendChangePhase(); if(m_OldState != m_State) { //sLog.outError("%u->%u", m_OldState, m_State); if(oldTeam != m_team) ChangeTeam(oldTeam); ChangeState(); return true; } return false; }