Skip to content

Commit

Permalink
add setVehicleSmokeTrailEnabled & isVehicleSmokeTrailEnabled function (
Browse files Browse the repository at this point in the history
  • Loading branch information
Proxy-99 authored Oct 23, 2024
1 parent 792d9aa commit a5dfc52
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void CLuaVehicleDefs::LoadFunctions()
{"getVehicleModelWheelSize", ArgumentParser<GetVehicleModelWheelSize>},
{"getVehicleWheelFrictionState", ArgumentParser<GetVehicleWheelFrictionState>},
{"getVehicleEntryPoints", ArgumentParser<GetVehicleEntryPoints>},
{"isVehicleSmokeTrailEnabled", ArgumentParser<IsSmokeTrailEnabled>},

// Vehicle set funcs
{"createVehicle", CreateVehicle},
Expand Down Expand Up @@ -156,6 +157,7 @@ void CLuaVehicleDefs::LoadFunctions()
{"setVehicleWheelScale", ArgumentParser<SetVehicleWheelScale>},
{"setVehicleModelWheelSize", ArgumentParser<SetVehicleModelWheelSize>},
{"spawnVehicleFlyingComponent", ArgumentParser<SpawnVehicleFlyingComponent>},
{"setVehicleSmokeTrailEnabled", ArgumentParser<SetSmokeTrailEnabled>},
};

// Add functions
Expand Down Expand Up @@ -244,6 +246,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "getModelWheelSize", "getVehicleModelWheelSize");
lua_classfunction(luaVM, "getWheelFrictionState", "getVehicleWheelFrictionState");
lua_classfunction(luaVM, "getEntryPoints", ArgumentParser<OOP_GetVehicleEntryPoints>);
lua_classfunction(luaVM, "isSmokeTrailEnabled", "isVehicleSmokeTrailEnabled");

lua_classfunction(luaVM, "setComponentVisible", "setVehicleComponentVisible");
lua_classfunction(luaVM, "setSirensOn", "setVehicleSirensOn");
Expand Down Expand Up @@ -292,6 +295,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "setVariant", "setVehicleVariant");
lua_classfunction(luaVM, "setWheelScale", "setVehicleWheelScale");
lua_classfunction(luaVM, "setModelWheelSize", "setVehicleModelWheelSize");
lua_classfunction(luaVM, "setSmokeTrailEnabled", "setVehicleSmokeTrailEnabled");

lua_classfunction(luaVM, "resetComponentPosition", "resetVehicleComponentPosition");
lua_classfunction(luaVM, "resetComponentRotation", "resetVehicleComponentRotation");
Expand Down Expand Up @@ -4340,3 +4344,19 @@ bool CLuaVehicleDefs::SpawnVehicleFlyingComponent(CClientVehicle* const vehicle,

return vehicle->SpawnFlyingComponent(partNodeIndex, collisionType, removalTime.value_or(-1));
}

bool CLuaVehicleDefs::SetSmokeTrailEnabled(CClientVehicle* vehicle, bool state)
{
std::uint16_t model = vehicle->GetModel();
if (model != 512 && model != 513)
throw LuaFunctionError("Invaild model ID");

vehicle->SetSmokeTrailEnabled(state);
return true;
}

bool CLuaVehicleDefs::IsSmokeTrailEnabled(CClientVehicle* vehicle) noexcept
{
return vehicle->IsSmokeTrailEnabled();
}

3 changes: 3 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,7 @@ class CLuaVehicleDefs : public CLuaDefs
LUA_DECLARE(GetVehicleComponents);

static bool SpawnVehicleFlyingComponent(CClientVehicle* const vehicle, std::uint8_t nodeIndex, std::optional<std::uint8_t> componentCollisionType, std::optional<std::uint32_t> removalTime);

static bool SetSmokeTrailEnabled(CClientVehicle* vehicle, bool state);
static bool IsSmokeTrailEnabled(CClientVehicle* vehicle) noexcept;
};

0 comments on commit a5dfc52

Please sign in to comment.