diff --git a/code/components/extra-natives-five/src/VehicleExtraNatives.cpp b/code/components/extra-natives-five/src/VehicleExtraNatives.cpp index c6c28e5f90..8028d10b61 100644 --- a/code/components/extra-natives-five/src/VehicleExtraNatives.cpp +++ b/code/components/extra-natives-five/src/VehicleExtraNatives.cpp @@ -242,6 +242,7 @@ static void writeVehicleMemory(fx::ScriptContext& context, std::string_view nn) } static float* PassengerMassPtr; +static float* SnowGripFactor; static int StreamRenderGfxPtrOffset; static int HandlingDataPtrOffset; @@ -775,6 +776,12 @@ static HookFunction initFunction([]() PassengerMassPtr = hook::get_address(location); } + { + SnowGripFactor = (float*)hook::AllocateStubMemory(4); + static uint8_t* location = hook::get_pattern("F3 0F 5C C8 48 3B C8", 4); + hook::put(location, (intptr_t)SnowGripFactor - (intptr_t)location - 4); + } + { std::initializer_list list = { { "44 38 ? ? ? ? 02 74 ? F3 0F 10 1D", 13 }, @@ -1581,6 +1588,22 @@ static HookFunction initFunction([]() context.SetResult(*PassengerMassPtr); }); + fx::ScriptEngine::RegisterNativeHandler("SET_VEHICLE_XMAS_SNOW_FACTOR", [](fx::ScriptContext& context) + { + float gripFactor = context.GetArgument(0); + + if (gripFactor < 0.0) + { + gripFactor = 0.0; + } + *SnowGripFactor = gripFactor; + }); + + fx::ScriptEngine::RegisterNativeHandler("GET_VEHICLE_XMAS_SNOW_FACTOR", [](fx::ScriptContext& context) + { + context.SetResult(*SnowGripFactor); + }); + static struct : jitasm::Frontend { static bool ShouldSkipRepairFunc(fwEntity* VehPointer) @@ -1660,6 +1683,7 @@ static HookFunction initFunction([]() g_globalFuelConsumptionMultiplier = 1.f; *PassengerMassPtr = 0.05f; + *SnowGripFactor = 0.2f; }); fx::ScriptEngine::RegisterNativeHandler("SET_VEHICLE_AUTO_REPAIR_DISABLED", [](fx::ScriptContext& context) diff --git a/ext/native-decls/GetVehicleXmasSnowFactor.md b/ext/native-decls/GetVehicleXmasSnowFactor.md new file mode 100644 index 0000000000..ebee222856 --- /dev/null +++ b/ext/native-decls/GetVehicleXmasSnowFactor.md @@ -0,0 +1,12 @@ +--- +ns: CFX +apiset: client +game: gta5 +--- +## GET_VEHICLE_XMAS_SNOW_FACTOR +```c +float GET_VEHICLE_XMAS_SNOW_FACTOR(); +``` +A getter for [SET_VEHICLE_XMAS_SNOW_FACTOR](#_80cc4c9e). +## Return value +Returns the grip factor for the vehicles wheels during xmas weather. default value is 0.2. \ No newline at end of file diff --git a/ext/native-decls/SetVehicleXmasSnowFactor.md b/ext/native-decls/SetVehicleXmasSnowFactor.md new file mode 100644 index 0000000000..7d1069508a --- /dev/null +++ b/ext/native-decls/SetVehicleXmasSnowFactor.md @@ -0,0 +1,11 @@ +--- +ns: CFX +apiset: client +game: gta5 +--- +## SET_VEHICLE_XMAS_SNOW_FACTOR +```c +void SET_VEHICLE_XMAS_SNOW_FACTOR(float gripFactor); +``` +## Parameters +* **gripFactor**: amount of grip strength vehicle wheels have when xmas weather is active, 1.0 being normal weather grip. 0.2 is the default. \ No newline at end of file