*Use total max veh number instead of max veh number per workshop to check if can build vehicle in wintergrasp.
*Do not despawn vehicles when workshop is destroyed or captured. --HG-- branch : trunk
This commit is contained in:
+31
-14
@@ -268,8 +268,8 @@ void OPvPWintergrasp::ProcessEvent(GameObject *obj, uint32 eventId)
|
||||
|
||||
if(itr->second->type == BUILDING_WORKSHOP)
|
||||
{
|
||||
if(SiegeWorkshop *workshop = GetWorkshop(obj->GetDBTableGUIDLow()))
|
||||
workshop->DespawnAllVehicles();
|
||||
//if(SiegeWorkshop *workshop = GetWorkshop(obj->GetDBTableGUIDLow()))
|
||||
// workshop->DespawnAllVehicles();
|
||||
ModifyWorkshopCount(itr->second->team, false);
|
||||
}
|
||||
}
|
||||
@@ -330,8 +330,11 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
|
||||
{
|
||||
if(add)
|
||||
{
|
||||
if(m_wartime && workshop->CanBuildVehicle())
|
||||
workshop->m_vehicles.insert((Vehicle*)creature);
|
||||
if(CanBuildVehicle(workshop))
|
||||
{
|
||||
m_vehicles[team].insert((Vehicle*)creature);
|
||||
//workshop->m_vehicles.insert((Vehicle*)creature);
|
||||
}
|
||||
else
|
||||
{
|
||||
creature->setDeathState(DEAD);
|
||||
@@ -340,14 +343,17 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
|
||||
}
|
||||
}
|
||||
// TODO: now you have to wait until the corpse of vehicle disappear to build a new one
|
||||
else if(!workshop->m_vehicles.erase((Vehicle*)creature))
|
||||
sLog.outError("OPvPWintergrasp::OnCreatureCreate: a vehicle is removed but it does not have record in workshop!");
|
||||
else
|
||||
{
|
||||
m_vehicles[team].erase((Vehicle*)creature);
|
||||
//if(!workshop->m_vehicles.erase((Vehicle*)creature))
|
||||
// sLog.outError("OPvPWintergrasp::OnCreatureCreate: a vehicle is removed but it does not have record in workshop!");
|
||||
}
|
||||
}
|
||||
}
|
||||
//case 28366: tower
|
||||
if(add)
|
||||
{
|
||||
m_vehicles[team].insert((Vehicle*)creature);
|
||||
if(m_tenacityStack > 0)
|
||||
{
|
||||
if(team == TEAM_ALLIANCE)
|
||||
@@ -359,8 +365,6 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
|
||||
creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, -m_tenacityStack);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_vehicles[team].erase((Vehicle*)creature);
|
||||
SendUpdateWorldState(VehNumWorldState[team], m_vehicles[team].size());
|
||||
break;
|
||||
}
|
||||
@@ -757,16 +761,27 @@ void OPvPWintergrasp::EndBattle()
|
||||
|
||||
void OPvPWintergrasp::SetData(uint32 id, uint32 value)
|
||||
{
|
||||
if(id == DATA_ENGINEER_DIE)
|
||||
if(SiegeWorkshop *workshop = GetWorkshopByEngGuid(value))
|
||||
workshop->DespawnAllVehicles();
|
||||
//if(id == DATA_ENGINEER_DIE)
|
||||
// if(SiegeWorkshop *workshop = GetWorkshopByEngGuid(value))
|
||||
// workshop->DespawnAllVehicles();
|
||||
}
|
||||
|
||||
bool OPvPWintergrasp::CanBuildVehicle(SiegeWorkshop *workshop) const
|
||||
{
|
||||
TeamId team = workshop->m_buildingState->team;
|
||||
if(team == TEAM_NEUTRAL)
|
||||
return false;
|
||||
|
||||
return m_wartime
|
||||
&& workshop->m_buildingState->damageState != DAMAGE_DESTROYED
|
||||
&& m_vehicles[team].size() < m_workshopCount[team] * MAX_VEHICLE_PER_WORKSHOP;
|
||||
}
|
||||
|
||||
uint32 OPvPWintergrasp::GetData(uint32 id)
|
||||
{
|
||||
// if can build more vehicles
|
||||
if(SiegeWorkshop *workshop = GetWorkshopByEngGuid(id))
|
||||
return m_wartime && workshop->CanBuildVehicle() ? 1 : 0;
|
||||
return CanBuildVehicle(workshop) ? 1 : 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -869,7 +884,7 @@ void SiegeWorkshop::ChangeTeam(TeamId oldTeam)
|
||||
if(entry != m_engineer->GetEntry() || !m_engineer->isAlive())
|
||||
{
|
||||
m_engineer->Respawn(true);
|
||||
DespawnAllVehicles();
|
||||
//DespawnAllVehicles();
|
||||
}
|
||||
m_engineer->SetVisibility(VISIBILITY_ON);
|
||||
}
|
||||
@@ -880,9 +895,11 @@ void SiegeWorkshop::ChangeTeam(TeamId oldTeam)
|
||||
sLog.outDebug("Wintergrasp workshop now belongs to %u.", (uint32)m_buildingState->team);
|
||||
}
|
||||
|
||||
/*
|
||||
void SiegeWorkshop::DespawnAllVehicles()
|
||||
{
|
||||
while(!m_vehicles.empty())
|
||||
(*m_vehicles.begin())->Dismiss();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
@@ -187,6 +187,8 @@ class OPvPWintergrasp : public OutdoorPvP
|
||||
bool UpdateCreatureInfo(Creature *creature) const;
|
||||
bool UpdateGameObjectInfo(GameObject *go) const;
|
||||
|
||||
bool CanBuildVehicle(SiegeWorkshop *workshop) const;
|
||||
|
||||
void RebuildAllBuildings();
|
||||
|
||||
void VehicleCastSpell(TeamId team, int32 spellId) const;
|
||||
@@ -201,15 +203,15 @@ class SiegeWorkshop : public OPvPCapturePoint
|
||||
void SetTeamByBuildingState();
|
||||
void ChangeState() {}
|
||||
void ChangeTeam(TeamId oldteam);
|
||||
void DespawnAllVehicles();
|
||||
//void DespawnAllVehicles();
|
||||
|
||||
bool CanBuildVehicle() const { return m_vehicles.size() < MAX_VEHICLE_PER_WORKSHOP && m_buildingState->damageState != DAMAGE_DESTROYED; }
|
||||
//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;
|
||||
uint32 m_workshopGuid;
|
||||
VehicleSet m_vehicles;
|
||||
//VehicleSet m_vehicles;
|
||||
BuildingState *m_buildingState;
|
||||
protected:
|
||||
OPvPWintergrasp *m_wintergrasp;
|
||||
|
||||
Reference in New Issue
Block a user