Removed errant waypoint icons in get_objective_location. (#3509)
Some checks are pending
Nightly Build / Build Nightly (push) Waiting to run
Nightly Build / Recreate Release (push) Blocked by required conditions
Nightly Build / Check Recent Commit (push) Successful in 27s

This commit is contained in:
gir489 2024-08-03 12:19:43 -04:00 committed by GitHub
parent 09a60a98b7
commit eefd71196c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 1121 additions and 700 deletions

View File

@ -1,18 +1,18 @@
#include "backend/looped_command.hpp" #include "backend/looped_command.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "util/teleport.hpp" #include "util/teleport.hpp"
namespace big namespace big
{ {
class auto_tp_to_waypoint : looped_command class auto_tp_to_waypoint : looped_command
{ {
using looped_command::looped_command; using looped_command::looped_command;
virtual void on_tick() override virtual void on_tick() override
{ {
teleport::to_blip((int)BlipIcons::Waypoint); teleport::to_blip((int)BlipIcons::RADAR_WAYPOINT);
} }
}; };
auto_tp_to_waypoint g_auto_tp_to_waypoint("autotptowp", "BACKEND_LOOPED_AUTO_TP_TO_WAYPOINT", "BACKEND_LOOPED_AUTO_TP_TO_WAYPOINT_DESC", g.self.auto_tp); auto_tp_to_waypoint g_auto_tp_to_waypoint("autotptowp", "BACKEND_LOOPED_AUTO_TP_TO_WAYPOINT", "BACKEND_LOOPED_AUTO_TP_TO_WAYPOINT_DESC", g.self.auto_tp);
} }

View File

@ -1,109 +1,109 @@
#include "backend/looped/looped.hpp" #include "backend/looped/looped.hpp"
#include "gta/enums.hpp" #include "gta/enums.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "util/blip.hpp" #include "util/blip.hpp"
#include "util/entity.hpp" #include "util/entity.hpp"
#include "util/vehicle.hpp" #include "util/vehicle.hpp"
namespace big namespace big
{ {
void looped::vehicle_auto_drive() void looped::vehicle_auto_drive()
{ {
static std::unordered_map<AutoDriveStyle, int> driving_style_flags = {{AutoDriveStyle::LAW_ABIDING, 443}, {AutoDriveStyle::THE_ROAD_IS_YOURS, 787004}}; static std::unordered_map<AutoDriveStyle, int> driving_style_flags = {{AutoDriveStyle::LAW_ABIDING, 443}, {AutoDriveStyle::THE_ROAD_IS_YOURS, 787004}};
static int changing_driving_styles = false; static int changing_driving_styles = false;
static AutoDriveDestination current_destination = AutoDriveDestination::STOPPED; static AutoDriveDestination current_destination = AutoDriveDestination::STOPPED;
static int current_driving_flag = driving_style_flags[AutoDriveStyle::LAW_ABIDING]; static int current_driving_flag = driving_style_flags[AutoDriveStyle::LAW_ABIDING];
static float current_speed = 8; static float current_speed = 8;
static bool started = false; static bool started = false;
static Vector3 waypoint; static Vector3 waypoint;
if (g.vehicle.auto_drive_destination != AutoDriveDestination::STOPPED) if (g.vehicle.auto_drive_destination != AutoDriveDestination::STOPPED)
{ {
current_destination = g.vehicle.auto_drive_destination; current_destination = g.vehicle.auto_drive_destination;
g.vehicle.auto_drive_destination = AutoDriveDestination::STOPPED; g.vehicle.auto_drive_destination = AutoDriveDestination::STOPPED;
changing_driving_styles = true; changing_driving_styles = true;
} }
if (!self::veh && current_destination != AutoDriveDestination::STOPPED) if (!self::veh && current_destination != AutoDriveDestination::STOPPED)
{ {
current_destination = AutoDriveDestination::STOPPED; current_destination = AutoDriveDestination::STOPPED;
changing_driving_styles = false; changing_driving_styles = false;
g_notification_service.push_warning("AUTO_DRIVE"_T.data(), "PLAYER_INFO_NO_VEHICLE"_T.data()); g_notification_service.push_warning("AUTO_DRIVE"_T.data(), "PLAYER_INFO_NO_VEHICLE"_T.data());
} }
else if (current_driving_flag != driving_style_flags[g.vehicle.auto_drive_style] || current_speed != g.vehicle.auto_drive_speed) else if (current_driving_flag != driving_style_flags[g.vehicle.auto_drive_style] || current_speed != g.vehicle.auto_drive_speed)
{ {
current_driving_flag = driving_style_flags[g.vehicle.auto_drive_style]; current_driving_flag = driving_style_flags[g.vehicle.auto_drive_style];
current_speed = g.vehicle.auto_drive_speed; current_speed = g.vehicle.auto_drive_speed;
changing_driving_styles = true; changing_driving_styles = true;
} }
if (current_destination != AutoDriveDestination::STOPPED) if (current_destination != AutoDriveDestination::STOPPED)
{ {
Vector3 last_waypoint = waypoint; Vector3 last_waypoint = waypoint;
bool does_waypoint_exist = false; bool does_waypoint_exist = false;
bool to_waypoint = false; bool to_waypoint = false;
if (current_destination == AutoDriveDestination::OBJECTITVE) if (current_destination == AutoDriveDestination::OBJECTITVE)
{ {
to_waypoint = true; to_waypoint = true;
does_waypoint_exist = blip::get_objective_location(waypoint); does_waypoint_exist = blip::get_objective_location(waypoint);
} }
else if (current_destination == AutoDriveDestination::WAYPOINT) else if (current_destination == AutoDriveDestination::WAYPOINT)
{ {
to_waypoint = true; to_waypoint = true;
does_waypoint_exist = blip::get_blip_location(waypoint, (int)BlipIcons::Waypoint); does_waypoint_exist = blip::get_blip_location(waypoint, (int)BlipIcons::RADAR_WAYPOINT);
} }
if (does_waypoint_exist if (does_waypoint_exist
&& (last_waypoint.x != waypoint.x || last_waypoint.y != waypoint.y || last_waypoint.z != waypoint.z)) && (last_waypoint.x != waypoint.x || last_waypoint.y != waypoint.y || last_waypoint.z != waypoint.z))
{ {
changing_driving_styles = true; changing_driving_styles = true;
} }
bool interupted = (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_LEFT_ONLY) || PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_RIGHT_ONLY) || PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_ACCELERATE) || PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_BRAKE) || PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_EXIT) || PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HANDBRAKE)); bool interupted = (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_LEFT_ONLY) || PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_RIGHT_ONLY) || PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_ACCELERATE) || PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_BRAKE) || PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_EXIT) || PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HANDBRAKE));
if (current_destination == AutoDriveDestination::EMERGENCY_STOP || (to_waypoint && !does_waypoint_exist) || interupted) if (current_destination == AutoDriveDestination::EMERGENCY_STOP || (to_waypoint && !does_waypoint_exist) || interupted)
{ {
TASK::CLEAR_PRIMARY_VEHICLE_TASK(self::veh); TASK::CLEAR_PRIMARY_VEHICLE_TASK(self::veh);
TASK::CLEAR_PED_TASKS(self::ped); TASK::CLEAR_PED_TASKS(self::ped);
if (!interupted && started) if (!interupted && started)
{ {
VEHICLE::SET_VEHICLE_FORWARD_SPEED(self::veh, 0); VEHICLE::SET_VEHICLE_FORWARD_SPEED(self::veh, 0);
} }
current_destination = AutoDriveDestination::STOPPED; current_destination = AutoDriveDestination::STOPPED;
if (to_waypoint && !does_waypoint_exist) if (to_waypoint && !does_waypoint_exist)
{ {
g_notification_service.push_warning("AUTO_DRIVE"_T.data(), "TELEPORT_NO_WAYPOINT_SET"_T.data()); g_notification_service.push_warning("AUTO_DRIVE"_T.data(), "TELEPORT_NO_WAYPOINT_SET"_T.data());
} }
else else
{ {
g_notification_service.push_warning("AUTO_DRIVE"_T.data(), "BACKEND_LOOPED_VEHICLE_AUTO_DRIVE_STOPPED"_T.data()); g_notification_service.push_warning("AUTO_DRIVE"_T.data(), "BACKEND_LOOPED_VEHICLE_AUTO_DRIVE_STOPPED"_T.data());
} }
started = false; started = false;
} }
else if (changing_driving_styles) else if (changing_driving_styles)
{ {
changing_driving_styles = false; changing_driving_styles = false;
TASK::CLEAR_PRIMARY_VEHICLE_TASK(self::veh); TASK::CLEAR_PRIMARY_VEHICLE_TASK(self::veh);
TASK::CLEAR_PED_TASKS(self::ped); TASK::CLEAR_PED_TASKS(self::ped);
if (to_waypoint) if (to_waypoint)
{ {
TASK::TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE(self::ped, self::veh, waypoint.x, waypoint.y, waypoint.z, current_speed, current_driving_flag, 20); TASK::TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE(self::ped, self::veh, waypoint.x, waypoint.y, waypoint.z, current_speed, current_driving_flag, 20);
} }
else else
{ {
TASK::TASK_VEHICLE_DRIVE_WANDER(self::ped, self::veh, current_speed, current_driving_flag); TASK::TASK_VEHICLE_DRIVE_WANDER(self::ped, self::veh, current_speed, current_driving_flag);
} }
started = true; started = true;
} }
} }
} }
} }

View File

@ -1,106 +1,106 @@
#include "backend/looped_command.hpp" #include "backend/looped_command.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "script.hpp" #include "script.hpp"
#include "util/blip.hpp" #include "util/blip.hpp"
namespace big namespace big
{ {
class waypoint_beacon : looped_command class waypoint_beacon : looped_command
{ {
using looped_command::looped_command; using looped_command::looped_command;
virtual void on_tick() override virtual void on_tick() override
{ {
Vector3 location; Vector3 location;
if (blip::get_blip_location(location, (int)BlipIcons::Waypoint)) if (blip::get_blip_location(location, (int)BlipIcons::RADAR_WAYPOINT))
{ {
int color[3] = {0, 0, 0}; int color[3] = {0, 0, 0};
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
color[i] = (int)(255 * g.world.waypoint_n_objective.waypoint_beacon_color[i]); color[i] = (int)(255 * g.world.waypoint_n_objective.waypoint_beacon_color[i]);
// no need to bool check this, z-coord just have to be under/on the ground it doesn't really matter // no need to bool check this, z-coord just have to be under/on the ground it doesn't really matter
MISC::GET_GROUND_Z_FOR_3D_COORD(location.x, location.y, location.z, &location.z, 1, 0); MISC::GET_GROUND_Z_FOR_3D_COORD(location.x, location.y, location.z, &location.z, 1, 0);
GRAPHICS::DRAW_MARKER_EX(1, GRAPHICS::DRAW_MARKER_EX(1,
location.x, location.x,
location.y, location.y,
location.z, location.z,
0.f, 0.f,
0.f, 0.f,
0.f, 0.f,
0.f, 0.f,
0.f, 0.f,
0.f, 0.f,
7.5f, 7.5f,
7.f, 7.f,
location.z + 1500.f, // the beam's end location.z + 1500.f, // the beam's end
color[0], color[0],
color[1], color[1],
color[2], color[2],
180, 180,
0, 0,
0, 0,
2, 2,
0, 0,
0, 0,
0, 0,
0, 0,
1, 1,
1); 1);
} }
} }
}; };
class objective_beacon : looped_command class objective_beacon : looped_command
{ {
using looped_command::looped_command; using looped_command::looped_command;
virtual void on_tick() override virtual void on_tick() override
{ {
Vector3 location; Vector3 location;
if (blip::get_objective_location(location)) if (blip::get_objective_location(location))
{ {
int color[3] = {0, 0, 0}; int color[3] = {0, 0, 0};
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
color[i] = (int)(255 * g.world.waypoint_n_objective.objective_beacon_color[i]); color[i] = (int)(255 * g.world.waypoint_n_objective.objective_beacon_color[i]);
// no need to bool check this, z-coord just have to be under/on the ground it doesn't really matter // no need to bool check this, z-coord just have to be under/on the ground it doesn't really matter
MISC::GET_GROUND_Z_FOR_3D_COORD(location.x, location.y, location.z, &location.z, 1, 0); MISC::GET_GROUND_Z_FOR_3D_COORD(location.x, location.y, location.z, &location.z, 1, 0);
GRAPHICS::DRAW_MARKER_EX(1, GRAPHICS::DRAW_MARKER_EX(1,
location.x, location.x,
location.y, location.y,
location.z, location.z,
0.f, 0.f,
0.f, 0.f,
0.f, 0.f,
0.f, 0.f,
0.f, 0.f,
0.f, 0.f,
7.5f, 7.5f,
7.f, 7.f,
location.z + 1500.f, // the beam's end location.z + 1500.f, // the beam's end
color[0], color[0],
color[1], color[1],
color[2], color[2],
180, 180,
0, 0,
0, 0,
2, 2,
0, 0,
0, 0,
0, 0,
0, 0,
1, 1,
1); 1);
} }
} }
}; };
waypoint_beacon g_waypoint_beacon("waypointbeacon", "BACKEND_LOOPED_WORLD_BEACON_WAYPOINT", "BACKEND_LOOPED_WORLD_BEACON_WAYPOINT_DESC", g.world.waypoint_n_objective.waypoint_beacon); waypoint_beacon g_waypoint_beacon("waypointbeacon", "BACKEND_LOOPED_WORLD_BEACON_WAYPOINT", "BACKEND_LOOPED_WORLD_BEACON_WAYPOINT_DESC", g.world.waypoint_n_objective.waypoint_beacon);
objective_beacon g_objective_beacon("objectivebeacon", "BACKEND_LOOPED_WORLD_BEACON_OBJECTIVE", "BACKEND_LOOPED_WORLD_BEACON_OBJECTIVE_DESC", g.world.waypoint_n_objective.objective_beacon); objective_beacon g_objective_beacon("objectivebeacon", "BACKEND_LOOPED_WORLD_BEACON_OBJECTIVE", "BACKEND_LOOPED_WORLD_BEACON_OBJECTIVE_DESC", g.world.waypoint_n_objective.objective_beacon);
} }

File diff suppressed because it is too large Load Diff

View File

@ -50,19 +50,17 @@ namespace big::blip
bool get_objective_location(Vector3& location) bool get_objective_location(Vector3& location)
{ {
if (get_objective_location_iteration(location, {BlipIcons::Circle}, {BlipColors::YellowMission, BlipColors::YellowMission2, BlipColors::Mission})) if (get_objective_location_iteration(location, {BlipIcons::RADAR_LEVEL}, {BlipColors::YellowMission, BlipColors::YellowMission2, BlipColors::Mission}))
return true; return true;
if (get_objective_location_iteration(location, {BlipIcons::RaceFinish}, {BlipColors::None})) if (get_objective_location_iteration(location, {BlipIcons::RADAR_RACEFLAG}, {BlipColors::None}))
return true; return true;
if (get_objective_location_iteration(location, {BlipIcons::Circle}, {BlipColors::Green, BlipColors::Blue})) if (get_objective_location_iteration(location, {BlipIcons::RADAR_LEVEL}, {BlipColors::Green, BlipColors::Blue}))
return true;
if (get_objective_location_iteration(location, {BlipIcons::CrateDrop}))
return true; return true;
auto blip_icons = {0, 1, 2, 143, 144, 145, 146, 280, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 535, 536, 537, 538, 539, 540, 541, 542}; static const auto blip_icons = {BlipIcons::RADAR_OBJECTIVE_BLUE, BlipIcons::RADAR_OBJECTIVE_GREEN, BlipIcons::RADAR_OBJECTIVE_RED, BlipIcons::RADAR_OBJECTIVE_YELLOW, BlipIcons::RADAR_CRATEDROP, BlipIcons::RADAR_TARGET_A, BlipIcons::RADAR_TARGET_B, BlipIcons::RADAR_TARGET_C, BlipIcons::RADAR_TARGET_D, BlipIcons::RADAR_TARGET_E, BlipIcons::RADAR_TARGET_F, BlipIcons::RADAR_TARGET_G, BlipIcons::RADAR_TARGET_H, BlipIcons::RADAR_SM_CARGO, BlipIcons::RADAR_BAT_CARGO, BlipIcons::RADAR_DEAD_DROP_PACKAGE};
for (const auto& icon : blip_icons) for (const auto icon : blip_icons)
{ {
if (get_blip_location_from_offset(location, icon)) if (get_blip_location_from_offset(location, (int)icon))
return true; return true;
} }

View File

@ -169,7 +169,7 @@ namespace big::teleport
if (!blip::get_blip_location(location, sprite, color)) if (!blip::get_blip_location(location, sprite, color))
return false; return false;
if (sprite == (int)BlipIcons::Waypoint) if (sprite == (int)BlipIcons::RADAR_WAYPOINT)
entity::load_ground_at_3dcoord(location); entity::load_ground_at_3dcoord(location);
to_coords(location); to_coords(location);
@ -193,7 +193,7 @@ namespace big::teleport
inline bool to_waypoint() inline bool to_waypoint()
{ {
if (!to_blip((int)BlipIcons::Waypoint)) if (!to_blip((int)BlipIcons::RADAR_WAYPOINT))
{ {
g_notification_service.push_warning("TELEPORT"_T.data(), "TELEPORT_NO_WAYPOINT_SET"_T.data()); g_notification_service.push_warning("TELEPORT"_T.data(), "TELEPORT_NO_WAYPOINT_SET"_T.data());

View File

@ -18,7 +18,7 @@ namespace big
ImGui::SameLine(); ImGui::SameLine();
components::button("VIEW_PLAYER_TELEPORT_YOUR_WAYPOINT"_T, [] { components::button("VIEW_PLAYER_TELEPORT_YOUR_WAYPOINT"_T, [] {
Vector3 location; Vector3 location;
if (blip::get_blip_location(location, (int)BlipIcons::Waypoint)) if (blip::get_blip_location(location, (int)BlipIcons::RADAR_WAYPOINT))
entity::load_ground_at_3dcoord(location), teleport::teleport_player_to_coords(g_player_service->get_selected(), location); entity::load_ground_at_3dcoord(location), teleport::teleport_player_to_coords(g_player_service->get_selected(), location);
}); });