TmpMenu/src/backend/looped/self/dance_mode.cpp

65 lines
1.9 KiB
C++
Raw Normal View History

2022-12-06 16:12:02 +00:00
#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"
2022-12-06 16:12:02 +00:00
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;
2022-12-06 16:12:02 +00:00
if (g.self.dance_mode && g.self.dance_mode != bLastDanceMode)
2022-12-06 16:12:02 +00:00
{
g_script_patcher_service->update();
scripts::request_script("am_mp_nightclub"_J);
if (!scripts::wait_till_loaded("am_mp_nightclub"_J))
2022-12-06 16:12:02 +00:00
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);
2022-12-06 16:12:02 +00:00
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);
2022-12-06 16:12:02 +00:00
g.m_dance_thread->m_context.m_state = rage::eThreadState::unk_3;
2022-12-06 16:12:02 +00:00
// perform initial setup
gta_util::execute_as_script(g.m_dance_thread, [] {
NETWORK::NETWORK_SET_THIS_SCRIPT_IS_NETWORK_SCRIPT(32, true, 32);
2022-12-06 16:12:02 +00:00
scr_functions::init_nightclub_script({});
});
scr_functions::dance_loop.populate_ip();
bLastDanceMode = true;
return;
}
if (!g.self.dance_mode && g.self.dance_mode != bLastDanceMode)
2022-12-06 16:12:02 +00:00
{
if (g.m_dance_thread)
g.m_dance_thread->kill();
2022-12-06 16:12:02 +00:00
g.m_dance_thread = nullptr;
g.m_dance_program = nullptr;
2022-12-06 16:12:02 +00:00
g_script_patcher_service->update();
2022-12-06 16:12:02 +00:00
bLastDanceMode = false;
return;
}
if (g.self.dance_mode && g.m_dance_thread->m_handler)
2022-12-06 16:12:02 +00:00
{
*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, {});
2022-12-06 16:12:02 +00:00
}
}
}