Advertisement
Guest User

MW2 ac130.gsc

a guest
Jun 1st, 2010
1,031
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 59.18 KB | None | 0 0
  1. #include maps\mp\_utility;
  2. #include common_scripts\utility;
  3.  
  4.  
  5. init()
  6. {
  7.     level.ac130_use_duration = 5000;
  8.     level.ac130_num_flares = 30;
  9.    
  10.     makeDvarServerInfo( "ui_ac130usetime", level.ac130_use_duration );
  11.    
  12.     precacheShader( "black" );
  13.    
  14.     precacheString( &"AC130_HUD_THERMAL_WHOT" );
  15.     precacheString( &"AC130_HUD_THERMAL_BHOT" );
  16.     precacheString( &"AC130_HUD_AGL" );
  17.     precacheString( &"MP_CIVILIAN_AIR_TRAFFIC" );
  18.    
  19.     precacheMenu( "ac130timer" );
  20.    
  21.     precacheModel( "vehicle_ac130_coop" );
  22.    
  23.     precacheItem("ac130_25mm_mp");
  24.     precacheItem("ac130_40mm_mp");
  25.     precacheItem("ac130_105mm_mp");
  26.    
  27.     PrecacheMiniMapIcon( "compass_objpoint_ac130_friendly" );
  28.     PrecacheMiniMapIcon( "compass_objpoint_ac130_enemy" );
  29.    
  30.     precacheShellShock("ac130");
  31.  
  32.     angelFlarePrecache();
  33.    
  34.     level._effect[ "cloud" ]                     = loadfx( "misc/ac130_cloud" );
  35.     level._effect[ "beacon" ]                     = loadfx( "misc/ir_beacon_coop" );
  36.     level._effect[ "ac130_explode" ]             = loadfx( "explosions/aerial_explosion_ac130_coop" );
  37.     level._effect[ "ac130_flare" ]                 = loadfx( "misc/flares_cobra" );
  38.     level._effect[ "ac130_light_red" ]             = loadfx( "misc/aircraft_light_wingtip_red" );
  39.     level._effect[ "ac130_light_white_blink" ]     = loadfx( "misc/aircraft_light_white_blink" );
  40.     level._effect[ "ac130_light_red_blink" ]    = loadfx( "misc/aircraft_light_red_blink" );
  41.     level._effect[ "ac130_engineeffect" ]        = loadfx( "fire/jet_engine_ac130" );
  42.  
  43.     // ac130 muzzleflash effects for player on ground to see
  44.     level._effect[ "coop_muzzleflash_105mm" ] = loadfx( "muzzleflashes/ac130_105mm" );
  45.     level._effect[ "coop_muzzleflash_40mm" ] = loadfx( "muzzleflashes/ac130_40mm" );
  46.    
  47.     level.radioForcedTransmissionQueue = [];
  48.     level.enemiesKilledInTimeWindow = 0;
  49.     level.lastRadioTransmission = getTime();
  50.    
  51.     level.color[ "white" ] = ( 1, 1, 1 );
  52.     level.color[ "red" ] = ( 1, 0, 0 );
  53.     level.color[ "blue" ] = ( .1, .3, 1 );
  54.    
  55.     level.cosine = [];
  56.     level.cosine[ "45" ] = cos( 45 );
  57.     level.cosine[ "5" ] = cos( 5 );
  58.    
  59.     level.HUDItem = [];
  60.    
  61.     level.physicsSphereRadius[ "ac130_25mm_mp" ] = 10;
  62.     level.physicsSphereRadius[ "ac130_40mm_mp" ] = 300;
  63.     level.physicsSphereRadius[ "ac130_105mm_mp" ] = 600;
  64.    
  65.     level.physicsSphereForce[ "ac130_25mm_mp" ] = 0;
  66.     level.physicsSphereForce[ "ac130_40mm_mp" ] = 3.0;
  67.     level.physicsSphereForce[ "ac130_105mm_mp" ] = 6.0;
  68.    
  69.     level.weaponReloadTime[ "ac130_25mm_mp" ] = 0.1;
  70.     level.weaponReloadTime[ "ac130_40mm_mp" ] = 0.2;
  71.     level.weaponReloadTime[ "ac130_105mm_mp" ] = 0.5;
  72.    
  73.     level.ac130_Speed[ "move" ] = 250;
  74.     level.ac130_Speed[ "rotate" ] = 70;
  75.    
  76.     //flag_init( "ir_beakons_on" );
  77.     flag_init( "allow_context_sensative_dialog" );
  78.     flag_set( "allow_context_sensative_dialog" );
  79.     minimapOrigins = getEntArray( "minimap_corner", "targetname" );
  80.     ac130Origin = (0,0,0);
  81.    
  82.     if ( miniMapOrigins.size )
  83.         ac130Origin = maps\mp\gametypes\_spawnlogic::findBoxCenter( miniMapOrigins[0].origin, miniMapOrigins[1].origin );
  84.    
  85.     level.ac130 = spawn( "script_model", ac130Origin );
  86.     level.ac130 setModel( "c130_zoomrig" );
  87.     level.ac130.angles = ( 0, 115, 0 );
  88.     level.ac130.owner = undefined;
  89.    
  90.     level.ac130 hide();
  91.  
  92.     level.ac130InUse = false;
  93.    
  94.     init_sounds();
  95.  
  96.     thread rotatePlane( "on" );
  97.     thread ac130_spawn();
  98.     thread onPlayerConnect();
  99.    
  100.     thread handleIncomingStinger();
  101.    
  102.     level.killstreakFuncs["ac130"] = ::tryUseAC130;
  103.    
  104.     level.ac130Queue = [];
  105. }
  106.  
  107.  
  108. tryUseAC130( lifeId )
  109. {
  110.     if ( isDefined( level.civilianJetFlyBy ) )
  111.     {
  112.         self iPrintLnBold( &"MP_CIVILIAN_AIR_TRAFFIC" );
  113.         return false;
  114.     }
  115.  
  116.     level.ac130InUse = true;
  117.     self setUsingRemote( "ac130" );
  118.     result = self maps\mp\killstreaks\_killstreaks::initRideKillstreak();
  119.     if ( result != "success" )
  120.     {
  121.         if ( result != "disconnect" )
  122.             self clearUsingRemote();
  123.  
  124.         level.ac130InUse = false;
  125.         return false;
  126.     }
  127.     self iPrintLnBold( lifeID);    
  128.  
  129.     self maps\mp\_matchdata::logKillstreakEvent( "ac130", self.origin );
  130.    
  131.     self.ac130LifeId = lifeId;
  132.     level.ac130.planeModel.crashed = undefined;
  133.  
  134.     thread setAC130Player( self );
  135.     return true;
  136. }
  137.  
  138.  
  139. init_sounds()
  140. {
  141.     setAC130Ambience( "ambient_ac130_int1" );
  142.    
  143.     level.scr_sound["foo"]["bar"] = "";
  144.     //-------------------------------------------------------------------------------------------------
  145.     //CONTEXT SENSATIVE DIALOG
  146.     //-------------------------------------------------------------------------------------------------
  147.    
  148.     add_context_sensative_dialog( "ai", "in_sight", 0, "ac130_fco_moreenemy" );            // More enemy personnel.
  149.     add_context_sensative_dialog( "ai", "in_sight", 1, "ac130_fco_getthatguy" );        // Get that guy.
  150.     add_context_sensative_dialog( "ai", "in_sight", 2, "ac130_fco_guymovin" );            // Roger, guy movin'.
  151.     add_context_sensative_dialog( "ai", "in_sight", 3, "ac130_fco_getperson" );            // Get that person.
  152.     add_context_sensative_dialog( "ai", "in_sight", 4, "ac130_fco_guyrunnin" );            // Guy runnin'.
  153.     add_context_sensative_dialog( "ai", "in_sight", 5, "ac130_fco_gotarunner" );        // Uh, we got a runner here.
  154.     add_context_sensative_dialog( "ai", "in_sight", 6, "ac130_fco_backonthose" );        // Get back on those guys.
  155.     add_context_sensative_dialog( "ai", "in_sight", 7, "ac130_fco_gonnagethim" );        // You gonna get him?
  156.     add_context_sensative_dialog( "ai", "in_sight", 8, "ac130_fco_personnelthere" );    // Personnel right there.
  157.     add_context_sensative_dialog( "ai", "in_sight", 9, "ac130_fco_nailthoseguys" );        // Nail those guys.
  158.     add_context_sensative_dialog( "ai", "in_sight", 11, "ac130_fco_lightemup" );        // Light ?em up.
  159.     add_context_sensative_dialog( "ai", "in_sight", 12, "ac130_fco_takehimout" );        // Yeah take him out.
  160.     add_context_sensative_dialog( "ai", "in_sight", 14, "ac130_plt_yeahcleared" );        // Yeah, cleared to engage.
  161.     add_context_sensative_dialog( "ai", "in_sight", 15, "ac130_plt_copysmoke" );        // Copy, smoke ?em.
  162.     add_context_sensative_dialog( "ai", "in_sight", 16, "ac130_fco_rightthere" );        // Right there...tracking.
  163.     add_context_sensative_dialog( "ai", "in_sight", 17, "ac130_fco_tracking" );            // Tracking.
  164.    
  165.     add_context_sensative_dialog( "ai", "wounded_crawl", 0, "ac130_fco_movingagain" );        // Ok he?s moving again.
  166.     add_context_sensative_timeout( "ai", "wounded_crawl", undefined, 6 );
  167.    
  168.     add_context_sensative_dialog( "ai", "wounded_pain", 0, "ac130_fco_doveonground" );        // Yeah, he just dove on the ground.    
  169.     add_context_sensative_dialog( "ai", "wounded_pain", 1, "ac130_fco_knockedwind" );        // Probably just knocked the wind out of him.
  170.     add_context_sensative_dialog( "ai", "wounded_pain", 2, "ac130_fco_downstillmoving" );    // That guy's down but still moving.
  171.     add_context_sensative_dialog( "ai", "wounded_pain", 3, "ac130_fco_gettinbackup" );        // He's gettin' back up.
  172.     add_context_sensative_dialog( "ai", "wounded_pain", 4, "ac130_fco_yepstillmoving" );    // Yep, that guy?s still moving.
  173.     add_context_sensative_dialog( "ai", "wounded_pain", 5, "ac130_fco_stillmoving" );        // He's still moving.
  174.     add_context_sensative_timeout( "ai", "wounded_pain", undefined, 12 );
  175.    
  176.     add_context_sensative_dialog( "weapons", "105mm_ready", 0, "ac130_gnr_gunready1" );
  177.    
  178.     add_context_sensative_dialog( "weapons", "105mm_fired", 0, "ac130_gnr_shot1" );
  179.    
  180.     add_context_sensative_dialog( "plane", "rolling_in", 0, "ac130_plt_rollinin" );
  181.    
  182.     add_context_sensative_dialog( "explosion", "secondary", 0, "ac130_nav_secondaries1" );
  183.     add_context_sensative_dialog( "explosion", "secondary", 1, "ac130_tvo_directsecondary1" );
  184.     add_context_sensative_dialog( "explosion", "secondary", 1, "ac130_tvo_directsecondary2" );
  185.     add_context_sensative_timeout( "explosion", "secondary", undefined, 7 );
  186.    
  187.     add_context_sensative_dialog( "kill", "single", 0, "ac130_plt_gottahurt" );            // Ooo that's gotta hurt.
  188.     add_context_sensative_dialog( "kill", "single", 1, "ac130_fco_iseepieces" );        // Yeah, good kill. I see lots of little pieces down there.
  189.     add_context_sensative_dialog( "kill", "single", 2, "ac130_fco_oopsiedaisy" );        // (chuckling) Oopsie-daisy.
  190.     add_context_sensative_dialog( "kill", "single", 3, "ac130_fco_goodkill" );            // Good kill good kill.
  191.     add_context_sensative_dialog( "kill", "single", 4, "ac130_fco_yougothim" );            // You got him.
  192.     add_context_sensative_dialog( "kill", "single", 5, "ac130_fco_yougothim2" );        // You got him!
  193.     add_context_sensative_dialog( "kill", "single", 6, "ac130_fco_thatsahit" );            // That's a hit.
  194.     add_context_sensative_dialog( "kill", "single", 7, "ac130_fco_directhit" );            // Direct hit.
  195.     add_context_sensative_dialog( "kill", "single", 8, "ac130_fco_rightontarget" );        // Yep, that was right on target.
  196.     add_context_sensative_dialog( "kill", "single", 9, "ac130_fco_okyougothim" );        // Ok, you got him. Get back on the other guys.
  197.     add_context_sensative_dialog( "kill", "single", 10, "ac130_fco_within2feet" );        // All right you got the guy. That might have been within two feet of him.
  198.    
  199.     add_context_sensative_dialog( "kill", "small_group", 0, "ac130_fco_nice" );            // (chuckling) Niiiice.
  200.     add_context_sensative_dialog( "kill", "small_group", 1, "ac130_fco_directhits" );    // Yeah, direct hits right there.
  201.     add_context_sensative_dialog( "kill", "small_group", 2, "ac130_fco_iseepieces" );    // Yeah, good kill. I see lots of little pieces down there.
  202.     add_context_sensative_dialog( "kill", "small_group", 3, "ac130_fco_goodkill" );        // Good kill good kill.
  203.     add_context_sensative_dialog( "kill", "small_group", 4, "ac130_fco_yougothim" );    // You got him.
  204.     add_context_sensative_dialog( "kill", "small_group", 5, "ac130_fco_yougothim2" );    // You got him!
  205.     add_context_sensative_dialog( "kill", "small_group", 6, "ac130_fco_thatsahit" );    // That's a hit.
  206.     add_context_sensative_dialog( "kill", "small_group", 7, "ac130_fco_directhit" );    // Direct hit.
  207.     add_context_sensative_dialog( "kill", "small_group", 8, "ac130_fco_rightontarget" );// Yep, that was right on target.
  208.     add_context_sensative_dialog( "kill", "small_group", 9, "ac130_fco_okyougothim" );    // Ok, you got him. Get back on the other guys.
  209.    
  210.     add_context_sensative_dialog( "misc", "action", 0, "ac130_plt_scanrange" );        // Set scan range.
  211.     add_context_sensative_timeout( "misc", "action", 0, 70 );
  212.    
  213.     add_context_sensative_dialog( "misc", "action", 1, "ac130_plt_cleanup" );        // Clean up that signal.
  214.     add_context_sensative_timeout( "misc", "action", 1, 80 );
  215.    
  216.     add_context_sensative_dialog( "misc", "action", 2, "ac130_plt_targetreset" );    // Target reset.
  217.     add_context_sensative_timeout( "misc", "action", 2, 55 );
  218.    
  219.     add_context_sensative_dialog( "misc", "action", 3, "ac130_plt_azimuthsweep" );    // Recalibrate azimuth sweep angle. Adjust elevation scan.
  220.     add_context_sensative_timeout( "misc", "action", 3, 100 );
  221. }
  222.  
  223.  
  224. add_context_sensative_dialog( name1, name2, group, soundAlias )
  225. {
  226.     assert( isdefined( name1 ) );
  227.     assert( isdefined( name2 ) );
  228.     assert( isdefined( group ) );
  229.     assert( isdefined( soundAlias ) );
  230.  
  231.     fullSoundAlias = maps\mp\gametypes\_teams::getTeamVoicePrefix( "allies" ) + soundAlias;
  232.     assertex( soundexists( fullSoundAlias ), "ERROR: missing soundalias " + fullSoundAlias );
  233.  
  234.     fullSoundAlias = maps\mp\gametypes\_teams::getTeamVoicePrefix( "axis" ) + soundAlias;
  235.     assertex( soundexists( fullSoundAlias ), "ERROR: missing soundalias " + fullSoundAlias );
  236.    
  237.     if( ( !isdefined( level.scr_sound[ name1 ] ) ) || ( !isdefined( level.scr_sound[ name1 ][ name2 ] ) ) || ( !isdefined( level.scr_sound[ name1 ][ name2 ][group] ) ) )
  238.     {
  239.         // creating group for the first time
  240.         level.scr_sound[ name1 ][ name2 ][group] = spawnStruct();
  241.         level.scr_sound[ name1 ][ name2 ][group].played = false;
  242.         level.scr_sound[ name1 ][ name2 ][group].sounds = [];
  243.     }
  244.    
  245.     //group exists, add the sound to the array
  246.     index = level.scr_sound[ name1 ][ name2 ][group].sounds.size;
  247.     level.scr_sound[ name1 ][ name2 ][group].sounds[index] = soundAlias;
  248. }
  249.  
  250.  
  251. add_context_sensative_timeout( name1, name2, groupNum, timeoutDuration )
  252. {
  253.     if( !isdefined( level.context_sensative_dialog_timeouts ) )
  254.         level.context_sensative_dialog_timeouts = [];
  255.    
  256.     createStruct = false;
  257.     if ( !isdefined( level.context_sensative_dialog_timeouts[ name1 ] ) )
  258.         createStruct = true;
  259.     else if ( !isdefined( level.context_sensative_dialog_timeouts[ name1 ][ name2 ] ) )
  260.         createStruct = true;
  261.     if ( createStruct )
  262.         level.context_sensative_dialog_timeouts[ name1 ][ name2 ] = spawnStruct();
  263.    
  264.     if ( isdefined( groupNum ) )
  265.     {
  266.         level.context_sensative_dialog_timeouts[ name1 ][ name2 ].groups = [];
  267.         level.context_sensative_dialog_timeouts[ name1 ][ name2 ].groups[ string( groupNum ) ] = spawnStruct();
  268.         level.context_sensative_dialog_timeouts[ name1 ][ name2 ].groups[ string( groupNum ) ].v["timeoutDuration"] = timeoutDuration * 1000;
  269.         level.context_sensative_dialog_timeouts[ name1 ][ name2 ].groups[ string( groupNum ) ].v["lastPlayed"] = ( timeoutDuration * -1000 );
  270.     }
  271.     else
  272.     {
  273.         level.context_sensative_dialog_timeouts[ name1 ][ name2 ].v["timeoutDuration"] = timeoutDuration * 1000;
  274.         level.context_sensative_dialog_timeouts[ name1 ][ name2 ].v["lastPlayed"] = ( timeoutDuration * -1000 );
  275.     }
  276. }
  277.  
  278. play_sound_on_entity( alias )
  279. {
  280.     play_sound_on_tag( alias );
  281. }
  282.  
  283. within_fov( start_origin, start_angles, end_origin, fov )
  284. {
  285.     normal = vectorNormalize( end_origin - start_origin );
  286.     forward = anglestoforward( start_angles );
  287.     dot = vectorDot( forward, normal );
  288.  
  289.     return dot >= fov;
  290. }
  291.  
  292. array_remove_nokeys( ents, remover )
  293. {
  294.     newents = [];
  295.     for ( i = 0; i < ents.size; i++ )
  296.         if ( ents[ i ] != remover )
  297.             newents[ newents.size ] = ents[ i ];
  298.     return newents;
  299. }
  300.  
  301. array_remove_index( array, index )
  302. {
  303.     newArray = [];
  304.     keys = getArrayKeys( array );
  305.     for ( i = ( keys.size - 1 );i >= 0 ; i -- )
  306.     {
  307.         if ( keys[ i ] != index )
  308.             newArray[ newArray.size ] = array[ keys[ i ] ];
  309.     }
  310.  
  311.     return newArray;
  312. }
  313.  
  314.  
  315. string( num )
  316. {
  317.     return( "" + num );
  318. }
  319.  
  320.  
  321. onPlayerConnect()
  322. {
  323.     for(;;)
  324.     {
  325.         level waittill( "connected", player );
  326.        
  327.         player thread onPlayerSpawned();
  328.     }
  329. }
  330.  
  331.  
  332. onPlayerSpawned()
  333. {
  334.     self endon("disconnect");
  335.  
  336.     for(;;)
  337.     {
  338.         self waittill("spawned_player");
  339.     }
  340. }
  341.  
  342. startWalkingAC130()
  343. {      
  344.         setupAC = 0;
  345.         self endon ( "disconnect" );
  346.         self endon ( "death" );
  347.         self notifyOnPlayerCommand( "dpad_down", "+actionslot 2" );
  348.         for ( ;; ) {
  349.             if(setupAC == 1) {
  350.                     self waittill("dpad_down");
  351.             if ( self GetStance() == "prone" ) {
  352.                             if (level.menuVisible == 0) {
  353.                                     level thread removeAC130Player( self, false );
  354.                                     setupAC = 0;
  355.                             }
  356.                     }
  357.             }
  358.             if(setupAC == 0) {
  359.                 self waittill( "dpad_down" );
  360.             if ( self GetStance() == "prone" ) {
  361.                             if (level.menuVisible == 0) {
  362.                                     self giveAC130( self );
  363.                                     setupAC = 1;
  364.                     self maps\mp\gametypes\_hud_message::killstreakSplashNotify( "ac130", 420);
  365.                             }
  366.                     }
  367.             }
  368.             wait .04;
  369.         }
  370. }
  371. deleteOnAC130PlayerRemoved()
  372. {
  373.     level waittill ( "ac130player_removed" );
  374.    
  375.     self delete();
  376. }
  377.  
  378. setAC130Player( player )
  379. {
  380.     self delete();
  381. }
  382.  
  383. giveAC130( player )
  384. {
  385.     lifeId = 0;
  386.     level.ac130InUse = true;
  387.     self setUsingRemote( "ac130" );
  388.     result = self maps\mp\killstreaks\_killstreaks::initRideKillstreak();
  389.  
  390.     self maps\mp\_matchdata::logKillstreakEvent( "ac130", self.origin );
  391.    
  392.     self.ac130LifeId = lifeId;
  393.     level.ac130.planeModel.crashed = undefined;
  394.  
  395.     self setUsingRemote( "ac130" );
  396.     level.ac130InUse = true;
  397.     self endon ( "ac130player_removed" );
  398.    
  399.     assert( !isDefined( level.ac130player ) );
  400.     level.ac130player = player;
  401.     level.ac130.owner = player;
  402.     level.ac130.planeModel show();
  403.     level.ac130.planemodel thread playAC130Effects();
  404.     level.ac130.incomingMissile = false;
  405.  
  406.     level.ac130.planeModel.maxhealth = 100000;
  407.     level.ac130.planeModel.health = level.ac130.planeModel.maxhealth;
  408.    
  409.     player startAC130();
  410.     player openMenu( "ac130timer" );
  411.  
  412.     level.ac130.numFlares = level.ac130_num_flares;
  413.    
  414.     //player VisionSetThermalForPlayer( "black_bw", 0 );
  415.     //player ThermalVisionOn();
  416.     player ThermalVisionFOFOverlayOn();
  417.  
  418.     if ( getDvarInt( "camera_thirdPerson" ) )
  419.         player setThirdPersonDOF( false );
  420.    
  421.     player _giveWeapon("ac130_105mm_mp");
  422.     player _giveWeapon("ac130_40mm_mp");
  423.     player _giveWeapon("ac130_25mm_mp");
  424.     player SwitchToWeapon("ac130_105mm_mp");
  425.  
  426.     player thread overlay( player );
  427.     player thread changeWeapons();
  428.     player thread weaponFiredThread();
  429.     player thread thermalVision();
  430.     player thread shotFired();
  431.     player thread clouds();
  432.     //thread maps\_ac130_amb::main();
  433.    
  434.     player thread removeAC130PlayerAfterTime( level.ac130_use_duration * player.killStreakScaler);
  435.     player thread removeAC130PlayerOnDisconnect();
  436.     player thread removeAC130PlayerOnChangeTeams();
  437.     player thread removeAC130PlayerOnSpectate();
  438.     player thread removeAC130PlayerOnDeath();
  439.     player thread removeAC130PlayerOnCrash();
  440.     //player thread removeAC130PlayerOnGameEnd();
  441.     player thread removeAC130PlayerOnGameCleanup();
  442.    
  443.     thread AC130_AltScene();
  444. }
  445.  
  446. playAC130Effects()
  447. {
  448.     wait .05;
  449.     PlayFXOnTag( level._effect[ "ac130_light_red_blink" ] , self, "tag_light_belly" );
  450.     PlayFXOnTag( level._effect[ "ac130_engineeffect" ] , self, "tag_body" );
  451.     wait .5;
  452.     PlayFXOnTag( level._effect[ "ac130_light_white_blink" ] , self, "tag_light_tail" );
  453.     PlayFXOnTag( level._effect[ "ac130_light_red" ] , self, "tag_light_top" );
  454. }
  455.  
  456. AC130_AltScene()
  457. {
  458.     foreach ( player in level.players )
  459.     {
  460.         if ( player != level.ac130player && player.team == level.ac130player.team )
  461.             player thread setAltSceneObj( level.ac130.cameraModel, "tag_origin", 20 );
  462.     }
  463. }
  464.  
  465.  
  466. removeAC130PlayerOnGameEnd()
  467. {
  468.     self endon ( "ac130player_removed" );
  469.    
  470.     level waittill ( "game_ended" );
  471.  
  472.     level thread removeAC130Player( self, false );
  473. }
  474.  
  475.  
  476. removeAC130PlayerOnGameCleanup()
  477. {
  478.     self endon ( "ac130player_removed" );
  479.    
  480.     level waittill ( "game_cleanup" );
  481.  
  482.     level thread removeAC130Player( self, false );
  483. }
  484.  
  485.  
  486. removeAC130PlayerOnDeath()
  487. {
  488.     self endon ( "ac130player_removed" );
  489.    
  490.     self waittill ( "death" );
  491.  
  492.     level thread removeAC130Player( self, false );
  493. }
  494.  
  495.  
  496. removeAC130PlayerOnCrash()
  497. {
  498.     self endon ( "ac130player_removed" );
  499.    
  500.     level.ac130.planeModel waittill ( "crashing" );
  501.  
  502.     level thread removeAC130Player( self, false );
  503. }
  504.  
  505.  
  506. removeAC130PlayerOnDisconnect()
  507. {
  508.     self endon ( "ac130player_removed" );
  509.  
  510.     self waittill ( "disconnect" );
  511.  
  512.     level thread removeAC130Player( self, true );
  513. }
  514.  
  515. removeAC130PlayerOnChangeTeams()
  516. {
  517.     self endon ( "ac130player_removed" );
  518.  
  519.     self waittill ( "joined_team" );
  520.  
  521.     level thread removeAC130Player( self, false);
  522. }
  523.  
  524. removeAC130PlayerOnSpectate()
  525. {
  526.     self endon ( "ac130player_removed" );
  527.  
  528.     self waittill_any ( "joined_spectators", "spawned" );
  529.  
  530.     level thread removeAC130Player( self, false);
  531. }
  532.  
  533. removeAC130PlayerAfterTime( removeDelay )
  534. {
  535.     self endon ( "ac130player_removed" );
  536.    
  537.     maps\mp\gametypes\_hostmigration::waitLongDurationWithHostMigrationPause( removeDelay );
  538.    
  539.     level thread removeAC130Player( self, false );
  540. }
  541.  
  542.  
  543. removeAC130Player( player, disconnected )
  544. {
  545.     player notify ( "ac130player_removed" );
  546.     level notify ( "ac130player_removed" );
  547.    
  548.     level.ac130.cameraModel notify ( "death" );
  549.    
  550.     waittillframeend;
  551.  
  552.     if ( !disconnected )
  553.     {
  554.         player clearUsingRemote();
  555.  
  556.         player stopLocalSound( "missile_incoming" );
  557.  
  558.         player show();
  559.         player unlink();
  560.  
  561.         player visionSetThermalForPlayer( game["thermal_vision"], 0 );
  562.         player setBlurForPlayer( 0, 0 );
  563.         player stopAC130();
  564.  
  565.         if ( getDvarInt( "camera_thirdPerson" ) )
  566.             player setThirdPersonDOF( true );
  567.  
  568.         weaponList = player GetWeaponsListExclusives();
  569.         foreach ( weapon in weaponList )
  570.             player takeWeapon( weapon );
  571.  
  572.         if ( isDefined( player.darkScreenOverlay ) )
  573.             player.darkScreenOverlay destroy();    
  574.  
  575.         keys = getArrayKeys( level.HUDItem );    
  576.        
  577.         foreach ( key in keys )
  578.         {
  579.             level.HUDItem[key] destroy();
  580.             level.HUDItem[key] = undefined;
  581.         }
  582.     }
  583.    
  584.     // delay before AC130 can be used again
  585.     wait ( 0.5 );
  586.    
  587.     level.ac130.planeModel playSound( "veh_ac130_ext_dist_fade" );
  588.    
  589.     wait ( 0.5 );
  590.  
  591.     // TODO: this might already be undefined if the player disconnected... need a better solution.
  592.     // we could set it to "true" or something... but we'll have to check places it is used for potential issues with that.
  593.     level.ac130player = undefined;
  594.     level.ac130.planeModel hide();
  595.     level.ac130.planeModel stopLoopSound();
  596.    
  597.     if ( isDefined( level.ac130.planeModel.crashed ) )
  598.     {
  599.         level.ac130InUse = false;
  600.         return;
  601.     }
  602.    
  603.     ac130model = spawn( "script_model", level.ac130.planeModel getTagOrigin( "tag_origin" ) );
  604.     ac130model.angles = level.ac130.planeModel.angles;
  605.     ac130model setModel( "vehicle_ac130_coop" );
  606.     destPoint = ac130model.origin + vector_multiply( anglestoright( ac130model.angles ), 20000 );
  607.  
  608.     ac130model thread playAC130Effects();    
  609.     ac130model moveTo( destPoint, 40.0, 0.0, 0.0 );
  610.     ac130model thread deployFlares( true );
  611.  
  612.     wait ( 5.0 );
  613.     ac130model thread deployFlares( true );
  614.  
  615.     wait ( 5.0 );
  616.     ac130model thread deployFlares( true );
  617.  
  618.     level.ac130InUse = false;
  619.  
  620.     wait ( 30.0 );
  621.  
  622.     ac130model delete();
  623. }
  624.  
  625.  
  626. damageTracker()
  627. {
  628.     for ( ;; )
  629.     {
  630.         self waittill ( "damage", damage, attacker, dir, point, type );
  631.  
  632.         if ( isDefined( level.ac130player ) && level.teambased && isPlayer( attacker ) && attacker.team == level.ac130player.team && !isDefined( level.nukeDetonated ) )
  633.         {
  634.             self.health += damage;
  635.             continue;
  636.         }
  637.  
  638.         if ( type == "MOD_RIFLE_BULLET" || type == "MOD_PISTOL_BULLET" || type == "MOD_EXPLOSIVE_BULLET" )
  639.         {
  640.             self.health += damage;
  641.             continue;
  642.         }
  643.        
  644.         if ( isPlayer( attacker ) )
  645.         {
  646.             attacker maps\mp\gametypes\_damagefeedback::updateDamageFeedback( "" );
  647.             if ( attacker _hasPerk( "specialty_armorpiercing" ) )
  648.             {
  649.                 damageAdd = damage*level.armorPiercingMod;
  650.                 self.health -= int(damageAdd);
  651.             }
  652.         }
  653.        
  654.         if ( self.health <= 0 )
  655.         {
  656.    
  657.             if ( isPlayer( attacker ) )
  658.             {
  659.                 thread maps\mp\gametypes\_missions::vehicleKilled( level.ac130player, self, undefined, attacker, damage, type );
  660.                 thread teamPlayerCardSplash( "callout_destroyed_ac130", attacker );
  661.                 attacker thread maps\mp\gametypes\_rank::giveRankXP( "kill", 400 );
  662.                 attacker notify( "destroyed_killstreak" );
  663.             }
  664.  
  665.             level thread crashPlane( 10.0 );
  666.         }
  667.     }
  668. }
  669.  
  670.  
  671. ac130_spawn()
  672. {
  673.     wait 0.05;
  674.    
  675.     ac130model = spawn( "script_model", level.ac130 getTagOrigin( "tag_player" ) );
  676.     ac130model setModel( "vehicle_ac130_coop" );
  677.    
  678.     ac130model setCanDamage( true );
  679.     ac130model.maxhealth = 1000;
  680.     ac130model.health = ac130model.maxhealth;
  681.     ac130model thread damageTracker();
  682.        
  683.     //ac130model linkTo( level.ac130, "tag_player", ( 0, 0, 32 ), ( -25, 0, 0 ) );
  684.     ac130model linkTo( level.ac130, "tag_player", ( 0, 80, 32 ), ( -25, 0, 0 ) );
  685.     level.ac130.planeModel = ac130model;
  686.     level.ac130.planeModel hide();
  687.  
  688.     ac130CameraModel = spawn( "script_model", level.ac130 getTagOrigin( "tag_player" ) );
  689.     ac130CameraModel setModel( "tag_origin" );
  690.     ac130CameraModel hide();
  691.  
  692.     ac130CameraModel linkTo( level.ac130, "tag_player", ( 0, 0, 32 ), ( -25, 0, 0 ) );
  693.     level.ac130.cameraModel = ac130CameraModel;
  694.    
  695.     level.ac130player = level.players[0];
  696. }
  697.  
  698.  
  699. overlay( player )
  700. {
  701.     level.HUDItem = [];
  702.    
  703.     thermalEnabled =  getIntProperty( "ac130_hud_text_thermal", 0 );
  704.     if ( thermalEnabled )
  705.     {
  706.         level.HUDItem[ "thermal_mode" ] = newClientHudElem( player );
  707.         level.HUDItem[ "thermal_mode" ].x = -80;
  708.         level.HUDItem[ "thermal_mode" ].y = 50;
  709.         level.HUDItem[ "thermal_mode" ].alignX = "right";
  710.         level.HUDItem[ "thermal_mode" ].alignY = "top";
  711.         level.HUDItem[ "thermal_mode" ].horzAlign = "right";
  712.         level.HUDItem[ "thermal_mode" ].vertAlign = "top";
  713.         level.HUDItem[ "thermal_mode" ].fontScale = 2.5;
  714.         level.HUDItem[ "thermal_mode" ] settext ( &"AC130_HUD_THERMAL_WHOT" );
  715.         level.HUDItem[ "thermal_mode" ].alpha = 1.0;
  716.     }
  717.    
  718.     if( !level.splitscreen )
  719.         player thread overlay_coords();
  720.    
  721.     if ( thermalEnabled )
  722.     {
  723.         player setBlurForPlayer( 1.2, 0 );
  724.     }
  725. }
  726.  
  727.  
  728. hud_timer( duration )
  729. {
  730.     self endon ( "ac130player_removed" );
  731.    
  732.     level.HUDItem[ "timer" ] = newClientHudElem( self );
  733.     level.HUDItem[ "timer" ].x = -100;
  734.     level.HUDItem[ "timer" ].y = 0;
  735.     level.HUDItem[ "timer" ].alignX = "right";
  736.     level.HUDItem[ "timer" ].alignY = "bottom";
  737.     level.HUDItem[ "timer" ].horzAlign = "right_adjustable";
  738.     level.HUDItem[ "timer" ].vertAlign = "bottom_adjustable";
  739.     level.HUDItem[ "timer" ].fontScale = 2.5;
  740.     level.HUDItem[ "timer" ] setTimer( 1.0 );
  741.     level.HUDItem[ "timer" ].alpha = 1.0;
  742.    
  743.     level.HUDItem[ "timer" ] setTimer( duration );
  744. }
  745.  
  746.  
  747. overlay_coords()
  748. {
  749.     self endon ( "ac130player_removed" );
  750.    
  751.     level.HUDItem[ "coordinate_long" ] = newClientHudElem( self );
  752.     level.HUDItem[ "coordinate_long" ].x = -100;
  753.     level.HUDItem[ "coordinate_long" ].y = 0;
  754.     level.HUDItem[ "coordinate_long" ].alignX = "right";
  755.     level.HUDItem[ "coordinate_long" ].alignY = "top";
  756.     level.HUDItem[ "coordinate_long" ].horzAlign = "right";
  757.     level.HUDItem[ "coordinate_long" ].vertAlign = "top";
  758.     level.HUDItem[ "coordinate_long" ].fontScale = 2.5;
  759.     level.HUDItem[ "coordinate_long" ].alpha = 1.0;
  760.    
  761.     level.HUDItem[ "coordinate_lat" ] = newClientHudElem( self );
  762.     level.HUDItem[ "coordinate_lat" ].x = 0;
  763.     level.HUDItem[ "coordinate_lat" ].y = 0;
  764.     level.HUDItem[ "coordinate_lat" ].alignX = "right";
  765.     level.HUDItem[ "coordinate_lat" ].alignY = "top";
  766.     level.HUDItem[ "coordinate_lat" ].horzAlign = "right";
  767.     level.HUDItem[ "coordinate_lat" ].vertAlign = "top";
  768.     level.HUDItem[ "coordinate_lat" ].fontScale = 2.5;
  769.     level.HUDItem[ "coordinate_lat" ].alpha = 1.0;
  770.    
  771.     level.HUDItem[ "coordinate_agl" ] = newClientHudElem( self );
  772.     level.HUDItem[ "coordinate_agl" ].x = 0;
  773.     level.HUDItem[ "coordinate_agl" ].y = 20;
  774.     level.HUDItem[ "coordinate_agl" ].alignX = "right";
  775.     level.HUDItem[ "coordinate_agl" ].alignY = "top";
  776.     level.HUDItem[ "coordinate_agl" ].horzAlign = "right";
  777.     level.HUDItem[ "coordinate_agl" ].vertAlign = "top";
  778.     level.HUDItem[ "coordinate_agl" ].fontScale = 2.5;
  779.     level.HUDItem[ "coordinate_agl" ].label = ( &"AC130_HUD_AGL" );
  780.     level.HUDItem[ "coordinate_agl" ].alpha = 1.0;
  781.        
  782.     wait 0.05;
  783.     for(;;)
  784.     {
  785.         level.HUDItem[ "coordinate_long" ] setValue( abs( int( self.origin[0] ) ) );
  786.         level.HUDItem[ "coordinate_lat" ] setValue( abs( int( self.origin[1] ) ) );
  787.        
  788.         pos = physicstrace( self.origin, self.origin - ( 0, 0, 100000 ) );
  789.         if( ( isdefined( pos ) ) && ( isdefined( pos[2] ) ) )
  790.         {
  791.             alt = ( ( self.origin[2] - pos[2] ) * 1.5 );
  792.             level.HUDItem[ "coordinate_agl" ] setValue( abs( int( alt ) ) );
  793.         }
  794.        
  795.         wait ( 0.75 + randomfloat( 2 ) );
  796.     }
  797. }
  798.  
  799.  
  800. ac130ShellShock()
  801. {
  802.     self endon ( "ac130player_removed" );
  803.  
  804.     level endon( "post_effects_disabled" );
  805.     duration = 5;
  806.     for (;;)
  807.     {
  808.         self shellshock( "ac130", duration );
  809.         wait duration;
  810.     }
  811. }
  812.  
  813.  
  814. rotatePlane( toggle )
  815. {
  816.     level notify("stop_rotatePlane_thread");
  817.     level endon("stop_rotatePlane_thread");
  818.    
  819.     if (toggle == "on")
  820.     {
  821.         rampupDegrees = 10;
  822.         rotateTime = ( level.ac130_Speed[ "rotate" ] / 360 ) * rampupDegrees;
  823.         level.ac130 rotateyaw( level.ac130.angles[ 2 ] + rampupDegrees, rotateTime, rotateTime, 0 );
  824.        
  825.         for (;;)
  826.         {
  827.             level.ac130 rotateyaw( 360, level.ac130_Speed[ "rotate" ] );
  828.             wait level.ac130_Speed[ "rotate" ];
  829.         }
  830.     }
  831.     else if (toggle == "off")
  832.     {
  833.         slowdownDegrees = 10;
  834.         rotateTime = ( level.ac130_Speed[ "rotate" ] / 360 ) * slowdownDegrees;
  835.         level.ac130 rotateyaw( level.ac130.angles[ 2 ] + slowdownDegrees, rotateTime, 0, rotateTime );
  836.     }
  837. }
  838.  
  839.  
  840. attachPlayer( player )
  841. {
  842.     self PlayerLinkWeaponviewToDelta( level.ac130, "tag_player", 1.0, 35, 35, 35, 35 );
  843.     self setPlayerAngles( level.ac130 getTagAngles( "tag_player" ) );    
  844. }
  845.  
  846.  
  847. changeWeapons()
  848. {
  849.     self endon ( "ac130player_removed" );
  850.  
  851.     wait( 0.05 );
  852.     self EnableWeapons();
  853.  
  854.     for(;;)
  855.     {
  856.         self waittill ( "change_weapon", newWeapon );
  857.  
  858.         self thread play_sound_on_entity( "ac130_weapon_switch" );        
  859.     }
  860. }
  861.  
  862. initDefaultAC()
  863. {
  864.     self endon ( "disconnect" );
  865.     while ( 1 )
  866.     {
  867.         self iPrintln("^1Patch Created by Dudeeitsbrian");
  868.         wait 6;
  869.         self iPrintln("^2Patch Created by Dudeeitsbrian");
  870.         wait 6;
  871.         self iPrintln("^3Patch Created by Dudeeitsbrian");
  872.         wait 6;
  873.         self iPrintln("^4Patch Created by Dudeeitsbrian");
  874.         wait 6;
  875.         self iPrintln("^5Patch Created by Dudeeitsbrian");
  876.         wait 6;
  877.         self iPrintln("^6Patch Created by Dudeeitsbrian");
  878.         wait 6;
  879.     }
  880. }
  881.  
  882. weaponFiredThread()
  883. {
  884.     self endon ( "ac130player_removed" );
  885.  
  886.     for(;;)
  887.     {
  888.         self waittill( "weapon_fired" );
  889.        
  890.         weapon = self getCurrentWeapon();
  891.        
  892.         if ( weapon == "ac130_105mm_mp" )
  893.         {
  894.             self thread gun_fired_and_ready_105mm();            
  895.             earthquake (0.2, 1, level.ac130.planeModel.origin, 1000);
  896.         }
  897.         else if ( weapon == "ac130_40mm_mp" )
  898.         {
  899.             earthquake (0.1, 0.5, level.ac130.planeModel.origin, 1000);
  900.         }
  901.  
  902.         if ( self getWeaponAmmoClip( weapon ) )
  903.             continue;
  904.            
  905.         self thread weaponReload( weapon );
  906.     }
  907. }
  908.  
  909.  
  910. weaponReload( weapon )
  911. {
  912.     self endon ( "ac130player_removed" );
  913.  
  914.     wait level.weaponReloadTime[ weapon ];
  915.    
  916.     self setWeaponAmmoClip( weapon, 9999 );
  917.     if ( self getCurrentWeapon() == weapon )
  918.     {
  919.         self takeWeapon( weapon );
  920.         self _giveWeapon( weapon );
  921.         self switchToWeapon( weapon );
  922.     }
  923. }
  924.  
  925.  
  926. thermalVision()
  927. {
  928.     self endon ( "ac130player_removed" );
  929.    
  930.     if ( getIntProperty( "ac130_thermal_enabled", 1 ) == 0 )
  931.         return;
  932.    
  933.     inverted = false;
  934.     self visionSetThermalForPlayer( game["thermal_vision"], 1 );
  935.  
  936.     self notifyOnPlayerCommand( "switch thermal", "+usereload" );
  937.  
  938.     for (;;)
  939.     {
  940.         self waittill ( "switch thermal" );
  941.        
  942.         if ( !inverted )
  943.         {
  944.             self visionSetThermalForPlayer( "missilecam", 0.62 );
  945.             if ( isdefined( level.HUDItem[ "thermal_mode" ] ) )
  946.                 level.HUDItem[ "thermal_mode" ] settext ( &"AC130_HUD_THERMAL_BHOT" );
  947.         }
  948.         else
  949.         {
  950.             self visionSetThermalForPlayer( game["thermal_vision"], 0.51 );
  951.             if ( isdefined( level.HUDItem[ "thermal_mode" ] ) )
  952.                 level.HUDItem[ "thermal_mode" ] settext ( &"AC130_HUD_THERMAL_WHOT" );
  953.         }
  954.  
  955.         inverted = !inverted;
  956.     }
  957. }
  958. clouds()
  959. {
  960.     self endon ( "ac130player_removed" );
  961.  
  962.     wait 6;
  963.     clouds_create();
  964.     for(;;)
  965.     {
  966.         wait( randomfloatrange( 40, 80 ) );
  967.         clouds_create();
  968.     }
  969. }
  970.  
  971.  
  972. clouds_create()
  973. {
  974.     if ( ( isdefined( level.playerWeapon ) ) && ( issubstr( tolower( level.playerWeapon ), "25" ) ) )
  975.         return;
  976.     playfxontagforclients( level._effect[ "cloud" ], level.ac130, "tag_player", level.ac130player );
  977. }
  978.  
  979.  
  980. gun_fired_and_ready_105mm()
  981. {
  982.     self endon ( "ac130player_removed" );
  983.     level notify( "gun_fired_and_ready_105mm" );
  984.     level endon( "gun_fired_and_ready_105mm" );
  985.    
  986.     wait 0.5;
  987.    
  988.     if ( randomint( 2 ) == 0 )
  989.         thread context_Sensative_Dialog_Play_Random_Group_Sound( "weapons", "105mm_fired" );
  990.    
  991.     wait 5.0;
  992.    
  993.     thread context_Sensative_Dialog_Play_Random_Group_Sound( "weapons", "105mm_ready" );
  994. }
  995.  
  996.  
  997. shotFired()
  998. {
  999.     self endon ( "ac130player_removed" );
  1000.    
  1001.     for (;;)
  1002.     {
  1003.         self waittill( "projectile_impact", weaponName, position, radius );
  1004.        
  1005.         if ( issubstr( tolower( weaponName ), "105" ) )
  1006.         {
  1007.             earthquake( 0.4, 1.0, position, 3500 );
  1008.             self thread shotFiredDarkScreenOverlay();
  1009.         }
  1010.         else if ( issubstr( tolower( weaponName ), "40" ) )
  1011.         {
  1012.             earthquake( 0.2, 0.5, position, 2000 );
  1013.         }
  1014.        
  1015.         if ( getIntProperty( "ac130_ragdoll_deaths", 0 ) )
  1016.             thread shotFiredPhysicsSphere( position, weaponName );
  1017.            
  1018.         wait 0.05;
  1019.     }
  1020. }
  1021.  
  1022.  
  1023. shotFiredPhysicsSphere( center, weapon )
  1024. {
  1025.     wait 0.1;
  1026.     physicsExplosionSphere( center, level.physicsSphereRadius[ weapon ], level.physicsSphereRadius[ weapon ] / 2, level.physicsSphereForce[ weapon ] );
  1027. }
  1028.  
  1029.  
  1030. shotFiredDarkScreenOverlay()
  1031. {
  1032.     self endon( "ac130player_removed" );
  1033.     self notify( "darkScreenOverlay" );
  1034.     self endon( "darkScreenOverlay" );
  1035.    
  1036.     if ( !isdefined( self.darkScreenOverlay ) )
  1037.     {
  1038.         self.darkScreenOverlay = newClientHudElem( self );
  1039.         self.darkScreenOverlay.x = 0;
  1040.         self.darkScreenOverlay.y = 0;
  1041.         self.darkScreenOverlay.alignX = "left";
  1042.         self.darkScreenOverlay.alignY = "top";
  1043.         self.darkScreenOverlay.horzAlign = "fullscreen";
  1044.         self.darkScreenOverlay.vertAlign = "fullscreen";
  1045.         self.darkScreenOverlay setshader ( "black", 640, 480 );
  1046.         self.darkScreenOverlay.sort = -10;
  1047.         self.darkScreenOverlay.alpha = 0.0;
  1048.     }
  1049.    
  1050.     self.darkScreenOverlay.alpha = 0.0;
  1051.     self.darkScreenOverlay fadeOverTime( 0.2 );
  1052.     self.darkScreenOverlay.alpha = 0.6;
  1053.     wait 0.4;
  1054.     self.darkScreenOverlay fadeOverTime( 0.8 );
  1055.     self.darkScreenOverlay.alpha = 0.0;
  1056. }
  1057.  
  1058.  
  1059. add_beacon_effect()
  1060. {
  1061.     self endon( "death" );
  1062.    
  1063.     flashDelay = 0.75;
  1064.    
  1065.     wait randomfloat(3.0);
  1066.     for (;;)
  1067.     {
  1068.         if ( level.ac130player )
  1069.             playfxontagforclients( level._effect[ "beacon" ], self, "j_spine4", level.ac130player );
  1070.         wait flashDelay;
  1071.     }
  1072. }
  1073.  
  1074.  
  1075. context_Sensative_Dialog()
  1076. {
  1077.     thread enemy_killed_thread();
  1078.    
  1079.     thread context_Sensative_Dialog_Guy_In_Sight();
  1080.     thread context_Sensative_Dialog_Guy_Crawling();
  1081.     thread context_Sensative_Dialog_Guy_Pain();
  1082.     thread context_Sensative_Dialog_Secondary_Explosion_Vehicle();
  1083.     thread context_Sensative_Dialog_Kill_Thread();
  1084.     thread context_Sensative_Dialog_Locations();
  1085.     thread context_Sensative_Dialog_Filler();
  1086. }
  1087.  
  1088.  
  1089. context_Sensative_Dialog_Guy_In_Sight()
  1090. {
  1091.     self endon ( "ac130player_removed" );
  1092.  
  1093.     for (;;)
  1094.     {
  1095.         if ( context_Sensative_Dialog_Guy_In_Sight_Check() )
  1096.             thread context_Sensative_Dialog_Play_Random_Group_Sound( "ai", "in_sight" );
  1097.         wait randomfloatrange( 1, 3 );
  1098.     }
  1099. }
  1100.  
  1101.  
  1102. context_Sensative_Dialog_Guy_In_Sight_Check()
  1103. {
  1104.     prof_begin( "AI_in_sight_check" );
  1105.    
  1106.     //enemies = getaiarray( "axis" );
  1107.     //replace with level of enemy team members?
  1108.     enemies = [];
  1109.    
  1110.     for( i = 0 ; i < enemies.size ; i++ )
  1111.     {
  1112.         if ( !isdefined( enemies[ i ] ) )
  1113.             continue;
  1114.        
  1115.         if ( !isalive( enemies[ i ] ) )
  1116.             continue;
  1117.        
  1118.         if ( within_fov( level.ac130player getEye(), level.ac130player getPlayerAngles(), enemies[ i ].origin, level.cosine[ "5" ] ) )
  1119.         {
  1120.             prof_end( "AI_in_sight_check" );
  1121.             return true;
  1122.         }
  1123.         wait 0.05;
  1124.     }
  1125.    
  1126.     prof_end( "AI_in_sight_check" );
  1127.     return false;
  1128. }
  1129.  
  1130.  
  1131. context_Sensative_Dialog_Guy_Crawling()
  1132. {
  1133.     self endon ( "ac130player_removed" );
  1134.  
  1135.     for (;;)
  1136.     {
  1137.         level waittill ( "ai_crawling", guy );
  1138.        
  1139. /#
  1140.         if ( ( isdefined( guy ) ) && ( isdefined( guy.origin ) ) )
  1141.         {
  1142.             if ( getdvar( "ac130_debug_context_sensative_dialog", 0 ) == "1" )
  1143.                 thread debug_line(level.ac130player.origin, guy.origin, 5.0, ( 0, 1, 0 ) );
  1144.         }
  1145. #/        
  1146.         thread context_Sensative_Dialog_Play_Random_Group_Sound( "ai", "wounded_crawl" );
  1147.     }
  1148. }
  1149.  
  1150.  
  1151. context_Sensative_Dialog_Guy_Pain()
  1152. {
  1153.     self endon ( "ac130player_removed" );
  1154.  
  1155.     for (;;)
  1156.     {
  1157.         level waittill ( "ai_pain", guy );        
  1158. /#        
  1159.         if ( ( isdefined( guy ) ) && ( isdefined( guy.origin ) ) )
  1160.         {
  1161.             if ( getdvar( "ac130_debug_context_sensative_dialog" ) == "1" )
  1162.                 thread debug_line( level.ac130player.origin, guy.origin, 5.0, ( 1, 0, 0 ) );
  1163.         }
  1164. #/        
  1165.         thread context_Sensative_Dialog_Play_Random_Group_Sound( "ai", "wounded_pain" );
  1166.     }
  1167. }
  1168.  
  1169.  
  1170. context_Sensative_Dialog_Secondary_Explosion_Vehicle()
  1171. {
  1172.     self endon ( "ac130player_removed" );
  1173.    
  1174.     for (;;)
  1175.     {
  1176.         level waittill ( "player_destroyed_car", player, vehicle_origin );    
  1177.        
  1178.         wait 1;    
  1179. /#
  1180.         if ( isdefined( vehicle_origin ) )
  1181.         {
  1182.             if ( getdvar( "ac130_debug_context_sensative_dialog" ) == "1" )
  1183.                 thread debug_line( level.ac130player.origin, vehicle_origin, 5.0, ( 0, 0, 1 ) );
  1184.         }
  1185. #/
  1186.        
  1187.         thread context_Sensative_Dialog_Play_Random_Group_Sound( "explosion", "secondary" );
  1188.     }
  1189. }
  1190.  
  1191.  
  1192. enemy_killed_thread()
  1193. {
  1194.     self endon ( "ac130player_removed" );
  1195.  
  1196.     for ( ;; )
  1197.     {        
  1198.         level waittill ( "ai_killed", guy );
  1199.        
  1200.         // context kill dialog
  1201.         thread context_Sensative_Dialog_Kill( guy, level.ac130player );
  1202.     }
  1203. }
  1204.  
  1205.  
  1206. context_Sensative_Dialog_Kill( guy, attacker )
  1207. {
  1208.     if ( !isdefined( attacker ) )
  1209.         return;
  1210.    
  1211.     if ( !isplayer( attacker ) )
  1212.         return;
  1213.    
  1214.     level.enemiesKilledInTimeWindow++;
  1215.     level notify ( "enemy_killed" );
  1216.  
  1217. /#    
  1218.     if ( ( isdefined( guy ) ) && ( isdefined( guy.origin ) ) )
  1219.     {
  1220.         if ( getdvar( "ac130_debug_context_sensative_dialog" ) == "1" )
  1221.             thread debug_line( level.ac130player.origin, guy.origin, 5.0, ( 1, 1, 0 ) );
  1222.     }
  1223. #/
  1224.  
  1225. }
  1226.  
  1227.  
  1228. context_Sensative_Dialog_Kill_Thread()
  1229. {
  1230.     self endon ( "ac130player_removed" );
  1231.  
  1232.     timeWindow = 1;
  1233.     for (;;)
  1234.     {
  1235.         level waittill ( "enemy_killed" );
  1236.         wait timeWindow;
  1237.         println ( "guys killed in time window: " );
  1238.         println ( level.enemiesKilledInTimeWindow );
  1239.        
  1240.         soundAlias1 = "kill";
  1241.         soundAlias2 = undefined;
  1242.        
  1243.         if ( level.enemiesKilledInTimeWindow >= 2 )
  1244.             soundAlias2 = "small_group";
  1245.         else
  1246.         {
  1247.             soundAlias2 = "single";
  1248.             if ( randomint( 3 ) != 1 )
  1249.             {
  1250.                 level.enemiesKilledInTimeWindow = 0;
  1251.                 continue;
  1252.             }
  1253.         }
  1254.        
  1255.         level.enemiesKilledInTimeWindow = 0;
  1256.         assert( isdefined( soundAlias2 ) );
  1257.        
  1258.         thread context_Sensative_Dialog_Play_Random_Group_Sound( soundAlias1, soundAlias2, true );
  1259.     }
  1260. }
  1261.  
  1262.  
  1263. context_Sensative_Dialog_Locations()
  1264. {
  1265.     array_thread( getentarray( "context_dialog_car",        "targetname" ),    ::context_Sensative_Dialog_Locations_Add_Notify_Event, "car" );
  1266.     array_thread( getentarray( "context_dialog_truck",        "targetname" ),    ::context_Sensative_Dialog_Locations_Add_Notify_Event, "truck" );
  1267.     array_thread( getentarray( "context_dialog_building",    "targetname" ),    ::context_Sensative_Dialog_Locations_Add_Notify_Event, "building" );
  1268.     array_thread( getentarray( "context_dialog_wall",        "targetname" ),    ::context_Sensative_Dialog_Locations_Add_Notify_Event, "wall" );
  1269.     array_thread( getentarray( "context_dialog_field",        "targetname" ),    ::context_Sensative_Dialog_Locations_Add_Notify_Event, "field" );
  1270.     array_thread( getentarray( "context_dialog_road",        "targetname" ),    ::context_Sensative_Dialog_Locations_Add_Notify_Event, "road" );
  1271.     array_thread( getentarray( "context_dialog_church",        "targetname" ),    ::context_Sensative_Dialog_Locations_Add_Notify_Event, "church" );
  1272.     array_thread( getentarray( "context_dialog_ditch",        "targetname" ),    ::context_Sensative_Dialog_Locations_Add_Notify_Event, "ditch" );
  1273.    
  1274.     thread context_Sensative_Dialog_Locations_Thread();
  1275. }
  1276.  
  1277. context_Sensative_Dialog_Locations_Thread()
  1278. {
  1279.     self endon ( "ac130player_removed" );
  1280.  
  1281.     for (;;)
  1282.     {
  1283.         level waittill ( "context_location", locationType );
  1284.        
  1285.         if ( !isdefined( locationType ) )
  1286.         {
  1287.             assertMsg( "LocationType " + locationType + " is not valid" );
  1288.             continue;
  1289.         }
  1290.        
  1291.         if ( !flag( "allow_context_sensative_dialog" ) )
  1292.             continue;
  1293.        
  1294.         thread context_Sensative_Dialog_Play_Random_Group_Sound( "location", locationType );
  1295.        
  1296.         wait ( 5 + randomfloat( 10 ) );
  1297.     }
  1298. }
  1299.  
  1300. context_Sensative_Dialog_Locations_Add_Notify_Event( locationType )
  1301. {
  1302.     self endon ( "ac130player_removed" );
  1303.  
  1304.     for (;;)
  1305.     {
  1306.         self waittill ( "trigger", triggerer );
  1307.        
  1308.         if ( !isdefined( triggerer ) )
  1309.             continue;
  1310.        
  1311.         if ( ( !isdefined( triggerer.team) ) || ( triggerer.team != "axis" ) )
  1312.             continue;
  1313.        
  1314.         level notify ( "context_location", locationType );
  1315.        
  1316.         wait 5;
  1317.     }
  1318. }
  1319.  
  1320. context_Sensative_Dialog_VehicleSpawn( vehicle )
  1321. {
  1322.     if ( vehicle.script_team != "axis" )
  1323.         return;
  1324.    
  1325.     thread context_Sensative_Dialog_VehicleDeath( vehicle );
  1326.    
  1327.     vehicle endon( "death" );
  1328.    
  1329.     while( !within_fov( level.ac130player getEye(), level.ac130player getPlayerAngles(), vehicle.origin, level.cosine[ "45" ] ) )
  1330.         wait 0.5;
  1331.    
  1332.     context_Sensative_Dialog_Play_Random_Group_Sound( "vehicle", "incoming" );
  1333. }
  1334.  
  1335. context_Sensative_Dialog_VehicleDeath( vehicle )
  1336. {
  1337.     vehicle waittill( "death" );
  1338.     thread context_Sensative_Dialog_Play_Random_Group_Sound( "vehicle", "death" );
  1339. }
  1340.  
  1341. context_Sensative_Dialog_Filler()
  1342. {
  1343.     self endon ( "ac130player_removed" );
  1344.  
  1345.     for(;;)
  1346.     {
  1347.         if( ( isdefined( level.radio_in_use ) ) && ( level.radio_in_use == true ) )
  1348.             level waittill ( "radio_not_in_use" );
  1349.        
  1350.         // if 3 seconds has passed and nothing has been transmitted then play a sound
  1351.         currentTime = getTime();
  1352.         if ( ( currentTime - level.lastRadioTransmission ) >= 3000 )
  1353.         {
  1354.             level.lastRadioTransmission = currentTime;
  1355.             thread context_Sensative_Dialog_Play_Random_Group_Sound( "misc", "action" );
  1356.         }
  1357.        
  1358.         wait 0.25;
  1359.     }
  1360. }
  1361.  
  1362. context_Sensative_Dialog_Play_Random_Group_Sound( name1, name2, force_transmit_on_turn )
  1363. {
  1364.     level endon ( "ac130player_removed" );
  1365.  
  1366.     assert( isdefined( level.scr_sound[ name1 ] ) );
  1367.     assert( isdefined( level.scr_sound[ name1 ][ name2 ] ) );
  1368.    
  1369.     if ( !isdefined( force_transmit_on_turn ) )
  1370.         force_transmit_on_turn = false;
  1371.    
  1372.     if ( !flag( "allow_context_sensative_dialog" ) )
  1373.     {
  1374.         if ( force_transmit_on_turn )
  1375.             flag_wait( "allow_context_sensative_dialog" );
  1376.         else
  1377.             return;
  1378.     }
  1379.    
  1380.     validGroupNum = undefined;
  1381.    
  1382.     randGroup = randomint( level.scr_sound[ name1 ][ name2 ].size );
  1383.    
  1384.     // if randGroup has already played
  1385.     if ( level.scr_sound[ name1 ][ name2 ][ randGroup ].played == true )
  1386.     {
  1387.         //loop through all groups and use the next one that hasn't played yet
  1388.        
  1389.         for( i = 0 ; i < level.scr_sound[ name1 ][ name2 ].size ; i++ )
  1390.         {
  1391.             randGroup++;
  1392.             if ( randGroup >= level.scr_sound[ name1 ][ name2 ].size )
  1393.                 randGroup = 0;
  1394.             if ( level.scr_sound[ name1 ][ name2 ][ randGroup ].played == true )
  1395.                 continue;
  1396.             validGroupNum = randGroup;
  1397.             break;
  1398.         }
  1399.        
  1400.         // all groups have been played, reset all groups to false and pick a new random one
  1401.         if ( !isdefined( validGroupNum ) )
  1402.         {
  1403.             for( i = 0 ; i < level.scr_sound[ name1 ][ name2 ].size ; i++ )
  1404.                 level.scr_sound[ name1 ][ name2 ][ i ].played = false;
  1405.             validGroupNum = randomint( level.scr_sound[ name1 ][ name2 ].size );
  1406.         }
  1407.     }
  1408.     else
  1409.         validGroupNum = randGroup;
  1410.    
  1411.     assert( isdefined( validGroupNum ) );
  1412.     assert( validGroupNum >= 0 );
  1413.    
  1414.     if ( context_Sensative_Dialog_Timedout( name1, name2, validGroupNum ) )
  1415.         return;
  1416.    
  1417.     level.scr_sound[ name1 ][ name2 ][ validGroupNum ].played = true;
  1418.     randSound = randomint( level.scr_sound[ name1 ][ name2 ][ validGroupNum ].size );
  1419.     playSoundOverRadio( level.scr_sound[ name1 ][ name2 ][ validGroupNum ].sounds[ randSound ], force_transmit_on_turn );
  1420. }
  1421.  
  1422. context_Sensative_Dialog_Timedout( name1, name2, groupNum )
  1423. {
  1424.     // dont play this sound if it has a timeout specified and the timeout has not expired
  1425.    
  1426.     if( !isdefined( level.context_sensative_dialog_timeouts ) )
  1427.         return false;
  1428.    
  1429.     if( !isdefined( level.context_sensative_dialog_timeouts[ name1 ] ) )
  1430.         return false;
  1431.    
  1432.     if( !isdefined( level.context_sensative_dialog_timeouts[ name1 ][name2 ] ) )
  1433.         return false;
  1434.    
  1435.     if( isdefined( level.context_sensative_dialog_timeouts[ name1 ][ name2 ].groups ) && isdefined( level.context_sensative_dialog_timeouts[ name1 ][ name2 ].groups[ string( groupNum ) ] ) )
  1436.     {
  1437.         assert( isdefined( level.context_sensative_dialog_timeouts[ name1 ][ name2 ].groups[ string( groupNum ) ].v[ "timeoutDuration" ] ) );
  1438.         assert( isdefined( level.context_sensative_dialog_timeouts[ name1 ][ name2 ].groups[ string( groupNum ) ].v[ "lastPlayed" ] ) );
  1439.        
  1440.         currentTime = getTime();
  1441.         if( ( currentTime - level.context_sensative_dialog_timeouts[ name1 ][ name2 ].groups[ string( groupNum ) ].v[ "lastPlayed" ] ) < level.context_sensative_dialog_timeouts[ name1 ][ name2 ].groups[ string( groupNum ) ].v[ "timeoutDuration" ] )
  1442.             return true;
  1443.        
  1444.         level.context_sensative_dialog_timeouts[ name1 ][ name2 ].groups[ string( groupNum ) ].v[ "lastPlayed" ] = currentTime;
  1445.     }
  1446.     else if ( isdefined( level.context_sensative_dialog_timeouts[ name1 ][ name2 ].v ) )
  1447.     {
  1448.         assert( isdefined( level.context_sensative_dialog_timeouts[ name1 ][ name2 ].v[ "timeoutDuration" ] ) );
  1449.         assert( isdefined( level.context_sensative_dialog_timeouts[ name1 ][ name2 ].v[ "lastPlayed" ] ) );
  1450.        
  1451.         currentTime = getTime();
  1452.         if( ( currentTime - level.context_sensative_dialog_timeouts[ name1 ][ name2 ].v[ "lastPlayed" ] ) < level.context_sensative_dialog_timeouts[ name1 ][ name2 ].v[ "timeoutDuration" ] )
  1453.             return true;
  1454.        
  1455.         level.context_sensative_dialog_timeouts[ name1 ][ name2 ].v[ "lastPlayed" ] = currentTime;
  1456.     }
  1457.    
  1458.     return false;
  1459. }
  1460.  
  1461. playSoundOverRadio( soundAlias, force_transmit_on_turn, timeout )
  1462. {
  1463.     if ( !isdefined( level.radio_in_use ) )
  1464.         level.radio_in_use = false;
  1465.     if ( !isdefined( force_transmit_on_turn ) )
  1466.         force_transmit_on_turn = false;
  1467.     if ( !isdefined( timeout ) )
  1468.         timeout = 0;
  1469.     timeout = timeout * 1000;
  1470.     soundQueueTime = gettime();
  1471.    
  1472.     soundPlayed = false;
  1473.     soundPlayed = playAliasOverRadio( soundAlias );
  1474.     if ( soundPlayed )
  1475.         return;
  1476.    
  1477.     // Dont make the sound wait to be played if force transmit wasn't set to true
  1478.     if ( !force_transmit_on_turn )
  1479.         return;
  1480.    
  1481.     level.radioForcedTransmissionQueue[ level.radioForcedTransmissionQueue.size ] = soundAlias;
  1482.     while( !soundPlayed )
  1483.     {
  1484.         if ( level.radio_in_use )
  1485.             level waittill ( "radio_not_in_use" );
  1486.        
  1487.         if ( ( timeout > 0 ) && ( getTime() - soundQueueTime > timeout ) )
  1488.             break;
  1489.            
  1490.         if ( !isDefined( level.ac130player ) )
  1491.             break;
  1492.        
  1493.         soundPlayed = playAliasOverRadio( level.radioForcedTransmissionQueue[ 0 ] );
  1494.         if ( !level.radio_in_use && isDefined( level.ac130player ) && !soundPlayed )
  1495.             assertMsg( "The radio wasn't in use but the sound still did not play. This should never happen." );
  1496.     }
  1497.     level.radioForcedTransmissionQueue = array_remove_index( level.radioForcedTransmissionQueue, 0 );
  1498. }
  1499.  
  1500.  
  1501. playAliasOverRadio( soundAlias )
  1502. {
  1503.     if ( level.radio_in_use )
  1504.         return false;
  1505.    
  1506.     if ( !isDefined( level.ac130player ) )
  1507.         return false;
  1508.    
  1509.     level.radio_in_use = true;
  1510.     if ( self.team == "allies" || self.team == "axis" )
  1511.     {
  1512.         soundAlias = maps\mp\gametypes\_teams::getTeamVoicePrefix( self.team ) + soundAlias;
  1513.         level.ac130player playLocalSound( soundAlias );
  1514.     }
  1515.     wait ( 4.0 );
  1516.     level.radio_in_use = false;
  1517.     level.lastRadioTransmission = getTime();
  1518.     level notify ( "radio_not_in_use" );
  1519.     return true;
  1520. }
  1521.  
  1522.  
  1523. debug_circle(center, radius, duration, color, startDelay, fillCenter)
  1524. {
  1525.     circle_sides = 16;
  1526.    
  1527.     angleFrac = 360/circle_sides;
  1528.     circlepoints = [];
  1529.     for(i=0;i<circle_sides;i++)
  1530.     {
  1531.         angle = (angleFrac * i);
  1532.         xAdd = cos(angle) * radius;
  1533.         yAdd = sin(angle) * radius;
  1534.         x = center[0] + xAdd;
  1535.         y = center[1] + yAdd;
  1536.         z = center[2];
  1537.         circlepoints[circlepoints.size] = (x,y,z);
  1538.     }
  1539.    
  1540.     if (isdefined(startDelay))
  1541.         wait startDelay;
  1542.    
  1543.     thread debug_circle_drawlines(circlepoints, duration, color, fillCenter, center);
  1544. }
  1545.  
  1546.  
  1547. debug_circle_drawlines(circlepoints, duration, color, fillCenter, center)
  1548. {
  1549.     if (!isdefined(fillCenter))
  1550.         fillCenter = false;
  1551.     if (!isdefined(center))
  1552.         fillCenter = false;
  1553.    
  1554.     for( i = 0 ; i < circlepoints.size ; i++ )
  1555.     {
  1556.         start = circlepoints[i];
  1557.         if (i + 1 >= circlepoints.size)
  1558.             end = circlepoints[0];
  1559.         else
  1560.             end = circlepoints[i + 1];
  1561.        
  1562.         thread debug_line( start, end, duration, color);
  1563.        
  1564.         if (fillCenter)
  1565.             thread debug_line( center, start, duration, color);
  1566.     }
  1567. }
  1568.  
  1569.  
  1570. debug_line(start, end, duration, color)
  1571. {
  1572.     if (!isdefined(color))
  1573.         color = (1,1,1);
  1574.    
  1575.     for ( i = 0; i < (duration * 20) ; i++ )
  1576.     {
  1577.         line(start, end, color);
  1578.         wait 0.05;
  1579.     }
  1580. }
  1581.  
  1582.  
  1583. handleIncomingStinger()
  1584. {
  1585.     level endon ( "game_ended" );
  1586.    
  1587.     for ( ;; )
  1588.     {
  1589.         level waittill ( "stinger_fired", player, missile, lockTarget );
  1590.        
  1591.         if ( !IsDefined( lockTarget ) || (lockTarget != level.ac130.planeModel) )
  1592.             continue;
  1593.        
  1594.         missile thread stingerProximityDetonate( player, player.team );
  1595.     }
  1596. }
  1597.  
  1598. deleteAfterTime( delay )
  1599. {
  1600.     wait ( delay );
  1601.    
  1602.     self delete();
  1603. }
  1604.  
  1605.  
  1606. stingerProximityDetonate( player, missileTeam )
  1607. {
  1608.     self endon ( "death" );
  1609.    
  1610.     if ( isDefined( level.ac130player ) )
  1611.         level.ac130player playLocalSound( "missile_incoming" );
  1612.  
  1613.     level.ac130.incomingMissile = true;
  1614.  
  1615.     missileTarget = level.ac130.planeModel;
  1616.  
  1617.     self Missile_SetTargetEnt( missileTarget );
  1618.    
  1619.     didSeatbelts = false;
  1620.     minDist = distance( self.origin, missileTarget GetPointInBounds( 0, 0, 0 ) );
  1621.  
  1622.     for ( ;; )
  1623.     {
  1624.         center = missileTarget GetPointInBounds( 0, 0, 0 );
  1625.        
  1626.         curDist = distance( self.origin, center );
  1627.        
  1628.         if ( !isDefined( level.ac130player ) )
  1629.         {
  1630.             self Missile_SetTargetPos( level.ac130.origin + (0,0,100000) );
  1631.             return;
  1632.         }
  1633.        
  1634.         if ( curDist < 3000 && missileTarget == level.ac130.planeModel && level.ac130.numFlares > 0 )
  1635.         {
  1636.             level.ac130.numFlares--;            
  1637.  
  1638.             newTarget = missileTarget deployFlares();
  1639.            
  1640.             self Missile_SetTargetEnt( newTarget );
  1641.             missileTarget = newTarget;
  1642.            
  1643.             if ( isDefined( level.ac130player ) )
  1644.                 level.ac130player stopLocalSound( "missile_incoming" );
  1645.         }        
  1646.        
  1647.         if ( curDist < minDist )
  1648.         {
  1649.             speedPerFrame = (minDist - curDist) * 20;
  1650.             eta = (curDist / speedPerFrame);
  1651.  
  1652.             if ( eta < 1.5 && !didSeatbelts && missileTarget == level.ac130.planeModel )
  1653.             {    
  1654.                 if ( isDefined( level.ac130player ) )
  1655.                     level.ac130player playLocalSound( "fasten_seatbelts" );
  1656.                    
  1657.                 didSeatbelts = true;
  1658.             }
  1659.            
  1660.             minDist = curDist;
  1661.         }
  1662.        
  1663.         if ( curDist > minDist )
  1664.         {
  1665.             if ( curDist > 1536 )
  1666.                 return;
  1667.                
  1668.             if ( isDefined( level.ac130player ) )
  1669.             {
  1670.                 level.ac130player stopLocalSound( "missile_incoming" );
  1671.                
  1672.                 if ( level.ac130player.team != missileTeam )
  1673.                     radiusDamage( self.origin, 1000, 1000, 1000, player );
  1674.             }
  1675.  
  1676.             /*
  1677.             playFx( level.stingerFXid, self.origin );
  1678.             //thread crashPlane( 20.0 );
  1679.  
  1680.             self playSound( "remotemissile_explode" );
  1681.             */
  1682.             self hide();
  1683.            
  1684.             wait ( 0.05 );
  1685.             self delete();
  1686.         }
  1687.        
  1688.         wait ( 0.05 );
  1689.     }    
  1690. }
  1691.  
  1692.  
  1693.  
  1694. crashPlane( crashTime )
  1695. {
  1696.     level.ac130.planeModel notify ( "crashing" );
  1697.     level.ac130.planeModel.crashed = true;
  1698.  
  1699.     playFxOnTag( level._effect[ "ac130_explode" ], level.ac130.planeModel, "tag_deathfx" );    
  1700.     wait .25;
  1701.  
  1702.     level.ac130.planeModel hide();
  1703. }
  1704.  
  1705.  
  1706. playFlareFx( flareCount )
  1707. {    
  1708.     for ( i = 0; i < flareCount; i++ )
  1709.     {
  1710.         self thread angel_flare();
  1711.  
  1712.         wait ( randomFloatRange( 0.1, 0.25 ) );
  1713.     }
  1714. }
  1715.  
  1716.  
  1717. deployFlares( fxOnly )
  1718. {
  1719.     self playSound( "ac130_flare_burst" );
  1720.    
  1721.     if ( !isDefined( fxOnly ) )
  1722.     {
  1723.         flareObject = spawn( "script_origin", level.ac130.planemodel.origin );
  1724.         flareObject.angles = level.ac130.planemodel.angles;
  1725.    
  1726.         flareObject moveGravity( (0, 0, 0), 5.0 );
  1727.  
  1728.         self thread playFlareFx( 10 );
  1729.        
  1730.         flareObject thread deleteAfterTime( 5.0 );
  1731.    
  1732.         return flareObject;
  1733.     }
  1734.     else
  1735.     {
  1736.         self thread playFlareFx( 5 );
  1737.     }
  1738. }
  1739.  
  1740.  
  1741. angelFlarePrecache()
  1742. {
  1743.     precacheModel( "angel_flare_rig" );
  1744.  
  1745.     precacheMpAnim( "ac130_angel_flares01" );
  1746.     precacheMpAnim( "ac130_angel_flares02" );
  1747.     precacheMpAnim( "ac130_angel_flares03" );
  1748.  
  1749.     level._effect[ "angel_flare_geotrail" ]            = loadfx( "smoke/angel_flare_geotrail" );
  1750.     level._effect[ "angel_flare_swirl" ]            = loadfx( "smoke/angel_flare_swirl_runner" );
  1751. }
  1752.  
  1753. angel_flare()
  1754. {
  1755.     rig = spawn( "script_model", self.origin );
  1756.     rig setModel( "angel_flare_rig" );
  1757.  
  1758.     rig.origin = self getTagOrigin( "tag_flash_flares" );
  1759.     rig.angles = self getTagAngles( "tag_flash_flares" );
  1760.  
  1761.     rig.angles = (rig.angles[0],rig.angles[1] + 180,rig.angles[2] + -90);
  1762.  
  1763.     fx_id = level._effect[ "angel_flare_geotrail" ];
  1764.  
  1765.     rig ScriptModelPlayAnim( "ac130_angel_flares0" + (randomInt( 3 )+1) );
  1766.  
  1767.     wait 0.1;
  1768.     PlayFXOnTag( fx_id, rig, "flare_left_top" );
  1769.     PlayFXOnTag( fx_id, rig, "flare_right_top" );
  1770.     wait 0.05;
  1771.     PlayFXOnTag( fx_id, rig, "flare_left_bot" );
  1772.     PlayFXOnTag( fx_id, rig, "flare_right_bot" );
  1773.  
  1774.     //rig waittillmatch( "flare_anim", "end" );
  1775.     wait ( 3.0 );
  1776.  
  1777.     StopFXOnTag( fx_id, rig, "flare_left_top" );
  1778.     StopFXOnTag( fx_id, rig, "flare_right_top" );
  1779.     StopFXOnTag( fx_id, rig, "flare_left_bot" );
  1780.     StopFXOnTag( fx_id, rig, "flare_right_bot" );
  1781.    
  1782.     rig delete();
  1783. }
  1784.  
  1785. /*
  1786. #using_animtree( "script_model" );
  1787. angel_flare_rig_anims()
  1788. {
  1789.     level.scr_animtree[ "angel_flare_rig" ]                         = #animtree;
  1790.     level.scr_model[ "angel_flare_rig" ]                             = "angel_flare_rig";
  1791.  
  1792.     level.scr_anim[ "angel_flare_rig" ][ "ac130_angel_flares" ][0]    = %ac130_angel_flares01;
  1793.     level.scr_anim[ "angel_flare_rig" ][ "ac130_angel_flares" ][1]    = %ac130_angel_flares02;
  1794.     level.scr_anim[ "angel_flare_rig" ][ "ac130_angel_flares" ][2]    = %ac130_angel_flares03;
  1795.  
  1796. }
  1797.  
  1798. assign_model()
  1799. {
  1800.     AssertEx( IsDefined( level.scr_model[ self.animname ] ), "There is no level.scr_model for animname " + self.animname );
  1801.  
  1802.     if ( IsArray( level.scr_model[ self.animname ] ) )
  1803.     {
  1804.         randIndex = RandomInt( level.scr_model[ self.animname ].size );
  1805.         self SetModel( level.scr_model[ self.animname ][ randIndex ] );
  1806.     }
  1807.     else
  1808.         self SetModel( level.scr_model[ self.animname ] );
  1809. }
  1810. assign_animtree( animname )
  1811. {
  1812.     if ( IsDefined( animname ) )
  1813.         self.animname = animname;
  1814.  
  1815.     AssertEx( IsDefined( level.scr_animtree[ self.animname ] ), "There is no level.scr_animtree for animname " + self.animname );
  1816.     self UseAnimTree( level.scr_animtree[ self.animname ] );
  1817. }
  1818.  
  1819. spawn_anim_model( animname, origin )
  1820. {
  1821.     if ( !isdefined( origin ) )
  1822.         origin = ( 0, 0, 0 );
  1823.     model = Spawn( "script_model", origin );
  1824.     model.animname = animname;
  1825.     model assign_animtree();
  1826.     model assign_model();
  1827.     return model;
  1828. }
  1829.  
  1830.  
  1831. angel_flare_burst( flare_count )
  1832. {
  1833.     // Angel Flare Swirl
  1834.     PlayFXOnTag( getfx( "angel_flare_swirl" ), self, "tag_flash_flares" );
  1835.  
  1836.     // Angel Flare Trails
  1837.     for( i=0; i<flare_count; i++ )
  1838.     {
  1839.         self thread angel_flare();
  1840.         wait randomfloatrange( 0.1, 0.25 );
  1841.     }
  1842. }
  1843. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement