Skip to content

Commit

Permalink
[12231] Implement ApplySeat mods (vehicle controlling, spells and such)
Browse files Browse the repository at this point in the history
As always based on a long history of work by many people

Signed-off-by: Schmoozerd <schmoozerd@cmangos>
  • Loading branch information
kid10 authored and Salja committed Sep 15, 2012
1 parent 5c74292 commit 2fa7bc0
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
51 changes: 51 additions & 0 deletions src/game/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* - TODO Unboard
* - TODO Switch
* - CanBoard to check if a passenger can board a vehicle
* - Internal helper to set the controlling and spells for a vehicle's seat
* - Internal helper to control the available seats of a vehicle
*/

Expand Down Expand Up @@ -231,6 +232,56 @@ bool VehicleInfo:: IsUsableSeatForPlayer(uint32 seatFlags) const
/// Add control and such modifiers to a passenger if required
void VehicleInfo::ApplySeatMods(Unit* passenger, uint32 seatFlags)
{
Unit* pVehicle = (Unit*)m_owner; // Vehicles are alawys Unit

if (passenger->GetTypeId() == TYPEID_PLAYER)
{
Player* pPlayer = (Player*)passenger;

if (seatFlags & SEAT_FLAG_CAN_CONTROL)
{
pPlayer->GetCamera().SetView(pVehicle);

pPlayer->SetCharm(pVehicle);
pVehicle->SetCharmerGuid(pPlayer->GetObjectGuid());

pVehicle->addUnitState(UNIT_STAT_CONTROLLED);
pVehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);

pPlayer->SetClientControl(pVehicle, 1);
pPlayer->SetMover(pVehicle);

// Unconfirmed - default speed handling
if (pVehicle->GetTypeId() == TYPEID_UNIT)
{
if (!pPlayer->IsWalking() && pVehicle->IsWalking())
{
((Creature*)pVehicle)->SetWalk(false);
}
else if (pPlayer->IsWalking() && !pVehicle->IsWalking())
{
((Creature*)pVehicle)->SetWalk(true);
}
}
}

if (seatFlags & (SEAT_FLAG_USABLE | SEAT_FLAG_CAN_CAST))
{
CharmInfo* charmInfo = pVehicle->InitCharmInfo(pVehicle);
// ToDo: Send vehicle actionbar spells
charmInfo->InitEmptyActionBar();

pPlayer->PossessSpellInitialize();
}
}
else if (passenger->GetTypeId() == TYPEID_UNIT)
{
if (seatFlags & SEAT_FLAG_CAN_CONTROL)
{
passenger->SetCharm(pVehicle);
pVehicle->SetCharmerGuid(passenger->GetObjectGuid());
}
}
}

/// Remove control and such modifiers to a passenger if they were added
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12230"
#define REVISION_NR "12231"
#endif // __REVISION_NR_H__

0 comments on commit 2fa7bc0

Please sign in to comment.