2022-12-06 16:12:02 +00:00
# include "backend/looped/looped.hpp"
# include "natives.hpp"
# include "script_function.hpp"
2023-02-04 16:35:18 +00:00
# include "services/script_patcher/script_patcher_service.hpp"
2023-03-01 21:27:15 +00:00
# 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 ( )
{
2024-03-12 09:42:11 +01:00
if ( g . self . dance_mode & & SCRIPT : : GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH ( " maintransition " _J ) > 0 )
2022-12-18 23:15:52 +01:00
g . self . dance_mode = false ;
2022-12-06 16:12:02 +00:00
2022-12-18 23:15:52 +01:00
if ( g . self . dance_mode & & g . self . dance_mode ! = bLastDanceMode )
2022-12-06 16:12:02 +00:00
{
2023-02-04 16:35:18 +00:00
g_script_patcher_service - > update ( ) ;
2024-03-12 09:42:11 +01:00
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 ;
2024-03-12 09:42:11 +01:00
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 ;
2023-03-01 21:27:15 +00:00
g . m_dance_thread = gta_util : : find_script_thread_by_id ( thread ) ;
2024-03-12 09:42:11 +01:00
g . m_dance_program = gta_util : : find_script_program ( " am_mp_nightclub " _J ) ;
2022-12-06 16:12:02 +00:00
2022-12-18 23:15:52 +01:00
g . m_dance_thread - > m_context . m_state = rage : : eThreadState : : unk_3 ;
2022-12-06 16:12:02 +00:00
// perform initial setup
2023-03-01 21:27:15 +00:00
gta_util : : execute_as_script ( g . m_dance_thread , [ ] {
2023-02-13 20:38:30 +00:00
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 ;
}
2022-12-18 23:15:52 +01:00
if ( ! g . self . dance_mode & & g . self . dance_mode ! = bLastDanceMode )
2022-12-06 16:12:02 +00:00
{
2022-12-18 23:15:52 +01:00
if ( g . m_dance_thread )
g . m_dance_thread - > kill ( ) ;
2022-12-06 16:12:02 +00:00
2023-03-01 21:27:15 +00:00
g . m_dance_thread = nullptr ;
2022-12-18 23:15:52 +01:00
g . m_dance_program = nullptr ;
2022-12-06 16:12:02 +00:00
2023-02-04 16:35:18 +00:00
g_script_patcher_service - > update ( ) ;
2022-12-06 16:12:02 +00:00
bLastDanceMode = false ;
return ;
}
2022-12-18 23:15:52 +01:00
if ( g . self . dance_mode & & g . m_dance_thread - > m_handler )
2022-12-06 16:12:02 +00:00
{
2023-08-24 16:06:50 -04: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.
2022-12-18 23:15:52 +01:00
scr_functions : : dance_loop . call ( g . m_dance_thread , g . m_dance_program , { } ) ;
2022-12-06 16:12:02 +00:00
}
}
2024-03-12 09:42:11 +01:00
}