Skip to content

Commit

Permalink
tweak(extra-natives/five): Change native name: PASSENGER_WEIGHT -> GL…
Browse files Browse the repository at this point in the history
…OBAL_PASSENGER_MASS_MULTIPLIER

tweak(native-docs): Add information aboud default value

feat(extra-natives/five): Reset passenger mass OnKillNetwork

tweak(extra-natives/five): Change native name PASSENGER_WEIGHT -> GLOBAL_PASSENGER_MASS_MULTIPLIER
  • Loading branch information
Explooosion-code committed Sep 19, 2024
1 parent 11c4e85 commit 341dcc5
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 37 deletions.
18 changes: 11 additions & 7 deletions code/components/extra-natives-five/src/VehicleExtraNatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -757,7 +757,7 @@ static HookFunction initFunction([]()

{
auto location = hook::get_pattern<char>("F3 0F 59 3D ? ? ? ? F3 0F 58 3D ? ? ? ? 48 85 C9", 4);
PassengerWeightPtr = hook::get_address<float*>(location);
PassengerMassPtr = hook::get_address<float*>(location);
}

{
Expand Down Expand Up @@ -1525,21 +1525,23 @@ 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<float>(0);

if (weight < 0.0)
{
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<float>(* PassengerWeightPtr);
trace("Weight is %.6f\n", *PassengerMassPtr);

context.SetResult<float>(*PassengerMassPtr);
});

static struct : jitasm::Frontend
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions ext/native-decls/GetGlobalPassengerMassMultiplier.md
Original file line number Diff line number Diff line change
@@ -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
15 changes: 0 additions & 15 deletions ext/native-decls/GetPassengerWeight.md

This file was deleted.

15 changes: 15 additions & 0 deletions ext/native-decls/SetGlobalPassengerMassMultiplier.md
Original file line number Diff line number Diff line change
@@ -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
15 changes: 0 additions & 15 deletions ext/native-decls/SetPassengerWeight.md

This file was deleted.

0 comments on commit 341dcc5

Please sign in to comment.