diff options
| author | thenecromancer <none@none> | 2010-01-13 11:16:38 +0100 |
|---|---|---|
| committer | thenecromancer <none@none> | 2010-01-13 11:16:38 +0100 |
| commit | ea4e25f3aaa10efeacf0849bcb1583ad78ee2b28 (patch) | |
| tree | 9873402e58eb955e2db047f0c31b2760df32d019 /src/game/Unit.cpp | |
| parent | db24e2927c0a67576011692ef8c2f8150da9425f (diff) | |
Implement vehicles created by player mounts.
Original idea by Elmaster, packet research by Wrong, ty.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
| -rw-r--r-- | src/game/Unit.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index b1a7761788e..ef9a46c7855 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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; |
