*Allow players to capture siege workshops in wintergrasp.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-12 08:51:51 -05:00
parent cd78172c7d
commit 99eafd6a52
11 changed files with 216 additions and 116 deletions

View File

@@ -1392,6 +1392,10 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
if (!goinfo)
return 0;
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(mapId));
if(!map)
return 0;
uint32 guid = GenerateLowGuid(HIGHGUID_GAMEOBJECT);
GameObjectData& data = NewGOData(guid);
data.id = entry;
@@ -1414,22 +1418,21 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
AddGameobjectToGrid(guid, &data);
// Spawn if necessary (loaded grids only)
if(Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(mapId)))
// We use spawn coords to spawn
if(!map->Instanceable() && !map->IsRemovalGrid(x, y))
{
// We use spawn coords to spawn
if(!map->Instanceable() && !map->IsRemovalGrid(x, y))
GameObject *go = new GameObject;
if(!go->LoadFromDB(guid, map))
{
GameObject *go = new GameObject;
if(!go->LoadFromDB(guid, map))
{
sLog.outError("AddGameObject: cannot add gameobject entry %u to map", entry);
delete go;
return 0;
}
map->Add(go);
sLog.outError("AddGOData: cannot add gameobject entry %u to map", entry);
delete go;
return 0;
}
map->Add(go);
}
sLog.outDebug("AddGOData: dbguid %u entry %u map %u x %f y %f z %f o %f", guid, entry, mapId, x, y, z, o);
return guid;
}

View File

@@ -32,22 +32,43 @@
#include "CellImpl.h"
OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP * pvp)
: m_PvP(pvp), m_ShiftPhase(0), m_ShiftMaxPhase(0), m_OldPhase(0),
m_State(0), m_OldState(0), m_CapturePointGUID(0), m_NeutralValue(0),
m_ShiftMaxCaptureSpeed(0), m_capturePoint(NULL)
: m_PvP(pvp), m_value(0), m_maxValue(0), m_oldValue(0),
m_State(0), m_OldState(0), m_CapturePointGUID(0), m_neutralValuePct(0),
m_maxSpeed(0), m_capturePoint(NULL)
{
}
bool OPvPCapturePoint::HandlePlayerEnter(Player * plr)
{
if(m_capturePoint)
{
plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f));
plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct);
}
return m_activePlayers[plr->GetTeamId()].insert(plr).second;
}
void OPvPCapturePoint::HandlePlayerLeave(Player * plr)
{
if(m_capturePoint)
plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 0);
m_activePlayers[plr->GetTeamId()].erase(plr);
}
void OPvPCapturePoint::SendChangePhase()
{
if(!m_capturePoint)
return;
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
// send these updates to only the ones in this objective
SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f));
// send this too, sometimes it resets :S
SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct);
}
void OPvPCapturePoint::AddGO(uint32 type, uint32 guid, uint32 entry)
{
if(!entry)
@@ -113,9 +134,10 @@ bool OPvPCapturePoint::AddCapturePoint(uint32 entry, uint32 map, float x, float
return false;
// get the needed values from goinfo
m_ShiftMaxPhase = goinfo->capturePoint.maxTime;
m_ShiftMaxCaptureSpeed = m_ShiftMaxPhase / float(goinfo->capturePoint.minTime);
m_NeutralValue = goinfo->capturePoint.neutralPercent;
m_maxValue = goinfo->capturePoint.maxTime;
m_maxSpeed = m_maxValue / (goinfo->capturePoint.minTime ? goinfo->capturePoint.minTime : 60);
m_neutralValuePct = goinfo->capturePoint.neutralPercent;
m_minValue = m_maxValue * goinfo->capturePoint.neutralPercent / 100;
return true;
}
@@ -281,55 +303,51 @@ bool OPvPCapturePoint::Update(uint32 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_ShiftPhase <= -m_ShiftMaxPhase)
if(m_State == OBJECTIVESTATE_HORDE && m_value <= -m_maxValue)
return false;
if(fact_diff < -m_ShiftMaxCaptureSpeed)
fact_diff = -m_ShiftMaxCaptureSpeed;
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_ShiftPhase >= m_ShiftMaxPhase)
if(m_State == OBJECTIVESTATE_ALLIANCE && m_value >= m_maxValue)
return false;
if(fact_diff > m_ShiftMaxCaptureSpeed)
fact_diff = m_ShiftMaxCaptureSpeed;
if(fact_diff > maxDiff)
fact_diff = maxDiff;
Challenger = ALLIANCE;
}
m_OldPhase = m_ShiftPhase;
m_oldValue = m_value;
m_OldState = m_State;
m_ShiftPhase += fact_diff;
m_value += fact_diff;
// check limits, these are over the grey part
if(m_ShiftPhase < -m_ShiftMaxPhase * (float)(m_NeutralValue) / 100.0f)
if(m_value < -m_minValue) // red
{
if(m_ShiftPhase < -m_ShiftMaxPhase)
m_ShiftPhase = -m_ShiftMaxPhase;
if(m_value < -m_maxValue)
m_value = -m_maxValue;
m_State = OBJECTIVESTATE_HORDE;
return true;
}
else if(m_ShiftPhase > m_ShiftMaxPhase * (float)(m_NeutralValue) / 100.0f)
else if(m_value > m_minValue) // blue
{
if(m_ShiftPhase > m_ShiftMaxPhase)
m_ShiftPhase = m_ShiftMaxPhase;
if(m_value > m_maxValue)
m_value = m_maxValue;
m_State = OBJECTIVESTATE_ALLIANCE;
return true;
}
if(m_OldPhase*m_ShiftPhase <=0)
else if(m_oldValue * m_value <= 0) // grey, go through mid point
{
// gone through neutral
// if challenger is ally, then n->a challenge
if(Challenger == ALLIANCE)
m_State = OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE;
@@ -337,7 +355,7 @@ bool OPvPCapturePoint::Update(uint32 diff)
else if(Challenger == HORDE)
m_State = OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE;
}
else
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))
@@ -346,9 +364,12 @@ bool OPvPCapturePoint::Update(uint32 diff)
m_State = OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE;
}
if(m_ShiftPhase != m_OldPhase)
if(m_value != m_oldValue)
SendChangePhase();
//if(m_OldState != m_State)
// sLog.outError("%u->%u", m_OldState, m_State);
return m_OldState != m_State;
}
@@ -569,6 +590,11 @@ void OutdoorPvP::OnGameObjectCreate(GameObject *go, bool add)
return;
for(OutdoorPvP::OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
{
if((*itr)->m_CapturePointGUID == go->GetDBTableGUIDLow())
{
(*itr)->m_capturePoint = add ? go : NULL;
break;
}
}
}

View File

@@ -80,9 +80,9 @@ public:
virtual void FillInitialWorldStates(WorldPacket & data) {}
// send world state update to all players present
virtual void SendUpdateWorldState(uint32 field, uint32 value);
void SendUpdateWorldState(uint32 field, uint32 value);
// send kill notify to players in the controlling faction
virtual void SendObjectiveComplete(uint32 id, uint64 guid);
void SendObjectiveComplete(uint32 id, uint64 guid);
// used when player is activated/inactivated in the area
virtual bool HandlePlayerEnter(Player * plr);
@@ -98,7 +98,7 @@ public:
// returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update.
virtual bool Update(uint32 diff);
virtual void ChangeState() = 0;
virtual void SendChangePhase() {}
virtual void SendChangePhase();
virtual bool HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid);
@@ -128,18 +128,19 @@ protected:
// active players in the area of the objective, 0 - alliance, 1 - horde
PlayerSet m_activePlayers[2];
// total shift needed to capture the objective
float m_ShiftMaxPhase;
float m_maxValue;
float m_minValue;
// maximum speed of capture
float m_ShiftMaxCaptureSpeed;
float m_maxSpeed;
// the status of the objective
float m_ShiftPhase;
float m_value;
// phase before update, used to check which faction is in conquer / control
float m_OldPhase;
float m_oldValue;
// objective states
uint32 m_OldState;
uint32 m_State;
// neutral value on capture bar
uint32 m_NeutralValue;
uint32 m_neutralValuePct;
// pointer to the OutdoorPvP this objective belongs to
OutdoorPvP* m_PvP;

View File

@@ -37,7 +37,7 @@ OPvPCapturePointEP_EWT::OPvPCapturePointEP_EWT(OutdoorPvP *pvp)
void OPvPCapturePointEP_EWT::ChangeState()
{
if(fabs(m_ShiftPhase) == m_ShiftMaxPhase) // state won't change, only phase when maxed out!
if(fabs(m_value) == m_maxValue) // state won't change, only phase when maxed out!
{
// if changing from controlling alliance to horde or vice versa
if( m_OldState == OBJECTIVESTATE_ALLIANCE && m_OldState != m_State )
@@ -56,7 +56,7 @@ void OPvPCapturePointEP_EWT::ChangeState()
switch(m_State)
{
case OBJECTIVESTATE_ALLIANCE:
if(m_ShiftPhase == m_ShiftMaxPhase)
if(m_value == m_maxValue)
m_TowerState = EP_TS_A;
else
m_TowerState = EP_TS_A_P;
@@ -66,7 +66,7 @@ void OPvPCapturePointEP_EWT::ChangeState()
if(m_OldState != m_State) sWorld.SendZoneText(EP_GraveYardZone,objmgr.GetTrinityStringForDBCLocale(LANG_OPVP_EP_CAPTURE_EWT_A));
break;
case OBJECTIVESTATE_HORDE:
if(m_ShiftPhase == -m_ShiftMaxPhase)
if(m_value == -m_maxValue)
m_TowerState = EP_TS_H;
else
m_TowerState = EP_TS_H_P;
@@ -115,10 +115,10 @@ void OPvPCapturePointEP_EWT::SendChangePhase()
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(EP_UI_TOWER_SLIDER_DISPLAY, 1);
// send these updates to only the ones in this objective
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
SendUpdateWorldState(EP_UI_TOWER_SLIDER_POS, phase);
// send this too, sometimes it resets :S
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_neutralValuePct);
}
void OPvPCapturePointEP_EWT::FillInitialWorldStates(WorldPacket &data)
@@ -148,9 +148,9 @@ bool OPvPCapturePointEP_EWT::HandlePlayerEnter(Player *plr)
if(OPvPCapturePoint::HandlePlayerEnter(plr))
{
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_DISPLAY, 1);
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_POS, phase);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_neutralValuePct);
return true;
}
return false;
@@ -191,7 +191,7 @@ OPvPCapturePointEP_NPT::OPvPCapturePointEP_NPT(OutdoorPvP *pvp)
void OPvPCapturePointEP_NPT::ChangeState()
{
if(fabs(m_ShiftPhase) == m_ShiftMaxPhase) // state won't change, only phase when maxed out!
if(fabs(m_value) == m_maxValue) // state won't change, only phase when maxed out!
{
// if changing from controlling alliance to horde or vice versa
if( m_OldState == OBJECTIVESTATE_ALLIANCE && m_OldState != m_State )
@@ -210,7 +210,7 @@ void OPvPCapturePointEP_NPT::ChangeState()
switch(m_State)
{
case OBJECTIVESTATE_ALLIANCE:
if(m_ShiftPhase == m_ShiftMaxPhase)
if(m_value == m_maxValue)
m_TowerState = EP_TS_A;
else
m_TowerState = EP_TS_A_P;
@@ -220,7 +220,7 @@ void OPvPCapturePointEP_NPT::ChangeState()
if(m_OldState != m_State) sWorld.SendZoneText(EP_GraveYardZone,objmgr.GetTrinityStringForDBCLocale(LANG_OPVP_EP_CAPTURE_NPT_A));
break;
case OBJECTIVESTATE_HORDE:
if(m_ShiftPhase == -m_ShiftMaxPhase)
if(m_value == -m_maxValue)
m_TowerState = EP_TS_H;
else
m_TowerState = EP_TS_H_P;
@@ -270,10 +270,10 @@ void OPvPCapturePointEP_NPT::SendChangePhase()
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(EP_UI_TOWER_SLIDER_DISPLAY, 1);
// send these updates to only the ones in this objective
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
SendUpdateWorldState(EP_UI_TOWER_SLIDER_POS, phase);
// send this too, sometimes it resets :S
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_neutralValuePct);
}
void OPvPCapturePointEP_NPT::FillInitialWorldStates(WorldPacket &data)
@@ -303,9 +303,9 @@ bool OPvPCapturePointEP_NPT::HandlePlayerEnter(Player *plr)
if(OPvPCapturePoint::HandlePlayerEnter(plr))
{
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_DISPLAY, 1);
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_POS, phase);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_neutralValuePct);
return true;
}
return false;
@@ -340,7 +340,7 @@ OPvPCapturePointEP_CGT::OPvPCapturePointEP_CGT(OutdoorPvP *pvp)
void OPvPCapturePointEP_CGT::ChangeState()
{
if(fabs(m_ShiftPhase) == m_ShiftMaxPhase) // state won't change, only phase when maxed out!
if(fabs(m_value) == m_maxValue) // state won't change, only phase when maxed out!
{
// if changing from controlling alliance to horde or vice versa
if( m_OldState == OBJECTIVESTATE_ALLIANCE && m_OldState != m_State )
@@ -359,7 +359,7 @@ void OPvPCapturePointEP_CGT::ChangeState()
switch(m_State)
{
case OBJECTIVESTATE_ALLIANCE:
if(m_ShiftPhase == m_ShiftMaxPhase)
if(m_value == m_maxValue)
m_TowerState = EP_TS_A;
else
m_TowerState = EP_TS_A_P;
@@ -369,7 +369,7 @@ void OPvPCapturePointEP_CGT::ChangeState()
if(m_OldState != m_State) sWorld.SendZoneText(EP_GraveYardZone,objmgr.GetTrinityStringForDBCLocale(LANG_OPVP_EP_CAPTURE_CGT_A));
break;
case OBJECTIVESTATE_HORDE:
if(m_ShiftPhase == -m_ShiftMaxPhase)
if(m_value == -m_maxValue)
m_TowerState = EP_TS_H;
else
m_TowerState = EP_TS_H_P;
@@ -417,10 +417,10 @@ void OPvPCapturePointEP_CGT::SendChangePhase()
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(EP_UI_TOWER_SLIDER_DISPLAY, 1);
// send these updates to only the ones in this objective
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
SendUpdateWorldState(EP_UI_TOWER_SLIDER_POS, phase);
// send this too, sometimes it resets :S
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_neutralValuePct);
}
void OPvPCapturePointEP_CGT::FillInitialWorldStates(WorldPacket &data)
@@ -450,9 +450,9 @@ bool OPvPCapturePointEP_CGT::HandlePlayerEnter(Player *plr)
if(OPvPCapturePoint::HandlePlayerEnter(plr))
{
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_DISPLAY, 1);
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_POS, phase);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_neutralValuePct);
return true;
}
return false;
@@ -484,7 +484,7 @@ OPvPCapturePointEP_PWT::OPvPCapturePointEP_PWT(OutdoorPvP *pvp)
void OPvPCapturePointEP_PWT::ChangeState()
{
if(fabs(m_ShiftPhase) == m_ShiftMaxPhase) // state won't change, only phase when maxed out!
if(fabs(m_value) == m_maxValue) // state won't change, only phase when maxed out!
{
// if changing from controlling alliance to horde or vice versa
if( m_OldState == OBJECTIVESTATE_ALLIANCE && m_OldState != m_State )
@@ -503,7 +503,7 @@ void OPvPCapturePointEP_PWT::ChangeState()
switch(m_State)
{
case OBJECTIVESTATE_ALLIANCE:
if(m_ShiftPhase == m_ShiftMaxPhase)
if(m_value == m_maxValue)
m_TowerState = EP_TS_A;
else
m_TowerState = EP_TS_A_P;
@@ -513,7 +513,7 @@ void OPvPCapturePointEP_PWT::ChangeState()
if(m_OldState != m_State) sWorld.SendZoneText(EP_GraveYardZone,objmgr.GetTrinityStringForDBCLocale(LANG_OPVP_EP_CAPTURE_PWT_A));
break;
case OBJECTIVESTATE_HORDE:
if(m_ShiftPhase == -m_ShiftMaxPhase)
if(m_value == -m_maxValue)
m_TowerState = EP_TS_H;
else
m_TowerState = EP_TS_H_P;
@@ -563,10 +563,10 @@ void OPvPCapturePointEP_PWT::SendChangePhase()
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(EP_UI_TOWER_SLIDER_DISPLAY, 1);
// send these updates to only the ones in this objective
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
SendUpdateWorldState(EP_UI_TOWER_SLIDER_POS, phase);
// send this too, sometimes it resets :S
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_neutralValuePct);
}
void OPvPCapturePointEP_PWT::FillInitialWorldStates(WorldPacket &data)
@@ -596,9 +596,9 @@ bool OPvPCapturePointEP_PWT::HandlePlayerEnter(Player *plr)
if(OPvPCapturePoint::HandlePlayerEnter(plr))
{
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_DISPLAY, 1);
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_POS, phase);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
plr->SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_neutralValuePct);
return true;
}
return false;

View File

@@ -268,9 +268,9 @@ void OPvPCapturePointHP::ChangeState()
void OPvPCapturePointHP::SendChangePhase()
{
SendUpdateWorldState(HP_UI_TOWER_SLIDER_N, m_NeutralValue);
SendUpdateWorldState(HP_UI_TOWER_SLIDER_N, m_neutralValuePct);
// send these updates to only the ones in this objective
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
SendUpdateWorldState(HP_UI_TOWER_SLIDER_POS, phase);
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(HP_UI_TOWER_SLIDER_DISPLAY, 1);
@@ -308,9 +308,9 @@ bool OPvPCapturePointHP::HandlePlayerEnter(Player *plr)
if(OPvPCapturePoint::HandlePlayerEnter(plr))
{
plr->SendUpdateWorldState(HP_UI_TOWER_SLIDER_DISPLAY, 1);
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
plr->SendUpdateWorldState(HP_UI_TOWER_SLIDER_POS, phase);
plr->SendUpdateWorldState(HP_UI_TOWER_SLIDER_N, m_NeutralValue);
plr->SendUpdateWorldState(HP_UI_TOWER_SLIDER_N, m_neutralValuePct);
return true;
}
return false;

View File

@@ -188,9 +188,9 @@ bool OPvPCapturePointNA::HandlePlayerEnter(Player *plr)
if(OPvPCapturePoint::HandlePlayerEnter(plr))
{
plr->SendUpdateWorldState(NA_UI_TOWER_SLIDER_DISPLAY, 1);
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
plr->SendUpdateWorldState(NA_UI_TOWER_SLIDER_POS, phase);
plr->SendUpdateWorldState(NA_UI_TOWER_SLIDER_N, m_NeutralValue);
plr->SendUpdateWorldState(NA_UI_TOWER_SLIDER_N, m_neutralValuePct);
return true;
}
return false;
@@ -619,9 +619,9 @@ void OPvPCapturePointNA::SendChangePhase()
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(NA_UI_TOWER_SLIDER_DISPLAY, 1);
// send these updates to only the ones in this objective
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
SendUpdateWorldState(NA_UI_TOWER_SLIDER_POS, phase);
SendUpdateWorldState(NA_UI_TOWER_SLIDER_N, m_NeutralValue);
SendUpdateWorldState(NA_UI_TOWER_SLIDER_N, m_neutralValuePct);
}
void OPvPCapturePointNA::UpdateHalaaWorldState()

View File

@@ -104,9 +104,9 @@ bool OPvPCapturePointTF::HandlePlayerEnter(Player *plr)
if(OPvPCapturePoint::HandlePlayerEnter(plr))
{
plr->SendUpdateWorldState(TF_UI_TOWER_SLIDER_DISPLAY, 1);
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
plr->SendUpdateWorldState(TF_UI_TOWER_SLIDER_POS, phase);
plr->SendUpdateWorldState(TF_UI_TOWER_SLIDER_N, m_NeutralValue);
plr->SendUpdateWorldState(TF_UI_TOWER_SLIDER_N, m_neutralValuePct);
return true;
}
return false;
@@ -301,9 +301,9 @@ void OPvPCapturePointTF::SendChangePhase()
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(TF_UI_TOWER_SLIDER_DISPLAY, 1);
// send these updates to only the ones in this objective
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
SendUpdateWorldState(TF_UI_TOWER_SLIDER_POS, phase);
// send this too, sometimes it resets :S
SendUpdateWorldState(TF_UI_TOWER_SLIDER_N, m_NeutralValue);
SendUpdateWorldState(TF_UI_TOWER_SLIDER_N, m_neutralValuePct);
}

View File

@@ -57,9 +57,9 @@ bool OPvPCapturePointZM_Beacon::HandlePlayerEnter(Player *plr)
if(OPvPCapturePoint::HandlePlayerEnter(plr))
{
plr->SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_disp, 1);
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
plr->SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_pos, phase);
plr->SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_n, m_NeutralValue);
plr->SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_n, m_neutralValuePct);
return true;
}
return false;
@@ -119,9 +119,9 @@ void OPvPCapturePointZM_Beacon::SendChangePhase()
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_disp, 1);
// send these updates to only the ones in this objective
uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f);
uint32 phase = (uint32)ceil(( m_value + m_maxValue) / ( 2 * m_maxValue ) * 100.0f);
SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_pos, phase);
SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_n, m_NeutralValue);
SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_n, m_neutralValuePct);
}
bool OutdoorPvPZM::Update(uint32 diff)

View File

@@ -6544,7 +6544,7 @@ void Player::CheckDuelDistance(time_t currTime)
bool Player::IsOutdoorPvPActive()
{
return (isAlive() && !HasInvisibilityAura() && !HasStealthAura() && (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP) || sWorld.IsPvPRealm()) && !HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && !isInFlight());
return (isAlive() && !HasInvisibilityAura() && !HasStealthAura() && (IsPvP() || sWorld.IsPvPRealm()) && !HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && !isInFlight());
}
void Player::DuelComplete(DuelCompleteType type)

View File

@@ -25,10 +25,16 @@
typedef uint32 TeamPair[2];
enum CreatureEntry
{
CRE_ENG_A = 30499,
CRE_ENG_H = 30400,
};
const TeamPair CreatureEntryPair[] =
{
{30739, 30740},
{30400, 30499},
//{30400, 30499},
{0,0}
};
@@ -56,39 +62,69 @@ typedef std::list<const AreaPOIEntry *> AreaPOIList;
SiegeWorkshop::SiegeWorkshop(OPvPWintergrasp *opvp, BuildingState *state)
: OPvPCapturePoint(opvp), m_buildingState(state), m_wintergrasp(opvp)
, m_vehNum(0)
, m_vehNum(0), m_engineer(NULL), m_engGuid(0)
{
}
void SiegeWorkshop::SetStateByBuildingState()
{
if(m_buildingState->team == TEAM_ALLIANCE)
{
m_value = m_maxValue;
m_State = OBJECTIVESTATE_ALLIANCE;
}
else if(m_buildingState->team == TEAM_HORDE)
{
m_value = -m_maxValue;
m_State = OBJECTIVESTATE_HORDE;
}
else
{
m_value = 0;
m_State = OBJECTIVESTATE_NEUTRAL;
}
ChangeState();
SendChangePhase();
}
void SiegeWorkshop::ChangeState()
{
Creature *creature = ObjectAccessor::GetObjectInWorld(m_Creatures[0], (Creature*)NULL);
if(!creature)
return;
uint32 entry = 0;
if(m_State == OBJECTIVESTATE_ALLIANCE)
if(m_State == OBJECTIVESTATE_ALLIANCE) // to do m_buildingState->team == TEAM_ALLIANCE;
{
m_buildingState->team = TEAM_ALLIANCE;
entry = 30499;
entry = CRE_ENG_A;
}
else if(m_State == OBJECTIVESTATE_HORDE)
{
m_buildingState->team = TEAM_HORDE;
entry = 30400;
entry = CRE_ENG_H;
}
else
return;
*m_engEntry = entry;
// TODO: this may be sent twice
m_wintergrasp->BroadcastStateChange(m_buildingState);
if(entry != creature->GetEntry())
// does not work, entry may change
/*Creature *creature = ObjectAccessor::GetObjectInWorld(m_Creatures[0], (Creature*)NULL);
if(!creature)
{
creature->SetOriginalEntry(entry);
creature->Respawn(true);
sLog.outError("SiegeWorkshop::ChangeState cannot find creature " I64FMT " !", m_Creatures[0]);
return;
}*/
if(m_engineer)
{
m_engineer->SetOriginalEntry(entry);
if(entry != m_engineer->GetEntry() || !m_engineer->isAlive())
m_engineer->Respawn(true);
}
else if(!creature->isAlive())
creature->Respawn(true);
sLog.outDebug("Wintergrasp workshop now belongs to %u.", (uint32)m_buildingState->team);
}
bool OPvPWintergrasp::SetupOutdoorPvP()
@@ -156,7 +192,7 @@ bool OPvPWintergrasp::SetupOutdoorPvP()
areaPOIs.erase(poi);
//disable for now
continue;
//continue;
// add capture point
uint32 capturePointEntry = 0;
@@ -184,7 +220,7 @@ bool OPvPWintergrasp::SetupOutdoorPvP()
QueryResult *result = WorldDatabase.PQuery("SELECT `guid` FROM `creature`"
" WHERE `creature`.`map`=571"
" AND `creature`.`id` IN (30400, 30499);");
" AND `creature`.`id` IN (%u, %u);", CRE_ENG_A, CRE_ENG_H);
if(!result)
{
@@ -217,16 +253,24 @@ bool OPvPWintergrasp::SetupOutdoorPvP()
}
SiegeWorkshop *workshop = new SiegeWorkshop(this, m_buildingStates[guid]);
if(!workshop->AddCapturePoint(capturePointEntry, goData->id, goData->posX, goData->posY, goData->posZ))
if(!workshop->AddCapturePoint(capturePointEntry, goData->mapid, goData->posX, goData->posY, goData->posZ))
{
delete workshop;
sLog.outError("Cannot add capture point!");
continue;
}
const CreatureData *creData = objmgr.GetCreatureData(engGuid);
if(!creData)
continue;
workshop->m_engEntry = const_cast<uint32*>(&creData->id);
const_cast<CreatureData*>(creData)->displayid = 0;
workshop->AddGO(0, guid, goData->id);
workshop->AddCre(0, engGuid);
workshop->m_engGuid = engGuid;
//workshop->AddCre(0, engGuid, creData->id);
//sLog.outDebug("Demolisher Engineerer lowguid %u is linked to workshop lowguid %u.", engGuid, guid);
m_capturePoints.push_back(workshop);
workshop->ChangeState();
workshop->SetStateByBuildingState();
}
}while(result->NextRow());
delete result;
@@ -286,7 +330,8 @@ uint32 OPvPWintergrasp::GetCreatureEntry(uint32 guidlow, const CreatureData *dat
void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
{
if(creature->isVehicle())
uint32 entry = creature->GetEntry();
if(creature->isVehicle()) // vehicles
{
TeamId team;
if(creature->getFaction() == WintergraspFaction[TEAM_ALLIANCE])
@@ -296,7 +341,7 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
else
return;
switch(creature->GetEntry())
switch(entry)
{
case 27881:
case 28094:
@@ -322,11 +367,21 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
break;
}
}
else if(m_creEntryPair.find(creature->GetEntry()) != m_creEntryPair.end())
else if(m_creEntryPair.find(entry) != m_creEntryPair.end()) // guards and npc
{
if(add) m_creatures.insert(creature);
else m_creatures.erase(creature);
}
else if(entry == CRE_ENG_A || entry == CRE_ENG_H) // demolisher engineers
{
for(OutdoorPvP::OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
if(SiegeWorkshop *workshop = dynamic_cast<SiegeWorkshop*>(*itr))
if(workshop->m_engGuid == creature->GetDBTableGUIDLow())
{
workshop->m_engineer = add ? creature : NULL;
break;
}
}
}
void OPvPWintergrasp::OnGameObjectCreate(GameObject *go, bool add)
@@ -361,13 +416,19 @@ void OPvPWintergrasp::OnGameObjectCreate(GameObject *go, bool add)
void OPvPWintergrasp::UpdateAllWorldObject()
{
// update cre and go factions
for(GameObjectSet::iterator itr = m_gobjects.begin(); itr != m_gobjects.end(); ++itr)
UpdateGameObjectInfo(*itr);
for(CreatureSet::iterator itr = m_creatures.begin(); itr != m_creatures.end(); ++itr)
UpdateCreatureInfo(*itr);
// rebuild and update building states
RebuildAllBuildings();
//if(GameObject *obj = ObjectAccessor::GetObjectInWorld(
// update capture points
for(OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
if(SiegeWorkshop *workshop = dynamic_cast<SiegeWorkshop*>(*itr))
workshop->SetStateByBuildingState();
SendInitWorldStatesTo();
}
@@ -571,7 +632,12 @@ void OPvPWintergrasp::VehicleCastSpell(TeamId team, int32 spellId)
bool OPvPWintergrasp::Update(uint32 diff)
{
if(m_timer > diff)
{
m_timer -= diff;
if(m_wartime)
OutdoorPvP::Update(diff); // update capture points
}
else
{
if(m_wartime)

View File

@@ -166,11 +166,15 @@ class SiegeWorkshop : public OPvPCapturePoint
{
public:
explicit SiegeWorkshop(OPvPWintergrasp *opvp, BuildingState *state);
void SetStateByBuildingState();
void ChangeState();
uint32 m_vehNum;
uint32 *m_engEntry;
uint32 m_engGuid;
Creature *m_engineer;
protected:
BuildingState *m_buildingState;
OPvPWintergrasp *m_wintergrasp;
uint32 m_vehNum;
};
#endif