[11385] Add support for static vehicle spawns

Signed-off-by: zergtmn <zerg@myisp.com>
This commit is contained in:
zergtmn 2011-04-20 23:23:47 +06:00
parent 75e1e7c3a3
commit 2835aa5f20
32 changed files with 115 additions and 331 deletions

View file

@ -39,6 +39,7 @@
#include "Pet.h"
#include "Util.h"
#include "Totem.h"
#include "Vehicle.h"
#include "BattleGround.h"
#include "InstanceData.h"
#include "MapPersistentStateMgr.h"
@ -180,8 +181,10 @@ void GlobalCooldownMgr::CancelGlobalCooldown(SpellEntry const* spellInfo)
////////////////////////////////////////////////////////////
// Methods of class Unit
Unit::Unit()
: WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostileRefManager(this)
Unit::Unit() :
i_motionMaster(this), m_ThreatManager(this), m_HostileRefManager(this),
m_charmInfo(NULL),
m_vehicleInfo(NULL)
{
m_objectType |= TYPEMASK_UNIT;
m_objectTypeId = TYPEID_UNIT;
@ -258,8 +261,6 @@ Unit::Unit()
for (int i = 0; i < MAX_MOVE_TYPE; ++i)
m_speed_rate[i] = 1.0f;
m_charmInfo = NULL;
// remove aurastates allowing special moves
for(int i=0; i < MAX_REACTIVE; ++i)
m_reactiveTimer[i] = 0;
@ -277,8 +278,8 @@ Unit::~Unit()
}
}
if (m_charmInfo)
delete m_charmInfo;
delete m_charmInfo;
delete m_vehicleInfo;
// those should be already removed at "RemoveFromWorld()" call
MANGOS_ASSERT(m_gameObj.size() == 0);
@ -848,7 +849,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if (cVictim->IsTemporarySummon())
{
TemporarySummon* pSummon = (TemporarySummon*)cVictim;
if (pSummon->GetSummonerGuid().IsCreature())
if (pSummon->GetSummonerGuid().IsCreatureOrVehicle())
if(Creature* pSummoner = cVictim->GetMap()->GetCreature(pSummon->GetSummonerGuid()))
if (pSummoner->AI())
pSummoner->AI()->SummonedCreatureJustDied(cVictim);
@ -8438,10 +8439,6 @@ bool Unit::CanHaveThreatList() const
if (creature->IsTotem())
return false;
// vehicles can not have threat list
if (creature->IsVehicle())
return false;
// pets can not have a threat list, unless they are controlled by a creature
if (creature->IsPet() && creature->GetOwnerGuid().IsPlayer())
return false;
@ -10826,3 +10823,30 @@ void Unit::OnRelocated()
}
ScheduleAINotify(World::GetRelocationAINotifyDelay());
}
void Unit::SetVehicleId(uint32 entry)
{
delete m_vehicleInfo;
if (entry)
{
VehicleEntry const* ventry = sVehicleStore.LookupEntry(entry);
MANGOS_ASSERT(ventry != NULL);
m_vehicleInfo = new VehicleInfo(ventry);
m_updateFlag |= UPDATEFLAG_VEHICLE;
}
else
{
m_vehicleInfo = NULL;
m_updateFlag &= ~UPDATEFLAG_VEHICLE;
}
if (GetTypeId() == TYPEID_PLAYER)
{
WorldPacket data(SMSG_SET_VEHICLE_REC_ID, 16);
data << GetPackGUID();
data << uint32(entry);
SendMessageToSet(&data, true);
}
}