void Vehicle::Load(CreatureProto * proto_, uint32 mode, float x, float y, float z, float o /* = 0.0f */) { proto = proto_; if(!proto) return; if(proto->vehicle_entry != -1) { m_vehicleEntry = proto->vehicle_entry; } else { m_vehicleEntry = 124; if(sLog.IsOutDevelopement()) printf("Attempted to create vehicle %u with invalid vehicle_entry, defaulting to 124, check your creature_proto table.\n", proto->Id); else OUT_DEBUG("Attempted to create vehicle %u with invalid vehicle_entry, defaulting to 124, check your creature_proto table.", proto->Id); } m_maxPassengers = 0; m_seatSlotMax = 0; VehicleEntry * ve = dbcVehicle.LookupEntry( m_vehicleEntry ); if(!ve) { if(sLog.IsOutDevelopement()) printf("Attempted to create non-existant vehicle %u.\n", GetVehicleEntry()); else OUT_DEBUG("Attempted to create non-existant vehicle %u.", GetVehicleEntry()); return; } for( uint32 i = 0; i < 8; i++ ) { if( ve->m_seatID[i] ) { m_vehicleSeats[i] = dbcVehicleSeat.LookupEntry( ve->m_seatID[i] ); m_seatSlotMax = i+1; if(m_vehicleSeats[i]->IsUsable()) { seatisusable[i] = true; ++m_maxPassengers; } } } Initialised = true; Creature::Load(proto_, mode, x, y, z, o); }
void VehicleInfo::Initialize() { if (!m_overwriteNpcEntry) m_overwriteNpcEntry = m_owner->GetEntry(); // Loading passengers (rough version only!) SQLMultiStorage::SQLMSIteratorBounds<VehicleAccessory> bounds = sVehicleAccessoryStorage.getBounds<VehicleAccessory>(m_overwriteNpcEntry); for (SQLMultiStorage::SQLMultiSIterator<VehicleAccessory> itr = bounds.first; itr != bounds.second; ++itr) { if (Creature* summoned = m_owner->SummonCreature(itr->passengerEntry, m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ(), 2 * m_owner->GetOrientation(), TEMPSPAWN_DEAD_DESPAWN, 0)) { DEBUG_LOG("VehicleInfo(of %s)::Initialize: Load vehicle accessory %s onto seat %u", m_owner->GetGuidStr().c_str(), summoned->GetGuidStr().c_str(), itr->seatId); m_accessoryGuids.insert(summoned->GetObjectGuid()); int32 basepoint0 = itr->seatId + 1; summoned->CastCustomSpell((Unit*)m_owner, SPELL_RIDE_VEHICLE_HARDCODED, &basepoint0, nullptr, nullptr, TRIGGERED_OLD_TRIGGERED); } } // Initialize movement limitations uint32 vehicleFlags = GetVehicleEntry()->m_flags; Unit* pVehicle = (Unit*)m_owner; if (vehicleFlags & VEHICLE_FLAG_NO_STRAFE) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_NO_STRAFE); if (vehicleFlags & VEHICLE_FLAG_NO_JUMPING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_NO_JUMPING); if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDTURNING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_FULLSPEEDTURNING); if (vehicleFlags & VEHICLE_FLAG_ALLOW_PITCHING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_ALLOW_PITCHING); if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDPITCHING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_FULLSPEEDPITCHING); // NOTE: this is the best possible combination to root a vehicle; However, there are still exceptions, such as creature 27292 if (vehicleFlags & VEHICLE_FLAG_FIXED_POSITION || (!(vehicleFlags & VEHICLE_FLAG_UNK7) && vehicleFlags & VEHICLE_FLAG_UNK15)) pVehicle->SetRoot(true); // TODO: Guesswork, but it looks correct if (vehicleFlags & VEHICLE_FLAG_PASSIVE) pVehicle->AI()->SetReactState(REACT_PASSIVE); // Initialize power type based on DBC values (creatures only) if (pVehicle->GetTypeId() == TYPEID_UNIT) { if (PowerDisplayEntry const* powerEntry = sPowerDisplayStore.LookupEntry(GetVehicleEntry()->m_powerDisplayID)) pVehicle->SetPowerType(Powers(powerEntry->power)); } m_isInitialized = true; }
bool Vehicle::Load(CreatureSpawn *spawn, uint32 mode, MapInfo *info) { proto = CreatureProtoStorage.LookupEntry(spawn->entry); if(!proto) return false; if(proto->vehicle_entry != -1) { m_vehicleEntry = proto->vehicle_entry; } else { m_vehicleEntry = 124; if(sLog.IsOutDevelopement()) printf("Attempted to create vehicle %u with invalid vehicle_entry, defaulting to 124, check your creature_proto table.\n", proto->Id); else OUT_DEBUG("Attempted to create vehicle %u with invalid vehicle_entry, defaulting to 124, check your creature_proto table.", proto->Id); } m_maxPassengers = 0; m_seatSlotMax = 0; VehicleEntry * ve = dbcVehicle.LookupEntry( m_vehicleEntry ); if(!ve) { if(sLog.IsOutDevelopement()) printf("Attempted to create non-existant vehicle %u.\n", GetVehicleEntry()); else OUT_DEBUG("Attempted to create non-existant vehicle %u.", GetVehicleEntry()); return false; } for( uint32 i = 0; i < 8; i++ ) { if( ve->m_seatID[i] ) { m_vehicleSeats[i] = dbcVehicleSeat.LookupEntry( ve->m_seatID[i] ); m_seatSlotMax = i + 1; if(m_vehicleSeats[i]->IsUsable()) { seatisusable[i] = true; ++m_maxPassengers; } } } Initialised = true; return Creature::Load(spawn, mode, info); }
void VehicleInfo::Initialize() { if (!m_overwriteNpcEntry) m_overwriteNpcEntry = m_owner->GetEntry(); // Loading passengers (rough version only!) SQLMultiStorage::SQLMSIteratorBounds<VehicleAccessory> bounds = sVehicleAccessoryStorage.getBounds<VehicleAccessory>(m_overwriteNpcEntry); for (SQLMultiStorage::SQLMultiSIterator<VehicleAccessory> itr = bounds.first; itr != bounds.second; ++itr) { if (Creature* summoned = m_owner->SummonCreature(itr->passengerEntry, m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ(), 2 * m_owner->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0)) { DEBUG_LOG("VehicleInfo(of %s)::Initialize: Load vehicle accessory %s onto seat %u", m_owner->GetGuidStr().c_str(), summoned->GetGuidStr().c_str(), itr->seatId); m_accessoryGuids.insert(summoned->GetObjectGuid()); int32 basepoint0 = itr->seatId + 1; summoned->CastCustomSpell((Unit*)m_owner, SPELL_RIDE_VEHICLE_HARDCODED, &basepoint0, NULL, NULL, true); } } // Initialize movement limitations uint32 vehicleFlags = GetVehicleEntry()->m_flags; Unit* pVehicle = (Unit*)m_owner; if (vehicleFlags & VEHICLE_FLAG_NO_STRAFE) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_NO_STRAFE); if (vehicleFlags & VEHICLE_FLAG_NO_JUMPING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_NO_JUMPING); if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDTURNING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_FULLSPEEDTURNING); if (vehicleFlags & VEHICLE_FLAG_ALLOW_PITCHING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_ALLOW_PITCHING); if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDPITCHING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_FULLSPEEDPITCHING); // Initialize power type based on DBC values (creatures only) if (pVehicle->GetTypeId() == TYPEID_UNIT) { if (PowerDisplayEntry const* powerEntry = sPowerDisplayStore.LookupEntry(GetVehicleEntry()->m_powerDisplayID)) pVehicle->SetPowerType(Powers(powerEntry->power)); } m_isInitialized = true; }
/// Remove control and such modifiers to a passenger if they were added void VehicleInfo::RemoveSeatMods(Unit* passenger, uint32 seatFlags) { Unit* pVehicle = (Unit*)m_owner; if (seatFlags & SEAT_FLAG_NOT_SELECTABLE) passenger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); // ToDo: reset 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->SetCharm(nullptr); pVehicle->SetCharmer(nullptr); pPlayer->UpdateClientControl(pVehicle, false); pPlayer->SetMover(nullptr); pVehicle->StopMoving(true); pVehicle->GetMotionMaster()->Clear(); pVehicle->clearUnitState(UNIT_STAT_POSSESSED); pVehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); pVehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); // must be called after movement control unapplying pPlayer->GetCamera().ResetView(); if (pVehicle->GetTypeId() == TYPEID_UNIT) { // reset vehicle faction ((Creature*)pVehicle)->ClearTemporaryFaction(); // Reset react state if (!(GetVehicleEntry()->m_flags & VEHICLE_FLAG_PASSIVE)) pVehicle->AI()->SetReactState(REACT_AGGRESSIVE); } } if (seatFlags & SEAT_FLAG_CAN_CAST) pPlayer->RemovePetActionBar(); } else if (passenger->GetTypeId() == TYPEID_UNIT) { if (seatFlags & SEAT_FLAG_CAN_CONTROL) { passenger->SetCharm(nullptr); pVehicle->SetCharmer(nullptr); } // Reinitialize movement if (((Creature*)passenger)->AI()) ((Creature*)passenger)->AI()->SetCombatMovement(true, true); if (!passenger->getVictim()) passenger->GetMotionMaster()->Initialize(); } }