From 747af1027735c8762bbc9557ac5cc2cbee658e9e Mon Sep 17 00:00:00 2001 From: "Quentin E. / iDeath" Date: Mon, 27 Jun 2022 15:45:26 +0200 Subject: [PATCH] Feat teleport improv (#292) --- BigBaseV2/src/util/teleport.hpp | 15 ++++---- BigBaseV2/src/util/vehicle.hpp | 4 ++- BigBaseV2/src/views/self/view_teleport.cpp | 42 +++++++++++++--------- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/BigBaseV2/src/util/teleport.hpp b/BigBaseV2/src/util/teleport.hpp index 77ccc149..304ba6d7 100644 --- a/BigBaseV2/src/util/teleport.hpp +++ b/BigBaseV2/src/util/teleport.hpp @@ -66,9 +66,9 @@ namespace big::teleport 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; } @@ -112,7 +112,8 @@ namespace big::teleport if (!blip::get_blip_location(location, sprite, color)) 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); @@ -154,12 +155,14 @@ namespace big::teleport if (to_blip((int)BlipIcons::Circle, (int)BlipColors::Blue)) 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 }; - for (int i = 0; i < (sizeof(blips) / sizeof(*blips)); i++) { - if (to_blip(blips[i], 5)) { + for (const auto& blip : blips) + { + if (to_blip(blip, 5)) + { return true; } } g_notification_service->push_warning("Teleport", "Failed to find objective position"); return false; } -} \ No newline at end of file +} diff --git a/BigBaseV2/src/util/vehicle.hpp b/BigBaseV2/src/util/vehicle.hpp index 3011022f..0d154287 100644 --- a/BigBaseV2/src/util/vehicle.hpp +++ b/BigBaseV2/src/util/vehicle.hpp @@ -14,9 +14,11 @@ namespace big::vehicle { *script_global(2671447).at(8).as() = 1; } - + 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); teleport::load_ground_at_3dcoord(vecVehicleLocation); diff --git a/BigBaseV2/src/views/self/view_teleport.cpp b/BigBaseV2/src/views/self/view_teleport.cpp index ca394b51..154a21b6 100644 --- a/BigBaseV2/src/views/self/view_teleport.cpp +++ b/BigBaseV2/src/views/self/view_teleport.cpp @@ -6,34 +6,44 @@ namespace big { - void view::teleport() { - + void view::teleport() + { ImGui::Text("Blips:"); - components::button("Waypoint", [] { + components::button("Waypoint", [] + { teleport::to_waypoint(); - }); + }); - components::button("Objective", [] { + components::button("Objective", [] + { teleport::to_objective(); - }); + }); 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(); - if (ENTITY::IS_ENTITY_DEAD(veh, false)) return g_notification_service->push_error("Teleport", "Invalid vehicle handle..."); vehicle::bring(veh, self::pos); - }); + }); - components::button("Teleport to Personal Vehicle", [] { + components::button("Teleport to 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( - ENTITY::GET_ENTITY_COORDS(veh, true) - ); - }); + teleport::into_vehicle(veh); + }); } -} \ No newline at end of file +}