Files
TmpMenu/src/backend/looped/self/dance_mode.cpp
Andreas Maerten 88036b91da refactor: switch RAGE_JOAAT with string literal functions (#2806)
Why? Shorter to write and removes the macro usage

I used the following regex to find all occurrences:
```r
RAGE_JOAAT\("(.*?)"\)
```
then the following to replace it all:
```r
"$1"_J
```
2024-03-12 09:42:11 +01:00

67 lines
2.0 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_pointers->m_gta.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(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, {});
}
}
}