Completely rewrote Vehicle Godmode.
This commit is contained in:
parent
ee69b3b0b9
commit
391596eb49
@ -2,8 +2,8 @@ include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
gtav_classes
|
||||
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
|
||||
GIT_TAG b9b832ab00c95a731f8472f696c5d026a29fd767
|
||||
GIT_REPOSITORY https://github.com/gir489returns/GTAV-Classes.git
|
||||
GIT_TAG 9dd81150412bbd2a207eff0beb9415f4f5d9348c
|
||||
GIT_PROGRESS TRUE
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
|
@ -33,7 +33,6 @@ namespace big
|
||||
while (g_running)
|
||||
{
|
||||
looped::system_self_globals();
|
||||
looped::system_update_pointers();
|
||||
looped::system_update_desync_kick();
|
||||
looped::system_spoofing();
|
||||
looped::system_mission_creator();
|
||||
|
@ -39,7 +39,6 @@ namespace big
|
||||
static void session_modder_detection();
|
||||
|
||||
static void system_self_globals();
|
||||
static void system_update_pointers();
|
||||
static void system_update_desync_kick();
|
||||
static void system_spoofing();
|
||||
static void system_mission_creator();
|
||||
|
@ -1,34 +1,36 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "pointers.hpp"
|
||||
|
||||
#include <network/CNetworkPlayerMgr.hpp>
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::system_self_globals()
|
||||
{
|
||||
if (!(*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player
|
||||
|| (*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player->m_player_id == static_cast<uint8_t>(-1)) [[unlikely]]
|
||||
self::id = 0;
|
||||
else [[likely]]
|
||||
self::id = (*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player->m_player_id;
|
||||
|
||||
self::ped = PLAYER::PLAYER_PED_ID();
|
||||
|
||||
STATS::STAT_GET_INT("MPPLY_LAST_MP_CHAR"_J, &self::char_index, true);
|
||||
|
||||
self::pos = ENTITY::GET_ENTITY_COORDS(self::ped, false /*Unused*/);
|
||||
|
||||
self::rot = ENTITY::GET_ENTITY_ROTATION(self::ped, 2);
|
||||
|
||||
if (PED::IS_PED_IN_ANY_VEHICLE(self::ped, 0))
|
||||
{
|
||||
self::veh = PED::GET_VEHICLE_PED_IS_IN(self::ped, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self::veh = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "pointers.hpp"
|
||||
#include "gta_util.hpp"
|
||||
|
||||
#include <network/CNetworkPlayerMgr.hpp>
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::system_self_globals()
|
||||
{
|
||||
if (!(*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player
|
||||
|| (*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player->m_player_id == static_cast<uint8_t>(-1)) [[unlikely]]
|
||||
self::id = 0;
|
||||
else [[likely]]
|
||||
self::id = (*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player->m_player_id;
|
||||
|
||||
self::ped = PLAYER::PLAYER_PED_ID();
|
||||
g_local_player = gta_util::get_local_ped();
|
||||
|
||||
STATS::STAT_GET_INT("MPPLY_LAST_MP_CHAR"_J, &self::char_index, true);
|
||||
|
||||
self::pos = ENTITY::GET_ENTITY_COORDS(self::ped, false /*Unused*/);
|
||||
|
||||
self::rot = ENTITY::GET_ENTITY_ROTATION(self::ped, 2);
|
||||
|
||||
if (PED::IS_PED_IN_ANY_VEHICLE(self::ped, 0))
|
||||
{
|
||||
self::veh = PED::GET_VEHICLE_PED_IS_IN(self::ped, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self::veh = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "gta_util.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::system_update_pointers()
|
||||
{
|
||||
g_local_player = gta_util::get_local_ped();
|
||||
}
|
||||
}
|
@ -11,6 +11,8 @@ namespace big
|
||||
|
||||
virtual void on_tick() override
|
||||
{
|
||||
return;
|
||||
|
||||
Vehicle veh = self::veh;
|
||||
|
||||
if (veh == 0 || VEHICLE::GET_PED_IN_VEHICLE_SEAT(self::veh, SEAT_DRIVER, FALSE) != self::ped)
|
||||
|
@ -104,6 +104,8 @@ namespace big
|
||||
|
||||
virtual void on_tick() override
|
||||
{
|
||||
return;
|
||||
|
||||
if (g_local_player)
|
||||
{
|
||||
const auto personal_vehicle = get_personal_vehicle();
|
||||
@ -114,6 +116,8 @@ namespace big
|
||||
|
||||
virtual void on_disable() override
|
||||
{
|
||||
return;
|
||||
|
||||
if (g_local_player)
|
||||
{
|
||||
if (g_local_player->m_vehicle)
|
||||
|
@ -411,6 +411,10 @@ namespace big
|
||||
|
||||
functions::is_ped_enemies_with m_is_ped_enemies_with;
|
||||
functions::can_do_damage_to_ped m_can_do_damage_to_ped;
|
||||
|
||||
PVOID m_damage_vehicle;
|
||||
PVOID m_deform_vehicle;
|
||||
PVOID m_is_driver_invincible;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned");
|
||||
|
@ -156,6 +156,10 @@ namespace big
|
||||
|
||||
detour_hook_helper::add<hooks::create_pool_item>("CPI", g_pointers->m_gta.m_create_pool_item);
|
||||
|
||||
detour_hook_helper::add<hooks::damage_vehicle>("VDF", g_pointers->m_gta.m_damage_vehicle);
|
||||
detour_hook_helper::add<hooks::apply_deformation>("ADFV", g_pointers->m_gta.m_deform_vehicle);
|
||||
detour_hook_helper::add<hooks::is_vehicle_invincible>("ISDINV", g_pointers->m_gta.m_is_driver_invincible);
|
||||
|
||||
g_hooking = this;
|
||||
}
|
||||
|
||||
|
@ -213,6 +213,10 @@ namespace big
|
||||
static void error_packet_memmove(void* dst, void* src, int size);
|
||||
|
||||
static void* create_pool_item(GenericPool* pool);
|
||||
|
||||
static float damage_vehicle(CVehicleDamage* thisptr, rage::CEntity* source, eDamageType damage_type, Hash weapon, float damage, rage::fvector3* position, rage::fvector3* dot_product, rage::fvector3* unk, std::uint32_t body_part, std::uint64_t damage_material, std::int32_t wheel_index, bool unk1, bool unk2, float radius, bool unk3, bool unk4, bool source_is_melee, const bool unk5, bool max_damage);
|
||||
static bool apply_deformation(CDeformation* thisptr, rage::fvector3* unk, rage::fvector3* unk2, rage::CEntity* source, bool set_all_deformations, bool break_glass);
|
||||
static bool is_vehicle_invincible(CVehicleDamage* thisptr);
|
||||
};
|
||||
|
||||
class minhook_keepalive
|
||||
|
73
src/hooks/vehicle/do_damage.cpp
Normal file
73
src/hooks/vehicle/do_damage.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include "hooking/hooking.hpp"
|
||||
#include "pointers.hpp"
|
||||
#include "util/mobile.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
float hooks::damage_vehicle(CVehicleDamage* thisptr, rage::CEntity* source, eDamageType damage_type, Hash weapon, float damage, rage::fvector3* position, rage::fvector3* dot_product, rage::fvector3* unk, std::uint32_t body_part, std::uint64_t damage_material, std::int32_t wheel_index, bool unk1, bool unk2, float radius, bool unk3, bool unk4, bool source_is_melee, bool unk5, bool max_damage)
|
||||
{
|
||||
if (g.vehicle.god_mode)
|
||||
{
|
||||
if (self::veh != 0)
|
||||
{
|
||||
if (const auto current_vehicle = g_local_player->m_vehicle)
|
||||
{
|
||||
if (current_vehicle->m_driver == g_local_player && ¤t_vehicle->m_vehicle_damage == thisptr)
|
||||
{
|
||||
LOG(INFO) << "damage_vehicle REJECTED";
|
||||
return 0.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (const auto personal_vehicle = mobile::mechanic::get_personal_cvehicle())
|
||||
{
|
||||
if (&personal_vehicle->m_vehicle_damage == thisptr)
|
||||
{
|
||||
LOG(INFO) << "personal_vehicle damage_vehicle REJECTED";
|
||||
return 0.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
return g_hooking->get_original<hooks::damage_vehicle>()(thisptr, source, damage_type, weapon, damage, position, dot_product, unk, body_part, damage_material, wheel_index, unk1, unk2, radius, unk3, unk4, source_is_melee, unk5, max_damage);
|
||||
}
|
||||
|
||||
bool hooks::apply_deformation(CDeformation* thisptr, rage::fvector3* unk, rage::fvector3* unk2, rage::CEntity* source, bool set_all_deformations, bool break_glass)
|
||||
{
|
||||
if (g.vehicle.proof_collision)
|
||||
{
|
||||
if (self::veh != 0)
|
||||
{
|
||||
if (const auto current_vehicle = g_local_player->m_vehicle)
|
||||
{
|
||||
if (current_vehicle->m_driver == g_local_player && ¤t_vehicle->m_vehicle_damage.m_deformation == thisptr)
|
||||
{
|
||||
LOG(INFO) << "apply_deformation REJECTED";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (const auto personal_vehicle = mobile::mechanic::get_personal_cvehicle())
|
||||
{
|
||||
if (&personal_vehicle->m_vehicle_damage.m_deformation == thisptr)
|
||||
{
|
||||
LOG(INFO) << "personal_vehicle apply_deformation REJECTED";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return g_hooking->get_original<hooks::apply_deformation>()(thisptr, unk, unk2, source, set_all_deformations, break_glass);
|
||||
}
|
||||
|
||||
bool hooks::is_vehicle_invincible(CVehicleDamage* thisptr)
|
||||
{
|
||||
if (g.vehicle.proof_collision)
|
||||
{
|
||||
if (thisptr->m_vehicle->m_driver == g_local_player)
|
||||
{
|
||||
//LOG(INFO) << "is_vehicle_invincible spoofed";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return g_hooking->get_original<hooks::is_vehicle_invincible>()(thisptr);
|
||||
}
|
||||
}
|
@ -1958,6 +1958,33 @@ namespace big
|
||||
{
|
||||
g_pointers->m_gta.m_can_do_damage_to_ped = ptr.add(1).rip().as<functions::can_do_damage_to_ped>();
|
||||
}
|
||||
},
|
||||
// Damage vehicle.
|
||||
{
|
||||
"DVF",
|
||||
"E8 ? ? ? ? 32 D2 32 C9",
|
||||
[](memory::handle ptr)
|
||||
{
|
||||
g_pointers->m_gta.m_damage_vehicle = ptr.add(1).rip().as<PVOID>();
|
||||
}
|
||||
},
|
||||
// Deform vehicle.
|
||||
{
|
||||
"DEFV",
|
||||
"E8 ? ? ? ? 33 D2 38 96",
|
||||
[](memory::handle ptr)
|
||||
{
|
||||
g_pointers->m_gta.m_deform_vehicle = ptr.add(1).rip().as<PVOID>();
|
||||
}
|
||||
},
|
||||
// Is Driver Invincible
|
||||
{
|
||||
"ISDINV",
|
||||
"E8 ? ? ? ? 49 8B 56 ? 84 C0",
|
||||
[](memory::handle ptr)
|
||||
{
|
||||
g_pointers->m_gta.m_is_driver_invincible = ptr.add(1).rip().as<PVOID>();
|
||||
}
|
||||
}
|
||||
>(); // don't leave a trailing comma at the end
|
||||
|
||||
|
@ -139,6 +139,17 @@ namespace big::mobile
|
||||
return *scr_globals::freemode_global.at(301).as<Vehicle*>();
|
||||
}
|
||||
|
||||
inline CVehicle* get_personal_cvehicle()
|
||||
{
|
||||
Vehicle personal_vehicle = get_personal_vehicle();
|
||||
if (personal_vehicle != -1 && ENTITY::DOES_ENTITY_EXIST(personal_vehicle))
|
||||
{
|
||||
return reinterpret_cast<CVehicle*>(g_pointers->m_gta.m_handle_to_ptr(personal_vehicle));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline void summon_vehicle_by_index(int veh_idx)
|
||||
{
|
||||
if (*scr_globals::freemode_global.at(1000).as<int*>() != -1)
|
||||
|
Reference in New Issue
Block a user