diff --git a/src/util/teleport.hpp b/src/util/teleport.hpp index 007d9de0..46ac8180 100644 --- a/src/util/teleport.hpp +++ b/src/util/teleport.hpp @@ -12,6 +12,9 @@ namespace big::teleport { Entity ent = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(player->id()); + if(ent == self::ped || ent == self::veh) + PED::SET_PED_COORDS_KEEP_VEHICLE(ent, coords.x, coords.y, coords.z); + if (ENTITY::IS_ENTITY_DEAD(ent, true)) { g_notification_service->push_warning("TELEPORT"_T.data(), "TELEPORT_PLAYER_IS_DEAD"_T.data()); diff --git a/src/views/network/missions/cp_collection.hpp b/src/views/network/missions/cp_collection.hpp new file mode 100644 index 00000000..78f925f7 --- /dev/null +++ b/src/views/network/missions/cp_collection.hpp @@ -0,0 +1,67 @@ +#include "views/view.hpp" +#include "gta_util.hpp" +#include "core/scr_globals.hpp" +#include "util/scripts.hpp" + +namespace big +{ + inline void render_cp_collection_ui() + { + components::sub_title("Checkpoints"); + + components::button("Start Event##cp_collection", [] { + if (scripts::force_host(RAGE_JOAAT("am_cp_collection"))) + if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_cp_collection"))) + *script_local(script->m_stack, scr_locals::am_cp_collection::broadcast_idx).at(667).as() = 0; + }); + ImGui::SameLine(); + components::button("Finish Event##cp_collection", [] { + if (scripts::force_host(RAGE_JOAAT("am_cp_collection"))) + if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_cp_collection"))) + *script_local(script->m_stack, scr_locals::am_cp_collection::broadcast_idx).at(661).as() = 0; + }); + + components::button("Win Event", [] { + if (auto checkpoints = gta_util::find_script_thread(RAGE_JOAAT("am_cp_collection"))) + *script_local(checkpoints->m_stack, scr_locals::am_cp_collection::player_broadcast_idx) + .at(checkpoints->m_net_component->m_local_participant_index, 5) + .at(4) + .as() = 999'999'999; + + script::get_current()->yield(1s); + + if (scripts::force_host(RAGE_JOAAT("am_cp_collection"))) + { + if (auto checkpoints = gta_util::find_script_thread(RAGE_JOAAT("am_cp_collection"))) + { + *script_local(checkpoints->m_stack, scr_locals::am_cp_collection::broadcast_idx).at(708).as() = 0; + } + } + }); + ImGui::SameLine(); + components::button("Scramble Checkpoints", [] { + std::vector active_player_positions; + + for (auto& plyr : g_player_service->players()) + { + if (plyr.second->is_valid() && NETWORK::NETWORK_IS_PLAYER_A_PARTICIPANT_ON_SCRIPT(plyr.second->id(), "am_cp_collection", -1)) + { + active_player_positions.push_back( + ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(plyr.second->id()), false)); + } + } + + if (scripts::force_host(RAGE_JOAAT("am_cp_collection"))) + { + if (auto checkpoints = gta_util::find_script_thread(RAGE_JOAAT("am_cp_collection"))) + { + for (int i = 0; i < 100; i++) + { + *script_local(checkpoints->m_stack, scr_locals::am_cp_collection::broadcast_idx).at(10).at(i, 5).as() = + active_player_positions[i % active_player_positions.size()]; + } + } + } + }); + } +} \ No newline at end of file diff --git a/src/views/network/missions/criminal_damage.hpp b/src/views/network/missions/criminal_damage.hpp new file mode 100644 index 00000000..5467b686 --- /dev/null +++ b/src/views/network/missions/criminal_damage.hpp @@ -0,0 +1,27 @@ +#include "core/scr_globals.hpp" +#include "util/scripts.hpp" +#include "views/view.hpp" + +namespace big +{ + inline void render_criminal_damage_ui() + { + components::sub_title("Criminal Damage"); + components::button("Start Event##criminal_damage", [] { + if (scripts::force_host(RAGE_JOAAT("am_criminal_damage"))) + if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_criminal_damage"))) + *script_local(script->m_stack, scr_locals::am_criminal_damage::broadcast_idx).at(43).as() = 0; + }); + ImGui::SameLine(); + components::button("Finish Event##criminal_damage", [] { + if (scripts::force_host(RAGE_JOAAT("am_criminal_damage"))) + if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_criminal_damage"))) + *script_local(script->m_stack, scr_locals::am_criminal_damage::broadcast_idx).at(39).as() = 0; + }); + + components::button("Max Score", [] { + if (auto criminal_damage = gta_util::find_script_thread(RAGE_JOAAT("am_criminal_damage"))) + *script_local(criminal_damage->m_stack, scr_locals::am_criminal_damage::score_idx).as() = 999'999'999; + }); + } +} \ No newline at end of file diff --git a/src/views/network/missions/hunt_the_beast.hpp b/src/views/network/missions/hunt_the_beast.hpp new file mode 100644 index 00000000..94183859 --- /dev/null +++ b/src/views/network/missions/hunt_the_beast.hpp @@ -0,0 +1,78 @@ +#include "core/scr_globals.hpp" +#include "script_local.hpp" +#include "util/math.hpp" +#include "util/scripts.hpp" +#include "util/teleport.hpp" +#include "views/view.hpp" + +namespace big +{ + int get_land_mark_beast_is_closest_to(player_ptr player, script_local land_mark_list) + { + if (!player->get_ped() || !player->get_ped()->m_navigation) + return -1; + + int closest_index = 0; + Vector3 transformed_vector = Vector3(player->get_ped()->m_navigation->get_position()->x, + player->get_ped()->m_navigation->get_position()->y, + player->get_ped()->m_navigation->get_position()->z); + float distance = math::distance_between_vectors(transformed_vector, *land_mark_list.at(0, 3).as()); + + for (int i = 1; i < *script_global(262145).at(11711).as(); i++) + { + float new_distance = math::distance_between_vectors(transformed_vector, *land_mark_list.at(i, 3).as()); + if (new_distance < distance) + { + distance = new_distance; + closest_index = i; + } + } + + return closest_index; + } + + inline void render_hunt_the_beast_ui() + { + if (auto hunt_the_beast_script_thread = gta_util::find_script_thread(RAGE_JOAAT("am_hunt_the_beast"))) + { + auto beast_player_index = + *script_local(hunt_the_beast_script_thread, scr_locals::am_hunt_the_beast::broadcast_idx).at(1).at(6).as(); + if (auto beast = g_player_service->get_by_id(beast_player_index)) + { + ImGui::Text("%s is the beast", g_player_service->get_by_id(beast_player_index).get()->get_name()); + ImGui::SameLine(); + components::button("Set as selected", [beast] { + g_player_service->set_selected(beast); + }); + + ImGui::Spacing(); + + auto beast_land_mark_list = script_local(hunt_the_beast_script_thread, 599).at(1).at(19); + auto beast_land_marks = *script_global(262145).at(11711).as(); + + if (ImGui::ListBoxHeader("##beastlandmarks", ImVec2(400, 300))) + { + for (int i = 0; i < beast_land_marks; i++) + { + auto script_local_land_mark = *beast_land_mark_list.at(i, 3).as(); + std::string label = std::format("Tp to landmark {} at {} {} {}", + i, + script_local_land_mark.x, + script_local_land_mark.y, + script_local_land_mark.z); + + if (ImGui::Selectable(label.data(), i == get_land_mark_beast_is_closest_to(g_player_service->get_by_id(beast_player_index), beast_land_mark_list))) + g_fiber_pool->queue_job([script_local_land_mark, beast] { + teleport::teleport_player_to_coords(g.player.spectating ? beast : g_player_service->get_self(), script_local_land_mark); + }); + } + ImGui::ListBoxFooter(); + } + } + else + { + ImGui::Text("Hunt the beast event is active..."); + } + } + } +} \ No newline at end of file diff --git a/src/views/network/missions/king_of_the_castle.hpp b/src/views/network/missions/king_of_the_castle.hpp new file mode 100644 index 00000000..8e6a693f --- /dev/null +++ b/src/views/network/missions/king_of_the_castle.hpp @@ -0,0 +1,100 @@ +#include "views/view.hpp" + +namespace big +{ + inline void render_king_of_the_castle_ui() + { + components::sub_title("King Of The Castle"); + components::button("Complete Event##kotc", [] { + if (scripts::force_host(RAGE_JOAAT("am_king_of_the_castle"))) + if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_king_of_the_castle"))) + *script_local(script->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx).at(1).at(1).as() = 0; + }); + ImGui::SameLine(); + components::button("Expire Event (if possible)##kotc", [] { + if (scripts::force_host(RAGE_JOAAT("am_king_of_the_castle"))) + if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_king_of_the_castle"))) + *script_local(script->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx).at(1).at(3).as() = 0; + }); + + components::button("Become The King##kotc", [] { + if (scripts::force_host(RAGE_JOAAT("am_king_of_the_castle"))) + { + if (auto kotc = gta_util::find_script_thread(RAGE_JOAAT("am_king_of_the_castle"))) + { + *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) + .at(6) + .at(0, 204) + .at(74) + .at(0, 4) + .as() = 0; + *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) + .at(6) + .at(0, 204) + .at(74) + .at(0, 4) + .at(1) + .as() = self::id; + *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) + .at(6) + .at(0, 204) + .at(74) + .at(0, 4) + .at(2) + .as() = self::id; + *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) + .at(6) + .at(0, 204) + .at(74) + .at(0, 4) + .at(3) + .as() = 999999999.0f; + } + } + }); + ImGui::SameLine(); + components::button("Dethrone Everyone##kotc", [] { + if (scripts::force_host(RAGE_JOAAT("am_king_of_the_castle"))) + { + if (auto kotc = gta_util::find_script_thread(RAGE_JOAAT("am_king_of_the_castle"))) + { + for (int i = 0; i < *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) + .at(6) + .at(0, 204) + .at(74) + .as(); + i++) + { + *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) + .at(6) + .at(0, 204) + .at(74) + .at(i, 4) + .as() = -1; + *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) + .at(6) + .at(0, 204) + .at(74) + .at(i, 4) + .at(1) + .as() = -1; + *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) + .at(6) + .at(0, 204) + .at(74) + .at(i, 4) + .at(2) + .as() = -1; + *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) + .at(6) + .at(0, 204) + .at(74) + .at(i, 4) + .at(3) + .as() = -1.0f; + } + } + } + }); + } +} \ No newline at end of file diff --git a/src/views/network/view_missions.cpp b/src/views/network/view_missions.cpp index a6bb1bef..0a40e680 100644 --- a/src/views/network/view_missions.cpp +++ b/src/views/network/view_missions.cpp @@ -4,6 +4,10 @@ #include "script_local.hpp" #include "util/scripts.hpp" #include "views/view.hpp" +#include "views/network/missions/hunt_the_beast.hpp" +#include "views/network/missions/king_of_the_castle.hpp" +#include "views/network/missions/cp_collection.hpp" +#include "views/network/missions/criminal_damage.hpp" namespace big { @@ -109,184 +113,16 @@ namespace big ImGui::Separator(); if (check_script(RAGE_JOAAT("am_criminal_damage"))) - { - components::sub_title("Criminal Damage"); - components::button("Start Event##criminal_damage", [] { - if (scripts::force_host(RAGE_JOAAT("am_criminal_damage"))) - if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_criminal_damage"))) - *script_local(script->m_stack, scr_locals::am_criminal_damage::broadcast_idx).at(43).as() = 0; - }); - ImGui::SameLine(); - components::button("Finish Event##criminal_damage", [] { - if (scripts::force_host(RAGE_JOAAT("am_criminal_damage"))) - if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_criminal_damage"))) - *script_local(script->m_stack, scr_locals::am_criminal_damage::broadcast_idx).at(39).as() = 0; - }); - - components::button("Max Score", [] { - if (auto criminal_damage = gta_util::find_script_thread(RAGE_JOAAT("am_criminal_damage"))) - *script_local(criminal_damage->m_stack, scr_locals::am_criminal_damage::score_idx).as() = 999'999'999; - }); - } + render_criminal_damage_ui(); if (check_script(RAGE_JOAAT("am_cp_collection"))) - { - components::sub_title("Checkpoints"); - - components::button("Start Event##cp_collection", [] { - if (scripts::force_host(RAGE_JOAAT("am_cp_collection"))) - if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_cp_collection"))) - *script_local(script->m_stack, scr_locals::am_cp_collection::broadcast_idx).at(667).as() = 0; - }); - ImGui::SameLine(); - components::button("Finish Event##cp_collection", [] { - if (scripts::force_host(RAGE_JOAAT("am_cp_collection"))) - if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_cp_collection"))) - *script_local(script->m_stack, scr_locals::am_cp_collection::broadcast_idx).at(661).as() = 0; - }); - - components::button("Win Event", [] { - if (auto checkpoints = gta_util::find_script_thread(RAGE_JOAAT("am_cp_collection"))) - *script_local(checkpoints->m_stack, scr_locals::am_cp_collection::player_broadcast_idx) - .at(checkpoints->m_net_component->m_local_participant_index, 5) - .at(4) - .as() = 999'999'999; - - script::get_current()->yield(1s); - - if (scripts::force_host(RAGE_JOAAT("am_cp_collection"))) - { - if (auto checkpoints = gta_util::find_script_thread(RAGE_JOAAT("am_cp_collection"))) - { - *script_local(checkpoints->m_stack, scr_locals::am_cp_collection::broadcast_idx).at(708).as() = 0; - } - } - }); - ImGui::SameLine(); - components::button("Scramble Checkpoints", [] { - std::vector active_player_positions; - - for (auto& plyr : g_player_service->players()) - { - if (plyr.second->is_valid() && NETWORK::NETWORK_IS_PLAYER_A_PARTICIPANT_ON_SCRIPT(plyr.second->id(), "am_cp_collection", -1)) - { - active_player_positions.push_back( - ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(plyr.second->id()), false)); - } - } - - if (scripts::force_host(RAGE_JOAAT("am_cp_collection"))) - { - if (auto checkpoints = gta_util::find_script_thread(RAGE_JOAAT("am_cp_collection"))) - { - for (int i = 0; i < 100; i++) - { - *script_local(checkpoints->m_stack, scr_locals::am_cp_collection::broadcast_idx) - .at(10) - .at(i, 5) - .as() = active_player_positions[i % active_player_positions.size()]; - } - } - } - }); - } + render_cp_collection_ui(); if (check_script(RAGE_JOAAT("am_king_of_the_castle"))) - { - components::sub_title("King Of The Castle"); - components::button("Complete Event##kotc", [] { - if (scripts::force_host(RAGE_JOAAT("am_king_of_the_castle"))) - if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_king_of_the_castle"))) - *script_local(script->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx).at(1).at(1).as() = 0; - }); - ImGui::SameLine(); - components::button("Expire Event (if possible)##kotc", [] { - if (scripts::force_host(RAGE_JOAAT("am_king_of_the_castle"))) - if (auto script = gta_util::find_script_thread(RAGE_JOAAT("am_king_of_the_castle"))) - *script_local(script->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx).at(1).at(3).as() = 0; - }); - - components::button("Become The King##kotc", [] { - if (scripts::force_host(RAGE_JOAAT("am_king_of_the_castle"))) - { - if (auto kotc = gta_util::find_script_thread(RAGE_JOAAT("am_king_of_the_castle"))) - { - *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) - .at(6) - .at(0, 204) - .at(74) - .at(0, 4) - .as() = 0; - *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) - .at(6) - .at(0, 204) - .at(74) - .at(0, 4) - .at(1) - .as() = self::id; - *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) - .at(6) - .at(0, 204) - .at(74) - .at(0, 4) - .at(2) - .as() = self::id; - *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) - .at(6) - .at(0, 204) - .at(74) - .at(0, 4) - .at(3) - .as() = 999999999.0f; - } - } - }); - ImGui::SameLine(); - components::button("Dethrone Everyone##kotc", [] { - if (scripts::force_host(RAGE_JOAAT("am_king_of_the_castle"))) - { - if (auto kotc = gta_util::find_script_thread(RAGE_JOAAT("am_king_of_the_castle"))) - { - for (int i = 0; i < *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) - .at(6) - .at(0, 204) - .at(74) - .as(); - i++) - { - *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) - .at(6) - .at(0, 204) - .at(74) - .at(i, 4) - .as() = -1; - *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) - .at(6) - .at(0, 204) - .at(74) - .at(i, 4) - .at(1) - .as() = -1; - *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) - .at(6) - .at(0, 204) - .at(74) - .at(i, 4) - .at(2) - .as() = -1; - *script_local(kotc->m_stack, scr_locals::am_king_of_the_castle::broadcast_idx) - .at(6) - .at(0, 204) - .at(74) - .at(i, 4) - .at(3) - .as() = -1.0f; - } - } - } - }); - } + render_king_of_the_castle_ui(); + if(check_script(RAGE_JOAAT("am_hunt_the_beast"))) + render_hunt_the_beast_ui(); if (!mission_found) {