[12165] Move opvpmgr based capture point saving / loading to opvp class

Also improve capture point locking code and fix saving lock state in NA and GH

Note: Keep in mind that capture points won't be activated before you call SetCapturePointSlider() function
This commit is contained in:
stfx 2012-08-31 15:24:03 +02:00 committed by Antz
parent 4dcb91df9f
commit d22e1d3b7a
14 changed files with 97 additions and 83 deletions

View file

@ -190,19 +190,19 @@ void BattleGroundEY::HandleGameObjectCreate(GameObject* go)
{ {
case GO_CAPTURE_POINT_BLOOD_ELF_TOWER: case GO_CAPTURE_POINT_BLOOD_ELF_TOWER:
m_towers[NODE_BLOOD_ELF_TOWER] = go->GetObjectGuid(); m_towers[NODE_BLOOD_ELF_TOWER] = go->GetObjectGuid();
go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); go->SetCapturePointSlider(CAPTURE_SLIDER_MIDDLE);
break; break;
case GO_CAPTURE_POINT_FEL_REAVER_RUINS: case GO_CAPTURE_POINT_FEL_REAVER_RUINS:
m_towers[NODE_FEL_REAVER_RUINS] = go->GetObjectGuid(); m_towers[NODE_FEL_REAVER_RUINS] = go->GetObjectGuid();
go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); go->SetCapturePointSlider(CAPTURE_SLIDER_MIDDLE);
break; break;
case GO_CAPTURE_POINT_MAGE_TOWER: case GO_CAPTURE_POINT_MAGE_TOWER:
m_towers[NODE_MAGE_TOWER] = go->GetObjectGuid(); m_towers[NODE_MAGE_TOWER] = go->GetObjectGuid();
go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); go->SetCapturePointSlider(CAPTURE_SLIDER_MIDDLE);
break; break;
case GO_CAPTURE_POINT_DRAENEI_RUINS: case GO_CAPTURE_POINT_DRAENEI_RUINS:
m_towers[NODE_DRAENEI_RUINS] = go->GetObjectGuid(); m_towers[NODE_DRAENEI_RUINS] = go->GetObjectGuid();
go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); go->SetCapturePointSlider(CAPTURE_SLIDER_MIDDLE);
break; break;
} }
} }

View file

@ -83,16 +83,13 @@ void GameObject::AddToWorld()
void GameObject::RemoveFromWorld() void GameObject::RemoveFromWorld()
{ {
// store the slider value for non instance, non locked capture points
if (!GetMap()->IsBattleGroundOrArena())
{
if (GetGOInfo()->type == GAMEOBJECT_TYPE_CAPTURE_POINT && m_lootState == GO_ACTIVATED)
sOutdoorPvPMgr.SetCapturePointSlider(GetEntry(), m_captureSlider);
}
///- Remove the gameobject from the accessor ///- Remove the gameobject from the accessor
if (IsInWorld()) if (IsInWorld())
{ {
// Notify the outdoor pvp script
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId()))
outdoorPvP->HandleGameObjectRemove(this);
// Remove GO from owner // Remove GO from owner
if (ObjectGuid owner_guid = GetOwnerGuid()) if (ObjectGuid owner_guid = GetOwnerGuid())
{ {
@ -165,19 +162,11 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
SetGoArtKit(0); // unknown what this is SetGoArtKit(0); // unknown what this is
SetGoAnimProgress(animprogress); SetGoAnimProgress(animprogress);
// Notify the battleground script // Notify the battleground or outdoor pvp script
if (map->IsBattleGroundOrArena()) if (map->IsBattleGroundOrArena())
((BattleGroundMap*)map)->GetBG()->HandleGameObjectCreate(this); ((BattleGroundMap*)map)->GetBG()->HandleGameObjectCreate(this);
else else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId()))
{ outdoorPvP->HandleGameObjectCreate(this);
// set initial data and activate non instance capture points
if (goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT)
SetCapturePointSlider(sOutdoorPvPMgr.GetCapturePointSliderValue(goinfo->id));
// Notify the outdoor pvp script
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId()))
outdoorPvP->HandleGameObjectCreate(this);
}
// Notify the map's instance data. // Notify the map's instance data.
// Only works if you create the object in it, not if it is moves to that map. // Only works if you create the object in it, not if it is moves to that map.
@ -1960,32 +1949,27 @@ bool GameObject::HasStaticDBSpawnData() const
return sObjectMgr.GetGOData(GetGUIDLow()) != NULL; return sObjectMgr.GetGOData(GetGUIDLow()) != NULL;
} }
void GameObject::SetCapturePointSlider(int8 value) void GameObject::SetCapturePointSlider(float value)
{ {
GameObjectInfo const* info = GetGOInfo(); GameObjectInfo const* info = GetGOInfo();
switch (value) // only activate non-locked capture point
if (value >= 0)
{ {
case CAPTURE_SLIDER_ALLIANCE_LOCKED: m_captureSlider = value;
m_captureSlider = CAPTURE_SLIDER_ALLIANCE; SetLootState(GO_ACTIVATED);
break;
case CAPTURE_SLIDER_HORDE_LOCKED:
m_captureSlider = CAPTURE_SLIDER_HORDE;
break;
default:
m_captureSlider = value;
SetLootState(GO_ACTIVATED);
break;
} }
else
m_captureSlider = -value;
// set the state of the capture point based on the slider value // set the state of the capture point based on the slider value
if (m_captureSlider == CAPTURE_SLIDER_ALLIANCE) if ((int)m_captureSlider == CAPTURE_SLIDER_ALLIANCE)
m_captureState = CAPTURE_STATE_WIN_ALLIANCE; m_captureState = CAPTURE_STATE_WIN_ALLIANCE;
else if (m_captureSlider == CAPTURE_SLIDER_HORDE) else if ((int)m_captureSlider == CAPTURE_SLIDER_HORDE)
m_captureState = CAPTURE_STATE_WIN_HORDE; m_captureState = CAPTURE_STATE_WIN_HORDE;
else if (m_captureSlider > CAPTURE_SLIDER_NEUTRAL + info->capturePoint.neutralPercent * 0.5f) else if (m_captureSlider > CAPTURE_SLIDER_MIDDLE + info->capturePoint.neutralPercent * 0.5f)
m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE; m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE;
else if (m_captureSlider < CAPTURE_SLIDER_NEUTRAL - info->capturePoint.neutralPercent * 0.5f) else if (m_captureSlider < CAPTURE_SLIDER_MIDDLE - info->capturePoint.neutralPercent * 0.5f)
m_captureState = CAPTURE_STATE_PROGRESS_HORDE; m_captureState = CAPTURE_STATE_PROGRESS_HORDE;
else else
m_captureState = CAPTURE_STATE_NEUTRAL; m_captureState = CAPTURE_STATE_NEUTRAL;
@ -2006,7 +1990,7 @@ void GameObject::TickCapturePoint()
GuidSet tempUsers(m_UniqueUsers); GuidSet tempUsers(m_UniqueUsers);
uint32 neutralPercent = info->capturePoint.neutralPercent; uint32 neutralPercent = info->capturePoint.neutralPercent;
uint32 oldValue = m_captureSlider; int oldValue = m_captureSlider;
int rangePlayers = 0; int rangePlayers = 0;
for (std::list<Player*>::iterator itr = capturingPlayers.begin(); itr != capturingPlayers.end(); ++itr) for (std::list<Player*>::iterator itr = capturingPlayers.begin(); itr != capturingPlayers.end(); ++itr)
@ -2085,7 +2069,7 @@ void GameObject::TickCapturePoint()
} }
// return if slider did not move a whole percent // return if slider did not move a whole percent
if ((uint32)m_captureSlider == oldValue) if ((int)m_captureSlider == oldValue)
return; return;
// on retail this is also sent to newly added players even though they already received a slider value // on retail this is also sent to newly added players even though they already received a slider value
@ -2097,13 +2081,13 @@ void GameObject::TickCapturePoint()
/* WIN EVENTS */ /* WIN EVENTS */
// alliance wins tower with max points // alliance wins tower with max points
if (m_captureState != CAPTURE_STATE_WIN_ALLIANCE && (uint32)m_captureSlider == CAPTURE_SLIDER_ALLIANCE) if (m_captureState != CAPTURE_STATE_WIN_ALLIANCE && (int)m_captureSlider == CAPTURE_SLIDER_ALLIANCE)
{ {
eventId = info->capturePoint.winEventID1; eventId = info->capturePoint.winEventID1;
m_captureState = CAPTURE_STATE_WIN_ALLIANCE; m_captureState = CAPTURE_STATE_WIN_ALLIANCE;
} }
// horde wins tower with max points // horde wins tower with max points
else if (m_captureState != CAPTURE_STATE_WIN_HORDE && (uint32)m_captureSlider == CAPTURE_SLIDER_HORDE) else if (m_captureState != CAPTURE_STATE_WIN_HORDE && (int)m_captureSlider == CAPTURE_SLIDER_HORDE)
{ {
eventId = info->capturePoint.winEventID2; eventId = info->capturePoint.winEventID2;
m_captureState = CAPTURE_STATE_WIN_HORDE; m_captureState = CAPTURE_STATE_WIN_HORDE;
@ -2111,7 +2095,7 @@ void GameObject::TickCapturePoint()
/* PROGRESS EVENTS */ /* PROGRESS EVENTS */
// alliance takes the tower from neutral, contested or horde (if there is no neutral area) to alliance // alliance takes the tower from neutral, contested or horde (if there is no neutral area) to alliance
else if (m_captureState != CAPTURE_STATE_PROGRESS_ALLIANCE && m_captureSlider > CAPTURE_SLIDER_NEUTRAL + neutralPercent * 0.5f && progressFaction == ALLIANCE) else if (m_captureState != CAPTURE_STATE_PROGRESS_ALLIANCE && m_captureSlider > CAPTURE_SLIDER_MIDDLE + neutralPercent * 0.5f && progressFaction == ALLIANCE)
{ {
eventId = info->capturePoint.progressEventID1; eventId = info->capturePoint.progressEventID1;
@ -2124,7 +2108,7 @@ void GameObject::TickCapturePoint()
m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE; m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE;
} }
// horde takes the tower from neutral, contested or alliance (if there is no neutral area) to horde // horde takes the tower from neutral, contested or alliance (if there is no neutral area) to horde
else if (m_captureState != CAPTURE_STATE_PROGRESS_HORDE && m_captureSlider < CAPTURE_SLIDER_NEUTRAL - neutralPercent * 0.5f && progressFaction == HORDE) else if (m_captureState != CAPTURE_STATE_PROGRESS_HORDE && m_captureSlider < CAPTURE_SLIDER_MIDDLE - neutralPercent * 0.5f && progressFaction == HORDE)
{ {
eventId = info->capturePoint.progressEventID2; eventId = info->capturePoint.progressEventID2;
@ -2139,13 +2123,13 @@ void GameObject::TickCapturePoint()
/* NEUTRAL EVENTS */ /* NEUTRAL EVENTS */
// alliance takes the tower from horde to neutral // alliance takes the tower from horde to neutral
else if (m_captureState != CAPTURE_STATE_NEUTRAL && m_captureSlider >= CAPTURE_SLIDER_NEUTRAL - neutralPercent * 0.5f && m_captureSlider <= CAPTURE_SLIDER_NEUTRAL + neutralPercent * 0.5f && progressFaction == ALLIANCE) else if (m_captureState != CAPTURE_STATE_NEUTRAL && m_captureSlider >= CAPTURE_SLIDER_MIDDLE - neutralPercent * 0.5f && m_captureSlider <= CAPTURE_SLIDER_MIDDLE + neutralPercent * 0.5f && progressFaction == ALLIANCE)
{ {
eventId = info->capturePoint.neutralEventID1; eventId = info->capturePoint.neutralEventID1;
m_captureState = CAPTURE_STATE_NEUTRAL; m_captureState = CAPTURE_STATE_NEUTRAL;
} }
// horde takes the tower from alliance to neutral // horde takes the tower from alliance to neutral
else if (m_captureState != CAPTURE_STATE_NEUTRAL && m_captureSlider >= CAPTURE_SLIDER_NEUTRAL - neutralPercent * 0.5f && m_captureSlider <= CAPTURE_SLIDER_NEUTRAL + neutralPercent * 0.5f && progressFaction == HORDE) else if (m_captureState != CAPTURE_STATE_NEUTRAL && m_captureSlider >= CAPTURE_SLIDER_MIDDLE - neutralPercent * 0.5f && m_captureSlider <= CAPTURE_SLIDER_MIDDLE + neutralPercent * 0.5f && progressFaction == HORDE)
{ {
eventId = info->capturePoint.neutralEventID2; eventId = info->capturePoint.neutralEventID2;
m_captureState = CAPTURE_STATE_NEUTRAL; m_captureState = CAPTURE_STATE_NEUTRAL;

View file

@ -611,10 +611,7 @@ enum CapturePointSlider
{ {
CAPTURE_SLIDER_ALLIANCE = 100, // full alliance CAPTURE_SLIDER_ALLIANCE = 100, // full alliance
CAPTURE_SLIDER_HORDE = 0, // full horde CAPTURE_SLIDER_HORDE = 0, // full horde
CAPTURE_SLIDER_NEUTRAL = 50, // middle CAPTURE_SLIDER_MIDDLE = 50 // middle
CAPTURE_SLIDER_ALLIANCE_LOCKED = -1, // used to store additional information
CAPTURE_SLIDER_HORDE_LOCKED = -2
}; };
class Unit; class Unit;
@ -771,7 +768,8 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
GameObject* LookupFishingHoleAround(float range); GameObject* LookupFishingHoleAround(float range);
void SetCapturePointSlider(int8 value); void SetCapturePointSlider(float value);
float GetCapturePointSlider() const { return m_captureSlider; }
GridReference<GameObject>& GetGridRef() { return m_gridRef; } GridReference<GameObject>& GetGridRef() { return m_gridRef; }
@ -785,7 +783,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
// For traps/goober this: spell casting cooldown, for doors/buttons: reset time. // For traps/goober this: spell casting cooldown, for doors/buttons: reset time.
uint32 m_captureTimer; // (msecs) timer used for capture points uint32 m_captureTimer; // (msecs) timer used for capture points
float m_captureSlider; float m_captureSlider; // capture point slider value in range of [0..100]
CapturePointState m_captureState; CapturePointState m_captureState;
GuidSet m_SkillupSet; // players that already have skill-up at GO use GuidSet m_SkillupSet; // players that already have skill-up at GO use

View file

@ -61,7 +61,7 @@ void OutdoorPvP::HandlePlayerLeaveZone(Player* player, bool isMainZone)
*/ */
void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value) void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value)
{ {
for (GuidZoneMap::iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) for (GuidZoneMap::const_iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr)
{ {
// only send world state update to main zone // only send world state update to main zone
if (!itr->second) if (!itr->second)
@ -72,6 +72,20 @@ void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value)
} }
} }
void OutdoorPvP::HandleGameObjectCreate(GameObject* go)
{
// set initial data and activate capture points
if (go->GetGOInfo()->type == GAMEOBJECT_TYPE_CAPTURE_POINT)
go->SetCapturePointSlider(sOutdoorPvPMgr.GetCapturePointSliderValue(go->GetEntry(), CAPTURE_SLIDER_MIDDLE));
}
void OutdoorPvP::HandleGameObjectRemove(GameObject* go)
{
// save capture point slider value (negative value if locked)
if (go->GetGOInfo()->type == GAMEOBJECT_TYPE_CAPTURE_POINT)
sOutdoorPvPMgr.SetCapturePointSlider(go->GetEntry(), go->getLootState() == GO_ACTIVATED ? go->GetCapturePointSlider() : -go->GetCapturePointSlider());
}
/** /**
Function that handles player kills in the main outdoor pvp zones Function that handles player kills in the main outdoor pvp zones
@ -110,7 +124,7 @@ void OutdoorPvP::HandlePlayerKill(Player* killer, Player* victim)
// apply a team buff for the main and affected zones // apply a team buff for the main and affected zones
void OutdoorPvP::BuffTeam(Team team, uint32 spellId, bool remove /*= false*/) void OutdoorPvP::BuffTeam(Team team, uint32 spellId, bool remove /*= false*/)
{ {
for (GuidZoneMap::iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) for (GuidZoneMap::const_iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr)
{ {
Player* player = sObjectMgr.GetPlayer(itr->first); Player* player = sObjectMgr.GetPlayer(itr->first);
if (player && player->GetTeam() == team) if (player && player->GetTeam() == team)

View file

@ -64,9 +64,12 @@ class OutdoorPvP
// handle capture objective complete // handle capture objective complete
virtual void HandleObjectiveComplete(uint32 /*eventId*/, std::list<Player*> /*players*/, Team /*team*/) {} virtual void HandleObjectiveComplete(uint32 /*eventId*/, std::list<Player*> /*players*/, Team /*team*/) {}
// Called when a creature or gameobject is created // Called when a creature is created
virtual void HandleCreatureCreate(Creature* /*creature*/) {} virtual void HandleCreatureCreate(Creature* /*creature*/) {}
virtual void HandleGameObjectCreate(GameObject* /*go*/) {}
// Called when a gameobject is created or removed
virtual void HandleGameObjectCreate(GameObject* /*go*/);
virtual void HandleGameObjectRemove(GameObject* /*go*/);
// Called on creature death // Called on creature death
virtual void HandleCreatureDeath(Creature* /*creature*/) {} virtual void HandleCreatureDeath(Creature* /*creature*/) {}

View file

@ -109,6 +109,8 @@ void OutdoorPvPEP::HandleCreatureCreate(Creature* creature)
void OutdoorPvPEP::HandleGameObjectCreate(GameObject* go) void OutdoorPvPEP::HandleGameObjectCreate(GameObject* go)
{ {
OutdoorPvP::HandleGameObjectCreate(go);
switch (go->GetEntry()) switch (go->GetEntry())
{ {
case GO_TOWER_BANNER_NORTHPASS: case GO_TOWER_BANNER_NORTHPASS:

View file

@ -63,6 +63,8 @@ void OutdoorPvPGH::HandleCreatureDeath(Creature* creature)
void OutdoorPvPGH::HandleGameObjectCreate(GameObject* go) void OutdoorPvPGH::HandleGameObjectCreate(GameObject* go)
{ {
OutdoorPvP::HandleGameObjectCreate(go);
if (go->GetEntry() == GO_VENTURE_BAY_LIGHTHOUSE) if (go->GetEntry() == GO_VENTURE_BAY_LIGHTHOUSE)
{ {
m_capturePoint = go->GetObjectGuid(); m_capturePoint = go->GetObjectGuid();
@ -137,8 +139,9 @@ void OutdoorPvPGH::LockLighthouse(const WorldObject* objRef)
{ {
if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint)) if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint))
go->SetLootState(GO_JUST_DEACTIVATED); go->SetLootState(GO_JUST_DEACTIVATED);
else
sOutdoorPvPMgr.SetCapturePointSlider(m_capturePoint, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE_LOCKED : CAPTURE_SLIDER_HORDE_LOCKED); // if grid is unloaded, changing the saved slider value is enough
sOutdoorPvPMgr.SetCapturePointSlider(GO_VENTURE_BAY_LIGHTHOUSE, m_zoneOwner == ALLIANCE ? -CAPTURE_SLIDER_ALLIANCE : -CAPTURE_SLIDER_HORDE);
} }
// Handle Lighthouse unlock when the commander is killed // Handle Lighthouse unlock when the commander is killed
@ -146,8 +149,7 @@ void OutdoorPvPGH::UnlockLighthouse(const WorldObject* objRef)
{ {
if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint)) if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint))
go->SetCapturePointSlider(m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE); go->SetCapturePointSlider(m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE);
// no banner visual update needed because it already has the correct one
else else
// if grid is unloaded, resetting the slider value is enough // if grid is unloaded, resetting the saved slider value is enough
sOutdoorPvPMgr.SetCapturePointSlider(m_capturePoint, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE); sOutdoorPvPMgr.SetCapturePointSlider(GO_VENTURE_BAY_LIGHTHOUSE, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE);
} }

View file

@ -80,6 +80,8 @@ void OutdoorPvPHP::HandlePlayerLeaveZone(Player* player, bool isMainZone)
void OutdoorPvPHP::HandleGameObjectCreate(GameObject* go) void OutdoorPvPHP::HandleGameObjectCreate(GameObject* go)
{ {
OutdoorPvP::HandleGameObjectCreate(go);
switch (go->GetEntry()) switch (go->GetEntry())
{ {
case GO_TOWER_BANNER_OVERLOOK: case GO_TOWER_BANNER_OVERLOOK:

View file

@ -19,7 +19,6 @@
#include "OutdoorPvPMgr.h" #include "OutdoorPvPMgr.h"
#include "Policies/SingletonImp.h" #include "Policies/SingletonImp.h"
#include "OutdoorPvP.h" #include "OutdoorPvP.h"
#include "GameObject.h"
#include "World.h" #include "World.h"
#include "Log.h" #include "Log.h"
#include "OutdoorPvPEP.h" #include "OutdoorPvPEP.h"
@ -170,14 +169,14 @@ void OutdoorPvPMgr::Update(uint32 diff)
Function that gets the capture point slider value Function that gets the capture point slider value
@param capture point entry @param capture point entry
@param default value being returned if no saved value for the capture point was found
*/ */
int8 OutdoorPvPMgr::GetCapturePointSliderValue(uint32 entry) float OutdoorPvPMgr::GetCapturePointSliderValue(uint32 entry, float defaultValue)
{ {
std::map<uint32, int8>::iterator itr = m_capturePointSlider.find(entry); CapturePointSliderMap::const_iterator itr = m_capturePointSlider.find(entry);
if (itr != m_capturePointSlider.end()) if (itr != m_capturePointSlider.end())
return itr->second; return itr->second;
// return default value if we can't find any // return default value if we can't find any
return CAPTURE_SLIDER_NEUTRAL; return defaultValue;
} }

View file

@ -101,9 +101,9 @@ class OutdoorPvPMgr
void Update(uint32 diff); void Update(uint32 diff);
// Handle capture point stuff // Save and load capture point slider values
int8 GetCapturePointSliderValue(uint32 entry); float GetCapturePointSliderValue(uint32 entry, float defaultValue);
void SetCapturePointSlider(uint32 entry, int8 value) { m_capturePointSlider[entry] = value; } void SetCapturePointSlider(uint32 entry, float value) { m_capturePointSlider[entry] = value; }
private: private:
// return assigned outdoor pvp script // return assigned outdoor pvp script
@ -112,7 +112,9 @@ class OutdoorPvPMgr
// contains all outdoor pvp scripts // contains all outdoor pvp scripts
OutdoorPvP* m_scripts[MAX_OPVP_ID]; OutdoorPvP* m_scripts[MAX_OPVP_ID];
std::map<uint32 /*capture point entry*/, int8 /*slider value*/> m_capturePointSlider; typedef std::map<uint32 /*capture point entry*/, float /*slider value*/> CapturePointSliderMap;
CapturePointSliderMap m_capturePointSlider;
// update interval // update interval
ShortIntervalTimer m_updateTimer; ShortIntervalTimer m_updateTimer;

View file

@ -189,6 +189,8 @@ void OutdoorPvPNA::HandleCreatureDeath(Creature* creature)
void OutdoorPvPNA::HandleGameObjectCreate(GameObject* go) void OutdoorPvPNA::HandleGameObjectCreate(GameObject* go)
{ {
OutdoorPvP::HandleGameObjectCreate(go);
switch (go->GetEntry()) switch (go->GetEntry())
{ {
case GO_HALAA_BANNER: case GO_HALAA_BANNER:
@ -523,7 +525,7 @@ void OutdoorPvPNA::Update(uint32 diff)
// Handle soldiers respawn on timer - this will summon a replacement for the dead soldier // Handle soldiers respawn on timer - this will summon a replacement for the dead soldier
void OutdoorPvPNA::RespawnSoldier() void OutdoorPvPNA::RespawnSoldier()
{ {
for (GuidZoneMap::iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) for (GuidZoneMap::const_iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr)
{ {
// Find player who is in main zone (Nagrand) to get correct map reference // Find player who is in main zone (Nagrand) to get correct map reference
if (!itr->second) if (!itr->second)
@ -544,8 +546,9 @@ void OutdoorPvPNA::LockHalaa(const WorldObject* objRef)
{ {
if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint)) if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint))
go->SetLootState(GO_JUST_DEACTIVATED); go->SetLootState(GO_JUST_DEACTIVATED);
else
sOutdoorPvPMgr.SetCapturePointSlider(m_capturePoint, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE_LOCKED : CAPTURE_SLIDER_HORDE_LOCKED); // if grid is unloaded, changing the saved slider value is enough
sOutdoorPvPMgr.SetCapturePointSlider(GO_HALAA_BANNER, m_zoneOwner == ALLIANCE ? -CAPTURE_SLIDER_ALLIANCE : -CAPTURE_SLIDER_HORDE);
} }
// Unlock Halaa when all the soldiers are killed // Unlock Halaa when all the soldiers are killed
@ -553,8 +556,7 @@ void OutdoorPvPNA::UnlockHalaa(const WorldObject* objRef)
{ {
if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint)) if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint))
go->SetCapturePointSlider(m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE); go->SetCapturePointSlider(m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE);
// no banner visual update needed because it already has the correct one
else else
// if grid is unloaded, resetting the slider value is enough // if grid is unloaded, resetting the saved slider value is enough
sOutdoorPvPMgr.SetCapturePointSlider(m_capturePoint, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE); sOutdoorPvPMgr.SetCapturePointSlider(GO_HALAA_BANNER, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE);
} }

View file

@ -88,6 +88,8 @@ void OutdoorPvPTF::HandlePlayerLeaveZone(Player* player, bool isMainZone)
void OutdoorPvPTF::HandleGameObjectCreate(GameObject* go) void OutdoorPvPTF::HandleGameObjectCreate(GameObject* go)
{ {
OutdoorPvP::HandleGameObjectCreate(go);
switch (go->GetEntry()) switch (go->GetEntry())
{ {
case GO_TOWER_BANNER_WEST: case GO_TOWER_BANNER_WEST:
@ -283,7 +285,7 @@ void OutdoorPvPTF::UnlockZone()
SendUpdateWorldState(WORLD_STATE_TF_TOWER_COUNT_A, m_towersAlliance); SendUpdateWorldState(WORLD_STATE_TF_TOWER_COUNT_A, m_towersAlliance);
SendUpdateWorldState(WORLD_STATE_TF_TOWER_COUNT_H, m_towersHorde); SendUpdateWorldState(WORLD_STATE_TF_TOWER_COUNT_H, m_towersHorde);
for (GuidZoneMap::iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) for (GuidZoneMap::const_iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr)
{ {
// Find player who is in main zone (Terokkar Forest) to get correct map reference // Find player who is in main zone (Terokkar Forest) to get correct map reference
if (!itr->second) if (!itr->second)
@ -345,8 +347,9 @@ void OutdoorPvPTF::LockTowers(const WorldObject* objRef)
{ {
if (GameObject* go = objRef->GetMap()->GetGameObject(m_towerBanners[i])) if (GameObject* go = objRef->GetMap()->GetGameObject(m_towerBanners[i]))
go->SetLootState(GO_JUST_DEACTIVATED); go->SetLootState(GO_JUST_DEACTIVATED);
else
sOutdoorPvPMgr.SetCapturePointSlider(terokkarTowers[i], m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE_LOCKED : CAPTURE_SLIDER_HORDE_LOCKED); // if grid is unloaded, changing the saved slider value is enough
sOutdoorPvPMgr.SetCapturePointSlider(terokkarTowers[i], m_zoneOwner == ALLIANCE ? -CAPTURE_SLIDER_ALLIANCE : -CAPTURE_SLIDER_HORDE);
} }
} }
@ -357,11 +360,12 @@ void OutdoorPvPTF::ResetTowers(const WorldObject* objRef)
{ {
if (GameObject* go = objRef->GetMap()->GetGameObject(m_towerBanners[i])) if (GameObject* go = objRef->GetMap()->GetGameObject(m_towerBanners[i]))
{ {
go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); go->SetCapturePointSlider(CAPTURE_SLIDER_MIDDLE);
// visual update needed because banner still has artkit from previous owner
SetBannerVisual(go, CAPTURE_ARTKIT_NEUTRAL, CAPTURE_ANIM_NEUTRAL); SetBannerVisual(go, CAPTURE_ARTKIT_NEUTRAL, CAPTURE_ANIM_NEUTRAL);
} }
else else
// if grid is unloaded, resetting the slider value is enough // if grid is unloaded, resetting the saved slider value is enough
sOutdoorPvPMgr.SetCapturePointSlider(terokkarTowers[i], CAPTURE_SLIDER_NEUTRAL); sOutdoorPvPMgr.SetCapturePointSlider(terokkarTowers[i], CAPTURE_SLIDER_MIDDLE);
} }
} }

View file

@ -117,6 +117,8 @@ void OutdoorPvPZM::HandleCreatureCreate(Creature* creature)
void OutdoorPvPZM::HandleGameObjectCreate(GameObject* go) void OutdoorPvPZM::HandleGameObjectCreate(GameObject* go)
{ {
OutdoorPvP::HandleGameObjectCreate(go);
switch (go->GetEntry()) switch (go->GetEntry())
{ {
case GO_ZANGA_BANNER_EAST: case GO_ZANGA_BANNER_EAST:

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "12164" #define REVISION_NR "12165"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__