refactor: all weapons in vehicle (#1197)

This commit is contained in:
Aure7138 2023-04-06 02:25:20 +08:00 committed by GitHub
parent 96d1c26242
commit 51e3b6e132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 13 deletions

View File

@ -7,20 +7,10 @@ namespace big
{
using looped_command::looped_command;
virtual void on_enable() override
{
g_pointers->m_allow_weapons_in_vehicle->apply();
}
virtual void on_tick() override
{
}
virtual void on_disable() override
{
g_pointers->m_allow_weapons_in_vehicle->restore();
}
};
veh_unlimited_weapons g_veh_unlimited_weapons("vehallweapons", "Allow Weapons In Vehicle", "Allows you to use all weapons in vehicle", g.vehicle.unlimited_weapons);
}

View File

@ -123,6 +123,8 @@ namespace big
detour_hook_helper::add<hooks::fipackfile_mount>("FPFM", g_pointers->m_fipackfile_mount);
detour_hook_helper::add<hooks::allow_weapons_in_vehicle>("AWIV", g_pointers->m_allow_weapons_in_vehicle);
g_hooking = this;
}

View File

@ -165,6 +165,8 @@ namespace big
static void write_vehicle_proximity_migration_data_node(rage::netObject* veh, CVehicleProximityMigrationDataNode* node);
static bool fipackfile_mount(rage::fiPackfile* this_, const char* mount_point);
static bool allow_weapons_in_vehicle(int64_t unk, int weaponinfo_group);
};
class minhook_keepalive

View File

@ -0,0 +1,15 @@
#include "hooking.hpp"
namespace big
{
bool hooks::allow_weapons_in_vehicle(int64_t unk, int weaponinfo_group)
{
if (g.vehicle.unlimited_weapons)
{
if (weaponinfo_group == RAGE_JOAAT("GROUP_THROWN")) //Because the thrower can be used without bypassing, we let the game decide the return value, since this function has multiple xrefs, it may be necessary to return 0 at some point
return g_hooking->get_original<allow_weapons_in_vehicle>()(unk, weaponinfo_group);
return true;
}
return g_hooking->get_original<allow_weapons_in_vehicle>()(unk, weaponinfo_group);
}
}

View File

@ -737,8 +737,8 @@ namespace big
});
// Allow Weapons In Vehicle
main_batch.add("AWIV", "49 3B C9 7C F0 ? ? C3", [this](memory::handle ptr) {
m_allow_weapons_in_vehicle = memory::byte_patch::make(ptr.add(5).as<uint16_t*>(), 0x01B0).get(); //In order for the second xref loop not to stop
main_batch.add("AWIV", "49 8B 40 08 39 10", [this](memory::handle ptr) {
m_allow_weapons_in_vehicle = ptr.sub(23).as<PVOID>();
});
// Crash Trigger

View File

@ -255,7 +255,7 @@ namespace big
bool* m_refresh_audio_input{};
memory::byte_patch* m_disable_collision{};
memory::byte_patch* m_allow_weapons_in_vehicle{};
PVOID m_allow_weapons_in_vehicle{};
PVOID m_taskjump_constructor{};