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
91 changes: 91 additions & 0 deletions code/components/extra-natives-five/src/PedAccuracyExtraNatives.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include <StdInc.h>
#include <Hooking.h>

#include <ScriptEngine.h>

#include <Resource.h>
#include <fxScripting.h>

struct PlayerRecoilModifiers
{
float recoilModifierMin;
float recoilModifierMax;
float recoilCrouchedModifier;
float blindFireModifierMin;
float blindFireModifierMax;
float recentlyDamagedModifier;
};

static PlayerRecoilModifiers* g_playerModifiers;

static HookFunction initFunction([]()
{
auto location = hook::get_pattern<char>("48 8B C8 E8 ? ? ? ? F3 0F 10 1D ? ? ? ? F3 0F 5C 1D ? ? ? ? 0F 28 C8");
g_playerModifiers = hook::get_address<PlayerRecoilModifiers*>(location + 20);

fx::ScriptEngine::RegisterNativeHandler("GET_PLAYER_RECOIL_MODIFIER_MIN", [=](fx::ScriptContext& context)
{
context.SetResult<float>(g_playerModifiers->recoilModifierMin);
});

fx::ScriptEngine::RegisterNativeHandler("SET_PLAYER_RECOIL_MODIFIER_MIN", [=](fx::ScriptContext& context)
{
const float value = context.GetArgument<float>(0);
g_playerModifiers->recoilModifierMin = value;
});

fx::ScriptEngine::RegisterNativeHandler("GET_PLAYER_RECOIL_MODIFIER_MAX", [=](fx::ScriptContext& context)
{
context.SetResult<float>(g_playerModifiers->recoilModifierMax);
});

fx::ScriptEngine::RegisterNativeHandler("SET_PLAYER_RECOIL_MODIFIER_MAX", [=](fx::ScriptContext& context)
{
const float value = context.GetArgument<float>(0);
g_playerModifiers->recoilModifierMax = value;
});

fx::ScriptEngine::RegisterNativeHandler("GET_PLAYER_RECOIL_CROUCHED_MODIFIER", [=](fx::ScriptContext& context)
{
context.SetResult<float>(g_playerModifiers->recoilCrouchedModifier);
});

fx::ScriptEngine::RegisterNativeHandler("SET_PLAYER_RECOIL_CROUCHED_MODIFIER", [=](fx::ScriptContext& context)
{
const float value = context.GetArgument<float>(0);
g_playerModifiers->recoilCrouchedModifier = value;
});

fx::ScriptEngine::RegisterNativeHandler("GET_PLAYER_BLIND_FIRE_MODIFIER_MIN", [=](fx::ScriptContext& context)
{
context.SetResult<float>(g_playerModifiers->blindFireModifierMin);
});

fx::ScriptEngine::RegisterNativeHandler("SET_PLAYER_BLIND_FIRE_MODIFIER_MIN", [=](fx::ScriptContext& context)
{
const float value = context.GetArgument<float>(0);
g_playerModifiers->blindFireModifierMin = value;
});

fx::ScriptEngine::RegisterNativeHandler("GET_PLAYER_BLIND_FIRE_MODIFIER_MAX", [=](fx::ScriptContext& context)
{
context.SetResult<float>(g_playerModifiers->blindFireModifierMax);
});

fx::ScriptEngine::RegisterNativeHandler("SET_PLAYER_BLIND_FIRE_MODIFIER_MAX", [=](fx::ScriptContext& context)
{
const float value = context.GetArgument<float>(0);
g_playerModifiers->blindFireModifierMax = value;
});

fx::ScriptEngine::RegisterNativeHandler("GET_PLAYER_RECENTLY_DAMAGED_MODIFIER", [=](fx::ScriptContext& context)
{
context.SetResult<float>(g_playerModifiers->recentlyDamagedModifier);
});

fx::ScriptEngine::RegisterNativeHandler("SET_PLAYER_RECENTLY_DAMAGED_MODIFIER", [=](fx::ScriptContext& context)
{
const float value = context.GetArgument<float>(0);
g_playerModifiers->recentlyDamagedModifier = value;
});
});
15 changes: 15 additions & 0 deletions ext/native-decls/GetPlayerBlindFireModifierMax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
ns: CFX
apiset: client
game: gta5
---
## GET_PLAYER_BLIND_FIRE_MODIFIER_MAX

```c
float GET_PLAYER_BLIND_FIRE_MODIFIER_MAX();
```

A getter for [`SET_PLAYER_BLIND_FIRE_MODIFIER_MAX`](#_0X39AC373D).

## Return value
The current blind fire maximum recoil modifier value.
15 changes: 15 additions & 0 deletions ext/native-decls/GetPlayerBlindFireModifierMin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
ns: CFX
apiset: client
game: gta5
---
## GET_PLAYER_BLIND_FIRE_MODIFIER_MIN

```c
float GET_PLAYER_BLIND_FIRE_MODIFIER_MIN();
```

A getter for [`SET_PLAYER_BLIND_FIRE_MODIFIER_MIN`](#_0X695C0D48).

## Return value
The current blind fire minimum recoil modifier value.
15 changes: 15 additions & 0 deletions ext/native-decls/GetPlayerRecentlyDamagedModifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
ns: CFX
apiset: client
game: gta5
---
## GET_PLAYER_RECENTLY_DAMAGED_MODIFIER

```c
float GET_PLAYER_RECENTLY_DAMAGED_MODIFIER();
```

A getter for [`SET_PLAYER_RECENTLY_DAMAGED_MODIFIER`](#_0XC5A3A790).

## Return value
The current recently damaged recoil modifier value.
15 changes: 15 additions & 0 deletions ext/native-decls/GetPlayerRecoilCrouchedModifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
ns: CFX
apiset: client
game: gta5
---
## GET_PLAYER_RECOIL_CROUCHED_MODIFIER

```c
float GET_PLAYER_RECOIL_CROUCHED_MODIFIER();
```

Getter for [`SET_PLAYER_RECOIL_CROUCHED_MODIFIER`](#_0X432FBA5C).

## Return value
The current crouched recoil modifier value.
15 changes: 15 additions & 0 deletions ext/native-decls/GetPlayerRecoilModifierMax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
ns: CFX
apiset: client
game: gta5
---
## GET_PLAYER_RECOIL_MODIFIER_MAX

```c
float GET_PLAYER_RECOIL_MODIFIER_MAX();
```

Getter for [`SET_PLAYER_RECOIL_MODIFIER_MAX`](#_0X37C2D9F4).

## Return value
The current maximum recoil modifier value.
15 changes: 15 additions & 0 deletions ext/native-decls/GetPlayerRecoilModifierMin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
ns: CFX
apiset: client
game: gta5
---
## GET_PLAYER_RECOIL_MODIFIER_MIN

```c
float GET_PLAYER_RECOIL_MODIFIER_MIN();
```

Getter for [`SET_PLAYER_RECOIL_MODIFIER_MIN`](#_0X104413EF).

## Return value
The current minimum recoil modifier value.
16 changes: 16 additions & 0 deletions ext/native-decls/SetPlayerBlindFireModifierMax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
ns: CFX
apiset: client
game: gta5
---
## SET_PLAYER_BLIND_FIRE_MODIFIER_MAX

```c
void SET_PLAYER_BLIND_FIRE_MODIFIER_MAX(float value);
```

Sets the maximum recoil modifier when firing blindly from cover.
Default value `4.0`.

## Parameters
* **value**: New modifier
16 changes: 16 additions & 0 deletions ext/native-decls/SetPlayerBlindFireModifierMin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
ns: CFX
apiset: client
game: gta5
---
## SET_PLAYER_BLIND_FIRE_MODIFIER_MIN

```c
void SET_PLAYER_BLIND_FIRE_MODIFIER_MIN(float value);
```

Sets the minimum recoil modifier when firing blindly from cover.
Default value `2.0`.

## Parameters
* **value**: New modifier
16 changes: 16 additions & 0 deletions ext/native-decls/SetPlayerRecentlyDamagedModifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
ns: CFX
apiset: client
game: gta5
---
## SET_PLAYER_RECENTLY_DAMAGED_MODIFIER

```c
void SET_PLAYER_RECENTLY_DAMAGED_MODIFIER(float value);
```

Sets the recoil modifier applied when the player has been recently damaged.
The default value is `0.3`.

## Parameters
* **value**: New modifier
16 changes: 16 additions & 0 deletions ext/native-decls/SetPlayerRecoilCrouchedModifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
ns: CFX
apiset: client
game: gta5
---
## SET_PLAYER_RECOIL_CROUCHED_MODIFIER

```c
void SET_PLAYER_RECOIL_CROUCHED_MODIFIER(float value);
```

Sets the recoil modifier applied when the player is crouching.
The default value is `0.5`.

## Parameters
* **value**: New modifier
16 changes: 16 additions & 0 deletions ext/native-decls/SetPlayerRecoilModifierMax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
ns: CFX
apiset: client
game: gta5
---
## SET_PLAYER_RECOIL_MODIFIER_MAX

```c
void SET_PLAYER_RECOIL_MODIFIER_MAX(float value);
```

Sets the recoil modifier.
The default value is `1.0`.

## Parameters
* **value**: New modifier
16 changes: 16 additions & 0 deletions ext/native-decls/SetPlayerRecoilModifierMin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
ns: CFX
apiset: client
game: gta5
---
## SET_PLAYER_RECOIL_MODIFIER_MIN

```c
void SET_PLAYER_RECOIL_MODIFIER_MIN(float value);
```

Sets the recoil modifier.
The default value is `0.8`.

## Parameters
* **value**: New modifier
Loading