diff --git a/scripts/gtav-classes.cmake b/scripts/gtav-classes.cmake index 93e48aa6..34b070a5 100644 --- a/scripts/gtav-classes.cmake +++ b/scripts/gtav-classes.cmake @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( gtav_classes GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git - GIT_TAG 298907d8987862286512bc92cf97b022643315ce + GIT_TAG 6fe1eefa9f24ec37727807bfe7a18a4dd2ef8621 GIT_PROGRESS TRUE CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/src/backend/backend.cpp b/src/backend/backend.cpp index 7781100a..cc3346a4 100644 --- a/src/backend/backend.cpp +++ b/src/backend/backend.cpp @@ -19,6 +19,8 @@ namespace big looped::system_update_pointers(); looped::system_desync_kick_protection(); looped::system_force_session_host(); + looped::system_mission_creator(); + looped::system_auto_tp(); script::get_current()->yield(); } @@ -44,6 +46,7 @@ namespace big looped::self_no_water_collision(); looped::self_mobile_radio(); looped::self_fast_respawn(); + looped::self_dance_mode(); script::get_current()->yield(); } @@ -118,6 +121,10 @@ namespace big looped::hud_transition_state(); looped::tunables_disable_phone(); looped::session_local_time(); + looped::session_pop_multiplier_areas(); + looped::session_force_thunder(); + looped::session_randomize_ceo_colors(); + looped::session_auto_kick_host(); script::get_current()->yield(); } diff --git a/src/backend/looped/hud/hud_transition_state.cpp b/src/backend/looped/hud/hud_transition_state.cpp index f330b4fa..5b7f7333 100644 --- a/src/backend/looped/hud/hud_transition_state.cpp +++ b/src/backend/looped/hud/hud_transition_state.cpp @@ -1,11 +1,15 @@ #include "backend/looped/looped.hpp" #include "natives.hpp" #include "script_global.hpp" +#include "gta/joaat.hpp" +#include "util/kick.hpp" +#include "services/players/player_service.hpp" // Credits: QuickNET namespace big { - constexpr char transition_states[][48] = { + constexpr char transition_states[][48] = + { "TRANSITION_STATE_EMPTY", "Singleplayer Swoop Up", "Multiplayer Swoop Up", @@ -84,6 +88,9 @@ namespace big { const auto state = *transition_state.as(); + if (SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) == 0) + return; + // When freemode script loaded remove loading screen. if (state == eTransitionState::TRANSITION_STATE_WAIT_JOIN_FM_SESSION && DLC::GET_IS_LOADING_SCREEN_ACTIVE()) @@ -93,7 +100,7 @@ namespace big if (last_state == state || state == eTransitionState::TRANSITION_STATE_EMPTY - || state > eTransitionState::TRANSITION_STATE_DLC_INTRO_BINK) + || state > eTransitionState::TRANSITION_STATE_SPAWN_INTO_PERSONAL_VEHICLE) { return; } @@ -103,12 +110,6 @@ namespace big HUD::BUSYSPINNER_OFF(); } - // sometimes when going into a single player mission or transition this one remains on screen permanently - if (state == eTransitionState::TRANSITION_STATE_TERMINATE_MAINTRANSITION) - { - return; - } - if ((int)state > 0 && (int)state < std::size(transition_states)) { HUD::BEGIN_TEXT_COMMAND_BUSYSPINNER_ON("STRING"); diff --git a/src/backend/looped/looped.hpp b/src/backend/looped/looped.hpp index 40dcb8ae..322c9ccb 100644 --- a/src/backend/looped/looped.hpp +++ b/src/backend/looped/looped.hpp @@ -32,15 +32,22 @@ namespace big static void self_unlimited_oxygen(); static void self_no_water_collision(); static void self_mobile_radio(); + static void self_dance_mode(); static void self_fast_respawn(); static void session_local_time(); + static void session_pop_multiplier_areas(); + static void session_force_thunder(); + static void session_randomize_ceo_colors(); + static void session_auto_kick_host(); static void system_disable_sigscanner(); static void system_self_globals(); static void system_update_pointers(); static void system_desync_kick_protection(); static void system_force_session_host(); + static void system_mission_creator(); + static void system_auto_tp(); static void vehicle_auto_drive(); static void vehicle_boost_behavior(); diff --git a/src/backend/looped/self/dance_mode.cpp b/src/backend/looped/self/dance_mode.cpp new file mode 100644 index 00000000..5994108c --- /dev/null +++ b/src/backend/looped/self/dance_mode.cpp @@ -0,0 +1,67 @@ +#include "backend/looped/looped.hpp" +#include "natives.hpp" +#include "util/entity.hpp" +#include "util/scripts.hpp" +#include "script_function.hpp" + +namespace big +{ + bool bLastDanceMode = false; + void looped::self_dance_mode() + { + if (g->self.dance_mode && SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) > 0) + g->self.dance_mode = false; + + if (g->self.dance_mode && g->self.dance_mode != bLastDanceMode) + { + scripts::request_script(RAGE_JOAAT("am_mp_nightclub")); + if (!scripts::wait_till_loaded(RAGE_JOAAT("am_mp_nightclub"))) + return; + + auto thread = SYSTEM::START_NEW_SCRIPT_WITH_NAME_HASH(RAGE_JOAAT("am_mp_nightclub"), 19400 /*PROPERTY_INT*/); + SCRIPT::SET_SCRIPT_WITH_NAME_HASH_AS_NO_LONGER_NEEDED(RAGE_JOAAT("am_mp_nightclub")); + + if (!thread) + return; + + g->m_dance_thread = gta_util::find_script_thread(RAGE_JOAAT("am_mp_nightclub")); + g->m_dance_program = gta_util::find_script_program(RAGE_JOAAT("am_mp_nightclub")); + + (*g_pointers->m_script_handler_mgr)->attach_thread(g->m_dance_thread); + + g->m_dance_thread->m_context.m_state = rage::eThreadState::unk_3; + + // perform initial setup + gta_util::execute_as_script(RAGE_JOAAT("am_mp_nightclub"), [] + { + NETWORK::NETWORK_SET_THIS_SCRIPT_IS_NETWORK_SCRIPT(32, false, 32); + scr_functions::init_nightclub_script({}); + }); + + scr_functions::dance_loop.populate_ip(); + bLastDanceMode = true; + return; + } + + if (!g->self.dance_mode && g->self.dance_mode != bLastDanceMode) + { + if (g->m_dance_thread) + g->m_dance_thread->kill(); + + g->m_dance_thread = nullptr; + g->m_dance_program = nullptr; + + bLastDanceMode = false; + return; + } + + if (g->self.dance_mode && g->m_dance_thread->m_handler) + { + *script_global(1946244).as() = true; + misc::set_bit(scr_globals::gpbd_fm_1.at(self::id, scr_globals::size::gpbd_fm_1).at(267).at(295).at(7).as(), 0); + misc::set_bit(scr_globals::gpbd_fm_1.at(self::id, scr_globals::size::gpbd_fm_1).at(267).at(295).at(7).as(), 1); + misc::set_bit(scr_globals::gpbd_fm_1.at(self::id, scr_globals::size::gpbd_fm_1).at(267).at(295).at(7).as(), 2); + scr_functions::dance_loop.call(g->m_dance_thread, g->m_dance_program, {}); + } + } +} \ No newline at end of file diff --git a/src/backend/looped/session/auto_kick_host.cpp b/src/backend/looped/session/auto_kick_host.cpp new file mode 100644 index 00000000..33e31ae2 --- /dev/null +++ b/src/backend/looped/session/auto_kick_host.cpp @@ -0,0 +1,22 @@ +#include "backend/looped/looped.hpp" +#include "natives.hpp" +#include "pointers.hpp" +#include "util/kick.hpp" + +namespace big +{ + static bool bLastKickHost = false; + void looped::session_auto_kick_host() + { + bool kick_host = *g_pointers->m_is_session_started && g->session.force_session_host && g->session.kick_host_when_forcing_host; + if (kick_host && !bLastKickHost) + { + g_player_service->iterate([](auto& plyr) + { + if (plyr.second->is_host()) + kick::lost_connection_kick(plyr.second); + }); + } + bLastKickHost = kick_host; + } +} diff --git a/src/backend/looped/session/force_thunder.cpp b/src/backend/looped/session/force_thunder.cpp new file mode 100644 index 00000000..25c879d2 --- /dev/null +++ b/src/backend/looped/session/force_thunder.cpp @@ -0,0 +1,36 @@ +#include "backend/looped/looped.hpp" +#include "natives.hpp" +#include "pointers.hpp" +#include "gta_util.hpp" +#include "util/session.hpp" + +namespace big +{ + static bool bLastForceThunderEnabled = false; + + void looped::session_force_thunder() + { + bool used = g->session.force_thunder && *g_pointers->m_is_session_started; + if (!bLastForceThunderEnabled && used) + { + if (!STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS() && gta_util::find_script_thread(RAGE_JOAAT("freemode")) && SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) == 0) + { + session::set_fm_event_index(9); + session::set_fm_event_index(10); + session::set_fm_event_index(11); + bLastForceThunderEnabled = true; + } + } + else if (bLastForceThunderEnabled && !used) + { + if (*g_pointers->m_is_session_started && !STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS() && gta_util::find_script_thread(RAGE_JOAAT("freemode"))) + { + session::clear_fm_event_index(9); + session::clear_fm_event_index(10); + session::clear_fm_event_index(11); + } + + bLastForceThunderEnabled = false; + } + } +} diff --git a/src/backend/looped/session/pop_multiplier_areas.cpp b/src/backend/looped/session/pop_multiplier_areas.cpp new file mode 100644 index 00000000..ca1eafbb --- /dev/null +++ b/src/backend/looped/session/pop_multiplier_areas.cpp @@ -0,0 +1,53 @@ +#include "backend/looped/looped.hpp" +#include "natives.hpp" +#include "pointers.hpp" +#include "gta_util.hpp" + +namespace big +{ + static bool bLastPopMultiplierAreasEnabled = false; + static bool bLastBlockPeds = false; + static bool bLastBlockVehs = false; + static int pop_multiplier_id = -1; + + void looped::session_pop_multiplier_areas() + { + bool used = (g->session.disable_traffic || g->session.disable_peds) && *g_pointers->m_is_session_started; + if (!bLastPopMultiplierAreasEnabled && used) + { + if (!STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS() && gta_util::find_script_thread(RAGE_JOAAT("freemode")) && SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) == 0) + { + gta_util::execute_as_script(RAGE_JOAAT("freemode"), [] + { + pop_multiplier_id = MISC::ADD_POP_MULTIPLIER_SPHERE(1.1f, 1.1f, 1.1f, 15000.0f, g->session.disable_peds ? 0.0f : 1.0f, g->session.disable_traffic ? 0.0f : 1.0f, false, true); + + bLastBlockPeds = g->session.disable_peds; + bLastBlockVehs = g->session.disable_traffic; + bLastPopMultiplierAreasEnabled = true; + + MISC::CLEAR_AREA(1.1f, 1.1f, 1.1f, 19999.9f, true, false, false, true); + }); + } + } + else if (bLastPopMultiplierAreasEnabled && (g->session.disable_traffic != bLastBlockVehs || g->session.disable_peds != bLastBlockPeds)) + { + bLastBlockPeds = g->session.disable_peds; + bLastBlockVehs = g->session.disable_traffic; + used = false; + } + + if (bLastPopMultiplierAreasEnabled && !used) + { + if (gta_util::find_script_thread(RAGE_JOAAT("freemode"))) + { + gta_util::execute_as_script(RAGE_JOAAT("freemode"), [] + { + MISC::REMOVE_POP_MULTIPLIER_SPHERE(pop_multiplier_id, false); + }); + } + + bLastPopMultiplierAreasEnabled = false; + pop_multiplier_id = -1; + } + } +} diff --git a/src/backend/looped/session/randomize_ceo_colors.cpp b/src/backend/looped/session/randomize_ceo_colors.cpp new file mode 100644 index 00000000..d9f70fcf --- /dev/null +++ b/src/backend/looped/session/randomize_ceo_colors.cpp @@ -0,0 +1,23 @@ +#include "backend/looped/looped.hpp" +#include "natives.hpp" +#include "pointers.hpp" +#include "gta_util.hpp" +#include "util/session.hpp" +#include "gta/script_handler.hpp" + +namespace big +{ + void looped::session_randomize_ceo_colors() + { + if (g->session.randomize_ceo_colors && *g_pointers->m_is_session_started && !STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS() && SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) == 0) + { + if (auto freemode = gta_util::find_script_thread(RAGE_JOAAT("freemode")); freemode && freemode->m_net_component && freemode->m_net_component->is_local_player_host()) + { + for (int i = 0; i < *scr_globals::gsbd.at(818).at(44).as(); i++) + { + *scr_globals::gsbd.at(818).at(44).at(i, 2).at(1).as() = rand() % 15; + } + } + } + } +} diff --git a/src/backend/looped/system/auto_tp.cpp b/src/backend/looped/system/auto_tp.cpp new file mode 100644 index 00000000..b2983f3a --- /dev/null +++ b/src/backend/looped/system/auto_tp.cpp @@ -0,0 +1,28 @@ +#include "backend/looped/looped.hpp" +#include "fiber_pool.hpp" +#include "natives.hpp" +#include "script.hpp" +#include "pointers.hpp" + +namespace big +{ + bool bLastAutoTP = false; + void looped::system_auto_tp() + { + bool temp_disable_tp = (!*g_pointers->m_is_session_started) && CUTSCENE::IS_CUTSCENE_ACTIVE(); + + if ((!g->self.auto_tp || temp_disable_tp) && bLastAutoTP) + { + MISC::USING_MISSION_CREATOR(false); + MISC::ALLOW_MISSION_CREATOR_WARP(false); + } + + if (g->self.auto_tp && !temp_disable_tp) + { + MISC::USING_MISSION_CREATOR(true); + MISC::ALLOW_MISSION_CREATOR_WARP(true); + } + + bLastAutoTP = g->self.auto_tp; + } +} \ No newline at end of file diff --git a/src/backend/looped/system/desync_kick_protection.cpp b/src/backend/looped/system/desync_kick_protection.cpp index b52ff891..09be8894 100644 --- a/src/backend/looped/system/desync_kick_protection.cpp +++ b/src/backend/looped/system/desync_kick_protection.cpp @@ -11,7 +11,13 @@ namespace big void looped::system_desync_kick_protection() { memset(>a_util::get_network()->m_game_complaint_mgr.m_host_tokens_complained, 0, 64 * sizeof(std::uint64_t)); - gta_util::get_network()->m_game_complaint_mgr.m_num_tokens_complained = 0; + if (!g_player_service->m_player_to_use_complaint_kick || !g_player_service->m_player_to_use_complaint_kick->get()->get_net_data()) + gta_util::get_network()->m_game_complaint_mgr.m_num_tokens_complained = 0; + else + { + gta_util::get_network()->m_game_complaint_mgr.m_num_tokens_complained = 1; + gta_util::get_network()->m_game_complaint_mgr.m_host_tokens_complained[0] = g_player_service->m_player_to_use_complaint_kick->get()->get_net_data()->m_host_token; + } auto old = gta_util::get_network()->m_game_complaint_mgr.m_host_token; diff --git a/src/backend/looped/system/mission_creator.cpp b/src/backend/looped/system/mission_creator.cpp new file mode 100644 index 00000000..1f528f25 --- /dev/null +++ b/src/backend/looped/system/mission_creator.cpp @@ -0,0 +1,39 @@ +#include "backend/looped/looped.hpp" +#include "fiber_pool.hpp" +#include "natives.hpp" +#include "script.hpp" +#include "gta_util.hpp" +#include "core/scr_globals.hpp" + +namespace big +{ + bool bLastMissionCreator = false; + void looped::system_mission_creator() + { + if (g->m_mission_creator_thread) + { + *scr_globals::terminate_creator.as() = false; + + if (SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) > 0) + { + if (g->m_mission_creator_thread) + g->m_mission_creator_thread->kill(); + g->m_mission_creator_thread = nullptr; + return; + } + + bLastMissionCreator = true; + } + else if (bLastMissionCreator) + { + *scr_globals::switch_struct.at(18).as() = 0; + STREAMING::SWITCH_TO_MULTI_SECONDPART(self::ped); + HUD::DISPLAY_HUD(true); + HUD::DISPLAY_RADAR(true); + PLAYER::SET_PLAYER_CONTROL(self::id, true, 0); + ENTITY::FREEZE_ENTITY_POSITION(self::ped, false); + ENTITY::SET_ENTITY_COLLISION(self::ped, true, true); + bLastMissionCreator = false; + } + } +} \ No newline at end of file diff --git a/src/backend/looped/vehicle/rgb_paint.cpp b/src/backend/looped/vehicle/rgb_paint.cpp index 300bdc52..b1f5e652 100644 --- a/src/backend/looped/vehicle/rgb_paint.cpp +++ b/src/backend/looped/vehicle/rgb_paint.cpp @@ -14,6 +14,9 @@ namespace big rgb_controller_blue_down, }; + std::chrono::system_clock::time_point last_rgb_run_time; + std::chrono::milliseconds delay = 0s; + void looped::vehicle_rainbow_paint() { static int rgb_controller_v = rgb_controller_green_up; @@ -22,7 +25,7 @@ namespace big static int green = 0; static int blue = 0; - if (self::veh && g->vehicle.rainbow_paint.type != RainbowPaintType::Off) + if (self::veh && g->vehicle.rainbow_paint.type != RainbowPaintType::Off && last_rgb_run_time + delay < std::chrono::system_clock::now()) { int delay_step = 100; @@ -117,8 +120,8 @@ namespace big VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(vehicle, red, green, blue); } - auto delay = std::chrono::milliseconds(((delay_step * 10) + 10) - (g->vehicle.rainbow_paint.speed * delay_step)); - script::get_current()->yield(delay); + delay = std::chrono::milliseconds(((delay_step * 10) + 10) - (g->vehicle.rainbow_paint.speed * delay_step)); + last_rgb_run_time = std::chrono::system_clock::now(); } } } \ No newline at end of file diff --git a/src/backend/script_patches.hpp b/src/backend/script_patches.hpp index 3b200f0f..4b09df4b 100644 --- a/src/backend/script_patches.hpp +++ b/src/backend/script_patches.hpp @@ -1,3 +1,4 @@ +#pragma once #include "services/script_patcher/script_patcher_service.hpp" #include