/// 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, true); } else if (pPlayer->IsWalking() && !pVehicle->IsWalking()) { ((Creature*)pVehicle)->SetWalk(true, true); } } } if (seatFlags & (SEAT_FLAG_USABLE | SEAT_FLAG_CAN_CAST)) { CharmInfo* charmInfo = pVehicle->InitCharmInfo(pVehicle); charmInfo->InitVehicleCreateSpells(); pPlayer->PossessSpellInitialize(); } } else if (passenger->GetTypeId() == TYPEID_UNIT) { if (seatFlags & SEAT_FLAG_CAN_CONTROL) { passenger->SetCharm(pVehicle); pVehicle->SetCharmerGuid(passenger->GetObjectGuid()); } ((Creature*)passenger)->AI()->SetCombatMovement(false); // Not entirely sure how this must be handled in relation to CONTROL // But in any way this at least would require some changes in the movement system most likely passenger->GetMotionMaster()->Clear(false, true); passenger->GetMotionMaster()->MoveIdle(); } }
/// 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, true); } else if (pPlayer->IsWalking() && !pVehicle->IsWalking()) { ((Creature*)pVehicle)->SetWalk(true, true); } } } if (seatFlags & (SEAT_FLAG_USABLE | SEAT_FLAG_CAN_CAST)) { CharmInfo* charmInfo = pVehicle->InitCharmInfo(pVehicle); charmInfo->InitVehicleCreateSpells(); pPlayer->PossessSpellInitialize(); } } else if (passenger->GetTypeId() == TYPEID_UNIT) { if (seatFlags & SEAT_FLAG_CAN_CONTROL) { passenger->SetCharm(pVehicle); pVehicle->SetCharmerGuid(passenger->GetObjectGuid()); } } }
/// 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 (seatFlags & SEAT_FLAG_NOT_SELECTABLE) passenger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); // ToDo: change passenger model id for SEAT_FLAG_HIDE_PASSENGER? if (passenger->GetTypeId() == TYPEID_PLAYER) { Player* pPlayer = (Player*)passenger; // group update if (pPlayer->GetGroup()) pPlayer->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_VEHICLE_SEAT); if (seatFlags & SEAT_FLAG_CAN_CONTROL) { pPlayer->GetCamera().SetView(pVehicle); pPlayer->SetCharm(pVehicle); pVehicle->SetCharmer(pPlayer); pVehicle->GetMotionMaster()->Clear(); pVehicle->GetMotionMaster()->MoveIdle(); pVehicle->StopMoving(true); pVehicle->addUnitState(UNIT_STAT_POSSESSED); pVehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); pVehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); pPlayer->UpdateClientControl(pVehicle, true); pPlayer->SetMover(pVehicle); // Unconfirmed - default speed handling if (pVehicle->GetTypeId() == TYPEID_UNIT) { if (!pPlayer->IsWalking() && pVehicle->IsWalking()) { ((Creature*)pVehicle)->SetWalk(false, true); } else if (pPlayer->IsWalking() && !pVehicle->IsWalking()) { ((Creature*)pVehicle)->SetWalk(true, true); } // set vehicle faction as per the controller faction ((Creature*)pVehicle)->SetFactionTemporary(pPlayer->getFaction(), TEMPFACTION_NONE); // set vehicle react state to passive; player will control the vehicle pVehicle->AI()->SetReactState(REACT_PASSIVE); } } if (seatFlags & SEAT_FLAG_CAN_CAST) { CharmInfo* charmInfo = pVehicle->InitCharmInfo(pVehicle); charmInfo->InitVehicleCreateSpells(); pPlayer->PossessSpellInitialize(); } } else if (passenger->GetTypeId() == TYPEID_UNIT) { if (seatFlags & SEAT_FLAG_CAN_CONTROL) { passenger->SetCharm(pVehicle); pVehicle->SetCharmer(passenger); // Change vehicle react state; ToDo: also change the vehicle faction? if (pVehicle->GetTypeId() == TYPEID_UNIT) pVehicle->AI()->SetReactState(passenger->AI()->GetReactState()); } ((Creature*)passenger)->AI()->SetCombatMovement(false); // Not entirely sure how this must be handled in relation to CONTROL // But in any way this at least would require some changes in the movement system most likely passenger->GetMotionMaster()->Clear(false, true); passenger->GetMotionMaster()->MoveIdle(); } }