From f105179a9adcc3fab48daff195628b3a9d8cbf88 Mon Sep 17 00:00:00 2001 From: Disquse Date: Wed, 7 Feb 2024 17:23:37 +0300 Subject: [PATCH 1/2] feat(extra-natives/five): drive-by clipset fallback bypass native --- .../src/VehicleExtraNatives.cpp | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/code/components/extra-natives-five/src/VehicleExtraNatives.cpp b/code/components/extra-natives-five/src/VehicleExtraNatives.cpp index 9460e36ae3..c6bbd411cb 100644 --- a/code/components/extra-natives-five/src/VehicleExtraNatives.cpp +++ b/code/components/extra-natives-five/src/VehicleExtraNatives.cpp @@ -371,6 +371,20 @@ static void DeleteNetworkCloneWrap(void* objectMgr, void* netObject, int reason, return g_origDeleteNetworkClone(objectMgr, netObject, reason, forceRemote1, forceRemote2); } +static bool g_overrideUseDefaultDriveByClipset = false; + +static bool (*g_origShouldUseDefaultDriveByClipset)(CPed*, char); + +static bool ShouldUseDefaultDriveByClipset(CPed* ped, char flag) +{ + if (g_overrideUseDefaultDriveByClipset) + { + return false; + } + + return g_origShouldUseDefaultDriveByClipset(ped, flag); +} + static void ResetFlyThroughWindscreenParams() { for (auto& entry : g_flyThroughWindscreenParams) @@ -1364,9 +1378,11 @@ static HookFunction initFunction([]() g_skipRepairVehicles.clear(); ResetFlyThroughWindscreenParams(); *g_trainsForceDoorsOpen = true; + g_overrideUseDefaultDriveByClipset = false; }); - fx::ScriptEngine::RegisterNativeHandler("SET_VEHICLE_AUTO_REPAIR_DISABLED", [](fx::ScriptContext& context) { + fx::ScriptEngine::RegisterNativeHandler("SET_VEHICLE_AUTO_REPAIR_DISABLED", [](fx::ScriptContext& context) + { auto vehHandle = context.GetArgument(0); auto shouldDisable = context.GetArgument(1); @@ -1422,6 +1438,11 @@ static HookFunction initFunction([]() g_overrideCanPedStandOnVehicle = context.GetArgument(0); }); + fx::ScriptEngine::RegisterNativeHandler("OVERRIDE_PEDS_USE_DEFAULT_DRIVE_BY_CLIPSET", [](fx::ScriptContext& context) + { + g_overrideUseDefaultDriveByClipset = context.GetArgument(0); + }); + // vehicle xenon lights patches to support RGB colors { static struct : jitasm::Frontend @@ -1591,6 +1612,7 @@ static HookFunction initFunction([]() MH_Initialize(); MH_CreateHook(hook::get_pattern("E8 ? ? ? ? 8A 83 DA 00 00 00 24 0F 3C 02", -0x32), DeleteVehicleWrap, (void**)&g_origDeleteVehicle); MH_CreateHook(hook::get_pattern("80 7A 4B 00 45 8A F9", -0x1D), DeleteNetworkCloneWrap, (void**)&g_origDeleteNetworkClone); + MH_CreateHook(hook::get_call(hook::get_pattern("E8 ? ? ? ? 84 C0 74 0F 8B 47 20")), ShouldUseDefaultDriveByClipset, (void**)&g_origShouldUseDefaultDriveByClipset); MH_CreateHook(hook::get_call(hook::get_pattern("74 22 48 8B CA E8 ? ? ? ? 84 C0 74 16", 5)), CanPedStandOnVehicleWrap, (void**)&g_origCanPedStandOnVehicle); MH_CreateHook(hook::get_call(hook::get_pattern("48 8B 4F 20 48 8D 54 24 ? E8", 0x9)), DashboardHandler, (void**)&g_origDashboardHandler); MH_EnableHook(MH_ALL_HOOKS); From 00e7ded7accd09323162301d814696bd5f981375 Mon Sep 17 00:00:00 2001 From: Disquse Date: Thu, 8 Feb 2024 19:58:37 +0300 Subject: [PATCH 2/2] feat(native-decls): add `OVERRIDE_PEDS_USE_DEFAULT_DRIVE_BY_CLIPSET` Co-Authored-By: Gottfried Leibniz <37632412+gottfriedleibniz@users.noreply.github.com> --- .../OverridePedsUseDefaultDriveByClipset.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 ext/native-decls/OverridePedsUseDefaultDriveByClipset.md diff --git a/ext/native-decls/OverridePedsUseDefaultDriveByClipset.md b/ext/native-decls/OverridePedsUseDefaultDriveByClipset.md new file mode 100644 index 0000000000..2c5573237f --- /dev/null +++ b/ext/native-decls/OverridePedsUseDefaultDriveByClipset.md @@ -0,0 +1,17 @@ +--- +ns: CFX +apiset: client +game: gta5 +--- +## OVERRIDE_PEDS_USE_DEFAULT_DRIVE_BY_CLIPSET + +```c +void OVERRIDE_PEDS_USE_DEFAULT_DRIVE_BY_CLIPSET(BOOL flag); +``` + +Allows the bypassing of default game behavior that prevents the use of [SET_PED_DRIVE_BY_CLIPSET_OVERRIDE](#_0xED34AB6C5CB36520) in certain scenarios to avoid clipping issues (e.g., when there is more than one Ped in a vehicle). + +Note: This flag and the overridden clipset are not replicated values and require synchronization through user scripts. Additionally, current game behavior also restricts applying this clipset locally when in first-person mode and will require a temporary workaround. + +## Parameters +* **flag**: true to override, false to use default game behavior.