aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-08-20 16:33:34 -0500
committermegamage <none@none>2009-08-20 16:33:34 -0500
commitf972a069359091091ddc6167e446dc5cd65e702f (patch)
treebfa91d02befc3e32f57d2e6e1e97caa903415c50 /src
parent5bde26a6a9d5dd6e5f7de2750fc6672cd4c5a11d (diff)
*Do not allow to build vehicles when workshop is destroyed.
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/scripts/northrend/wintergrasp.cpp5
-rw-r--r--src/game/Wintergrasp.cpp161
-rw-r--r--src/game/Wintergrasp.h3
3 files changed, 90 insertions, 79 deletions
diff --git a/src/bindings/scripts/scripts/northrend/wintergrasp.cpp b/src/bindings/scripts/scripts/northrend/wintergrasp.cpp
index 81f45738e4f..133138630b0 100644
--- a/src/bindings/scripts/scripts/northrend/wintergrasp.cpp
+++ b/src/bindings/scripts/scripts/northrend/wintergrasp.cpp
@@ -20,7 +20,10 @@
struct TRINITY_DLL_DECL npc_demolisher_engineererAI : public ScriptedAI
{
- npc_demolisher_engineererAI(Creature* pCreature) : ScriptedAI(pCreature) {}
+ npc_demolisher_engineererAI(Creature* pCreature) : ScriptedAI(pCreature)
+ {
+ me->SetReactState(REACT_PASSIVE);
+ }
/*
void JustDied(Unit *killer)
diff --git a/src/game/Wintergrasp.cpp b/src/game/Wintergrasp.cpp
index a6b633cfa21..a0c7b1da39c 100644
--- a/src/game/Wintergrasp.cpp
+++ b/src/game/Wintergrasp.cpp
@@ -72,82 +72,6 @@ void LoadTeamPair(TeamPairMap &pairMap, const TeamPair *pair)
typedef std::list<const AreaPOIEntry *> AreaPOIList;
-SiegeWorkshop::SiegeWorkshop(OPvPWintergrasp *opvp, BuildingState *state)
-: OPvPCapturePoint(opvp), m_buildingState(state), m_wintergrasp(opvp)
-, 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()
-{
- uint32 entry = 0;
- if(m_State == OBJECTIVESTATE_ALLIANCE) // to do m_buildingState->team == TEAM_ALLIANCE;
- {
- m_buildingState->team = TEAM_ALLIANCE;
- entry = CRE_ENG_A;
- }
- else if(m_State == OBJECTIVESTATE_HORDE)
- {
- m_buildingState->team = TEAM_HORDE;
- entry = CRE_ENG_H;
- }
- else
- return;
-
- *m_engEntry = entry;
-
- // TODO: this may be sent twice
- m_wintergrasp->BroadcastStateChange(m_buildingState);
-
- // does not work, entry may change
- /*Creature *creature = ObjectAccessor::GetObjectInWorld(m_Creatures[0], (Creature*)NULL);
- if(!creature)
- {
- 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);
- DespawnAllVehicles();
- }
- }
-
- sLog.outDebug("Wintergrasp workshop now belongs to %u.", (uint32)m_buildingState->team);
-}
-
-void SiegeWorkshop::DespawnAllVehicles()
-{
- while(!m_vehicles.empty())
- (*m_vehicles.begin())->Dismiss();
-}
-
bool OPvPWintergrasp::SetupOutdoorPvP()
{
m_defender = TeamId(rand()%2);
@@ -380,7 +304,7 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
{
if(add)
{
- if(m_wartime && workshop->m_vehicles.size() < MAX_VEHICLE_PER_WORKSHOP)
+ if(m_wartime && workshop->CanBuildVehicle())
workshop->m_vehicles.insert((Vehicle*)creature);
else
{
@@ -769,7 +693,7 @@ uint32 OPvPWintergrasp::GetData(uint32 id)
{
// if can build more vehicles
if(SiegeWorkshop *workshop = GetWorkshopByEngGuid(id))
- return m_wartime && workshop->m_vehicles.size() < MAX_VEHICLE_PER_WORKSHOP ? 1 : 0;
+ return m_wartime && workshop->CanBuildVehicle() ? 1 : 0;
return 0;
}
@@ -798,3 +722,84 @@ SiegeWorkshop *OPvPWintergrasp::GetWorkshopByGOGuid(uint32 lowguid) const
return workshop;
return NULL;
}
+
+/*######
+##SiegeWorkshop
+######*/
+
+SiegeWorkshop::SiegeWorkshop(OPvPWintergrasp *opvp, BuildingState *state)
+: OPvPCapturePoint(opvp), m_buildingState(state), m_wintergrasp(opvp)
+, 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()
+{
+ uint32 entry = 0;
+ if(m_State == OBJECTIVESTATE_ALLIANCE) // to do m_buildingState->team == TEAM_ALLIANCE;
+ {
+ m_buildingState->team = TEAM_ALLIANCE;
+ entry = CRE_ENG_A;
+ }
+ else if(m_State == OBJECTIVESTATE_HORDE)
+ {
+ m_buildingState->team = TEAM_HORDE;
+ entry = CRE_ENG_H;
+ }
+ else
+ return;
+
+ *m_engEntry = entry;
+
+ // TODO: this may be sent twice
+ m_wintergrasp->BroadcastStateChange(m_buildingState);
+
+ // does not work, entry may change
+ /*Creature *creature = ObjectAccessor::GetObjectInWorld(m_Creatures[0], (Creature*)NULL);
+ if(!creature)
+ {
+ 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);
+ DespawnAllVehicles();
+ }
+ }
+
+ sLog.outDebug("Wintergrasp workshop now belongs to %u.", (uint32)m_buildingState->team);
+}
+
+void SiegeWorkshop::DespawnAllVehicles()
+{
+ while(!m_vehicles.empty())
+ (*m_vehicles.begin())->Dismiss();
+}
+
diff --git a/src/game/Wintergrasp.h b/src/game/Wintergrasp.h
index 96f51728664..43d3d35f704 100644
--- a/src/game/Wintergrasp.h
+++ b/src/game/Wintergrasp.h
@@ -192,6 +192,9 @@ class SiegeWorkshop : public OPvPCapturePoint
void SetStateByBuildingState();
void ChangeState();
void DespawnAllVehicles();
+
+ bool CanBuildVehicle() const { return m_vehicles.size() < MAX_VEHICLE_PER_WORKSHOP && m_buildingState->damageState != DAMAGE_DESTROYED; }
+
uint32 *m_engEntry;
uint32 m_engGuid;
Creature *m_engineer;