chore: Rework mission viewer and added Hunt the beast event support (#1354)

This commit is contained in:
DayibBaba 2023-06-05 21:34:06 +02:00 committed by GitHub
parent f3a6f0117f
commit afca330766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 284 additions and 173 deletions

View File

@ -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());

View File

@ -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<int*>() = 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<int*>() = 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<int*>() = 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<int*>() = 0;
}
}
});
ImGui::SameLine();
components::button("Scramble Checkpoints", [] {
std::vector<Vector3> 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<Vector3*>() =
active_player_positions[i % active_player_positions.size()];
}
}
}
});
}
}

View File

@ -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<int*>() = 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<int*>() = 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<int*>() = 999'999'999;
});
}
}

View File

@ -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<Vector3*>());
for (int i = 1; i < *script_global(262145).at(11711).as<int*>(); i++)
{
float new_distance = math::distance_between_vectors(transformed_vector, *land_mark_list.at(i, 3).as<Vector3*>());
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<uint32_t*>();
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<int*>();
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<Vector3*>();
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...");
}
}
}
}

View File

@ -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<int*>() = 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<int*>() = 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<int*>() = 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<int*>() = 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<int*>() = 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<float*>() = 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<int*>();
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<int*>() = -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<int*>() = -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<int*>() = -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<float*>() = -1.0f;
}
}
}
});
}
}

View File

@ -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<int*>() = 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<int*>() = 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<int*>() = 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<int*>() = 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<int*>() = 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<int*>() = 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<int*>() = 0;
}
}
});
ImGui::SameLine();
components::button("Scramble Checkpoints", [] {
std::vector<Vector3> 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<Vector3*>() = 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<int*>() = 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<int*>() = 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<int*>() = 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<int*>() = 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<int*>() = 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<float*>() = 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<int*>();
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<int*>() = -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<int*>() = -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<int*>() = -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<float*>() = -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)
{