feat: Modify ocean level and add direct invite player from DB (#2384)

This commit is contained in:
thehorizon84 2023-11-05 22:39:53 +01:00 committed by GitHub
parent ebeef460df
commit 2121ff2b7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 154 additions and 0 deletions

View File

@ -0,0 +1,73 @@
#include "backend/looped_command.hpp"
#include "pointers.hpp"
#include "script.hpp"
namespace big
{
class modify_ocean : looped_command
{
using looped_command::looped_command;
struct quad_info
{
uint64_t m_quad_pool;
short m_quad_count;
};
struct ocean_quad
{
private:
char pad_0[0x8];
public:
int m_opacity;
private:
char pad_1[0x8];
public:
float m_height;
};
virtual void on_tick() override
{
if (auto ocean_quads = reinterpret_cast<quad_info*>(g_pointers->m_gta.m_ocean_quads))
{
for (uint64_t i = 0; i < ocean_quads->m_quad_count; i++)
{
const auto index = ocean_quads->m_quad_pool + (i * 0x1C);
const auto quad = reinterpret_cast<ocean_quad*>(index);
// Disable ocean by lowering its height
if (g.world.ocean.disable_ocean)
quad->m_height = -10000.f;
else
quad->m_height = 0.f;
// Change the ocean's opacity (alpha)
if (g.world.ocean.ocean_opacity == 100)
quad->m_opacity = 0x1A1A1A1A;
else if (!g.world.ocean.ocean_opacity)
quad->m_opacity = 0x01010101;
else
quad->m_opacity = (int)(255 * (float)(g.world.ocean.ocean_opacity / 100.f));
}
}
}
virtual void on_disable() override
{
if (auto ocean_quads = reinterpret_cast<quad_info*>(g_pointers->m_gta.m_ocean_quads))
{
for (uint64_t i = 0; i < ocean_quads->m_quad_count; i++)
{
const auto index = ocean_quads->m_quad_pool + (i * 0x1C);
const auto quad = reinterpret_cast<ocean_quad*>(index);
quad->m_height = 0.f;
quad->m_opacity = 0x1A1A1A1A;
}
}
}
};
modify_ocean g_modify_ocean("modifyocean", "BACKEND_LOOPED_WORLD_MODIFY_OCEAN", "BACKEND_LOOPED_WORLD_MODIFY_OCEAN_DESC", g.world.ocean.modify_ocean);
bool_command g_disable_ocean("disableocean", "BACKEND_LOOPED_WORLD_DISABLE_OCEAN", "BACKEND_LOOPED_WORLD_DISABLE_OCEAN_DESC", g.world.ocean.disable_ocean);
}

View File

@ -542,6 +542,15 @@ namespace big
NLOHMANN_DEFINE_TYPE_INTRUSIVE(water, part_water)
} water{};
struct ocean
{
bool modify_ocean = false;
bool disable_ocean = false;
int ocean_opacity = 100;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(ocean, modify_ocean, disable_ocean, ocean_opacity)
} ocean{};
struct spawn_ped
{
bool preview_ped = false;

View File

@ -117,6 +117,8 @@ namespace big::functions
using start_get_presence_attributes = bool (*)(int profile_index, rage::rlScHandle* handle, int num_handles, rage::rlQueryPresenceAttributesContext** contexts, int count, rage::rlScTaskStatus* state);
using join_session_by_info = bool (*)(Network* network, rage::rlSessionInfo* info, int unk, int flags, rage::rlGamerHandle* handles, int handlecount);
using invite_player_by_gamer_handle = bool(*)(uint64_t config, rage::rlGamerHandle* handle, int unk1, int unk2, int unk3, int unk4);
using generate_uuid = bool (*)(uint64_t* uuid);
using get_vehicle_gadget_array_size = int (*)(eVehicleGadgetType type);

View File

@ -92,6 +92,8 @@ namespace big
uint32_t* m_region_code;
uint64_t m_ocean_quads;
PVOID m_world_model_spawn_bypass;
PVOID m_native_return;
PVOID m_get_label_text;
@ -158,6 +160,9 @@ namespace big
functions::start_matchmaking_find_sessions m_start_matchmaking_find_sessions;
functions::join_session_by_info m_join_session_by_info;
functions::invite_player_by_gamer_handle m_invite_player_by_gamer_handle;
uint64_t m_network_config;
functions::reset_network_complaints m_reset_network_complaints;
functions::fidevice_get_device m_fidevice_get_device;

View File

@ -33,6 +33,15 @@ namespace big
g_pointers->m_gta.m_region_code = ptr.add(16).rip().add(1).as<uint32_t*>();
}
},
// Ocean Quads
{
"OQ",
"74 41 4C 8B 05 ? ? ?",
[](memory::handle ptr)
{
g_pointers->m_gta.m_ocean_quads = ptr.add(5).rip().as<uint64_t>();
}
},
// Game State
{
"GS",
@ -610,6 +619,24 @@ namespace big
g_pointers->m_gta.m_join_session_by_info = ptr.add(1).rip().as<functions::join_session_by_info>();
}
},
// Invite Player By Gamer Handle
{
"IPBGH",
"E8 ? ? ? ? 4C 8D 05 ? ? ? ? 48 8D 15 ? ? ? ? E9",
[](memory::handle ptr)
{
g_pointers->m_gta.m_invite_player_by_gamer_handle = ptr.add(1).rip().as<functions::invite_player_by_gamer_handle>();
}
},
// Network Config
{
"NC",
"48 8B 0D ? ? ? ? 45 33 C9 48 8B D7",
[](memory::handle ptr)
{
g_pointers->m_gta.m_network_config = ptr.add(3).rip().as<uint64_t>();
}
},
// Script VM
{
"VM",

View File

@ -158,6 +158,18 @@ namespace big::session
});
}
inline void invite_by_rockstar_id(uint64_t rid)
{
rage::rlGamerHandle player_handle(rid);
bool success = g_pointers->m_gta.m_invite_player_by_gamer_handle(g_pointers->m_gta.m_network_config, &player_handle, 1, 0, 0, 0);
if (!success)
return g_notification_service->push_error("Network", "Target player could not be invited, they might be offline?");
g_notification_service->push_success("Network", "Target player has been invited to your session!");
}
inline void add_infraction(player_ptr player, Infraction infraction, const std::string& custom_reason = "")
{
if (g.debug.fuzzer.enabled)

View File

@ -208,6 +208,10 @@ namespace big
session::join_by_rockstar_id(current_player->rockstar_id);
});
components::button("INVITE_PLAYER"_T, [] {
session::invite_by_rockstar_id(current_player->rockstar_id);
});
static char message[256];
components::input_text("INPUT_MSG"_T, message, sizeof(message));
if (components::button("SEND_MSG"_T))

View File

@ -56,6 +56,7 @@ namespace big
static void spawn_ped();
static void squad_spawner();
static void time_and_weather();
static void ocean();
static void spoofing();
static void teleport();
static void custom_teleport();

View File

@ -0,0 +1,16 @@
#include "views/view.hpp"
namespace big
{
void view::ocean()
{
components::command_checkbox<"modifyocean">();
if (g.world.ocean.modify_ocean)
{
components::command_checkbox<"disableocean">();
ImGui::SliderInt("OCEAN_OPACITY"_T.data(), &g.world.ocean.ocean_opacity, 0, 100);
}
}
}

View File

@ -14,6 +14,11 @@ namespace big
view::time_and_weather();
}
ImGui::SeparatorText("GUI_TAB_OCEAN"_T.data());
{
view::ocean();
}
ImGui::SeparatorText("PED"_T.data());
components::button<ImVec2(110, 0), ImVec4(0.70196f, 0.3333f, 0.00392f, 1.f)>("VIEW_DEBUG_THREADS_KILL"_T, [] {