From b93a072fe6aebe5898f4da2804a8f93661ef06ac Mon Sep 17 00:00:00 2001 From: thehorizon84 <149878244+thehorizon84@users.noreply.github.com> Date: Wed, 8 Nov 2023 23:16:10 +0100 Subject: [PATCH] feat: New world options + Request Gun Van anywhere (#2393) + World -> Gravity Editor (with presets for ease of use) + World -> Waypoint Beacon + World -> Objective Beacon + World -> Time And Weather -> Ground Snow + Self -> Mobile -> Request Gun Van (spawns the gun van right in front of you no matter where you are) --- .../commands/self/request_services.cpp | 11 ++ src/backend/looped/world/beacon.cpp | 106 ++++++++++++++++++ src/backend/looped/world/gravity.cpp | 26 +++++ src/backend/looped/world/groundsnow.cpp | 25 +++++ src/core/data/gravity_presets.hpp | 34 ++++++ src/core/scr_globals.hpp | 2 + src/core/settings.hpp | 23 +++- src/function_types.hpp | 2 + src/gta_pointers.hpp | 2 + src/pointers.cpp | 18 +++ src/util/mobile.hpp | 23 ++++ src/views/self/view_mobile.cpp | 1 + src/views/view.hpp | 2 + src/views/world/view_gravity.cpp | 22 ++++ src/views/world/view_time_and_weather.cpp | 2 + .../world/view_waypoint_and_objective.cpp | 17 +++ src/views/world/view_world.cpp | 10 ++ 17 files changed, 324 insertions(+), 2 deletions(-) create mode 100644 src/backend/looped/world/beacon.cpp create mode 100644 src/backend/looped/world/gravity.cpp create mode 100644 src/backend/looped/world/groundsnow.cpp create mode 100644 src/core/data/gravity_presets.hpp create mode 100644 src/views/world/view_gravity.cpp create mode 100644 src/views/world/view_waypoint_and_objective.cpp diff --git a/src/backend/commands/self/request_services.cpp b/src/backend/commands/self/request_services.cpp index 7cf4438f..87b166be 100644 --- a/src/backend/commands/self/request_services.cpp +++ b/src/backend/commands/self/request_services.cpp @@ -94,6 +94,16 @@ namespace big } }; + class request_gun_van : command + { + using command::command; + + virtual void execute(const command_arguments&, const std::shared_ptr ctx) override + { + mobile::mobile_misc::request_gun_van(); + } + }; + boat_pickup g_boat_pickup("boatpickup", "REQUEST_BOAT", "REQUEST_BOAT_DESC", 0); ballistic_armor g_ballistic_armor("ballisticarmor", "REQUEST_BALLISTIC", "REQUEST_BALLISTIC_DESC", 0); request_avenger g_request_avenger("avenger", "REQUEST_AVENGER", "REQUEST_AVENGER_DESC", 0); @@ -103,4 +113,5 @@ namespace big request_acidlab g_request_acidlab("acidlab", "REQUEST_ACIDLAB", "REQUEST_ACIDLAB_DESC", 0); request_acidlab_bike g_request_acidlab_bike("acidbike", "REQUEST_ACIDBIKE", "REQUEST_ACIDBIKE_DESC", 0); request_taxi g_request_taxi("taxi", "REQUEST_TAXI", "REQUEST_TAXI_DESC", 0); + request_gun_van g_request_gun_van("gunvan", "REQUEST_GUN_VAN", "REQUEST_GUN_VAN_DESC", 0); } \ No newline at end of file diff --git a/src/backend/looped/world/beacon.cpp b/src/backend/looped/world/beacon.cpp new file mode 100644 index 00000000..707f71d7 --- /dev/null +++ b/src/backend/looped/world/beacon.cpp @@ -0,0 +1,106 @@ +#include "backend/looped_command.hpp" +#include "natives.hpp" +#include "script.hpp" +#include "util/blip.hpp" + +namespace big +{ + class waypoint_beacon : looped_command + { + using looped_command::looped_command; + + virtual void on_tick() override + { + Vector3 location; + + if (blip::get_blip_location(location, (int)BlipIcons::Waypoint)) + { + int color[3] = {0, 0, 0}; + + for (int i = 0; i < 3; 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 + MISC::GET_GROUND_Z_FOR_3D_COORD(location.x, location.y, location.z, &location.z, 1, 0); + + GRAPHICS::DRAW_MARKER_EX(1, + location.x, + location.y, + location.z, + 0.f, + 0.f, + 0.f, + 0.f, + 0.f, + 0.f, + 7.5f, + 7.f, + location.z + 1500.f, // the beam's end + color[0], + color[1], + color[2], + 180, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 1, + 1); + } + } + }; + + class objective_beacon : looped_command + { + using looped_command::looped_command; + + virtual void on_tick() override + { + Vector3 location; + + if (blip::get_objective_location(location)) + { + int color[3] = {0, 0, 0}; + + for (int i = 0; i < 3; 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 + MISC::GET_GROUND_Z_FOR_3D_COORD(location.x, location.y, location.z, &location.z, 1, 0); + + GRAPHICS::DRAW_MARKER_EX(1, + location.x, + location.y, + location.z, + 0.f, + 0.f, + 0.f, + 0.f, + 0.f, + 0.f, + 7.5f, + 7.f, + location.z + 1500.f, // the beam's end + color[0], + color[1], + color[2], + 180, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 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); + objective_beacon g_objective_beacon("objectivebeacon", "BACKEND_LOOPED_WORLD_BEACON_OBJECTIVE", "BACKEND_LOOPED_WORLD_BEACON_OBJECTIVE_DESC", g.world.waypoint_n_objective.objective_beacon); +} \ No newline at end of file diff --git a/src/backend/looped/world/gravity.cpp b/src/backend/looped/world/gravity.cpp new file mode 100644 index 00000000..99570e87 --- /dev/null +++ b/src/backend/looped/world/gravity.cpp @@ -0,0 +1,26 @@ +#include "backend/looped_command.hpp" +#include "fiber_pool.hpp" +#include "gta_util.hpp" +#include "script.hpp" + +namespace big +{ + class modify_gravity : looped_command + { + using looped_command::looped_command; + + virtual void on_tick() override + { + *g_pointers->m_gta.m_gravity_level = g.world.gravity.current_gravity; + g_pointers->m_gta.m_set_gravity_level(0); + } + + virtual void on_disable() override + { + *g_pointers->m_gta.m_gravity_level = 9.8f; + g_pointers->m_gta.m_set_gravity_level(0); + } + }; + + modify_gravity g_modify_gravity("modifygravity", "BACKEND_LOOPED_WORLD_MODIFY_GRAVITY", "BACKEND_LOOPED_WORLD_MODIFY_GRAVITY_DESC", g.world.gravity.modify_gravity); +} \ No newline at end of file diff --git a/src/backend/looped/world/groundsnow.cpp b/src/backend/looped/world/groundsnow.cpp new file mode 100644 index 00000000..2fb3004e --- /dev/null +++ b/src/backend/looped/world/groundsnow.cpp @@ -0,0 +1,25 @@ +#include "backend/looped_command.hpp" +#include "fiber_pool.hpp" +#include "gta_util.hpp" +#include "script.hpp" +#include "services/tunables/tunables_service.hpp" + +namespace big +{ + class ground_snow : looped_command + { + using looped_command::looped_command; + + virtual void on_tick() override + { + g_tunables_service->set_tunable(RAGE_JOAAT("TURN_SNOW_ON_OFF"), true); + } + + virtual void on_disable() override + { + g_tunables_service->set_tunable(RAGE_JOAAT("TURN_SNOW_ON_OFF"), false); + } + }; + + ground_snow g_ground_snow("groundsnow", "BACKEND_LOOPED_WORLD_GROUND_SNOW", "BACKEND_LOOPED_WORLD_GROUND_SNOW_DESC", g.world.ground_snow); +} \ No newline at end of file diff --git a/src/core/data/gravity_presets.hpp b/src/core/data/gravity_presets.hpp new file mode 100644 index 00000000..68f539b8 --- /dev/null +++ b/src/core/data/gravity_presets.hpp @@ -0,0 +1,34 @@ +#pragma once + +namespace big +{ + constexpr const static auto gravity_presets = std::to_array({ + "Moon", + "Sun", + "Pluto", + "Space", + "Mercury", + "Venus", + "Earth", + "Mars", + "Jupiter", + "Saturn", + "Uranus", + "Neptune" + }); + + constexpr const static auto gravity_preset_values = std::to_array({ + 1.6f, + 274.f, + 0.6f, + 0.f, + 3.7f, + 8.9f, + 9.8f, + 3.7f, + 24.8f, + 10.5f, + 8.7f, + 11.2f + }); +} diff --git a/src/core/scr_globals.hpp b/src/core/scr_globals.hpp index 88f53cdc..90ae2175 100644 --- a/src/core/scr_globals.hpp +++ b/src/core/scr_globals.hpp @@ -56,6 +56,8 @@ namespace big::scr_globals static inline const script_global gooch(1890378); + static inline const script_global gun_van(1956855); + static inline const script_global passive(1574582); static inline const script_global property_garage(1945123); diff --git a/src/core/settings.hpp b/src/core/settings.hpp index 9e09da3a..a6b1fb6d 100644 --- a/src/core/settings.hpp +++ b/src/core/settings.hpp @@ -542,6 +542,14 @@ namespace big NLOHMANN_DEFINE_TYPE_INTRUSIVE(water, part_water) } water{}; + struct gravity + { + bool modify_gravity = false; + float current_gravity = 9.8f; + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(gravity, modify_gravity, current_gravity) + } gravity{}; + struct ocean { bool modify_ocean = false; @@ -551,6 +559,16 @@ namespace big NLOHMANN_DEFINE_TYPE_INTRUSIVE(ocean, modify_ocean, disable_ocean, ocean_opacity) } ocean{}; + struct waypoint_n_objective + { + bool waypoint_beacon = false; + bool objective_beacon = false; + float waypoint_beacon_color[3] = {1, 0, 1}; + float objective_beacon_color[3] = {1, 1, 0}; + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(waypoint_n_objective, waypoint_beacon, objective_beacon, objective_beacon_color, waypoint_beacon_color) + } waypoint_n_objective{}; + struct spawn_ped { bool preview_ped = false; @@ -615,9 +633,10 @@ namespace big bool override_weather = false; int local_weather = 0; - bool blackout = false; + bool blackout = false; + bool ground_snow = false; - NLOHMANN_DEFINE_TYPE_INTRUSIVE(world, water, spawn_ped, custom_time, blackhole, model_swapper, nearby, orbital_drone, local_weather, override_weather, blackout) + NLOHMANN_DEFINE_TYPE_INTRUSIVE(world, water, spawn_ped, custom_time, blackhole, model_swapper, nearby, orbital_drone, local_weather, override_weather, blackout, ground_snow) } world{}; struct spoofing diff --git a/src/function_types.hpp b/src/function_types.hpp index 768c69c1..40c6c3d3 100644 --- a/src/function_types.hpp +++ b/src/function_types.hpp @@ -63,6 +63,8 @@ namespace big::functions using ptr_to_handle = Entity (*)(void*); using handle_to_ptr = rage::CDynamicEntity* (*)(Entity); + using set_gravity_level = void(*)(int level); + using check_chat_profanity = int(__int64 chat_type, const char* input, const char** output); using write_player_game_state_data_node = bool (*)(rage::netObject* plr, CPlayerGameStateDataNode* node); diff --git a/src/gta_pointers.hpp b/src/gta_pointers.hpp index 6f6f5546..6dc635df 100644 --- a/src/gta_pointers.hpp +++ b/src/gta_pointers.hpp @@ -93,6 +93,8 @@ namespace big uint32_t* m_region_code; uint64_t m_ocean_quads; + float* m_gravity_level; + functions::set_gravity_level m_set_gravity_level; PVOID m_world_model_spawn_bypass; PVOID m_native_return; diff --git a/src/pointers.cpp b/src/pointers.cpp index 74dd026f..3df1e8a6 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -42,6 +42,24 @@ namespace big g_pointers->m_gta.m_ocean_quads = ptr.add(5).rip().as(); } }, + // Gravity Level + { + "GL", + "48 8D 0D ? ? ? ? F3 0F 10 04 81 F3 0F 11 05", + [](memory::handle ptr) + { + g_pointers->m_gta.m_gravity_level = ptr.add(3).rip().as(); + } + }, + // Set Gravity Level + { + "SGL", + "48 83 EC ? 83 F9 ? 77 ? 48 63 C1 48 8D 0D", + [](memory::handle ptr) + { + g_pointers->m_gta.m_set_gravity_level = ptr.as(); + } + }, // Game State { "GS", diff --git a/src/util/mobile.hpp b/src/util/mobile.hpp index 7d7e6fdb..d3f47ba5 100644 --- a/src/util/mobile.hpp +++ b/src/util/mobile.hpp @@ -190,5 +190,28 @@ namespace big::mobile { *scr_globals::freemode_global.at(853).as() = 1; } + + inline void request_gun_van() + { + auto local_pos = self::pos; + auto forward_vector = ENTITY::GET_ENTITY_FORWARD_VECTOR(self::ped); + Vector3 spawn_point; + + if (MISC::FIND_SPAWN_POINT_IN_DIRECTION(local_pos.x, + local_pos.y, + local_pos.z, + forward_vector.x, + forward_vector.y, + forward_vector.z, + 25.f, + &spawn_point)) + { + *scr_globals::gun_van.as() = spawn_point; + + return g_notification_service->push_success("GUI_TAB_MOBILE"_T.data(), "REQUEST_GUN_VAN_NOTIFY_SUCCESS"_T.data()); + } + + g_notification_service->push_warning("GUI_TAB_MOBILE"_T.data(), "REQUEST_GUN_VAN_NOTIFY_FAILED"_T.data()); + } } } diff --git a/src/views/self/view_mobile.cpp b/src/views/self/view_mobile.cpp index ce7d621b..edb5eaa7 100644 --- a/src/views/self/view_mobile.cpp +++ b/src/views/self/view_mobile.cpp @@ -53,6 +53,7 @@ namespace big components::command_button<"taxi">(); + components::command_button<"gunvan">(); ImGui::SeparatorText("MORS_MUTUAL"_T.data()); diff --git a/src/views/view.hpp b/src/views/view.hpp index 26156b89..2b0e33d5 100644 --- a/src/views/view.hpp +++ b/src/views/view.hpp @@ -56,7 +56,9 @@ namespace big static void spawn_ped(); static void squad_spawner(); static void time_and_weather(); + static void gravity(); static void ocean(); + static void waypoint_and_objective(); static void spoofing(); static void teleport(); static void custom_teleport(); diff --git a/src/views/world/view_gravity.cpp b/src/views/world/view_gravity.cpp new file mode 100644 index 00000000..a148ff7f --- /dev/null +++ b/src/views/world/view_gravity.cpp @@ -0,0 +1,22 @@ +#include "views/view.hpp" +#include "core/data/gravity_presets.hpp" + +namespace big +{ + void view::gravity() + { + components::command_checkbox<"modifygravity">(); + + if (g.world.gravity.modify_gravity) + { + ImGui::SliderFloat("GRAVITY_LEVEL"_T.data(), &g.world.gravity.current_gravity, 0.f, 1000.f, "%.1f"); + + static int selected_lunar_preset = 0; + + if (ImGui::Combo("GRAVITY_LUNAR_PRESETS"_T.data(), &selected_lunar_preset, gravity_presets.data(), gravity_presets.size())) + { + g.world.gravity.current_gravity = gravity_preset_values[selected_lunar_preset]; + } + } + } +} \ No newline at end of file diff --git a/src/views/world/view_time_and_weather.cpp b/src/views/world/view_time_and_weather.cpp index ba505d98..2282dfd2 100644 --- a/src/views/world/view_time_and_weather.cpp +++ b/src/views/world/view_time_and_weather.cpp @@ -40,5 +40,7 @@ namespace big } components::command_checkbox<"blackout">(); + + components::command_checkbox<"groundsnow">(); } } diff --git a/src/views/world/view_waypoint_and_objective.cpp b/src/views/world/view_waypoint_and_objective.cpp new file mode 100644 index 00000000..179a71a6 --- /dev/null +++ b/src/views/world/view_waypoint_and_objective.cpp @@ -0,0 +1,17 @@ +#include "views/view.hpp" + +namespace big +{ + void view::waypoint_and_objective() + { + components::command_checkbox<"waypointbeacon">(); + + if (g.world.waypoint_n_objective.waypoint_beacon) + ImGui::ColorPicker3("VIEW_BEACON_WAYPOINT_COLOR"_T.data(), g.world.waypoint_n_objective.waypoint_beacon_color, ImGuiColorEditFlags_NoDragDrop | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHex); + + components::command_checkbox<"objectivebeacon">(); + + if (g.world.waypoint_n_objective.objective_beacon) + ImGui::ColorPicker3("VIEW_BEACON_OBJECTIVE_COLOR"_T.data(), g.world.waypoint_n_objective.objective_beacon_color, ImGuiColorEditFlags_NoDragDrop | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHex); + } +} \ No newline at end of file diff --git a/src/views/world/view_world.cpp b/src/views/world/view_world.cpp index 22d9fd6f..090f002d 100644 --- a/src/views/world/view_world.cpp +++ b/src/views/world/view_world.cpp @@ -14,11 +14,21 @@ namespace big view::time_and_weather(); } + ImGui::SeparatorText("GUI_TAB_GRAVITY"_T.data()); + { + view::gravity(); + } + ImGui::SeparatorText("GUI_TAB_OCEAN"_T.data()); { view::ocean(); } + ImGui::SeparatorText("GUI_TAB_WAYPOINT_N_OBJECTIVE"_T.data()); + { + view::waypoint_and_objective(); + } + ImGui::SeparatorText("PED"_T.data()); components::button("VIEW_DEBUG_THREADS_KILL"_T, [] {