*Display max veh number and capture point banner in wintergrasp.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-21 12:31:52 -05:00
parent 3f24bc9085
commit 49abc30089
11 changed files with 101 additions and 75 deletions

View File

@@ -133,7 +133,7 @@ void GameObject::RemoveFromWorld()
}
}
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 ArtKit)
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit)
{
ASSERT(map);
SetMap(map);
@@ -183,7 +183,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
SetGoAnimProgress(animprogress);
SetByteValue(GAMEOBJECT_BYTES_1, 2, ArtKit);
SetByteValue(GAMEOBJECT_BYTES_1, 2, artKit);
switch(goinfo->type)
{
@@ -570,7 +570,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
data.animprogress = GetGoAnimProgress();
data.go_state = GetGoState();
data.spawnMask = spawnMask;
data.ArtKit = GetGoArtKit();
data.artKit = GetGoArtKit();
// updated in DB
std::ostringstream ss;
@@ -623,12 +623,12 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
uint32 animprogress = data->animprogress;
GOState go_state = data->go_state;
uint32 ArtKit = data->ArtKit;
uint32 artKit = data->artKit;
m_DBTableGuid = guid;
if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
if (!Create(guid,entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, ArtKit) )
if (!Create(guid,entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, artKit) )
return false;
if(data->spawntimesecs >= 0)
@@ -915,7 +915,22 @@ void GameObject::SetGoArtKit(uint8 kit)
SetByteValue(GAMEOBJECT_BYTES_1, 2, kit);
GameObjectData *data = const_cast<GameObjectData*>(objmgr.GetGOData(m_DBTableGuid));
if(data)
data->ArtKit = kit;
data->artKit = kit;
}
void GameObject::SetGoArtKit(uint8 artkit, GameObject *go, uint32 lowguid)
{
const GameObjectData *data = NULL;
if(go)
{
go->SetGoArtKit(artkit);
data = go->GetGOData();
}
else if(lowguid)
data = objmgr.GetGOData(lowguid);
if(data)
const_cast<GameObjectData*>(data)->artKit = artkit;
}
void GameObject::SwitchDoorOrButton(bool activate, bool alternative /* = false */)

View File

@@ -551,7 +551,7 @@ struct GameObjectData
uint32 animprogress;
GOState go_state;
uint8 spawnMask;
uint8 ArtKit;
uint8 artKit;
bool dbData;
};
@@ -582,7 +582,7 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
void RemoveFromWorld();
void CleanupsBeforeDelete();
bool Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 ArtKit = 0);
bool Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit = 0);
void Update(uint32 p_time);
static GameObject* GetGameObject(WorldObject& object, uint64 guid);
GameObjectInfo const* GetGOInfo() const { return m_goInfo; }
@@ -666,6 +666,7 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
void SetGoArtKit(uint8 artkit);
uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
static void SetGoArtKit(uint8 artkit, GameObject *go, uint32 lowguid = 0);
void Use(Unit* user);

View File

@@ -1444,6 +1444,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
data.spawnMask = 1;
data.go_state = GO_STATE_READY;
data.phaseMask = PHASEMASK_NORMAL;
data.artKit = goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT ? 21 : 0;
data.dbData = false;
AddGameobjectToGrid(guid, &data);
@@ -1581,7 +1582,7 @@ void ObjectMgr::LoadGameobjects()
}
data.animprogress = fields[12].GetUInt32();
data.ArtKit = 0;
data.artKit = 0;
uint32 go_state = fields[13].GetUInt32();
if (go_state >= MAX_GO_STATE)

View File

@@ -32,8 +32,8 @@
#include "CellImpl.h"
OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP * pvp)
: m_PvP(pvp), m_value(0), m_maxValue(0), m_oldValue(0),
m_State(OBJECTIVESTATE_NEUTRAL), m_OldState(OBJECTIVESTATE_NEUTRAL), m_CapturePointGUID(0), m_neutralValuePct(0),
: m_PvP(pvp), m_value(0), m_maxValue(0), m_team(TEAM_NEUTRAL),
m_State(OBJECTIVESTATE_NEUTRAL), m_OldState(OBJECTIVESTATE_NEUTRAL), m_capturePointGUID(0), m_neutralValuePct(0),
m_maxSpeed(0), m_capturePoint(NULL)
{
}
@@ -129,8 +129,8 @@ bool OPvPCapturePoint::SetCapturePointData(uint32 entry, uint32 map, float x, fl
return false;
}
m_CapturePointGUID = objmgr.AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3);
if(!m_CapturePointGUID)
m_capturePointGUID = objmgr.AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3);
if(!m_capturePointGUID)
return false;
// get the needed values from goinfo
@@ -198,8 +198,8 @@ bool OPvPCapturePoint::DelObject(uint32 type)
bool OPvPCapturePoint::DelCapturePoint()
{
objmgr.DeleteGOData(m_CapturePointGUID);
m_CapturePointGUID = 0;
objmgr.DeleteGOData(m_capturePointGUID);
m_capturePointGUID = 0;
if(m_capturePoint)
{
@@ -257,10 +257,7 @@ bool OutdoorPvP::Update(uint32 diff)
for(OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
{
if(itr->second->Update(diff))
{
itr->second->ChangeState();
objective_changed = true;
}
}
return objective_changed;
}
@@ -328,7 +325,8 @@ bool OPvPCapturePoint::Update(uint32 diff)
Challenger = ALLIANCE;
}
m_oldValue = m_value;
float oldValue = m_value;
TeamId oldTeam = m_team;
m_OldState = m_State;
@@ -339,14 +337,16 @@ bool OPvPCapturePoint::Update(uint32 diff)
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(m_oldValue * m_value <= 0) // grey, go through mid point
else if(oldValue * m_value <= 0) // grey, go through mid point
{
// if challenger is ally, then n->a challenge
if(Challenger == ALLIANCE)
@@ -354,6 +354,7 @@ bool OPvPCapturePoint::Update(uint32 diff)
// 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
{
@@ -362,15 +363,22 @@ bool OPvPCapturePoint::Update(uint32 diff)
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 != m_oldValue)
if(m_value != oldValue)
SendChangePhase();
//if(m_OldState != m_State)
// sLog.outError("%u->%u", m_OldState, m_State);
if(m_OldState != m_State)
{
//sLog.outError("%u->%u", m_OldState, m_State);
if(oldTeam != m_team)
ChangeTeam(oldTeam);
ChangeState();
return true;
}
return m_OldState != m_State;
return false;
}
void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value)

View File

@@ -36,6 +36,8 @@ enum OutdoorPvPTypes
OPVP_WINTERGRASP,
};
const uint8 CapturePointArtKit[3] = {2, 1, 21};
enum ObjectiveStates
{
OBJECTIVESTATE_NEUTRAL = 0,
@@ -109,6 +111,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 ChangeTeam(TeamId oldTeam) {}
virtual void SendChangePhase();
virtual bool HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid);
@@ -119,7 +122,7 @@ public:
virtual void DeleteSpawns();
uint32 m_CapturePointGUID;
uint32 m_capturePointGUID;
GameObject *m_capturePoint;
void AddGO(uint32 type, uint32 guid, uint32 entry = 0);
@@ -145,8 +148,7 @@ protected:
float m_maxSpeed;
// the status of the objective
float m_value;
// phase before update, used to check which faction is in conquer / control
float m_oldValue;
TeamId m_team;
// objective states
ObjectiveStates m_OldState;
ObjectiveStates m_State;
@@ -236,7 +238,7 @@ protected:
void AddCapturePoint(OPvPCapturePoint* cp)
{
m_capturePoints[cp->m_CapturePointGUID] = cp;
m_capturePoints[cp->m_capturePointGUID] = cp;
}
OPvPCapturePoint * GetCapturePoint(uint32 lowguid) const

View File

@@ -88,7 +88,7 @@ void OPvPCapturePointEP_EWT::ChangeState()
break;
}
GameObject* flag = HashMapHolder<GameObject>::Find(m_CapturePointGUID);
GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID);
GameObject* flag2 = HashMapHolder<GameObject>::Find(m_Objects[EP_EWT_FLAGS]);
if(flag)
{
@@ -244,7 +244,7 @@ void OPvPCapturePointEP_NPT::ChangeState()
break;
}
GameObject* flag = HashMapHolder<GameObject>::Find(m_CapturePointGUID);
GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID);
GameObject* flag2 = HashMapHolder<GameObject>::Find(m_Objects[EP_NPT_FLAGS]);
if(flag)
{
@@ -391,7 +391,7 @@ void OPvPCapturePointEP_CGT::ChangeState()
break;
}
GameObject* flag = HashMapHolder<GameObject>::Find(m_CapturePointGUID);
GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID);
GameObject* flag2 = HashMapHolder<GameObject>::Find(m_Objects[EP_CGT_FLAGS]);
if(flag)
{
@@ -537,7 +537,7 @@ void OPvPCapturePointEP_PWT::ChangeState()
break;
}
GameObject* flag = HashMapHolder<GameObject>::Find(m_CapturePointGUID);
GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID);
GameObject* flag2 = HashMapHolder<GameObject>::Find(m_Objects[EP_PWT_FLAGS]);
if(flag)
{

View File

@@ -244,7 +244,7 @@ void OPvPCapturePointHP::ChangeState()
break;
}
GameObject* flag = HashMapHolder<GameObject>::Find(m_CapturePointGUID);
GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID);
GameObject* flag2 = HashMapHolder<GameObject>::Find(m_Objects[m_TowerType]);
if(flag)
{

View File

@@ -604,7 +604,7 @@ void OPvPCapturePointNA::ChangeState()
break;
}
GameObject* flag = HashMapHolder<GameObject>::Find(m_CapturePointGUID);
GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID);
if(flag)
{
flag->SetGoArtKit(artkit);

View File

@@ -286,7 +286,7 @@ void OPvPCapturePointTF::ChangeState()
break;
}
GameObject* flag = HashMapHolder<GameObject>::Find(m_CapturePointGUID);
GameObject* flag = HashMapHolder<GameObject>::Find(m_capturePointGUID);
if(flag)
{
flag->SetGoArtKit(artkit);

View File

@@ -201,8 +201,8 @@ bool OPvPWintergrasp::SetupOutdoorPvP()
continue;
}
SiegeWorkshop *workshop = new SiegeWorkshop(this, m_buildingStates[guid]);
if(!workshop->SetCapturePointData(capturePointEntry, goData->mapid, goData->posX, goData->posY, goData->posZ))
SiegeWorkshop *workshop = new SiegeWorkshop(this, m_buildingStates[guid]);
if(!workshop->SetCapturePointData(capturePointEntry, goData->mapid, goData->posX + 40 * cos(goData->orientation + M_PI / 2), goData->posY + 40 * sin(goData->orientation + M_PI / 2), goData->posZ))
{
delete workshop;
sLog.outError("Cannot add capture point!");
@@ -261,7 +261,8 @@ void OPvPWintergrasp::ProcessEvent(GameObject *obj, uint32 eventId)
{
if(obj->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED))
itr->second->damageState = DAMAGE_DAMAGED;
else
else if(obj->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED)
&& itr->second->damageState != DAMAGE_DESTROYED)
{
itr->second->damageState = DAMAGE_DESTROYED;
@@ -280,7 +281,6 @@ void OPvPWintergrasp::ProcessEvent(GameObject *obj, uint32 eventId)
void OPvPWintergrasp::ModifyWorkshopCount(TeamId team, bool add)
{
return;
if(add)
++m_workshopCount[team];
else if(m_workshopCount[team])
@@ -441,11 +441,14 @@ void OPvPWintergrasp::RebuildAllBuildings()
else
itr->second->health = 0;
if(itr->second->damageState == DAMAGE_DESTROYED)
{
if(itr->second->type == BUILDING_WORKSHOP)
ModifyWorkshopCount(itr->second->team, true);
}
itr->second->damageState = DAMAGE_INTACT;
itr->second->team = m_defender == TEAM_ALLIANCE ? OTHER_TEAM(itr->second->defaultTeam) : itr->second->defaultTeam;
if(itr->second->type == BUILDING_WORKSHOP)
ModifyWorkshopCount(itr->second->team, true);
}
}
@@ -821,43 +824,30 @@ void SiegeWorkshop::SetTeamByBuildingState()
m_State = OBJECTIVESTATE_NEUTRAL;
}
// this will force ChangeState to update workshop count
m_buildingState->team = TEAM_NEUTRAL;
if(m_team != m_buildingState->team)
{
TeamId oldTeam = m_team;
m_team = m_buildingState->team;
ChangeTeam(oldTeam);
}
ChangeState();
SendChangePhase();
}
void SiegeWorkshop::ChangeState()
void SiegeWorkshop::ChangeTeam(TeamId oldTeam)
{
uint32 entry = 0;
if(m_State == OBJECTIVESTATE_ALLIANCE) // to do m_buildingState->team == TEAM_ALLIANCE;
if(oldTeam != TEAM_NEUTRAL)
m_wintergrasp->ModifyWorkshopCount(oldTeam, false);
if(m_team != TEAM_NEUTRAL)
{
if(m_buildingState->team != TEAM_ALLIANCE)
{
if(m_buildingState->team == TEAM_HORDE)
m_wintergrasp->ModifyWorkshopCount(TEAM_HORDE, false);
m_buildingState->team = TEAM_ALLIANCE;
m_wintergrasp->ModifyWorkshopCount(TEAM_ALLIANCE, true);
}
entry = CRE_ENG_A;
entry = m_team == TEAM_ALLIANCE ? CRE_ENG_A : CRE_ENG_H;
m_wintergrasp->ModifyWorkshopCount(m_team, true);
}
else if(m_State == OBJECTIVESTATE_HORDE)
{
if(m_buildingState->team != TEAM_HORDE)
{
if(m_buildingState->team == TEAM_ALLIANCE)
m_wintergrasp->ModifyWorkshopCount(TEAM_ALLIANCE, false);
m_buildingState->team = TEAM_HORDE;
m_wintergrasp->ModifyWorkshopCount(TEAM_HORDE, true);
}
entry = CRE_ENG_H;
}
else
return;
*m_engEntry = entry;
GameObject::SetGoArtKit(CapturePointArtKit[m_team], m_capturePoint, m_capturePointGUID);
m_buildingState->team = m_team;
// TODO: this may be sent twice
m_wintergrasp->BroadcastStateChange(m_buildingState);
@@ -869,15 +859,23 @@ void SiegeWorkshop::ChangeState()
return;
}*/
if(m_engineer)
if(entry)
{
m_engineer->SetOriginalEntry(entry);
if(entry != m_engineer->GetEntry() || !m_engineer->isAlive())
*m_engEntry = entry;
if(m_engineer)
{
m_engineer->Respawn(true);
DespawnAllVehicles();
m_engineer->SetOriginalEntry(entry);
if(entry != m_engineer->GetEntry() || !m_engineer->isAlive())
{
m_engineer->Respawn(true);
DespawnAllVehicles();
}
m_engineer->SetVisibility(VISIBILITY_ON);
}
}
else if(m_engineer)
m_engineer->SetVisibility(VISIBILITY_OFF);
sLog.outDebug("Wintergrasp workshop now belongs to %u.", (uint32)m_buildingState->team);
}

View File

@@ -199,7 +199,8 @@ class SiegeWorkshop : public OPvPCapturePoint
public:
explicit SiegeWorkshop(OPvPWintergrasp *opvp, BuildingState *state);
void SetTeamByBuildingState();
void ChangeState();
void ChangeState() {}
void ChangeTeam(TeamId oldteam);
void DespawnAllVehicles();
bool CanBuildVehicle() const { return m_vehicles.size() < MAX_VEHICLE_PER_WORKSHOP && m_buildingState->damageState != DAMAGE_DESTROYED; }