mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-07-15 15:07:51 +08:00
Add more spoofing options and added clang-format (#1020)
* feat(Spoofing): add spoofing * feat(Spoofing): prepare code for player attach * remove(PlayerAttach): isn't going to work due to netsync architecture * fix(GUI): fix scaling * feat(Project): add clang-format file * feat(Classes): update classes * fix(BlackHole): remove unnecessary cleanup * fix(Formatting): fix formatting for initializer lists * feat(clang-format): Set tab width and 1 space before comment Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
#include "context_menu_service.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "pointers.hpp"
|
||||
|
||||
#include "gta/replay.hpp"
|
||||
#include "gui.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "pointers.hpp"
|
||||
#include "util/misc.hpp"
|
||||
|
||||
namespace big
|
||||
@ -69,15 +70,18 @@ namespace big
|
||||
edge8.y = edge5.y - 2 * dimensions.z * up.y;
|
||||
edge8.z = edge5.z - 2 * dimensions.z * up.z;
|
||||
|
||||
auto any_fail = false;
|
||||
static auto imgui_world_to_screen = [&any_fail](rage::fvector3& world_input, ImVec2& screen_result)
|
||||
{
|
||||
auto any_fail = false;
|
||||
static auto imgui_world_to_screen = [&any_fail](rage::fvector3& world_input, ImVec2& screen_result) {
|
||||
if (any_fail)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto success = GRAPHICS::GET_SCREEN_COORD_FROM_WORLD_COORD(world_input.x, world_input.y, world_input.z, &screen_result.x, &screen_result.y);
|
||||
const auto success = GRAPHICS::GET_SCREEN_COORD_FROM_WORLD_COORD(world_input.x,
|
||||
world_input.y,
|
||||
world_input.z,
|
||||
&screen_result.x,
|
||||
&screen_result.y);
|
||||
if (success)
|
||||
{
|
||||
screen_result.x = static_cast<float>(*g_pointers->m_resolution_x) * screen_result.x;
|
||||
@ -141,8 +145,7 @@ namespace big
|
||||
{
|
||||
if (const auto ped = reinterpret_cast<CPed*>(m_pointer); ped)
|
||||
{
|
||||
if (ped->m_ped_task_flag & static_cast<uint8_t>(ePedTask::TASK_DRIVING) &&
|
||||
ped->m_vehicle)
|
||||
if (ped->m_ped_task_flag & static_cast<uint8_t>(ePedTask::TASK_DRIVING) && ped->m_vehicle)
|
||||
{
|
||||
if (!misc::has_bits_set(&g.context_menu.allowed_entity_types, static_cast<uint8_t>(ContextEntityType::VEHICLE)))
|
||||
{
|
||||
@ -179,8 +182,7 @@ namespace big
|
||||
|
||||
return &options.at(ContextEntityType::VEHICLE);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@ -202,7 +204,7 @@ namespace big
|
||||
const auto obj_interface_size = obj_interface->m_max_objects;
|
||||
const auto all_entities = std::make_unique<rage::CEntityHandle[]>(veh_interface_size + ped_interface_size + obj_interface_size);
|
||||
|
||||
const auto ptr = all_entities.get();
|
||||
const auto ptr = all_entities.get();
|
||||
std::uint32_t offset = 0;
|
||||
std::copy(ped_interface->m_ped_list->m_peds, ped_interface->m_ped_list->m_peds + ped_interface_size, ptr);
|
||||
offset += ped_interface_size;
|
||||
@ -213,7 +215,7 @@ namespace big
|
||||
std::copy(obj_interface->m_object_list->m_objects, obj_interface->m_object_list->m_objects + obj_interface_size, ptr + offset);
|
||||
offset += obj_interface_size;
|
||||
|
||||
double distance = 1;
|
||||
double distance = 1;
|
||||
bool got_an_entity = false;
|
||||
rage::fvector2 screen_pos{};
|
||||
for (std::uint32_t i = 0; i < offset; i++)
|
||||
@ -222,19 +224,17 @@ namespace big
|
||||
continue;
|
||||
|
||||
const auto temp_pointer = all_entities[i].m_entity_ptr;
|
||||
const auto temp_handle = g_pointers->m_ptr_to_handle(temp_pointer);
|
||||
const auto temp_handle = g_pointers->m_ptr_to_handle(temp_pointer);
|
||||
if (!temp_pointer->m_navigation)
|
||||
continue;
|
||||
|
||||
const auto pos = *temp_pointer->m_navigation->get_position();
|
||||
HUD::GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION(pos.x, pos.y, pos.z, &screen_pos.x, &screen_pos.y);
|
||||
if (distance_to_middle_of_screen(screen_pos) < distance &&
|
||||
ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY(PLAYER::PLAYER_PED_ID(), temp_handle, 17) &&
|
||||
temp_handle != PLAYER::PLAYER_PED_ID())
|
||||
if (distance_to_middle_of_screen(screen_pos) < distance && ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY(PLAYER::PLAYER_PED_ID(), temp_handle, 17) && temp_handle != PLAYER::PLAYER_PED_ID())
|
||||
{
|
||||
m_handle = temp_handle;
|
||||
m_pointer = temp_pointer;
|
||||
distance = distance_to_middle_of_screen(screen_pos);
|
||||
m_handle = temp_handle;
|
||||
m_pointer = temp_pointer;
|
||||
distance = distance_to_middle_of_screen(screen_pos);
|
||||
got_an_entity = true;
|
||||
}
|
||||
}
|
||||
@ -253,7 +253,9 @@ namespace big
|
||||
{
|
||||
if (type == ContextEntityType::SHARED)
|
||||
continue;
|
||||
menu.options.insert(menu.options.end(), options.at(ContextEntityType::SHARED).options.begin(), options.at(ContextEntityType::SHARED).options.end());
|
||||
menu.options.insert(menu.options.end(),
|
||||
options.at(ContextEntityType::SHARED).options.begin(),
|
||||
options.at(ContextEntityType::SHARED).options.end());
|
||||
|
||||
std::uint32_t max_size = 0;
|
||||
for (auto& [name, _] : menu.options)
|
||||
@ -261,23 +263,22 @@ namespace big
|
||||
max_size = static_cast<int>(max_size < name.length() ? name.length() : max_size);
|
||||
}
|
||||
|
||||
menu.menu_size = { (10.f * static_cast<float>(max_size)) + 10.f , 2 * (10.f * static_cast<float>(menu.options.size())) + 10.f };
|
||||
menu.menu_size = {(10.f * static_cast<float>(max_size)) + 10.f, 2 * (10.f * static_cast<float>(menu.options.size())) + 10.f};
|
||||
}
|
||||
}
|
||||
|
||||
static const ControllerInputs controls[] =
|
||||
{
|
||||
ControllerInputs::INPUT_NEXT_WEAPON,
|
||||
ControllerInputs::INPUT_PREV_WEAPON,
|
||||
ControllerInputs::INPUT_VEH_NEXT_RADIO,
|
||||
ControllerInputs::INPUT_VEH_SELECT_NEXT_WEAPON,
|
||||
ControllerInputs::INPUT_SELECT_NEXT_WEAPON,
|
||||
ControllerInputs::INPUT_SELECT_PREV_WEAPON,
|
||||
ControllerInputs::INPUT_WEAPON_WHEEL_NEXT,
|
||||
ControllerInputs::INPUT_WEAPON_WHEEL_PREV,
|
||||
ControllerInputs::INPUT_ATTACK,
|
||||
ControllerInputs::INPUT_SPECIAL_ABILITY,
|
||||
ControllerInputs::INPUT_VEH_MOUSE_CONTROL_OVERRIDE,
|
||||
static const ControllerInputs controls[] = {
|
||||
ControllerInputs::INPUT_NEXT_WEAPON,
|
||||
ControllerInputs::INPUT_PREV_WEAPON,
|
||||
ControllerInputs::INPUT_VEH_NEXT_RADIO,
|
||||
ControllerInputs::INPUT_VEH_SELECT_NEXT_WEAPON,
|
||||
ControllerInputs::INPUT_SELECT_NEXT_WEAPON,
|
||||
ControllerInputs::INPUT_SELECT_PREV_WEAPON,
|
||||
ControllerInputs::INPUT_WEAPON_WHEEL_NEXT,
|
||||
ControllerInputs::INPUT_WEAPON_WHEEL_PREV,
|
||||
ControllerInputs::INPUT_ATTACK,
|
||||
ControllerInputs::INPUT_SPECIAL_ABILITY,
|
||||
ControllerInputs::INPUT_VEH_MOUSE_CONTROL_OVERRIDE,
|
||||
};
|
||||
|
||||
void context_menu_service::disable_control_action_loop()
|
||||
@ -331,8 +332,7 @@ namespace big
|
||||
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV))
|
||||
cm->current_option = 0 > cm->current_option - 1 ? static_cast<int>(cm->options.size()) - 1 : cm->current_option - 1;
|
||||
|
||||
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK) ||
|
||||
PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_SPECIAL_ABILITY))
|
||||
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK) || PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_SPECIAL_ABILITY))
|
||||
{
|
||||
if (!g_context_menu_service->m_pointer)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ namespace big
|
||||
{
|
||||
ContextEntityType type;
|
||||
int current_option = 0;
|
||||
ImVec2 menu_size = {};
|
||||
ImVec2 menu_size = {};
|
||||
std::vector<context_option> options;
|
||||
};
|
||||
|
||||
@ -36,9 +36,9 @@ namespace big
|
||||
context_menu_service();
|
||||
~context_menu_service();
|
||||
|
||||
context_menu_service(const context_menu_service&) = delete;
|
||||
context_menu_service(context_menu_service&&) noexcept = delete;
|
||||
context_menu_service& operator=(const context_menu_service&) = delete;
|
||||
context_menu_service(const context_menu_service&) = delete;
|
||||
context_menu_service(context_menu_service&&) noexcept = delete;
|
||||
context_menu_service& operator=(const context_menu_service&) = delete;
|
||||
context_menu_service& operator=(context_menu_service&&) noexcept = delete;
|
||||
|
||||
bool enabled = false;
|
||||
@ -53,70 +53,56 @@ namespace big
|
||||
rage::fwEntity* m_pointer{};
|
||||
model_bounding_box_screen_space m_model_bounding_box_screen_space;
|
||||
|
||||
s_context_menu vehicle_menu{
|
||||
ContextEntityType::VEHICLE,
|
||||
0,{}, {
|
||||
{"KILL ENGINE", [this] {
|
||||
if (entity::take_control_of(m_handle))
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_ENGINE_HEALTH(m_handle, 0.f);
|
||||
VEHICLE::SET_VEHICLE_ENGINE_ON(m_handle, false, true, false);
|
||||
}
|
||||
}},
|
||||
{"DELETE", [this] {
|
||||
if (entity::take_control_of(m_handle))
|
||||
{
|
||||
entity::delete_entity(m_handle);
|
||||
}
|
||||
}},
|
||||
{ "TP INTO", [this] {
|
||||
teleport::into_vehicle(m_handle);
|
||||
}}
|
||||
} };
|
||||
s_context_menu vehicle_menu{ContextEntityType::VEHICLE,
|
||||
0,
|
||||
{},
|
||||
{{"KILL ENGINE",
|
||||
[this] {
|
||||
if (entity::take_control_of(m_handle))
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_ENGINE_HEALTH(m_handle, 0.f);
|
||||
VEHICLE::SET_VEHICLE_ENGINE_ON(m_handle, false, true, false);
|
||||
}
|
||||
}},
|
||||
{"DELETE",
|
||||
[this] {
|
||||
if (entity::take_control_of(m_handle))
|
||||
{
|
||||
entity::delete_entity(m_handle);
|
||||
}
|
||||
}},
|
||||
{"TP INTO", [this] {
|
||||
teleport::into_vehicle(m_handle);
|
||||
}}}};
|
||||
|
||||
s_context_menu ped_menu{
|
||||
ContextEntityType::PED,
|
||||
0,{}, {}};
|
||||
s_context_menu ped_menu{ContextEntityType::PED, 0, {}, {}};
|
||||
|
||||
s_context_menu object_menu{
|
||||
ContextEntityType::OBJECT,
|
||||
0,{}, {}};
|
||||
s_context_menu object_menu{ContextEntityType::OBJECT, 0, {}, {}};
|
||||
|
||||
s_context_menu player_menu{
|
||||
ContextEntityType::PLAYER,
|
||||
0,{}, {
|
||||
{"STEAL IDENTITY", [this]
|
||||
{
|
||||
ped::steal_identity(m_handle);
|
||||
}}
|
||||
} };
|
||||
s_context_menu player_menu{ContextEntityType::PLAYER, 0, {}, {{"STEAL IDENTITY", [this] {
|
||||
ped::steal_identity(m_handle);
|
||||
}}}};
|
||||
|
||||
s_context_menu shared_menu{
|
||||
ContextEntityType::SHARED,
|
||||
0,
|
||||
{}, {
|
||||
{"EXPLODE", [this] {
|
||||
rage::fvector3 pos = *m_pointer->m_navigation->get_position();
|
||||
FIRE::ADD_EXPLOSION(pos.x, pos.y, pos.z, 1, 1000, 1, 0, 1, 0);
|
||||
}},
|
||||
{"TP TO", [this] {
|
||||
rage::fvector3 pos = *m_pointer->m_navigation->get_position();
|
||||
teleport::to_coords({ pos.x, pos.y, pos.z });
|
||||
}},
|
||||
{"COPY HASH", [this] {
|
||||
ImGui::SetClipboardText(std::format("0x{:08X}", (rage::joaat_t)m_pointer->m_model_info->m_hash).c_str());
|
||||
g_notification_service->push("Context Menu", std::format("Copy hash 0x{:08X}", (rage::joaat_t)m_pointer->m_model_info->m_hash).c_str());
|
||||
}}
|
||||
}
|
||||
};
|
||||
s_context_menu shared_menu{ContextEntityType::SHARED,
|
||||
0,
|
||||
{},
|
||||
{{"EXPLODE",
|
||||
[this] {
|
||||
rage::fvector3 pos = *m_pointer->m_navigation->get_position();
|
||||
FIRE::ADD_EXPLOSION(pos.x, pos.y, pos.z, 1, 1000, 1, 0, 1, 0);
|
||||
}},
|
||||
{"TP TO",
|
||||
[this] {
|
||||
rage::fvector3 pos = *m_pointer->m_navigation->get_position();
|
||||
teleport::to_coords({pos.x, pos.y, pos.z});
|
||||
}},
|
||||
{"COPY HASH", [this] {
|
||||
ImGui::SetClipboardText(std::format("0x{:08X}", (rage::joaat_t)m_pointer->m_model_info->m_hash).c_str());
|
||||
g_notification_service->push("Context Menu",
|
||||
std::format("Copy hash 0x{:08X}", (rage::joaat_t)m_pointer->m_model_info->m_hash).c_str());
|
||||
}}}};
|
||||
|
||||
std::unordered_map<ContextEntityType, s_context_menu> options = {
|
||||
{ContextEntityType::VEHICLE, vehicle_menu},
|
||||
{ContextEntityType::PLAYER, player_menu},
|
||||
{ContextEntityType::PED, ped_menu},
|
||||
{ContextEntityType::SHARED, shared_menu},
|
||||
{ContextEntityType::OBJECT, object_menu}
|
||||
};
|
||||
std::unordered_map<ContextEntityType, s_context_menu> options = {{ContextEntityType::VEHICLE, vehicle_menu}, {ContextEntityType::PLAYER, player_menu}, {ContextEntityType::PED, ped_menu}, {ContextEntityType::SHARED, shared_menu}, {ContextEntityType::OBJECT, object_menu}};
|
||||
};
|
||||
|
||||
inline context_menu_service* g_context_menu_service{};
|
||||
|
Reference in New Issue
Block a user