Refactor how blips work (#3473)
This commit is contained in:
parent
6c5a653d1d
commit
80af2d7c6a
@ -3,7 +3,7 @@ include(FetchContent)
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
gtav_classes
|
gtav_classes
|
||||||
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
|
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
|
||||||
GIT_TAG 06c58d9c11a9a22336947fbe430d5f4951ff34d7
|
GIT_TAG a91475c198c59eff04de26929e83d86521299dda
|
||||||
GIT_PROGRESS TRUE
|
GIT_PROGRESS TRUE
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
BUILD_COMMAND ""
|
BUILD_COMMAND ""
|
||||||
|
@ -909,7 +909,7 @@ namespace big
|
|||||||
float fov = 60.f;
|
float fov = 60.f;
|
||||||
float distance = 200.f;
|
float distance = 200.f;
|
||||||
int32_t selected_bone = (int32_t)ePedBoneType::HEAD;
|
int32_t selected_bone = (int32_t)ePedBoneType::HEAD;
|
||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(aimbot, enable, only_on_ped_type, only_on_player, only_on_enemy, fov, distance, selected_bone)
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE(aimbot, enable, only_on_ped_type, only_on_player, only_on_enemy, fov, distance, selected_bone, use_weapon_range)
|
||||||
} aimbot{};
|
} aimbot{};
|
||||||
|
|
||||||
struct flying_axe
|
struct flying_axe
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "natives.hpp"
|
|
||||||
|
|
||||||
namespace rage
|
|
||||||
{
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
class Blip_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int32_t m_id; //0x0000
|
|
||||||
uint16_t m_blip_array_index;//0x0004
|
|
||||||
char pad_0006[4]; //0x0006
|
|
||||||
bool m_active; //0x000A
|
|
||||||
uint8_t N00000197; //0x000B
|
|
||||||
int32_t m_entity_id; //0x000C
|
|
||||||
float m_x; //0x0010
|
|
||||||
float m_y; //0x0014
|
|
||||||
float m_z; //0x0018
|
|
||||||
char pad_001C[4]; //0x001C
|
|
||||||
uint32_t m_display_bits; //0x0020
|
|
||||||
uint32_t m_render_bits; //0x0024
|
|
||||||
char* m_message; //0x0028
|
|
||||||
char pad_0030[8]; //0x0030
|
|
||||||
Hash m_description; //0x0038
|
|
||||||
char pad_003C[4]; //0x003C
|
|
||||||
int32_t m_icon; //0x0040
|
|
||||||
int16_t m_flash_interval; //0x0044
|
|
||||||
int16_t m_flash_timer; //0x0046
|
|
||||||
uint32_t m_color; //0x0048
|
|
||||||
uint32_t m_secondary_color; //0x004C
|
|
||||||
float m_scale_x; //0x0050
|
|
||||||
float m_scale_y; //0x0054
|
|
||||||
float m_rotation; //0x0058
|
|
||||||
uint8_t m_mission_bits; //0x005C
|
|
||||||
uint8_t m_priority; //0x005D
|
|
||||||
uint8_t m_display_id; //0x005E
|
|
||||||
uint8_t m_alpha; //0x005F
|
|
||||||
int8_t m_category; //0x0060
|
|
||||||
int8_t m_show_number; //0x0061
|
|
||||||
char pad_0062[14]; //0x0062
|
|
||||||
}; //Size: 0x0070
|
|
||||||
static_assert(sizeof(Blip_t) == 0x70, "Blip_t is not sized properly.");
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
class BlipEntry
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Blip_t* m_pBlip;//0x0000
|
|
||||||
|
|
||||||
};//Size=0x0008
|
|
||||||
|
|
||||||
class BlipList
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BlipEntry m_Blips[1500];//0x0000
|
|
||||||
char _0x2EE0[56];
|
|
||||||
|
|
||||||
};//Size=0x2F18
|
|
||||||
}
|
|
@ -1044,8 +1044,12 @@ enum class BlipColors
|
|||||||
WaypointColor = 0x54
|
WaypointColor = 0x54
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BlipDisplayBits
|
enum BlipDisplayBits : uint32_t
|
||||||
{
|
{
|
||||||
|
BlipIsFlashing = (1 << 2),
|
||||||
|
BlipIsGPSRoute = (1 << 4),
|
||||||
|
BlipShowHeightMarker = (1 << 5),
|
||||||
|
BlipsIsDirectional = (1 << 11),
|
||||||
BlipShowCheckmark = (1 << 16),
|
BlipShowCheckmark = (1 << 16),
|
||||||
BlipShowDollarSign = (1 << 17),
|
BlipShowDollarSign = (1 << 17),
|
||||||
BlipShowHeadingIndicator = (1 << 18),
|
BlipShowHeadingIndicator = (1 << 18),
|
||||||
|
84
src/util/blip.cpp
Normal file
84
src/util/blip.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "blip.hpp"
|
||||||
|
|
||||||
|
namespace big::blip
|
||||||
|
{
|
||||||
|
bool get_blip_location(Vector3& location, int sprite, int color)
|
||||||
|
{
|
||||||
|
Blip blip;
|
||||||
|
for (blip = HUD::GET_CLOSEST_BLIP_INFO_ID(sprite); HUD::DOES_BLIP_EXIST(blip) && color != -1 && HUD::GET_BLIP_COLOUR(blip) != color; blip = HUD::GET_NEXT_BLIP_INFO_ID(sprite))
|
||||||
|
;
|
||||||
|
|
||||||
|
if (!HUD::DOES_BLIP_EXIST(blip) || (color != -1 && HUD::GET_BLIP_COLOUR(blip) != color))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
location = HUD::GET_BLIP_COORDS(blip);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get_objective_location_iteration(Vector3& location, const std::unordered_set<BlipIcons> sprites, const std::unordered_set<BlipColors> blip_colors = {})
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 1500; i++)
|
||||||
|
{
|
||||||
|
auto blip = g_pointers->m_gta.m_blip_list->m_Blips[i].m_pBlip;
|
||||||
|
if (blip != nullptr
|
||||||
|
&& ((sprites.contains((BlipIcons)blip->m_icon)
|
||||||
|
&& (blip_colors.empty() || blip_colors.contains((BlipColors)blip->m_color)))
|
||||||
|
|| (blip->m_display_bits & BlipIsGPSRoute)))
|
||||||
|
{
|
||||||
|
location.x = blip->m_position.x;
|
||||||
|
location.y = blip->m_position.y;
|
||||||
|
location.z = blip->m_position.z;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
location = {};
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get_blip_location_from_offset(Vector3& location, int sprite)
|
||||||
|
{
|
||||||
|
Blip blip = HUD::GET_CLOSEST_BLIP_INFO_ID(sprite);
|
||||||
|
if (HUD::DOES_BLIP_EXIST(blip))
|
||||||
|
{
|
||||||
|
location = HUD::GET_BLIP_COORDS(blip);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get_objective_location(Vector3& location)
|
||||||
|
{
|
||||||
|
if (get_objective_location_iteration(location, {BlipIcons::Circle}, {BlipColors::YellowMission, BlipColors::YellowMission2, BlipColors::Mission}))
|
||||||
|
return true;
|
||||||
|
if (get_objective_location_iteration(location, {BlipIcons::RaceFinish}, {BlipColors::None}))
|
||||||
|
return true;
|
||||||
|
if (get_objective_location_iteration(location, {BlipIcons::Circle}, {BlipColors::Green, BlipColors::Blue}))
|
||||||
|
return true;
|
||||||
|
if (get_objective_location_iteration(location, {BlipIcons::CrateDrop}))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
auto blip_icons = {0, 1, 2, 143, 144, 145, 146, 280, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 535, 536, 537, 538, 539, 540, 541, 542};
|
||||||
|
for (const auto& icon : blip_icons)
|
||||||
|
{
|
||||||
|
if (get_blip_location_from_offset(location, icon))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
rage::CBlip* get_selected_blip()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 1500; i++)
|
||||||
|
{
|
||||||
|
auto blip = g_pointers->m_gta.m_blip_list->m_Blips[i].m_pBlip;
|
||||||
|
if (blip && (blip->m_display_bits & BlipIsSelected))
|
||||||
|
{
|
||||||
|
return blip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
@ -1,65 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "gta/enums.hpp"
|
#include "gta/enums.hpp"
|
||||||
#include "natives.hpp"
|
#include "natives.hpp"
|
||||||
#include "script.hpp"
|
|
||||||
#include "pointers.hpp"
|
#include "pointers.hpp"
|
||||||
#include "ui/blip_t.hpp"
|
#include "script.hpp"
|
||||||
#include "ui/CBlipList.hpp"
|
#include "ui/CBlipList.hpp"
|
||||||
|
|
||||||
namespace big::blip
|
namespace big::blip
|
||||||
{
|
{
|
||||||
inline bool get_blip_location(Vector3& location, int sprite, int color = -1)
|
bool get_blip_location(Vector3& location, int sprite, int color = -1);
|
||||||
{
|
|
||||||
Blip blip;
|
|
||||||
for (blip = HUD::GET_FIRST_BLIP_INFO_ID(sprite); HUD::DOES_BLIP_EXIST(blip) && color != -1 && HUD::GET_BLIP_COLOUR(blip) != color; blip = HUD::GET_NEXT_BLIP_INFO_ID(sprite))
|
|
||||||
;
|
|
||||||
|
|
||||||
if (!HUD::DOES_BLIP_EXIST(blip) || (color != -1 && HUD::GET_BLIP_COLOUR(blip) != color))
|
bool get_objective_location_iteration(Vector3& location, const std::unordered_set<BlipIcons> sprites, const std::unordered_set<BlipColors> blip_colors);
|
||||||
return false;
|
|
||||||
|
|
||||||
location = HUD::GET_BLIP_COORDS(blip);
|
bool get_blip_location_from_offset(Vector3& location, int sprite);
|
||||||
|
|
||||||
return true;
|
bool get_objective_location(Vector3& location);
|
||||||
}
|
|
||||||
|
|
||||||
inline bool get_objective_location(Vector3& location)
|
rage::CBlip* get_selected_blip();
|
||||||
{
|
|
||||||
if (get_blip_location(location, (int)BlipIcons::Circle, (int)BlipColors::YellowMission))
|
|
||||||
return true;
|
|
||||||
if (get_blip_location(location, (int)BlipIcons::Circle, (int)BlipColors::YellowMission2))
|
|
||||||
return true;
|
|
||||||
if (get_blip_location(location, (int)BlipIcons::Circle, (int)BlipColors::Mission))
|
|
||||||
return true;
|
|
||||||
if (get_blip_location(location, (int)BlipIcons::RaceFinish, (int)BlipColors::None))
|
|
||||||
return true;
|
|
||||||
if (get_blip_location(location, (int)BlipIcons::Circle, (int)BlipColors::Green))
|
|
||||||
return true;
|
|
||||||
if (get_blip_location(location, (int)BlipIcons::Circle, (int)BlipColors::Blue))
|
|
||||||
return true;
|
|
||||||
if (get_blip_location(location, (int)BlipIcons::CrateDrop))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
static const int blips[] = {1, 57, 128, 129, 130, 143, 144, 145, 146, 271, 286, 287, 288};
|
|
||||||
for (const auto& blip : blips)
|
|
||||||
{
|
|
||||||
if (get_blip_location(location, blip, 5))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline rage::Blip_t* get_selected_blip()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 1500; i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
auto blip = g_pointers->m_gta.m_blip_list->m_Blips[i].m_pBlip;
|
|
||||||
if (blip && (blip->m_display_bits & BlipDisplayBits::BlipIsSelected))
|
|
||||||
{
|
|
||||||
return blip;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -236,7 +236,7 @@ namespace big::teleport
|
|||||||
{
|
{
|
||||||
entity = self::veh;
|
entity = self::veh;
|
||||||
}
|
}
|
||||||
ENTITY::SET_ENTITY_COORDS_NO_OFFSET(entity, blip->m_x, blip->m_y, blip->m_z, FALSE, FALSE, TRUE);
|
ENTITY::SET_ENTITY_COORDS_NO_OFFSET(entity, blip->m_position.x, blip->m_position.y, blip->m_position.z, FALSE, FALSE, TRUE);
|
||||||
ENTITY::SET_ENTITY_HEADING(entity, blip->m_rotation);
|
ENTITY::SET_ENTITY_HEADING(entity, blip->m_rotation);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -125,9 +125,9 @@ namespace big
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
teleport_location.name = new_location_name;
|
teleport_location.name = new_location_name;
|
||||||
teleport_location.x = blip->m_x;
|
teleport_location.x = blip->m_position.x;
|
||||||
teleport_location.y = blip->m_y;
|
teleport_location.y = blip->m_position.y;
|
||||||
teleport_location.z = blip->m_z;
|
teleport_location.z = blip->m_position.z;
|
||||||
teleport_location.yaw = blip->m_rotation;
|
teleport_location.yaw = blip->m_rotation;
|
||||||
teleport_location.pitch = 0.0f;
|
teleport_location.pitch = 0.0f;
|
||||||
teleport_location.roll = 0.0f;
|
teleport_location.roll = 0.0f;
|
||||||
|
Reference in New Issue
Block a user