boiii-scripts/mp/mp_miniature_fly.gsc
2023-04-13 17:30:38 +02:00

97 lines
7.3 KiB
Plaintext

#using scripts\codescripts\struct;
#using scripts\shared\scene_shared;
#using scripts\shared\array_shared;
#using scripts\shared\util_shared;
#precache( "fx", "dlc4/mp_mini/fx_fly_death" );
function main()
{
scene::add_scene_func( "p7_fxanim_mp_mini_fly_idle_01_bundle", &run_fly );
scene::add_scene_func( "p7_fxanim_mp_mini_fly_idle_02_bundle", &run_fly );
scene::add_scene_func( "p7_fxanim_mp_mini_fly_land_01_bundle", &run_fly_idle, "done" );
level thread scene::play( "p7_fxanim_mp_mini_fly_idle_01_bundle" );
level thread scene::play( "p7_fxanim_mp_mini_fly_idle_02_bundle" );
}
function run_fly( a_ents )
{
self endon( "killed" );
e_fly = a_ents[ "fxanim_fly" ];
self thread fly_wait_death( e_fly );
wait 1;
fly_wait_disturbed( e_fly );
self scene::play( "p7_fxanim_mp_mini_fly_takeoff_01_bundle", a_ents );
if ( IsSubStr( self.targetname, "vista" ) )
{
self.script_play_multiple = true;
wait ( RandomFloatRange( 10, 30 ) );
self scene::play( "p7_fxanim_mp_mini_fly_land_01_bundle" );
}
}
function run_fly_idle( a_ents )
{
self thread scene::play( a_ents ); // plays the idle again, which will call run_fly to start the loop again
}
function fly_wait_death( e_fly )
{
e_fly notify( "fly_wait_death" );
e_fly endon( "fly_wait_death" );
e_fly waittill( "damage" );
PlayFxOnTag( "dlc4/mp_mini/fx_fly_death", e_fly, "body_jnt" );
{wait(.05);};
e_fly Delete();
self notify( "killed" );
}
function fly_wait_disturbed( e_fly )
{
while ( true )
{
foreach( player in level.players )
{
if( DistanceSquared( player.origin, e_fly.origin ) < ( 300 * 300 ) )
{
return;
}
}
{wait(.05);};
}
}