@@ -4263,6 +4263,164 @@ bool CLuaVehicleDefs::BlowVehicle(CClientEntity* entity, std::optional<bool> wit
42634263 return CStaticFunctionDefinitions::BlowVehicle (*entity, withExplosion);
42644264}
42654265
4266+ std::variant<bool , std::array<std::array<float , 3 >, 4 >> CLuaVehicleDefs::GetVehicleEntryPoints (CClientVehicle* vehicle)
4267+ {
4268+ auto entryPointVectors = OOP_GetVehicleEntryPoints (vehicle);
4269+
4270+ if (std::holds_alternative<bool >(entryPointVectors))
4271+ {
4272+ return false ;
4273+ }
4274+
4275+ std::array<std::array<float , 3 >, 4 > entryPoints;
4276+ std::array<CVector, 4 > vectorArray = std::get<std::array<CVector, 4 >>(entryPointVectors);
4277+
4278+ std::uint32_t i = 0 ;
4279+ for (auto & entryPoint : entryPoints)
4280+ {
4281+ entryPoints[i] = {vectorArray[i].fX , vectorArray[i].fY , vectorArray[i].fZ };
4282+ i++;
4283+ }
4284+
4285+ return entryPoints;
4286+ }
4287+
4288+ std::variant<bool , std::array<CVector, 4 >> CLuaVehicleDefs::OOP_GetVehicleEntryPoints (CClientVehicle* vehicle)
4289+ {
4290+ if (CClientVehicleManager::GetMaxPassengerCount (vehicle->GetModel ()) == 255 )
4291+ {
4292+ return false ;
4293+ }
4294+
4295+ std::array<CVector, 4 > entryPoints;
4296+
4297+ std::uint32_t i = 0 ;
4298+ for (auto & entryPoint : entryPoints)
4299+ {
4300+ entryPoint = vehicle->GetEntryPoint (i++);
4301+ }
4302+
4303+ return entryPoints;
4304+ }
4305+
4306+ bool CLuaVehicleDefs::SpawnVehicleFlyingComponent (CClientVehicle* const vehicle, std::uint8_t nodeIndex, std::optional<std::uint8_t > componentCollisionType,
4307+ std::optional<std::uint32_t > removalTime)
4308+ {
4309+ auto partNodeIndex = static_cast <eCarNodes>(nodeIndex);
4310+ auto collisionType = componentCollisionType.has_value () ? static_cast <eCarComponentCollisionTypes>(componentCollisionType.value ())
4311+ : eCarComponentCollisionTypes::COL_NODE_PANEL;
4312+
4313+ if (nodeIndex < 1 || partNodeIndex >= eCarNodes::NUM_NODES)
4314+ throw std::invalid_argument (" Invalid component index" );
4315+
4316+ if (collisionType >= eCarComponentCollisionTypes::COL_NODES_NUM)
4317+ throw std::invalid_argument (" Invalid collision type index" );
4318+
4319+ if (!componentCollisionType.has_value ())
4320+ {
4321+ switch (partNodeIndex)
4322+ {
4323+ case eCarNodes::WHEEL_RF:
4324+ case eCarNodes::WHEEL_RB:
4325+ case eCarNodes::WHEEL_LF:
4326+ case eCarNodes::WHEEL_LB:
4327+ {
4328+ collisionType = eCarComponentCollisionTypes::COL_NODE_WHEEL;
4329+ break ;
4330+ }
4331+ case eCarNodes::DOOR_RF:
4332+ case eCarNodes::DOOR_RR:
4333+ case eCarNodes::DOOR_LF:
4334+ case eCarNodes::DOOR_LR:
4335+ {
4336+ collisionType = eCarComponentCollisionTypes::COL_NODE_DOOR;
4337+ break ;
4338+ }
4339+ case eCarNodes::BUMP_FRONT:
4340+ case eCarNodes::BUMP_REAR:
4341+ case eCarNodes::WHEEL_LM:
4342+ case eCarNodes::WHEEL_RM:
4343+ {
4344+ collisionType = eCarComponentCollisionTypes::COL_NODE_BUMPER;
4345+ break ;
4346+ }
4347+ case eCarNodes::BOOT:
4348+ case eCarNodes::CHASSIS:
4349+ {
4350+ collisionType = eCarComponentCollisionTypes::COL_NODE_BOOT;
4351+ break ;
4352+ }
4353+ case eCarNodes::BONNET:
4354+ case eCarNodes::WINDSCREEN:
4355+ {
4356+ collisionType = eCarComponentCollisionTypes::COL_NODE_BONNET;
4357+ break ;
4358+ }
4359+ default :
4360+ {
4361+ collisionType = eCarComponentCollisionTypes::COL_NODE_PANEL;
4362+ break ;
4363+ }
4364+ }
4365+ }
4366+
4367+ return vehicle->SpawnFlyingComponent (partNodeIndex, collisionType, removalTime.value_or (-1 ));
4368+ }
4369+
4370+ bool CLuaVehicleDefs::AddVehicleSirens (CClientVehicle* vehicle, std::uint8_t sirenType, std::uint8_t sirenCount, std::optional<bool > enable360,
4371+ std::optional<bool > enableLOSCheck, std::optional<bool > enableRandomiser, std::optional<bool > enableSilent) noexcept
4372+ {
4373+ eClientVehicleType vehicleType = vehicle->GetVehicleType ();
4374+
4375+ if (vehicleType != CLIENTVEHICLE_CAR && vehicleType != CLIENTVEHICLE_MONSTERTRUCK && vehicleType != CLIENTVEHICLE_QUADBIKE)
4376+ return false ;
4377+
4378+ if (sirenType < 1 || sirenType > 6 )
4379+ return false ;
4380+
4381+ if (sirenCount < 0 || sirenCount > SIREN_COUNT_MAX)
4382+ return false ;
4383+
4384+ vehicle->GiveVehicleSirens (sirenType, sirenCount);
4385+ vehicle->SetVehicleFlags (enable360.value_or (false ), enableRandomiser.value_or (true ), enableLOSCheck.value_or (true ), enableSilent.value_or (false ));
4386+ return true ;
4387+ }
4388+
4389+ bool CLuaVehicleDefs::RemoveVehicleSirens (CClientVehicle* vehicle) noexcept
4390+ {
4391+ vehicle->RemoveVehicleSirens ();
4392+ return true ;
4393+ }
4394+
4395+ bool CLuaVehicleDefs::SetSmokeTrailEnabled (CClientVehicle* vehicle, bool state)
4396+ {
4397+ std::uint16_t model = vehicle->GetModel ();
4398+ if (model != 512 && model != 513 )
4399+ throw LuaFunctionError (" Invaild model ID" );
4400+
4401+ vehicle->SetSmokeTrailEnabled (state);
4402+ return true ;
4403+ }
4404+
4405+ bool CLuaVehicleDefs::IsSmokeTrailEnabled (CClientVehicle* vehicle) noexcept
4406+ {
4407+ return vehicle->IsSmokeTrailEnabled ();
4408+ }
4409+
4410+ bool CLuaVehicleDefs::SetVehicleRotorState (CClientVehicle* vehicle, bool state, std::optional<bool > stopRotor) noexcept
4411+ {
4412+ if (vehicle->GetVehicleType () != eClientVehicleType::CLIENTVEHICLE_HELI && vehicle->GetVehicleType () != eClientVehicleType::CLIENTVEHICLE_PLANE)
4413+ return false ;
4414+
4415+ vehicle->SetVehicleRotorState (state, stopRotor.value_or (true ));
4416+ return true ;
4417+ }
4418+
4419+ bool CLuaVehicleDefs::GetVehicleRotorState (CClientVehicle* vehicle) noexcept
4420+ {
4421+ return vehicle->GetVehicleRotorState ();
4422+ }
4423+
42664424bool CLuaVehicleDefs::SetVehicleModelAudioSetting (const uint uiModel, const eVehicleAudioSettingProperty eProperty, float varValue)
42674425{
42684426 CVehicleAudioSettingsEntry* pModelSettings = g_pGame->GetVehicleAudioSettingsManager ()->GetVehicleModelAudioSettingsData ((eVehicleTypes)uiModel);
0 commit comments