diff --git a/code/components/extra-natives-five/src/VehicleExtraNatives.cpp b/code/components/extra-natives-five/src/VehicleExtraNatives.cpp index 45ec7b816f..366950ae82 100644 --- a/code/components/extra-natives-five/src/VehicleExtraNatives.cpp +++ b/code/components/extra-natives-five/src/VehicleExtraNatives.cpp @@ -236,7 +236,7 @@ static void writeVehicleMemory(fx::ScriptContext& context, std::string_view nn) } } -static float* PassengerWeightPtr; +static float* PassengerMassPtr; static int StreamRenderGfxPtrOffset; static int HandlingDataPtrOffset; @@ -757,7 +757,7 @@ static HookFunction initFunction([]() { auto location = hook::get_pattern("F3 0F 59 3D ? ? ? ? F3 0F 58 3D ? ? ? ? 48 85 C9", 4); - PassengerWeightPtr = hook::get_address(location); + PassengerMassPtr = hook::get_address(location); } { @@ -1525,7 +1525,7 @@ static HookFunction initFunction([]() ResetFlyThroughWindscreenParams(); }); - fx::ScriptEngine::RegisterNativeHandler("SET_PASSENGER_WEIGHT", [](fx::ScriptContext& context) + fx::ScriptEngine::RegisterNativeHandler("SET_GLOBAL_PASSENGER_MASS_MULTIPLIER", [](fx::ScriptContext& context) { float weight = context.GetArgument(0); @@ -1533,13 +1533,15 @@ static HookFunction initFunction([]() { weight = 0.0; } - - *PassengerWeightPtr = weight; + trace("Setting weight %.6f was %.6f\n", weight, *PassengerMassPtr); + *PassengerMassPtr = weight; }); - fx::ScriptEngine::RegisterNativeHandler("GET_PASSENGER_WEIGHT", [](fx::ScriptContext& context) + fx::ScriptEngine::RegisterNativeHandler("GET_GLOBAL_PASSENGER_MASS_MULTIPLIER", [](fx::ScriptContext& context) { - context.SetResult(* PassengerWeightPtr); + trace("Weight is %.6f\n", *PassengerMassPtr); + + context.SetResult(*PassengerMassPtr); }); static struct : jitasm::Frontend @@ -1619,6 +1621,8 @@ static HookFunction initFunction([]() g_isFuelConsumptionOn = false; g_globalFuelConsumptionMultiplier = 1.f; + + *PassengerMassPtr = 0.05f; }); fx::ScriptEngine::RegisterNativeHandler("SET_VEHICLE_AUTO_REPAIR_DISABLED", [](fx::ScriptContext& context) diff --git a/ext/native-decls/GetGlobalPassengerMassMultiplier.md b/ext/native-decls/GetGlobalPassengerMassMultiplier.md new file mode 100644 index 0000000000..db229af498 --- /dev/null +++ b/ext/native-decls/GetGlobalPassengerMassMultiplier.md @@ -0,0 +1,15 @@ +--- +ns: CFX +apiset: client +game: gta5 +--- +## GET_GLOBAL_PASSENGER_MASS_MULTIPLIER + +```c +float GET_GLOBAL_PASSENGER_MASS_MULTIPLIER(); +``` + +A getter for [SET_GLOBAL_PASSENGER_MASS_MULTIPLIER](#_0x1c47f6ac). + +## Return value +Returns the mass of each passenger (not counting the driver) as a percentage of vehicle mass. Default value is 0.05 \ No newline at end of file diff --git a/ext/native-decls/GetPassengerWeight.md b/ext/native-decls/GetPassengerWeight.md deleted file mode 100644 index 6c8f015fe0..0000000000 --- a/ext/native-decls/GetPassengerWeight.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -ns: CFX -apiset: client -game: gta5 ---- -## GET_PASSENGER_WEIGHT - -```c -float GET_PASSENGER_WEIGHT(); -``` - -A getter for [SET_PASSENGER_WEIGHT](#_0x58e530aa). - -## Return value -Returns the weight of each passenger (not counting the driver) as a percentage of vehicle mass. \ No newline at end of file diff --git a/ext/native-decls/SetGlobalPassengerMassMultiplier.md b/ext/native-decls/SetGlobalPassengerMassMultiplier.md new file mode 100644 index 0000000000..12a9ef4d2f --- /dev/null +++ b/ext/native-decls/SetGlobalPassengerMassMultiplier.md @@ -0,0 +1,15 @@ +--- +ns: CFX +apiset: client +game: gta5 +--- +## SET_GLOBAL_PASSENGER_MASS_MULTIPLIER + +```c +void SET_GLOBAL_PASSENGER_MASS_MULTIPLIER(float massMul); +``` + +## Parameters +* **massMul**: Weight of each passenger (not counting the driver) as a percentage of vehicle mass. Is applied to all vehicles. Default value is 0.05 + +## Return value \ No newline at end of file diff --git a/ext/native-decls/SetPassengerWeight.md b/ext/native-decls/SetPassengerWeight.md deleted file mode 100644 index f07413b1e9..0000000000 --- a/ext/native-decls/SetPassengerWeight.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -ns: CFX -apiset: client -game: gta5 ---- -## SET_PASSENGER_WEIGHT - -```c -void SET_PASSENGER_WEIGHT(float weight); -``` - -## Parameters -* **weight**: Weight of each passenger (not counting the driver) as a percentage of vehicle mass. Is applied to all vehicles - -## Return value \ No newline at end of file