Toxic update (#641)

This commit is contained in:
maybegreat48
2022-12-06 16:12:02 +00:00
committed by GitHub
parent 7f74a436d2
commit a427ccb914
80 changed files with 3258 additions and 411 deletions

View File

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

View File

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

View File

@ -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<bool*>() = 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<int*>(), 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<int*>(), 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<int*>(), 2);
scr_functions::dance_loop.call(g->m_dance_thread, g->m_dance_program, {});
}
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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<int*>(); i++)
{
*scr_globals::gsbd.at(818).at(44).at(i, 2).at(1).as<int*>() = rand() % 15;
}
}
}
}
}

View File

@ -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;
}
}

View File

@ -11,7 +11,13 @@ namespace big
void looped::system_desync_kick_protection()
{
memset(&gta_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;

View File

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

View File

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