*Update OutdoorPvP functions. No longer need creature triggers for capture points.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-29 00:18:41 -05:00
parent 1288761fb7
commit bc32144310
27 changed files with 443 additions and 736 deletions
+156 -309
View File
@@ -23,45 +23,32 @@
#include "ObjectMgr.h"
#include "Map.h"
#include "MapManager.h"
#include "OutdoorPvPObjectiveAI.h"
#include "Group.h"
#include "WorldPacket.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
OutdoorPvPObjective::OutdoorPvPObjective(OutdoorPvP * pvp)
OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP * pvp)
: m_PvP(pvp), m_ShiftPhase(0), m_ShiftMaxPhase(0), m_OldPhase(0),
m_State(0), m_OldState(0), m_CapturePoint(0), m_NeutralValue(0),
m_ShiftMaxCaptureSpeed(0), m_CapturePointCreature(0)
m_State(0), m_OldState(0), m_CapturePointGUID(0), m_NeutralValue(0),
m_ShiftMaxCaptureSpeed(0), m_capturePoint(NULL)
{
}
bool OutdoorPvPObjective::HandlePlayerEnter(Player * plr)
bool OPvPCapturePoint::HandlePlayerEnter(Player * plr)
{
uint32 team = (plr->GetTeam() == HORDE) ? 1 : 0;
// only called if really entered, so no use in the return value anymore
// player distance and activity state was checked already in the AI
std::pair<std::set<uint64>::iterator,bool> newinsert = m_ActivePlayerGuids[team].insert(plr->GetGUID());
if(newinsert.second)
sLog.outDebug("player %u entered an outdoorpvpobjective", plr->GetGUIDLow());
return true;
return m_activePlayers[plr->GetTeamId()].insert(plr).second;
}
void OutdoorPvPObjective::HandlePlayerLeave(Player * plr)
void OPvPCapturePoint::HandlePlayerLeave(Player * plr)
{
uint32 team = (plr->GetTeam() == HORDE) ? 1 : 0;
// only decrease the count if the player is in the active list
if(m_ActivePlayerGuids[team].erase(plr->GetGUID()) > 0)
sLog.outDebug("player %u left an outdoorpvpobjective", plr->GetGUIDLow());
m_activePlayers[plr->GetTeamId()].erase(plr);
}
void OutdoorPvPObjective::HandlePlayerActivityChanged(Player * plr)
{
if(m_CapturePointCreature)
if(Creature * c = HashMapHolder<Creature>::Find(m_CapturePointCreature))
if(c->IsAIEnabled)
c->AI()->MoveInLineOfSight(plr);
}
bool OutdoorPvPObjective::AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
{
GameObjectInfo const* goinfo = objmgr.GetGameObjectInfo(entry);
if (!goinfo)
@@ -110,7 +97,7 @@ bool OutdoorPvPObjective::AddObject(uint32 type, uint32 entry, uint32 map, float
return true;
}
bool OutdoorPvPObjective::AddCreature(uint32 type, uint32 entry, uint32 teamval, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay)
bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 teamval, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay)
{
CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(entry);
if(!cinfo)
@@ -181,51 +168,26 @@ bool OutdoorPvPObjective::AddCreature(uint32 type, uint32 entry, uint32 teamval,
return true;
}
bool OutdoorPvPObjective::AddCapturePoint(uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
bool OPvPCapturePoint::AddCapturePoint(uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
{
sLog.outDebug("creating capture point %u and capture point creature",entry);
sLog.outDebug("Creating capture point %u", entry);
// check info existence
GameObjectInfo const* goinfo = objmgr.GetGameObjectInfo(entry);
if (!goinfo)
if(!goinfo || goinfo->type != GAMEOBJECT_TYPE_CAPTURE_POINT)
{
sLog.outError("OutdoorPvP: GO %u is not capture point!", goinfo->id);
return false;
CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(OPVP_TRIGGER_CREATURE_ENTRY);
if(!cinfo)
return false;
// create capture point creature
uint32 displayId = objmgr.ChooseDisplayId(0, cinfo, NULL);
uint32 creature_guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT);
CreatureData& cdata = objmgr.NewOrExistCreatureData(creature_guid);
cdata.id = OPVP_TRIGGER_CREATURE_ENTRY;
cdata.mapid = map;
cdata.displayid = displayId;
cdata.equipmentId = cinfo->equipmentId;
cdata.posX = x;
cdata.posY = y;
cdata.posZ = z;
cdata.orientation = o;
cdata.spawntimesecs = 1;
cdata.spawndist = 0;
cdata.currentwaypoint = 0;
cdata.curhealth = cinfo->maxhealth;
cdata.curmana = cinfo->maxmana;
cdata.is_dead = false;
cdata.movementType = cinfo->MovementType;
cdata.spawnMask = 1;
cdata.phaseMask = PHASEMASK_NORMAL;
objmgr.AddCreatureToGrid(creature_guid, &cdata);
m_CapturePointCreature = MAKE_NEW_GUID(creature_guid, OPVP_TRIGGER_CREATURE_ENTRY, HIGHGUID_UNIT);
}
// create capture point go
uint32 guid = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
m_CapturePointGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
// get the needed values from goinfo
m_ShiftMaxPhase = goinfo->capturePoint.maxTime;
m_ShiftMaxCaptureSpeed = m_ShiftMaxPhase / float(goinfo->capturePoint.minTime);
m_NeutralValue = goinfo->capturePoint.neutralPercent;
GameObjectData& data = objmgr.NewGOData(guid);
GameObjectData& data = objmgr.NewGOData(m_CapturePointGUID);
data.id = entry;
data.mapid = map;
@@ -243,60 +205,12 @@ bool OutdoorPvPObjective::AddCapturePoint(uint32 entry, uint32 map, float x, flo
data.go_state = GO_STATE_READY;
data.phaseMask = PHASEMASK_NORMAL;
objmgr.AddGameobjectToGrid(guid, &data);
objmgr.AddGameobjectToGrid(m_CapturePointGUID, &data);
m_CapturePoint = MAKE_NEW_GUID(guid, entry, HIGHGUID_GAMEOBJECT);
if(goinfo->type != GAMEOBJECT_TYPE_CAPTURE_POINT)
sLog.outError("OutdoorPvP: GO %u is not capture point!", goinfo->id);
// get the needed values from goinfo
m_ShiftMaxPhase = goinfo->capturePoint.maxTime;
m_ShiftMaxCaptureSpeed = m_ShiftMaxPhase / float(goinfo->capturePoint.minTime);
m_NeutralValue = goinfo->capturePoint.neutralPercent;
// add to map if map is already loaded
Map * pMap = MapManager::Instance().FindMap(map);
if(!pMap)
return true;
// add GO...
GameObject * go = new GameObject;
if(!go->Create(guid,entry, pMap,PHASEMASK_NORMAL,x,y,z,o,rotation0,rotation1,rotation2,rotation3,100,GO_STATE_READY))
{
sLog.outError("Gameobject template %u not found in database.", entry);
delete go;
}
else
{
go->SetRespawnTime(0);
objmgr.SaveGORespawnTime(go->GetDBTableGUIDLow(), 0, 0);
pMap->Add(go);
}
// add creature...
Creature* pCreature = new Creature;
if (!pCreature->Create(creature_guid, pMap, PHASEMASK_NORMAL, OPVP_TRIGGER_CREATURE_ENTRY, 0))
{
sLog.outError("Can't create creature entry: %u",entry);
delete pCreature;
return false;
}
else
{
pCreature->Relocate(x, y, z, o);
if(!pCreature->IsPositionValid())
{
sLog.outError("ERROR: Creature (guidlow %d, entry %d) not added to opvp. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
delete pCreature;
return false;
}
pMap->Add(pCreature);
}
return true;
}
bool OutdoorPvPObjective::DelCreature(uint32 type)
bool OPvPCapturePoint::DelCreature(uint32 type)
{
if(!m_Creatures[type])
{
@@ -331,7 +245,7 @@ bool OutdoorPvPObjective::DelCreature(uint32 type)
return true;
}
bool OutdoorPvPObjective::DelObject(uint32 type)
bool OPvPCapturePoint::DelObject(uint32 type)
{
if(!m_Objects[type])
return false;
@@ -351,46 +265,21 @@ bool OutdoorPvPObjective::DelObject(uint32 type)
return true;
}
bool OutdoorPvPObjective::DelCapturePoint()
bool OPvPCapturePoint::DelCapturePoint()
{
if(m_CapturePoint)
objmgr.DeleteGOData(m_CapturePointGUID);
m_CapturePointGUID = 0;
if(m_capturePoint)
{
GameObject *obj = HashMapHolder<GameObject>::Find(m_CapturePoint);
if(obj)
{
uint32 guid = obj->GetDBTableGUIDLow();
obj->SetRespawnTime(0); // not save respawn time
obj->Delete();
objmgr.DeleteGOData(guid);
}
m_CapturePoint = 0;
}
if(m_CapturePointCreature)
{
Creature *cr = HashMapHolder<Creature>::Find(m_CapturePointCreature);
if(cr)
{
uint32 guid = cr->GetDBTableGUIDLow();
// Don't save respawn time
cr->SetRespawnTime(0);
cr->RemoveCorpse();
cr->CleanupsBeforeDelete();
// explicit removal from map
// beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted
// so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed
//if(Map * map = MapManager::Instance().FindMap(cr->GetMapId()))
// map->Remove(cr,false);
// delete respawn time for this creature
WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE guid = '%u'", guid);
cr->AddObjectToRemoveList();
objmgr.DeleteCreatureData(guid);
}
m_CapturePointCreature = 0;
m_capturePoint->SetRespawnTime(0); // not save respawn time
m_capturePoint->Delete();
}
return true;
}
void OutdoorPvPObjective::DeleteSpawns()
void OPvPCapturePoint::DeleteSpawns()
{
for(std::map<uint32,uint64>::iterator i = m_Objects.begin(); i != m_Objects.end(); ++i)
DelObject(i->first);
@@ -401,7 +290,7 @@ void OutdoorPvPObjective::DeleteSpawns()
void OutdoorPvP::DeleteSpawns()
{
for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr)
for(OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
(*itr)->DeleteSpawns();
}
@@ -416,145 +305,133 @@ OutdoorPvP::~OutdoorPvP()
void OutdoorPvP::HandlePlayerEnterZone(Player * plr, uint32 zone)
{
m_players[TEAM_ID(plr->GetTeam())].insert(plr);
m_players[plr->GetTeamId()].insert(plr);
}
void OutdoorPvP::HandlePlayerLeaveZone(Player * plr, uint32 zone)
{
// inform the objectives of the leaving
for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr)
for(OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
(*itr)->HandlePlayerLeave(plr);
// remove the world state information from the player (we can't keep everyone up to date, so leave out those who are not in the concerning zones)
if(!plr->GetSession()->PlayerLogout())
SendRemoveWorldStates(plr);
m_players[TEAM_ID(plr->GetTeam())].erase(plr);
m_players[plr->GetTeamId()].erase(plr);
sLog.outDebug("Player %s left an outdoorpvp zone");
}
bool OutdoorPvP::Update(uint32 diff)
{
bool objective_changed = false;
for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr)
for(OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
objective_changed |= (*itr)->Update(diff);
return objective_changed;
}
void OutdoorPvPObjective::UpdateActivePlayerProximityCheck()
bool OPvPCapturePoint::Update(uint32 diff)
{
if(GameObject *cp = HashMapHolder<GameObject>::Find(m_CapturePoint))
if(!m_capturePoint)
return false;
float radius = m_capturePoint->GetGOInfo()->capturePoint.radius;
for(uint32 team = 0; team < 2; ++team)
{
for(int team = 0; team < 2; ++team)
for(PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();)
{
std::set<uint64>::iterator itr, next;
for(itr = m_ActivePlayerGuids[team].begin(); itr != m_ActivePlayerGuids[team].end(); itr = next)
{
next = itr;
++next;
// if the player is online
if(Player * pl = objmgr.GetPlayer(*itr))
{
if(!cp->IsWithinDistInMap(pl,cp->GetGOInfo()->raw.data[0]))
HandleCapturePointEvent(pl, cp->GetGOInfo()->raw.data[9]); //i_objective->HandlePlayerLeave((Player*)u);
}
else
{
sLog.outError("Player ("I64FMTD") offline, bit still in outdoor pvp, this should never happen.",(*itr));
}
}
Player *player = *itr;
++itr;
if(!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
HandlePlayerLeave(player);
}
}
}
bool OutdoorPvPObjective::Update(uint32 diff)
{
UpdateActivePlayerProximityCheck();
std::list<Player*> players;
Trinity::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(m_capturePoint, players, checker);
m_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).second)
HandlePlayerEnter(*itr);
}
}
// get the difference of numbers
float fact_diff = (float)m_activePlayers[0].size() - (float)m_activePlayers[1].size();
if(!fact_diff)
return false;
uint32 Challenger = 0;
// get the difference of numbers
float fact_diff = ((float)m_ActivePlayerGuids[0].size() - (float)m_ActivePlayerGuids[1].size());
if(fact_diff<0)
{
if(fact_diff < - m_ShiftMaxCaptureSpeed)
fact_diff = - m_ShiftMaxCaptureSpeed;
Challenger = HORDE;
// horde is in majority, but it's already horde-controlled -> no change
if(m_State == OBJECTIVESTATE_HORDE && m_ShiftPhase == - m_ShiftMaxPhase)
return false;
}
else if(fact_diff>0)
{
if(fact_diff > m_ShiftMaxCaptureSpeed)
fact_diff = m_ShiftMaxCaptureSpeed;
Challenger = ALLIANCE;
// ally is in majority, but it's already ally-controlled -> no change
if(m_State == OBJECTIVESTATE_ALLIANCE && m_ShiftPhase == m_ShiftMaxPhase)
return false;
}
else /*if(fact_diff==0)*/ // no change
if(fact_diff < 0)
{
// horde is in majority, but it's already horde-controlled -> no change
if(m_State == OBJECTIVESTATE_HORDE && m_ShiftPhase <= -m_ShiftMaxPhase)
return false;
m_OldPhase = m_ShiftPhase;
if(fact_diff < - m_ShiftMaxCaptureSpeed)
fact_diff = - m_ShiftMaxCaptureSpeed;
m_OldState = m_State;
m_ShiftPhase += fact_diff;
// check limits, these are over the grey part
if(m_ShiftPhase <= - m_ShiftMaxPhase * (float)(m_NeutralValue) / 100.0f)
{
if(m_ShiftPhase <= - m_ShiftMaxPhase)
m_ShiftPhase = - m_ShiftMaxPhase;
m_State = OBJECTIVESTATE_HORDE;
return true;
}
else if(m_ShiftPhase >= m_ShiftMaxPhase * (float)(m_NeutralValue) / 100.0f)
{
if(m_ShiftPhase >= m_ShiftMaxPhase)
m_ShiftPhase = m_ShiftMaxPhase;
m_State = OBJECTIVESTATE_ALLIANCE;
return true;
}
if(m_OldPhase*m_ShiftPhase <=0)
{
// gone through neutral
// 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;
}
else
{
// 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;
}
return true;
}
bool OutdoorPvPObjective::HandleCaptureCreaturePlayerMoveInLos(Player * p, Creature * c)
{
// check if guid matches
if(c->GetGUID() != m_CapturePointCreature)
return false;
// check if capture point go is spawned
GameObject * cp = HashMapHolder<GameObject>::Find(m_CapturePoint);
if(!cp)
return false;
// check range and activity
if(cp->IsWithinDistInMap(p,cp->GetGOInfo()->capturePoint.radius) && p->IsOutdoorPvPActive())
return HandleCapturePointEvent(p, cp->GetGOInfo()->capturePoint.progressEventID1); //i_objective->HandlePlayerEnter((Player*)u);
Challenger = HORDE;
}
else
return HandleCapturePointEvent(p, cp->GetGOInfo()->capturePoint.progressEventID2); //i_objective->HandlePlayerLeave((Player*)u);
{
// ally is in majority, but it's already ally-controlled -> no change
if(m_State == OBJECTIVESTATE_ALLIANCE && m_ShiftPhase >= m_ShiftMaxPhase)
return false;
if(fact_diff > m_ShiftMaxCaptureSpeed)
fact_diff = m_ShiftMaxCaptureSpeed;
Challenger = ALLIANCE;
}
m_OldPhase = m_ShiftPhase;
m_OldState = m_State;
m_ShiftPhase += fact_diff;
// check limits, these are over the grey part
if(m_ShiftPhase <= -m_ShiftMaxPhase * (float)(m_NeutralValue) / 100.0f)
{
if(m_ShiftPhase <= -m_ShiftMaxPhase)
m_ShiftPhase = -m_ShiftMaxPhase;
m_State = OBJECTIVESTATE_HORDE;
return true;
}
else if(m_ShiftPhase >= m_ShiftMaxPhase * (float)(m_NeutralValue) / 100.0f)
{
if(m_ShiftPhase >= m_ShiftMaxPhase)
m_ShiftPhase = m_ShiftMaxPhase;
m_State = OBJECTIVESTATE_ALLIANCE;
return true;
}
if(m_OldPhase*m_ShiftPhase <=0)
{
// gone through neutral
// 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;
}
else
{
// 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;
}
return true;
}
void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value)
@@ -568,23 +445,19 @@ void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value)
}
}
void OutdoorPvPObjective::SendUpdateWorldState(uint32 field, uint32 value)
void OPvPCapturePoint::SendUpdateWorldState(uint32 field, uint32 value)
{
for(uint32 team = 0; team < 2; ++team)
{
// send to all players present in the area
for(std::set<uint64>::iterator itr = m_ActivePlayerGuids[team].begin(); itr != m_ActivePlayerGuids[team].end(); ++itr)
for(PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
{
Player * plr = objmgr.GetPlayer(*itr);
if(plr)
{
plr->SendUpdateWorldState(field,value);
}
(*itr)->SendUpdateWorldState(field,value);
}
}
}
void OutdoorPvPObjective::SendObjectiveComplete(uint32 id,uint64 guid)
void OPvPCapturePoint::SendObjectiveComplete(uint32 id,uint64 guid)
{
uint32 team;
switch(m_State)
@@ -597,24 +470,11 @@ void OutdoorPvPObjective::SendObjectiveComplete(uint32 id,uint64 guid)
break;
default:
return;
break;
}
// send to all players present in the area
for(std::set<uint64>::iterator itr = m_ActivePlayerGuids[team].begin(); itr != m_ActivePlayerGuids[team].end(); ++itr)
{
Player * plr = objmgr.GetPlayer(*itr);
if(plr)
{
plr->KilledMonster(id,guid);
}
}
}
void OutdoorPvP::HandlePlayerActivityChanged(Player * plr)
{
for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr)
(*itr)->HandlePlayerActivityChanged(plr);
for(PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
(*itr)->KilledMonster(id, guid);
}
void OutdoorPvP::HandleKill(Player *killer, Unit * killed)
@@ -650,26 +510,23 @@ void OutdoorPvP::HandleKill(Player *killer, Unit * killed)
}
}
bool OutdoorPvP::IsInsideObjective(Player *plr)
bool OutdoorPvP::IsInsideObjective(Player *plr) const
{
for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr)
{
for(OPvPCapturePointMap::const_iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
if((*itr)->IsInsideObjective(plr))
return true;
}
return false;
}
bool OutdoorPvPObjective::IsInsideObjective(Player *plr)
bool OPvPCapturePoint::IsInsideObjective(Player *plr) const
{
uint32 team = (plr->GetTeam() == HORDE) ? 1 : 0;
std::set<uint64>::iterator itr = m_ActivePlayerGuids[team].find(plr->GetGUID());
return itr != m_ActivePlayerGuids[team].end();
return m_activePlayers[plr->GetTeamId()].find(plr) != m_activePlayers[plr->GetTeamId()].end();
}
bool OutdoorPvP::HandleCustomSpell(Player *plr, uint32 spellId, GameObject * go)
{
for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr)
for(OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
{
if((*itr)->HandleCustomSpell(plr,spellId,go))
return true;
@@ -677,7 +534,7 @@ bool OutdoorPvP::HandleCustomSpell(Player *plr, uint32 spellId, GameObject * go)
return false;
}
bool OutdoorPvPObjective::HandleCustomSpell(Player *plr, uint32 spellId, GameObject * go)
bool OPvPCapturePoint::HandleCustomSpell(Player *plr, uint32 spellId, GameObject * go)
{
if(!plr->IsOutdoorPvPActive())
return false;
@@ -686,7 +543,7 @@ bool OutdoorPvPObjective::HandleCustomSpell(Player *plr, uint32 spellId, GameObj
bool OutdoorPvP::HandleOpenGo(Player *plr, uint64 guid)
{
for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr)
for(OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
{
if((*itr)->HandleOpenGo(plr,guid) >= 0)
return true;
@@ -694,19 +551,9 @@ bool OutdoorPvP::HandleOpenGo(Player *plr, uint64 guid)
return false;
}
bool OutdoorPvP::HandleCaptureCreaturePlayerMoveInLos(Player * p, Creature * c)
{
for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr)
{
if((*itr)->HandleCaptureCreaturePlayerMoveInLos(p, c))
return true;
}
return false;
}
bool OutdoorPvP::HandleGossipOption(Player * plr, uint64 guid, uint32 id)
{
for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr)
for(OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
{
if((*itr)->HandleGossipOption(plr, guid, id))
return true;
@@ -716,7 +563,7 @@ bool OutdoorPvP::HandleGossipOption(Player * plr, uint64 guid, uint32 id)
bool OutdoorPvP::CanTalkTo(Player * plr, Creature * c, GossipOption &gso)
{
for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr)
for(OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
{
if((*itr)->CanTalkTo(plr, c, gso))
return true;
@@ -726,7 +573,7 @@ bool OutdoorPvP::CanTalkTo(Player * plr, Creature * c, GossipOption &gso)
bool OutdoorPvP::HandleDropFlag(Player * plr, uint32 id)
{
for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr)
for(OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
{
if((*itr)->HandleDropFlag(plr, id))
return true;
@@ -734,22 +581,22 @@ bool OutdoorPvP::HandleDropFlag(Player * plr, uint32 id)
return false;
}
bool OutdoorPvPObjective::HandleGossipOption(Player * plr, uint64 guid, uint32 id)
bool OPvPCapturePoint::HandleGossipOption(Player * plr, uint64 guid, uint32 id)
{
return false;
}
bool OutdoorPvPObjective::CanTalkTo(Player * plr, Creature * c, GossipOption &gso)
bool OPvPCapturePoint::CanTalkTo(Player * plr, Creature * c, GossipOption &gso)
{
return false;
}
bool OutdoorPvPObjective::HandleDropFlag(Player * plr, uint32 id)
bool OPvPCapturePoint::HandleDropFlag(Player * plr, uint32 id)
{
return false;
}
int32 OutdoorPvPObjective::HandleOpenGo(Player *plr, uint64 guid)
int32 OPvPCapturePoint::HandleOpenGo(Player *plr, uint64 guid)
{
std::map<uint64,uint32>::iterator itr = m_ObjectTypes.find(guid);
if(itr != m_ObjectTypes.end())
@@ -771,7 +618,7 @@ void OutdoorPvP::RegisterZone(uint32 zoneId)
bool OutdoorPvP::HasPlayer(Player *plr) const
{
return m_players[TEAM_ID(plr->GetTeam())].find(plr) != m_players[TEAM_ID(plr->GetTeam())].end();
return m_players[plr->GetTeamId()].find(plr) != m_players[plr->GetTeamId()].end();
}
void OutdoorPvP::TeamCastSpell(TeamId team, int32 spellId)