Skip to content

Tp to waypoint #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: enhanced
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/game/features/teleport/TpToWaypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@ namespace YimMenu::Features
{
constexpr float max_ground_check = 1000.f;
constexpr int max_attempts = 20;
float ground_z = vec.z;
constexpr float min_safe_z = 1.0f;

float ground_z = vec.z + 25.f; // empezar con una z un poco más alta
int current_attempts = 0;

do
{
STREAMING::REQUEST_COLLISION_AT_COORD(vec.x, vec.y, vec.z);
STREAMING::REQUEST_COLLISION_AT_COORD(vec.x, vec.y, ground_z);

float water_height;
if (WATER::GET_WATER_HEIGHT(vec.x, vec.y, vec.z, &water_height))
if (WATER::GET_WATER_HEIGHT(vec.x, vec.y, ground_z, &water_height))
{
vec.z = water_height;
vec.z = std::max(water_height, min_safe_z);
return;
}

if (MISC::GET_GROUND_Z_FOR_3D_COORD(vec.x, vec.y, max_ground_check, &ground_z, false, false))
if (MISC::GET_GROUND_Z_FOR_3D_COORD(vec.x, vec.y, ground_z, &ground_z, false, false))
{
vec.z = ground_z + 1.0f;
vec.z = std::max(ground_z + 1.0f, min_safe_z);
return;
}

Expand All @@ -41,7 +43,8 @@ namespace YimMenu::Features
ScriptMgr::Yield();
} while (current_attempts < max_attempts);

vec.z = PATHFIND::GET_APPROX_HEIGHT_FOR_POINT(vec.x, vec.y); // fallback value
// Último intento como fallback
vec.z = std::max(PATHFIND::GET_APPROX_HEIGHT_FOR_POINT(vec.x, vec.y), min_safe_z);
}

class TpToWaypoint : public Command
Expand Down Expand Up @@ -72,7 +75,7 @@ namespace YimMenu::Features
{
auto coords = HUD::GET_BLIP_COORDS(HUD::GET_CLOSEST_BLIP_INFO_ID(HUD::GET_WAYPOINT_BLIP_ENUM_ID()));
FiberPool::Push([coords] {
auto new_coords{coords};
auto new_coords = coords;
ResolveZCoordinate(new_coords);
Self::GetPed().TeleportTo(new_coords);
});
Expand Down