Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions code/components/extra-natives-five/src/VehicleExtraNatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ static int TrainStateOffset;
static int TrainCruiseSpeedOffset;
static int TrainSpeedOffset;

static int PlaneBladesSpeedOffset;
static int HeliBladesSpeedOffset;

constexpr int TrainStopAtStationsFlag = 4;

static int VehicleRepairMethodVtableOffset;
Expand Down Expand Up @@ -644,6 +647,8 @@ static HookFunction initFunction([]()
TrainCruiseSpeedOffset = *hook::get_pattern<uint32_t>("C7 87 ? ? ? ? ? ? ? ? E8 ? ? ? ? 4C 89 AF", 2);
TrainSpeedOffset = *hook::get_pattern<uint32_t>("4C 89 AF ? ? ? ? 44 89 AF ? ? ? ? 4C 89 AF ? ? ? ? 49 8B 0E", 3);
TrainTrackIndexOffset = *hook::get_pattern<uint32_t>("8A 8F ? ? ? ? F3 41 0F 58 CB", 2);
PlaneBladesSpeedOffset = *hook::get_pattern<uint32_t>("F3 0F 59 C6 F3 0F 11 83 ? ? ? ? 48 8B 83", 8);
HeliBladesSpeedOffset = *hook::get_pattern<uint32_t>("F3 0F 11 89 ? ? ? ? 48 8B D9 E8 ? ? ? ? 33 FF", 4);
}

{
Expand Down Expand Up @@ -1825,6 +1830,24 @@ static HookFunction initFunction([]()
g_overrideUseDefaultDriveByClipset = context.GetArgument<bool>(0);
});

fx::ScriptEngine::RegisterNativeHandler("GET_HELI_BLADES_SPEED", [](fx::ScriptContext& context)
{
if (fwEntity* vehicle = getAndCheckVehicle(context, "GET_HELI_BLADES_SPEED"))
{
int vehicleType = readValue<int>(vehicle, VehicleTypeOffset);

if (vehicleType == 1)
{
return context.SetResult<float>(readValue<float>(vehicle, PlaneBladesSpeedOffset));
}
else if (vehicleType >= 8 && vehicleType <= 10)
{
return context.SetResult<float>(readValue<float>(vehicle, HeliBladesSpeedOffset));
}
}
context.SetResult<float>(0.0f);
});

// vehicle xenon lights patches to support RGB colors
{
static struct : jitasm::Frontend
Expand Down
19 changes: 19 additions & 0 deletions ext/native-decls/GetHeliBladesSpeed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
ns: CFX
apiset: client
game: gta5
---
## GET_HELI_BLADES_SPEED

```c
float GET_HELI_BLADES_SPEED(Vehicle vehicle);
```

This native is a getter for [SET_HELI_BLADES_SPEED](#_0xFD280B4D7F3ABC4D)


## Parameters
* **vehicle**: The helicopter or the plane

## Return value
Returns a value representing the blade speed of the helicopter or plane. Value ranges from `0.0` to `1.0`.
Loading