Skip to content
7 changes: 7 additions & 0 deletions Client/mods/deathmatch/logic/CPacketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3448,6 +3448,13 @@ void CPacketHandler::Packet_EntityAdd(NetBitStreamInterface& bitStream)
bool bIsDerailable = bitStream.ReadBit();
bool bTrainDirection = bitStream.ReadBit();
bool bTaxiLightState = bitStream.ReadBit();
bool bSmokeTrailEnabled = bitStream.ReadBit();

// Set smoke trail for appropriate vehicles
if (usModel == 512 || usModel == 513)
{
pVehicle->SetSmokeTrailEnabled(bSmokeTrailEnabled);
}

// If the vehicle has a landing gear, set landing gear state
if (CClientVehicleManager::HasLandingGears(usModel))
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classvariable(luaVM, "wheelScale", "setVehicleWheelScale", "getVehicleWheelScale");
lua_classvariable(luaVM, "rotorState", "setVehicleRotorState", "getVehicleRotorState");
lua_classvariable(luaVM, "audioSettings", nullptr, "getVehicleAudioSettings");
lua_classvariable(luaVM, "smokeTrailEnabled", "setVehicleSmokeTrailEnabled", "isVehicleSmokeTrailEnabled");

lua_registerclass(luaVM, "Vehicle", "Element");
}
Expand Down
10 changes: 10 additions & 0 deletions Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void CVehicleRPCs::LoadFunctions()
AddHandler(SET_VEHICLE_PLATE_TEXT, SetVehiclePlateText, "setVehiclePlateText");
AddHandler(SPAWN_VEHICLE_FLYING_COMPONENT, SpawnVehicleFlyingComponent, "spawnVehicleFlyingComponent");
AddHandler(SET_VEHICLE_NITRO_ACTIVATED, SetVehicleNitroActivated, "SetVehicleNitroActivated");
AddHandler(SET_VEHICLE_SMOKE_TRAIL_ENABLED, SetVehicleSmokeTrailEnabled, "SetVehicleSmokeTrailEnabled");
}

void CVehicleRPCs::DestroyAllVehicles(NetBitStreamInterface& bitStream)
Expand Down Expand Up @@ -693,3 +694,12 @@ void CVehicleRPCs::SetVehicleNitroActivated(CClientEntity* pSourceEntity, NetBit
vehicle->SetNitroLevel(vehicle->GetNitroLevel() + 1.0001f);
}

void CVehicleRPCs::SetVehicleSmokeTrailEnabled(CClientEntity* pSourceEntity, NetBitStreamInterface& bitStream)
{
bool state = bitStream.ReadBit();
CClientVehicle* vehicle = m_pVehicleManager->Get(pSourceEntity->GetID());
if (!vehicle)
return;

vehicle->SetSmokeTrailEnabled(state);
}
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ class CVehicleRPCs : public CRPCFunctions
DECLARE_ELEMENT_RPC(SetVehiclePlateText);
DECLARE_ELEMENT_RPC(SpawnVehicleFlyingComponent);
DECLARE_ELEMENT_RPC(SetVehicleNitroActivated);
DECLARE_ELEMENT_RPC(SetVehicleSmokeTrailEnabled);
};
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class CStaticFunctionDefinitions
static bool GetEntryHandling(const CHandlingEntry* pEntry, eHandlingProperty eProperty, std::string& strValue);
static bool GetEntryHandling(const CHandlingEntry* pEntry, eHandlingProperty eProperty, unsigned int& uiValue);
static bool GetEntryHandling(const CHandlingEntry* pEntry, eHandlingProperty eProperty, unsigned char& ucValue);
static bool IsVehicleSmokeTrailEnabled(CVehicle* const vehicle);

// Vehicle set functions
static bool FixVehicle(CElement* pElement);
Expand Down
27 changes: 26 additions & 1 deletion Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void CLuaVehicleDefs::LoadFunctions()
{"isVehicleBlown", ArgumentParserWarn<false, IsVehicleBlown>},
{"getVehicleHeadLightColor", GetVehicleHeadLightColor},
{"getVehicleDoorOpenRatio", GetVehicleDoorOpenRatio},
{"isVehicleSmokeTrailEnabled", ArgumentParser<IsVehicleSmokeTrailEnabled>},

// Vehicle set funcs
{"fixVehicle", FixVehicle},
Expand Down Expand Up @@ -128,6 +129,7 @@ void CLuaVehicleDefs::LoadFunctions()
{"getVehicleSirenParams", GetVehicleSirenParams},
{"setVehiclePlateText", SetVehiclePlateText},
{"setVehicleNitroActivated", ArgumentParser<SetVehicleNitroActivated>},
{"setVehicleSmokeTrailEnabled", ArgumentParser<SetVehicleSmokeTrailEnabled>},
};

// Add functions
Expand Down Expand Up @@ -209,6 +211,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "isRespawnable", "isVehicleRespawnable");
lua_classfunction(luaVM, "getRespawnDelay", "getVehicleRespawnDelay");
lua_classfunction(luaVM, "getIdleRespawnDelay", "getVehicleIdleRespawnDelay");
lua_classfunction(luaVM, "isSmokeTrailEnabled", "isVehicleSmokeTrailEnabled");

lua_classfunction(luaVM, "setColor", "setVehicleColor");
lua_classfunction(luaVM, "setDamageProof", "setVehicleDamageProof");
Expand Down Expand Up @@ -244,6 +247,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "setTrainPosition", "setTrainPosition");
lua_classfunction(luaVM, "setTrainSpeed", "setTrainSpeed"); // Reduce confusion
lua_classfunction(luaVM, "spawnFlyingComponent", "spawnVehicleFlyingComponent");
lua_classfunction(luaVM, "setSmokeTrailEnabled", "setVehicleSmokeTrailEnabled");

lua_classvariable(luaVM, "damageProof", "setVehicleDamageProof", "isVehicleDamageProof");
lua_classvariable(luaVM, "locked", "setVehicleLocked", "isVehicleLocked");
Expand Down Expand Up @@ -286,6 +290,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classvariable(luaVM, "sirens", NULL, "getVehicleSirens");
lua_classvariable(luaVM, "handling", nullptr, "getVehicleHandling");
lua_classvariable(luaVM, "occupant", NULL, "getVehicleOccupant");
lua_classvariable(luaVM, "smokeTrailEnabled", "setVehicleSmokeTrailEnabled", "isVehicleSmokeTrailEnabled");

lua_registerclass(luaVM, "Vehicle", "Element");
}
Expand Down Expand Up @@ -3059,4 +3064,24 @@ bool CLuaVehicleDefs::SetVehicleNitroActivated(CVehicle* vehicle, bool state) no

m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(vehicle, SET_VEHICLE_NITRO_ACTIVATED, *BitStream.pBitStream));
return true;
}
}

bool CLuaVehicleDefs::SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state)
{
std::uint16_t model = vehicle->GetModel();
if (model != 512 && model != 513)
return false;

vehicle->SetSmokeTrailEnabled(state);

CBitStream BitStream;
BitStream.pBitStream->WriteBit(state);

m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(vehicle, SET_VEHICLE_SMOKE_TRAIL_ENABLED, *BitStream.pBitStream));
return true;
}

bool CLuaVehicleDefs::IsVehicleSmokeTrailEnabled(CVehicle* vehicle) noexcept
{
return vehicle->IsSmokeTrailEnabled();
}
2 changes: 2 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,6 @@ class CLuaVehicleDefs : public CLuaDefs

static bool SpawnVehicleFlyingComponent(CVehicle* const vehicle, std::uint8_t nodeIndex, std::optional<std::uint8_t> componentCollisionType, std::optional<std::uint32_t> removalTime);
static bool SetVehicleNitroActivated(CVehicle* vehicle, bool state) noexcept;
static bool SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state);
static bool IsVehicleSmokeTrailEnabled(CVehicle* vehicle) noexcept;
};
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ bool CEntityAddPacket::Write(NetBitStreamInterface& BitStream) const
BitStream.WriteBit(pVehicle->IsDerailable());
BitStream.WriteBit(pVehicle->GetTrainDirection());
BitStream.WriteBit(pVehicle->IsTaxiLightOn());
BitStream.WriteBit(pVehicle->IsSmokeTrailEnabled());

// Write alpha
SEntityAlphaSync alpha;
Expand Down
4 changes: 3 additions & 1 deletion Shared/sdk/net/rpc_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,10 @@ enum eElementRPCFunctions
SPAWN_VEHICLE_FLYING_COMPONENT,

SET_VEHICLE_NITRO_ACTIVATED,

SET_ELEMENT_ON_FIRE,

SET_VEHICLE_SMOKE_TRAIL_ENABLED,

NUM_RPC_FUNCS // Add above this line
};