feat(MainWindow): Added teleport to waypoint
This commit is contained in:
parent
a553bc0f3f
commit
f891e23760
22
BigBaseV2/src/gui/window/main/tab_teleport.cpp
Normal file
22
BigBaseV2/src/gui/window/main/tab_teleport.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "tabs.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
#include "util/teleport.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void tab_main::tab_teleport()
|
||||
{
|
||||
if (ImGui::BeginTabItem("Teleport"))
|
||||
{
|
||||
if (ImGui::Button("Waypoint"))
|
||||
{
|
||||
QUEUE_JOB_BEGIN_CLAUSE()
|
||||
{
|
||||
teleport::to_waypoint();
|
||||
}QUEUE_JOB_END_CLAUSE
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
@ -10,5 +10,6 @@ namespace big
|
||||
static void tab_spawn();
|
||||
static void tab_vehicle();
|
||||
static void tab_weapons();
|
||||
static void tab_teleport();
|
||||
};
|
||||
}
|
@ -12,6 +12,7 @@ namespace big
|
||||
ImGui::BeginTabBar("tabbar");
|
||||
tab_main::tab_self();
|
||||
tab_main::tab_spawn();
|
||||
tab_main::tab_teleport();
|
||||
tab_main::tab_vehicle();
|
||||
tab_main::tab_weapons();
|
||||
ImGui::EndTabBar();
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
#include "blip.hpp"
|
||||
#include "entity.hpp"
|
||||
#include "math.hpp"
|
||||
#include "notify.hpp"
|
||||
#include "teleport.hpp"
|
||||
#include "vehicle.hpp"
|
60
BigBaseV2/src/util/teleport.hpp
Normal file
60
BigBaseV2/src/util/teleport.hpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include "blip.hpp"
|
||||
#include "notify.hpp"
|
||||
|
||||
namespace big::teleport
|
||||
{
|
||||
inline bool load_ground_at_3dcoord(Vector3& location)
|
||||
{
|
||||
float groundZ;
|
||||
const uint8_t attempts = 10;
|
||||
|
||||
for (uint8_t i = 0; i < attempts; i++)
|
||||
{
|
||||
// Only request a collision after the first try failed because the location might already be loaded on first attempt.
|
||||
for (uint16_t z = 0; i && z < 1000; z += 100)
|
||||
{
|
||||
STREAMING::REQUEST_COLLISION_AT_COORD(location.x, location.y, (float)z);
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
|
||||
if (MISC::GET_GROUND_Z_FOR_3D_COORD(location.x, location.y, 1000.f, &groundZ, false, false))
|
||||
{
|
||||
location.z = groundZ + 1.f;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
|
||||
location.z = 1000.f;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool to_blip(int sprite, int color = -1)
|
||||
{
|
||||
Vector3 location;
|
||||
|
||||
if (!blip::get_blip_location(location, sprite, color))
|
||||
return false;
|
||||
|
||||
load_ground_at_3dcoord(location);
|
||||
|
||||
PED::SET_PED_COORDS_KEEP_VEHICLE(PLAYER::PLAYER_PED_ID(), location.x, location.y, location.z);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool to_waypoint()
|
||||
{
|
||||
if (!to_blip((int)BlipIcons::Waypoint))
|
||||
{
|
||||
notify::above_map("Failed to find waypoint position");
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user