Feat teleport improv (#292)

This commit is contained in:
Quentin E. / iDeath 2022-06-27 15:45:26 +02:00 committed by GitHub
parent 1384bd600d
commit 747af10277
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 23 deletions

View File

@ -66,9 +66,9 @@ namespace big::teleport
inline bool into_vehicle(Vehicle veh) inline bool into_vehicle(Vehicle veh)
{ {
if (!veh) if (!ENTITY::IS_ENTITY_A_VEHICLE(veh))
{ {
g_notification_service->push_warning("Teleport", "Player is not in a vehicle."); g_notification_service->push_warning("Teleport", "Invalid vehicle handle");
return false; return false;
} }
@ -112,7 +112,8 @@ namespace big::teleport
if (!blip::get_blip_location(location, sprite, color)) if (!blip::get_blip_location(location, sprite, color))
return false; return false;
load_ground_at_3dcoord(location); if (sprite == (int)BlipIcons::Waypoint)
load_ground_at_3dcoord(location);
PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped, location.x, location.y, location.z); PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped, location.x, location.y, location.z);
@ -154,12 +155,14 @@ namespace big::teleport
if (to_blip((int)BlipIcons::Circle, (int)BlipColors::Blue)) return true; if (to_blip((int)BlipIcons::Circle, (int)BlipColors::Blue)) return true;
if (to_blip((int)BlipIcons::CrateDrop)) return true; if (to_blip((int)BlipIcons::CrateDrop)) return true;
static const int blips[] = { 1, 57, 128, 129, 130, 143, 144, 145, 146, 271, 286, 287, 288 }; static const int blips[] = { 1, 57, 128, 129, 130, 143, 144, 145, 146, 271, 286, 287, 288 };
for (int i = 0; i < (sizeof(blips) / sizeof(*blips)); i++) { for (const auto& blip : blips)
if (to_blip(blips[i], 5)) { {
if (to_blip(blip, 5))
{
return true; return true;
} }
} }
g_notification_service->push_warning("Teleport", "Failed to find objective position"); g_notification_service->push_warning("Teleport", "Failed to find objective position");
return false; return false;
} }
} }

View File

@ -14,9 +14,11 @@ namespace big::vehicle
{ {
*script_global(2671447).at(8).as<int*>() = 1; *script_global(2671447).at(8).as<int*>() = 1;
} }
inline void bring(Vehicle veh, Vector3 location, bool put_in = true) inline void bring(Vehicle veh, Vector3 location, bool put_in = true)
{ {
if (!ENTITY::IS_ENTITY_A_VEHICLE(veh)) return g_notification_service->push_error("Vehicle", "Invalid handle");
Vector3 vecVehicleLocation = ENTITY::GET_ENTITY_COORDS(veh, true); Vector3 vecVehicleLocation = ENTITY::GET_ENTITY_COORDS(veh, true);
teleport::load_ground_at_3dcoord(vecVehicleLocation); teleport::load_ground_at_3dcoord(vecVehicleLocation);

View File

@ -6,34 +6,44 @@
namespace big namespace big
{ {
void view::teleport() { void view::teleport()
{
ImGui::Text("Blips:"); ImGui::Text("Blips:");
components::button("Waypoint", [] { components::button("Waypoint", []
{
teleport::to_waypoint(); teleport::to_waypoint();
}); });
components::button("Objective", [] { components::button("Objective", []
{
teleport::to_objective(); teleport::to_objective();
}); });
ImGui::Text("Vehicles:"); ImGui::Text("Vehicles:");
components::button("Bring Personal Vehicle", [] { components::button("Teleport to Last Vehicle", []
{
if (g_local_player && g_local_player->m_vehicle)
{
const Vehicle veh = g_pointers->m_ptr_to_handle(g_local_player->m_vehicle);
teleport::into_vehicle(veh);
}
});
components::button("Bring Personal Vehicle", []
{
Vehicle veh = globals::get_personal_vehicle(); Vehicle veh = globals::get_personal_vehicle();
if (ENTITY::IS_ENTITY_DEAD(veh, false)) return g_notification_service->push_error("Teleport", "Invalid vehicle handle...");
vehicle::bring(veh, self::pos); vehicle::bring(veh, self::pos);
}); });
components::button("Teleport to Personal Vehicle", [] { components::button("Teleport to Personal Vehicle", []
{
Vehicle veh = globals::get_personal_vehicle(); Vehicle veh = globals::get_personal_vehicle();
if (ENTITY::IS_ENTITY_DEAD(veh, false)) return g_notification_service->push_error("Teleport", "Invalid vehicle handle...");
teleport::to_coords( teleport::into_vehicle(veh);
ENTITY::GET_ENTITY_COORDS(veh, true) });
);
});
} }
} }