Added Teleport to Selected Blip and associated hotkey. (#1774)
This commit is contained in:
parent
44f79a4284
commit
7e50d5377a
@ -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 3267288d55ca84272da3a9511dc8e4d3b433abe3
|
GIT_TAG 5ef3545feb947a1bd143a84d15fdc624e1366c18
|
||||||
GIT_PROGRESS TRUE
|
GIT_PROGRESS TRUE
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
BUILD_COMMAND ""
|
BUILD_COMMAND ""
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
#include "backend/command.hpp"
|
||||||
|
#include "natives.hpp"
|
||||||
|
#include "util/teleport.hpp"
|
||||||
|
|
||||||
|
namespace big
|
||||||
|
{
|
||||||
|
class teleport_to_highlighted_blip : command
|
||||||
|
{
|
||||||
|
using command::command;
|
||||||
|
|
||||||
|
virtual void execute(const std::vector<std::uint64_t>&, const std::shared_ptr<command_context> ctx)
|
||||||
|
{
|
||||||
|
teleport::to_highlighted_blip();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
teleport_to_highlighted_blip g_teleport_to_highlighted_blip("highlighttp", "Teleport to Selected Blip", "Teleports you to whichever blip you have in your crosshairs on the map.", 0);
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
#include "backend/looped_command.hpp"
|
#include "backend/looped_command.hpp"
|
||||||
#include "fiber_pool.hpp"
|
#include "fiber_pool.hpp"
|
||||||
#include "natives.hpp"
|
#include "natives.hpp"
|
||||||
|
#include "gta/enums.hpp"
|
||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "natives.hpp"
|
#include "natives.hpp"
|
||||||
#include "pointers.hpp"
|
#include "pointers.hpp"
|
||||||
#include "util/entity.hpp"
|
#include "util/entity.hpp"
|
||||||
|
#include "gta/enums.hpp"
|
||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
|
@ -432,6 +432,7 @@ namespace big
|
|||||||
int teleport_waypoint = 0;
|
int teleport_waypoint = 0;
|
||||||
int teleport_objective = 0;
|
int teleport_objective = 0;
|
||||||
int teleport_pv = 0;
|
int teleport_pv = 0;
|
||||||
|
int teleport_selected = 0;
|
||||||
int noclip = 0;
|
int noclip = 0;
|
||||||
int vehicle_flymode = 0;
|
int vehicle_flymode = 0;
|
||||||
int bringvehicle = 0;
|
int bringvehicle = 0;
|
||||||
|
@ -1027,24 +1027,15 @@ enum class BlipColors
|
|||||||
WaypointColor = 0x54
|
WaypointColor = 0x54
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class BlipDisplayBits
|
enum BlipDisplayBits
|
||||||
{
|
{
|
||||||
BlipIsBright = (1 << 1),
|
BlipShowCheckmark = (1 << 16),
|
||||||
BlipEngageFlashing = (1 << 3),
|
BlipShowDollarSign = (1 << 17),
|
||||||
BlipFlashForRoute = (1 << 5),
|
BlipShowHeadingIndicator = (1 << 18),
|
||||||
BlipIsOnMinimap = (1 << 6),
|
BlipShowFullCircle = (1 << 19),
|
||||||
BlipIsHighDetail = (1 << 8),
|
BlipIsFriend = (1 << 20),
|
||||||
BlipUseBlipColorForDirection = (1 << 9),
|
BlipIsCrew = (1 << 21),
|
||||||
BlipIsSmall = (1 << 10),
|
BlipIsSelected = (1 << 23),
|
||||||
BlipShowCone = (1 << 11),
|
|
||||||
BlipIsMissionCreatorBlip = (1 << 12),
|
|
||||||
BlipShowCheckmark = (1 << 15),
|
|
||||||
BlipShowDollarSign = (1 << 16),
|
|
||||||
BlipShowHeadingIndicator = (1 << 17),
|
|
||||||
BlipShowFullCircle = (1 << 18),
|
|
||||||
BlipIsFriend = (1 << 19),
|
|
||||||
BlipIsCrew = (1 << 20),
|
|
||||||
BlipIsSelected = (1 << 22),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class BlipRenderBits
|
enum class BlipRenderBits
|
||||||
|
@ -11,6 +11,7 @@ class GenericPool;
|
|||||||
class VehiclePool;
|
class VehiclePool;
|
||||||
class CVehicleSeatMetadataMgr;
|
class CVehicleSeatMetadataMgr;
|
||||||
class CVehicleDriveByMetadataMgr;
|
class CVehicleDriveByMetadataMgr;
|
||||||
|
class CBlipList;
|
||||||
|
|
||||||
namespace rage
|
namespace rage
|
||||||
{
|
{
|
||||||
@ -281,6 +282,8 @@ namespace big
|
|||||||
|
|
||||||
CVehicleSeatMetadataMgr* m_vehicle_layout_metadata_mgr{};
|
CVehicleSeatMetadataMgr* m_vehicle_layout_metadata_mgr{};
|
||||||
CVehicleDriveByMetadataMgr* m_driveby_metadata_mgr{};
|
CVehicleDriveByMetadataMgr* m_driveby_metadata_mgr{};
|
||||||
|
|
||||||
|
CBlipList* m_blip_list{};
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned");
|
static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned");
|
||||||
|
@ -1391,6 +1391,15 @@ namespace big
|
|||||||
g_pointers->m_gta.m_driveby_metadata_mgr = ptr.as<CVehicleDriveByMetadataMgr*>();
|
g_pointers->m_gta.m_driveby_metadata_mgr = ptr.as<CVehicleDriveByMetadataMgr*>();
|
||||||
g_pointers->m_gta.m_vehicle_layout_metadata_mgr = ptr.add(0x20).as<CVehicleSeatMetadataMgr*>();
|
g_pointers->m_gta.m_vehicle_layout_metadata_mgr = ptr.add(0x20).as<CVehicleSeatMetadataMgr*>();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// Blip List
|
||||||
|
{
|
||||||
|
"BLPLST",
|
||||||
|
"4C 8D 05 ? ? ? ? 0F B7 C1",
|
||||||
|
[](memory::handle ptr)
|
||||||
|
{
|
||||||
|
g_pointers->m_gta.m_blip_list = ptr.add(3).rip().as<CBlipList*>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
>(); // don't leave a trailing comma at the end
|
>(); // don't leave a trailing comma at the end
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ namespace big
|
|||||||
register_hotkey("vehiclecontroller", g.settings.hotkeys.open_vehicle_controller, RAGE_JOAAT("vehiclecontrol"));
|
register_hotkey("vehiclecontroller", g.settings.hotkeys.open_vehicle_controller, RAGE_JOAAT("vehiclecontrol"));
|
||||||
register_hotkey("vehiclefly", g.settings.hotkeys.vehicle_flymode, RAGE_JOAAT("vehiclefly"));
|
register_hotkey("vehiclefly", g.settings.hotkeys.vehicle_flymode, RAGE_JOAAT("vehiclefly"));
|
||||||
register_hotkey("waypoint", g.settings.hotkeys.teleport_waypoint, RAGE_JOAAT("waypointtp"));
|
register_hotkey("waypoint", g.settings.hotkeys.teleport_waypoint, RAGE_JOAAT("waypointtp"));
|
||||||
|
register_hotkey("highlighttp", g.settings.hotkeys.teleport_selected, RAGE_JOAAT("highlighttp"));
|
||||||
|
|
||||||
g_renderer->add_wndproc_callback([this](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
g_renderer->add_wndproc_callback([this](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||||
wndproc(static_cast<eKeyState>(msg), wparam);
|
wndproc(static_cast<eKeyState>(msg), wparam);
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#include "gta/enums.hpp"
|
#include "gta/enums.hpp"
|
||||||
#include "natives.hpp"
|
#include "natives.hpp"
|
||||||
#include "script.hpp"
|
#include "script.hpp"
|
||||||
|
#include "pointers.hpp"
|
||||||
|
#include "ui/blip_t.hpp"
|
||||||
|
#include "ui/CBlipList.hpp"
|
||||||
|
|
||||||
namespace big::blip
|
namespace big::blip
|
||||||
{
|
{
|
||||||
@ -45,4 +48,18 @@ namespace big::blip
|
|||||||
|
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
@ -199,6 +199,31 @@ namespace big::teleport
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool to_highlighted_blip()
|
||||||
|
{
|
||||||
|
if (!*g_pointers->m_gta.m_is_session_started)
|
||||||
|
{
|
||||||
|
g_notification_service->push_warning("TELEPORT"_T.data(), "TELEPORT_NOT_ONLINE"_T.data());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto blip = blip::get_selected_blip();
|
||||||
|
if (blip == nullptr)
|
||||||
|
{
|
||||||
|
g_notification_service->push_warning("TELEPORT"_T.data(), "TELEPORT_NOTHING_SELECTED"_T.data());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Entity entity = self::ped;
|
||||||
|
if (PED::GET_PED_CONFIG_FLAG(self::ped, 62, TRUE))
|
||||||
|
{
|
||||||
|
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_HEADING(entity, blip->m_rotation);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool tp_on_top(Entity ent, bool match_velocity)
|
inline bool tp_on_top(Entity ent, bool match_velocity)
|
||||||
{
|
{
|
||||||
if (!ENTITY::DOES_ENTITY_EXIST(ent))
|
if (!ENTITY::DOES_ENTITY_EXIST(ent))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "services/custom_teleport/custom_teleport_service.hpp"
|
#include "services/custom_teleport/custom_teleport_service.hpp"
|
||||||
#include "util/math.hpp"
|
#include "util/math.hpp"
|
||||||
#include "util/teleport.hpp"
|
#include "util/teleport.hpp"
|
||||||
|
#include "util/blip.hpp"
|
||||||
#include "views/view.hpp"
|
#include "views/view.hpp"
|
||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
@ -38,7 +39,7 @@ namespace big
|
|||||||
void view::custom_teleport()
|
void view::custom_teleport()
|
||||||
{
|
{
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
static std::string new_location_name;
|
static std::string new_location_name{};
|
||||||
static std::string category = "Default";
|
static std::string category = "Default";
|
||||||
static telelocation deletion_telelocation;
|
static telelocation deletion_telelocation;
|
||||||
static std::string filter{};
|
static std::string filter{};
|
||||||
@ -74,8 +75,14 @@ namespace big
|
|||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
components::button("Save current location", [] {
|
components::button("Save current location", [] {
|
||||||
if (g_custom_teleport_service.get_saved_location_by_name(new_location_name))
|
if (new_location_name.empty())
|
||||||
|
{
|
||||||
|
g_notification_service->push_warning("Custom Teleport", "Please enter a valid name.");
|
||||||
|
}
|
||||||
|
else if (g_custom_teleport_service.get_saved_location_by_name(new_location_name))
|
||||||
|
{
|
||||||
g_notification_service->push_warning("Custom Teleport", std::format("Location with the name {} already exists", new_location_name));
|
g_notification_service->push_warning("Custom Teleport", std::format("Location with the name {} already exists", new_location_name));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
telelocation teleport_location;
|
telelocation teleport_location;
|
||||||
@ -93,6 +100,40 @@ namespace big
|
|||||||
g_custom_teleport_service.save_new_location(category, teleport_location);
|
g_custom_teleport_service.save_new_location(category, teleport_location);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
ImGui::SameLine();
|
||||||
|
components::button("Save current selected blip", [] {
|
||||||
|
if (new_location_name.empty())
|
||||||
|
{
|
||||||
|
g_notification_service->push_warning("Custom Teleport", "Please enter a valid name.");
|
||||||
|
}
|
||||||
|
else if (g_custom_teleport_service.get_saved_location_by_name(new_location_name))
|
||||||
|
{
|
||||||
|
g_notification_service->push_warning("Custom Teleport", std::format("Location with the name {} already exists", new_location_name));
|
||||||
|
}
|
||||||
|
else if (!*g_pointers->m_gta.m_is_session_started)
|
||||||
|
{
|
||||||
|
g_notification_service->push_warning("Custom Teleport", "TELEPORT_NOT_ONLINE"_T.data());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
telelocation teleport_location;
|
||||||
|
auto blip = blip::get_selected_blip();
|
||||||
|
if (blip == nullptr)
|
||||||
|
{
|
||||||
|
g_notification_service->push_warning("Custom Teleport", std::format("Cannot find selected blip."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
teleport_location.name = new_location_name;
|
||||||
|
teleport_location.x = blip->m_x;
|
||||||
|
teleport_location.y = blip->m_y;
|
||||||
|
teleport_location.z = blip->m_z;
|
||||||
|
teleport_location.yaw = blip->m_rotation;
|
||||||
|
teleport_location.pitch = 0.0f;
|
||||||
|
teleport_location.roll = 0.0f;
|
||||||
|
g_custom_teleport_service.save_new_location(category, teleport_location);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ namespace big
|
|||||||
components::command_button<"waypointtp">({}, "Waypoint");
|
components::command_button<"waypointtp">({}, "Waypoint");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
components::command_button<"objectivetp">({}, "Objective");
|
components::command_button<"objectivetp">({}, "Objective");
|
||||||
|
ImGui::SameLine();
|
||||||
|
components::command_button<"highlighttp">({}, "Selected");
|
||||||
components::command_checkbox<"autotptowp">();
|
components::command_checkbox<"autotptowp">();
|
||||||
|
|
||||||
ImGui::SeparatorText("Movement");
|
ImGui::SeparatorText("Movement");
|
||||||
|
Reference in New Issue
Block a user