Implement vehicles created by player mounts.

Original idea by Elmaster, packet research by Wrong, ty.

--HG--
branch : trunk
This commit is contained in:
thenecromancer
2010-01-13 11:16:38 +01:00
parent db24e2927c
commit ea4e25f3aa
11 changed files with 153 additions and 20 deletions
+48 -1
View File
@@ -11099,7 +11099,7 @@ float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM, const SpellEntry * s
return uint32((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60))
}
void Unit::Mount(uint32 mount)
void Unit::Mount(uint32 mount, uint32 VehicleId)
{
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNT);
@@ -11121,6 +11121,27 @@ void Unit::Mount(uint32 mount)
else
((Player*)this)->UnsummonPetTemporaryIfAny();
}
if(VehicleId !=0)
{
if(VehicleEntry const *ve = sVehicleStore.LookupEntry(VehicleId))
{
if (CreateVehicleKit(VehicleId))
{
GetVehicleKit()->Reset();
// Send others that we now have a vehicle
WorldPacket data( SMSG_PLAYER_VEHICLE_DATA, GetPackGUID().size()+4);
data.appendPackGUID(GetGUID());
data << uint32(VehicleId);
SendMessageToSet( &data,true );
data.Initialize(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
((Player*)this)->GetSession()->SendPacket( &data );
}
}
}
}
}
@@ -11148,6 +11169,16 @@ void Unit::Unmount()
else
((Player*)this)->ResummonPetTemporaryUnSummonedIfAny();
}
if(GetTypeId()==TYPEID_PLAYER && GetVehicleKit())
{
// Send other players that we are no longer a vehicle
WorldPacket data( SMSG_PLAYER_VEHICLE_DATA, 8+4 );
data.appendPackGUID(GetGUID());
data << uint32(0);
((Player*)this)->SendMessageToSet(&data, true);
// Remove vehicle class from player
RemoveVehicleKit();
}
}
void Unit::SetInCombatWith(Unit* enemy)
@@ -14956,6 +14987,22 @@ bool Unit::CreateVehicleKit(uint32 id)
return true;
}
void Unit::RemoveVehicleKit()
{
if (!m_vehicleKit)
return;
m_vehicleKit->Uninstall();
delete m_vehicleKit;
m_vehicleKit = NULL;
m_updateFlag &= ~UPDATEFLAG_VEHICLE;
m_unitTypeMask &= ~UNIT_MASK_VEHICLE;
RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE);
}
Unit *Unit::GetVehicleBase() const
{
return m_vehicle ? m_vehicle->GetBase() : NULL;