diff --git a/Client/mods/deathmatch/logic/CPacketHandler.cpp b/Client/mods/deathmatch/logic/CPacketHandler.cpp index 339110ff311..62456186cd1 100644 --- a/Client/mods/deathmatch/logic/CPacketHandler.cpp +++ b/Client/mods/deathmatch/logic/CPacketHandler.cpp @@ -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)) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 94945f0fbc5..01ce59562e2 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -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"); } diff --git a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp index 0d318c75467..378ae3680e4 100644 --- a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp +++ b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp @@ -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) @@ -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); +} diff --git a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h index c1649abd4bf..e49b6f42e07 100644 --- a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h +++ b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h @@ -59,4 +59,5 @@ class CVehicleRPCs : public CRPCFunctions DECLARE_ELEMENT_RPC(SetVehiclePlateText); DECLARE_ELEMENT_RPC(SpawnVehicleFlyingComponent); DECLARE_ELEMENT_RPC(SetVehicleNitroActivated); + DECLARE_ELEMENT_RPC(SetVehicleSmokeTrailEnabled); }; diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h index 388f38b4439..a4773fba16f 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h @@ -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); diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 13d72615fcd..862aba293d7 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -69,6 +69,7 @@ void CLuaVehicleDefs::LoadFunctions() {"isVehicleBlown", ArgumentParserWarn}, {"getVehicleHeadLightColor", GetVehicleHeadLightColor}, {"getVehicleDoorOpenRatio", GetVehicleDoorOpenRatio}, + {"isVehicleSmokeTrailEnabled", ArgumentParser}, // Vehicle set funcs {"fixVehicle", FixVehicle}, @@ -128,6 +129,7 @@ void CLuaVehicleDefs::LoadFunctions() {"getVehicleSirenParams", GetVehicleSirenParams}, {"setVehiclePlateText", SetVehiclePlateText}, {"setVehicleNitroActivated", ArgumentParser}, + {"setVehicleSmokeTrailEnabled", ArgumentParser}, }; // Add functions @@ -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"); @@ -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"); @@ -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"); } @@ -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; -} \ No newline at end of file +} + +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(); +} diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index 38652371c00..b3d4cf2c78f 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -128,4 +128,6 @@ class CLuaVehicleDefs : public CLuaDefs static bool SpawnVehicleFlyingComponent(CVehicle* const vehicle, std::uint8_t nodeIndex, std::optional componentCollisionType, std::optional removalTime); static bool SetVehicleNitroActivated(CVehicle* vehicle, bool state) noexcept; + static bool SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state); + static bool IsVehicleSmokeTrailEnabled(CVehicle* vehicle) noexcept; }; diff --git a/Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp b/Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp index f87a776f1ea..4dfb6638d0b 100644 --- a/Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp +++ b/Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp @@ -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; diff --git a/Shared/sdk/net/rpc_enums.h b/Shared/sdk/net/rpc_enums.h index 84c7518bc45..fa7128576f8 100644 --- a/Shared/sdk/net/rpc_enums.h +++ b/Shared/sdk/net/rpc_enums.h @@ -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 };