TmpMenu/src/backend/looped/self/dance_mode.cpp
maybegreat48 74ecf22ecf Menu revamp (#3274)
* Complete player and network UI redesign, meant to show all features instead of stuffing them into tiny boxes
* Added option to delete player vehicles
* Better clone player (now clones head blend too)
* Better host token spoofing, with an option to enter your own
* Better host token spoofing detection
* Better desync kick prot detections
* A script blocker for the entire session (per-player options will be added later)
* Added option to spoof data/DLC hashes
* Logging framework that allows developers to easily debug false positives
* Major protection improvements
2024-06-27 10:32:17 +02:00

65 lines
1.9 KiB
C++

#include "backend/looped/looped.hpp"
#include "natives.hpp"
#include "script_function.hpp"
#include "services/script_patcher/script_patcher_service.hpp"
#include "util/entity.hpp"
#include "util/scripts.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("maintransition"_J) > 0)
g.self.dance_mode = false;
if (g.self.dance_mode && g.self.dance_mode != bLastDanceMode)
{
g_script_patcher_service->update();
scripts::request_script("am_mp_nightclub"_J);
if (!scripts::wait_till_loaded("am_mp_nightclub"_J))
return;
auto thread = SYSTEM::START_NEW_SCRIPT_WITH_NAME_HASH("am_mp_nightclub"_J, 19400 /*PROPERTY_INT*/);
SCRIPT::SET_SCRIPT_WITH_NAME_HASH_AS_NO_LONGER_NEEDED("am_mp_nightclub"_J);
if (!thread)
return;
g.m_dance_thread = gta_util::find_script_thread_by_id(thread);
g.m_dance_program = gta_util::find_script_program("am_mp_nightclub"_J);
g.m_dance_thread->m_context.m_state = rage::eThreadState::unk_3;
// perform initial setup
gta_util::execute_as_script(g.m_dance_thread, [] {
NETWORK::NETWORK_SET_THIS_SCRIPT_IS_NETWORK_SCRIPT(32, true, 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;
g_script_patcher_service->update();
bLastDanceMode = false;
return;
}
if (g.self.dance_mode && g.m_dance_thread->m_handler)
{
*scr_globals::dance_state.as<PINT>() = TRUE; //Never once do the scripts read this as a boolean. It seems to be some kind of state the player is in. Runs from 4 to 35.
scr_functions::dance_loop.call(g.m_dance_thread, g.m_dance_program, {});
}
}
}