Guest User

_killstreaks.gsc

a guest
Jun 16th, 2013
148
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. **  Killstreaks HUD List Mod
  3. **
  4. **  "MADE BY Puffiamo | Steam: Puffiamo94"
  5. **
  6. **  shows killstreak icons above compass and kills to next reward
  7. **
  8. ** 
  9. **  changes by banz:
  10. **  - fixed issues in round based game types (resetting variables)
  11. **  - fixed various issues with hardline perk (when changing Hardline, after being spawned already (in SnD) etc. )
  12. **  - removed the resetting of self.pers["cur_kill_streak"] variable to keep killstreaks vanilla
  13. **  - fixed multi-kill bugs
  14. **  - hidden killstreak icons while perks are shown on spawn
  15. */
  16.  
  17. #include maps\mp\_utility;
  18. #include maps\mp\gametypes\_hud_util;
  19. #include common_scripts\utility;
  20.  
  21. KILLSTREAK_STRING_TABLE = "mp/killstreakTable.csv";
  22.  
  23. init()
  24. {
  25.     // &&1 Kill Streak!
  26.     precacheString( &"MP_KILLSTREAK_N" );
  27.     precacheString( &"MP_NUKE_ALREADY_INBOUND" );
  28.     precacheString( &"MP_UNAVILABLE_IN_LASTSTAND" );
  29.     precacheString( &"MP_UNAVAILABLE_WHEN_EMP" );
  30.     precacheString( &"MP_UNAVAILABLE_USING_TURRET" );
  31.     precacheString( &"MP_UNAVAILABLE_WHEN_INCAP" );
  32.     precacheString( &"MP_HELI_IN_QUEUE" );
  33.  
  34.     initKillstreakData();
  35.  
  36.     level.killstreakFuncs = [];
  37.     level.killstreakSetupFuncs = [];
  38.     level.killstreakWeapons = [];
  39.    
  40.     level.killStreakMod = 0;
  41.  
  42.     thread maps\mp\killstreaks\_ac130::init();
  43.     thread maps\mp\killstreaks\_remotemissile::init();
  44.     thread maps\mp\killstreaks\_uav::init();
  45.     thread maps\mp\killstreaks\_airstrike::init();
  46.     thread maps\mp\killstreaks\_airdrop::init();
  47.     thread maps\mp\killstreaks\_helicopter::init();
  48.     thread maps\mp\killstreaks\_autosentry::init();
  49.     thread maps\mp\killstreaks\_tank::init();
  50.     thread maps\mp\killstreaks\_emp::init();
  51.     thread maps\mp\killstreaks\_nuke::init();
  52.  
  53.     level.killstreakRoundDelay = getIntProperty( "scr_game_killstreakdelay", 8 );
  54.  
  55.     level thread onPlayerConnect();
  56. }
  57.  
  58.  
  59. initKillstreakData()
  60. {
  61.     for ( i = 1; true; i++ )
  62.     {
  63.         retVal = tableLookup( KILLSTREAK_STRING_TABLE, 0, i, 1 );
  64.         if ( !isDefined( retVal ) || retVal == "" )
  65.             break;
  66.  
  67.         streakRef = tableLookup( KILLSTREAK_STRING_TABLE, 0, i, 1 );
  68.         assert( streakRef != "" );
  69.  
  70.         streakUseHint = tableLookupIString( KILLSTREAK_STRING_TABLE, 0, i, 6 );
  71.         assert( streakUseHint != &"" );
  72.         precacheString( streakUseHint );
  73.  
  74.         streakEarnDialog = tableLookup( KILLSTREAK_STRING_TABLE, 0, i, 8 );
  75.         assert( streakEarnDialog != "" );
  76.         game[ "dialog" ][ streakRef ] = streakEarnDialog;
  77.  
  78.         streakAlliesUseDialog = tableLookup( KILLSTREAK_STRING_TABLE, 0, i, 9 );
  79.         assert( streakAlliesUseDialog != "" );
  80.         game[ "dialog" ][ "allies_friendly_" + streakRef + "_inbound" ] = "use_" + streakAlliesUseDialog;
  81.         game[ "dialog" ][ "allies_enemy_" + streakRef + "_inbound" ] = "enemy_" + streakAlliesUseDialog;
  82.  
  83.         streakAxisUseDialog = tableLookup( KILLSTREAK_STRING_TABLE, 0, i, 10 );
  84.         assert( streakAxisUseDialog != "" );
  85.         game[ "dialog" ][ "axis_friendly_" + streakRef + "_inbound" ] = "use_" + streakAxisUseDialog;
  86.         game[ "dialog" ][ "axis_enemy_" + streakRef + "_inbound" ] = "enemy_" + streakAxisUseDialog;
  87.  
  88.         streakWeapon = tableLookup( KILLSTREAK_STRING_TABLE, 0, i, 12 );
  89.         precacheItem( streakWeapon );
  90.  
  91.         streakPoints = int( tableLookup( KILLSTREAK_STRING_TABLE, 0, i, 13 ) );
  92.         assert( streakPoints != 0 );
  93.         maps\mp\gametypes\_rank::registerScoreInfo( "killstreak_" + streakRef, streakPoints );
  94.  
  95.         streakShader = tableLookup( KILLSTREAK_STRING_TABLE, 0, i, 14 );
  96.         precacheShader( streakShader );
  97.  
  98.         streakShader = tableLookup( KILLSTREAK_STRING_TABLE, 0, i, 15 );
  99.         if ( streakShader != "" )
  100.             precacheShader( streakShader );
  101.     }
  102. }
  103.  
  104.  
  105. onPlayerConnect()
  106. {
  107.     for ( ;; )
  108.     {
  109.         level waittill( "connected", player );
  110.        
  111.         if( !isDefined ( player.pers[ "killstreaks" ] ) )
  112.             player.pers[ "killstreaks" ] = [];
  113.  
  114.         if( !isDefined ( player.pers[ "kID" ] ) )
  115.             player.pers[ "kID" ] = 10;
  116.  
  117.         if( !isDefined ( player.pers[ "kIDs_valid" ] ) )
  118.             player.pers[ "kIDs_valid" ] = [];
  119.        
  120.         player.lifeId = 0;
  121.            
  122.         if ( isDefined( player.pers["deaths"] ) )
  123.             player.lifeId = player.pers["deaths"];
  124.            
  125.         if ( !isDefined( player.pers["hasKillstreak"] ) )
  126.             player.pers["hasKillstreak"] = player getPlayerData( "killstreaks", 0 );
  127.  
  128.         player VisionSetMissilecamForPlayer( game["thermal_vision"] );
  129.    
  130.         player thread onPlayerSpawned();
  131.         player thread onPlayerChangeKit();
  132.        
  133.         if( player.pers["hasKillstreak"] != "none" )
  134.             player showKillstreaksList( -11 );
  135.     }
  136. }
  137.  
  138.  
  139. onPlayerSpawned()
  140. {
  141.     self endon( "disconnect" );
  142.  
  143.     for ( ;; )
  144.     {
  145.         self waittill( "spawned_player" );
  146.         self thread killstreakUseWaiter();
  147.         self thread waitForChangeTeam();
  148.    
  149.         if( self.pers["hasKillstreak"] != "none" ) {
  150.             self thread monitorCurStreak( -11 );
  151.             self ksHudUpdate();
  152.         }
  153.        
  154.         //if( getIntProperty( "scr_showperksonspawn", 1 ) == 1 && game["state"] != "postgame" )
  155.         //  self thread hideForPerks();
  156.        
  157.         self giveOwnedKillstreakItem( true );
  158.     }
  159. }
  160.  
  161.  
  162.  
  163. onPlayerChangeKit()
  164. {
  165.     self endon( "disconnect" );
  166.    
  167.     for ( ;; )
  168.     {
  169.         self waittill( "changed_kit" );
  170.         self giveOwnedKillstreakItem();
  171.     }
  172. }
  173.  
  174.  
  175. waitForChangeTeam()
  176. {
  177.     self endon ( "disconnect" );
  178.    
  179.     self notify ( "waitForChangeTeam" );
  180.     self endon ( "waitForChangeTeam" );
  181.    
  182.     for ( ;; )
  183.     {
  184.         self waittill ( "joined_team" );
  185.         clearKillstreaks();
  186.     }
  187. }
  188.  
  189.  
  190. isRideKillstreak( streakName )
  191. {
  192.     switch( streakName )
  193.     {
  194.         case "helicopter_minigun":
  195.         case "helicopter_mk19":
  196.         case "ac130":
  197.         case "predator_missile":
  198.             return true;
  199.  
  200.         default:
  201.             return false;
  202.     }
  203. }
  204.  
  205. isCarryKillstreak( streakName )
  206. {
  207.     switch( streakName )
  208.     {
  209.         case "sentry":
  210.         case "sentry_gl":
  211.             return true;
  212.  
  213.         default:
  214.             return false;
  215.     }
  216. }
  217.  
  218.  
  219. deadlyKillstreak( streakName )
  220. {
  221.     switch ( streakName )
  222.     {
  223.         case "predator_missile":
  224.         case "precision_airstrike":
  225.         case "harrier_airstrike":
  226.         //case "helicopter":
  227.         //case "helicopter_flares":
  228.         case "stealth_airstrike":
  229.         //case "helicopter_minigun":
  230.         case "ac130":
  231.             return true;
  232.     }
  233.    
  234.     return false;
  235. }
  236.  
  237.  
  238. killstreakUsePressed()
  239. {
  240.     streakName = self.pers["killstreaks"][0].streakName;
  241.     lifeId = self.pers["killstreaks"][0].lifeId;
  242.     isEarned = self.pers["killstreaks"][0].earned;
  243.     awardXp = self.pers["killstreaks"][0].awardXp;
  244.     kID = self.pers["killstreaks"][0].kID;
  245.  
  246.     assert( isDefined( streakName ) );
  247.     assert( isDefined( level.killstreakFuncs[ streakName ] ) );
  248.  
  249.     if ( !self isOnGround() && ( isRideKillstreak( streakName ) || isCarryKillstreak( streakName ) ) )
  250.         return ( false );
  251.  
  252.     if ( self isUsingRemote() )
  253.         return ( false );
  254.  
  255.     if ( isDefined( self.selectingLocation ) )
  256.         return ( false );
  257.        
  258.     if ( deadlyKillstreak( streakName ) && level.killstreakRoundDelay && getGametypeNumLives() )
  259.     {
  260.         if ( level.gracePeriod - level.inGracePeriod < level.killstreakRoundDelay )
  261.         {
  262.             self iPrintLnBold( &"MP_UNAVAILABLE_FOR_N", (level.killstreakRoundDelay - (level.gracePeriod - level.inGracePeriod)) );
  263.             return ( false );
  264.         }
  265.     }
  266.  
  267.     if ( (level.teamBased && level.teamEMPed[self.team]) || (!level.teamBased && isDefined( level.empPlayer ) && level.empPlayer != self) )
  268.     {
  269.         self iPrintLnBold( &"MP_UNAVAILABLE_WHEN_EMP" );
  270.         return ( false );
  271.     }
  272.  
  273.     if ( self IsUsingTurret() && ( isRideKillstreak( streakName ) || isCarryKillstreak( streakName ) ) )
  274.     {
  275.         self iPrintLnBold( &"MP_UNAVAILABLE_USING_TURRET" );
  276.         return ( false );
  277.     }
  278.    
  279.     if ( isDefined( self.lastStand )  && isRideKillstreak( streakName ) )
  280.     {
  281.         self iPrintLnBold( &"MP_UNAVILABLE_IN_LASTSTAND" );
  282.         return ( false );
  283.     }
  284.    
  285.     if ( !self isWeaponEnabled() )
  286.         return ( false );
  287.  
  288.     if ( streakName == "airdrop" || streakName == "airdrop_sentry_minigun" || streakName == "airdrop_mega" )
  289.     {
  290.         if ( !self [[ level.killstreakFuncs[ streakName ] ]]( lifeId, kID ) )
  291.             return ( false );
  292.     }
  293.     else
  294.     {
  295.           if ( !self [[ level.killstreakFuncs[ streakName ] ]]( lifeId ) )
  296.               return ( false );
  297.     }
  298.    
  299.     self usedKillstreak( streakName, awardXp );
  300.     self shuffleKillStreaksFILO( streakName, kID );
  301.     self giveOwnedKillstreakItem();    
  302.  
  303.     return ( true );
  304. }
  305.  
  306.  
  307. //this overwrites killstreak at index 0 and decrements all other killstreaks (FCLS style)
  308. shuffleKillStreaksFILO( streakName, kID )
  309. {
  310.     self _setActionSlot( 4, "" );
  311.  
  312.     arraySize = self.pers["killstreaks"].size;
  313.  
  314.     streakIndex = -1;
  315.     for ( i = 0; i < arraySize; i++ )
  316.     {
  317.         if ( self.pers["killstreaks"][i].streakName != streakName )
  318.             continue;
  319.            
  320.         if ( isDefined( kID ) && self.pers["killstreaks"][i].kID != kID )
  321.             continue;
  322.            
  323.         streakIndex = i;
  324.         break;
  325.     }
  326.     assert( streakIndex >= 0 );
  327.  
  328.     self.pers["killstreaks"][streakIndex] = undefined;
  329.  
  330.     for( i = streakIndex + 1; i < arraySize; i++ ) 
  331.     {
  332.         if ( i == arraySize - 1 )
  333.         {  
  334.             self.pers["killstreaks"][i-1] = self.pers["killstreaks"][i];
  335.             self.pers["killstreaks"][i] = undefined;
  336.         }  
  337.         else
  338.         {
  339.             self.pers["killstreaks"][i-1] = self.pers["killstreaks"][i];
  340.         }  
  341.     }
  342. }
  343.  
  344.  
  345. usedKillstreak( streakName, awardXp )
  346. {
  347.     self playLocalSound( "weap_c4detpack_trigger_plr" );
  348.  
  349.     if ( awardXp )
  350.         self thread [[ level.onXPEvent ]]( "killstreak_" + streakName );
  351.  
  352.     self thread maps\mp\gametypes\_missions::useHardpoint( streakName );
  353.    
  354.     awardref = maps\mp\_awards::getKillstreakAwardRef( streakName );
  355.     if ( isDefined( awardref ) )
  356.         self thread incPlayerStat( awardref, 1 );
  357.  
  358.     team = self.team;
  359.  
  360.     if ( level.teamBased )
  361.     {
  362.         thread leaderDialog( team + "_friendly_" + streakName + "_inbound", team );
  363.        
  364.         if ( getKillstreakInformEnemy( streakName ) )
  365.             thread leaderDialog( team + "_enemy_" + streakName + "_inbound", level.otherTeam[ team ] );
  366.     }
  367.     else
  368.     {
  369.         self thread leaderDialogOnPlayer( team + "_friendly_" + streakName + "_inbound" );
  370.        
  371.         if ( getKillstreakInformEnemy( streakName ) )
  372.         {
  373.             excludeList[0] = self;
  374.             thread leaderDialog( team + "_enemy_" + streakName + "_inbound", undefined, undefined, excludeList );
  375.         }
  376.     }
  377. }
  378.  
  379.  
  380. clearKillstreaks()
  381. {
  382.     foreach ( index, streakStruct in self.pers["killstreaks"] )
  383.         self.pers["killstreaks"][index] = undefined;
  384. }
  385.  
  386. getFirstPrimaryWeapon()
  387. {
  388.     weaponsList = self getWeaponsListPrimaries();
  389.    
  390.     assert ( isDefined( weaponsList[0] ) );
  391.     assert ( !isKillstreakWeapon( weaponsList[0] ) );
  392.  
  393.     if ( weaponsList[0] == "onemanarmy_mp" )
  394.     {
  395.         assert ( isDefined( weaponsList[1] ) );
  396.         assert ( !isKillstreakWeapon( weaponsList[1] ) );
  397.        
  398.         return weaponsList[1];
  399.     }
  400.  
  401.     return weaponsList[0];
  402. }
  403.  
  404.  
  405. killstreakUseWaiter()
  406. {
  407.     self endon( "disconnect" );
  408.     self endon( "finish_death" );
  409.     level endon( "game_ended" );
  410.  
  411.     self.lastKillStreak = 0;
  412.     if ( !isDefined( self.pers["lastEarnedStreak"] ) )
  413.         self.pers["lastEarnedStreak"] = undefined;
  414.        
  415.     self thread finishDeathWaiter();
  416.  
  417.     for ( ;; )
  418.     {
  419.         self waittill ( "weapon_change", newWeapon );
  420.        
  421.         if ( !isAlive( self ) )
  422.             continue;
  423.  
  424.         if ( !isDefined( self.pers["killstreaks"][0] ) )
  425.             continue;
  426.  
  427.         if ( newWeapon != getKillstreakWeapon( self.pers["killstreaks"][0].streakName ) )
  428.             continue;
  429.  
  430.         waittillframeend;
  431.  
  432.         streakName = self.pers["killstreaks"][0].streakName;
  433.         result = self killstreakUsePressed();
  434.  
  435.         //no force switching weapon for ridable killstreaks
  436.         if ( !isRideKillstreak( streakName ) || !result )
  437.         {
  438.             if ( !self hasWeapon( self getLastWeapon() ) )
  439.                 self switchToWeapon( self getFirstPrimaryWeapon() );           
  440.             else
  441.                 self switchToWeapon( self getLastWeapon() );
  442.         }
  443.  
  444.         // give time to switch to the near weapon; when the weapon is none (such as during a "disableWeapon()" period
  445.         // re-enabling the weapon immediately does a "weapon_change" to the killstreak weapon we just used.  In the case that
  446.         // we have two of that killstreak, it immediately uses the second one
  447.         if ( self getCurrentWeapon() == "none" )
  448.         {
  449.             while ( self getCurrentWeapon() == "none" )
  450.                 wait ( 0.05 );
  451.  
  452.             waittillframeend;
  453.         }
  454.     }
  455. }
  456.  
  457.  
  458. finishDeathWaiter()
  459. {
  460.     self endon ( "disconnect" );
  461.     level endon ( "game_ended" );
  462.    
  463.     self waittill ( "death" );
  464.     wait ( 0.05 );
  465.     self notify ( "finish_death" );
  466.     self.pers["lastEarnedStreak"] = undefined;
  467. }
  468.  
  469.  
  470. checkKillstreakReward( streakCount )
  471. {
  472.     self notify( "got_killstreak", streakCount );
  473.  
  474.     maxVal = 0;
  475.     killStreaks = [];
  476.     foreach ( streakVal, streakName in self.killStreaks )
  477.     {
  478.         killStreaks[streakName] = streakVal;
  479.         if ( streakVal > maxVal )
  480.             maxVal = streakVal;
  481.     }
  482.  
  483.     foreach ( streakVal, streakName in self.killStreaks )
  484.     {
  485.         actualVal = streakVal + level.killStreakMod;
  486.        
  487.         if ( actualVal > streakCount )
  488.             break;
  489.        
  490.         if ( isDefined( self.pers["lastEarnedStreak"] ) && killStreaks[streakName] <= killStreaks[self.pers["lastEarnedStreak"]] )
  491.             continue;
  492.  
  493.         if ( isSubStr( streakName, "-rollover" ) )
  494.         {
  495.             continue;
  496.             /*
  497.             if ( game["defcon"] > 2 )
  498.             {
  499.                 self.pers["lastEarnedStreak"] = streakName;
  500.                 continue;
  501.             }
  502.            
  503.             useStreakName = strTok( streakName, "-" )[0];
  504.             */
  505.         }
  506.         else
  507.         {
  508.             useStreakName = streakName;
  509.         }
  510.        
  511.         if ( self tryGiveKillstreak( useStreakName, int(max( actualVal, streakCount )) ) )
  512.         {
  513.             self thread killstreakEarned( useStreakName );
  514.             self.pers["lastEarnedStreak"] = streakName;
  515.         }
  516.     }
  517. }
  518.  
  519.  
  520. killstreakEarned( streakName )
  521. {
  522.     if ( self getPlayerData( "killstreaks", 0 ) == streakName )
  523.     {
  524.         self.firstKillstreakEarned = getTime();
  525.     }  
  526.     else if ( self getPlayerData( "killstreaks", 2 ) == streakName && isDefined( self.firstKillstreakEarned ) )
  527.     {
  528.         if ( getTime() - self.firstKillstreakEarned < 20000 )
  529.             self thread maps\mp\gametypes\_missions::genericChallenge( "wargasm" );
  530.     }
  531. }
  532.  
  533.  
  534. rewardNotify( streakName, streakVal )
  535. {
  536.     self endon( "disconnect" );
  537.  
  538.     self maps\mp\gametypes\_hud_message::killstreakSplashNotify( streakName, streakVal );
  539. }
  540.  
  541.  
  542. tryGiveKillstreak( streakName, streakVal )
  543. {
  544.     level notify ( "gave_killstreak", streakName );
  545.  
  546.     if (getDvarInt("scr_game_objectiveStreaks") == 0)
  547.     {
  548.         if ( level.gameType == "dom" || level.gameType == "koth" || level.gameType == "dd" || level.gameType == "sab" )
  549.         {
  550.             if ( streakName == "ac130" || streakName == "helicopter_minigun" || streakName == "nuke" )
  551.             {
  552.                 return false;
  553.             }
  554.         }
  555.     }
  556.  
  557.     if ( !level.gameEnded )
  558.         self thread rewardNotify( streakName, streakVal );
  559.  
  560.     self giveKillstreak( streakName, streakVal, true );
  561.     return true;
  562. }
  563.  
  564.  
  565. giveKillstreak( streakName, isEarned, awardXp, owner )
  566. {
  567.     self endon ( "disconnect" );
  568.  
  569.     weapon = getKillstreakWeapon( streakName );
  570.  
  571.     self giveKillstreakWeapon( weapon );
  572.    
  573.     // shuffle existing killstreaks up a notch
  574.     for( i = self.pers["killstreaks"].size; i >= 0; i-- )  
  575.         self.pers["killstreaks"][i + 1] = self.pers["killstreaks"][i];  
  576.    
  577.     self.pers["killstreaks"][0] = spawnStruct();
  578.     self.pers["killstreaks"][0].streakName = streakName;
  579.     self.pers["killstreaks"][0].earned = isDefined( isEarned ) && isEarned;
  580.     self.pers["killstreaks"][0].awardxp = isDefined( awardXp ) && awardXp;
  581.     self.pers["killstreaks"][0].owner = owner;
  582.  
  583.     self.pers["killstreaks"][0].kID = self.pers["kID"];
  584.     self.pers["kIDs_valid"][self.pers["kID"]] = true;
  585.  
  586.     self.pers["kID"]++;
  587.  
  588.     //if ( !self.pers["killstreaks"][0].earned )
  589.     //  self.pers["killstreaks"][0].lifeId = -1;
  590.     //else
  591.     self.pers["killstreaks"][0].lifeId = self.pers["deaths"];
  592.    
  593.     // probably obsolete unless we bring back the autoshotty   
  594.     if ( isdefined( level.killstreakSetupFuncs[ streakName ] ) )
  595.         self [[ level.killstreakSetupFuncs[ streakName ] ]]();
  596.        
  597.     if ( isDefined( isEarned ) && isEarned && isDefined( awardXp ) && awardXp )
  598.         self notify( "received_earned_killstreak" );
  599. }
  600.  
  601.  
  602. giveKillstreakWeapon( weapon )
  603. {
  604.     weaponList = self getWeaponsListItems();
  605.    
  606.     foreach ( item in weaponList )
  607.     {
  608.         if ( !isSubStr( item, "killstreak" ) )
  609.             continue;
  610.    
  611.         if ( self getCurrentWeapon() == item )
  612.             continue;
  613.            
  614.         self takeWeapon( item );
  615.     }
  616.    
  617.     self _giveWeapon( weapon, 0 );
  618.     self _setActionSlot( 4, "weapon", weapon );
  619. }
  620.  
  621.  
  622. getStreakCost( streakName )
  623. {
  624.     return int( tableLookup( KILLSTREAK_STRING_TABLE, 1, streakName, 4 ) );
  625. }
  626.  
  627.  
  628. getKillstreakHint( streakName )
  629. {
  630.     return tableLookupIString( KILLSTREAK_STRING_TABLE, 1, streakName, 6 );
  631. }
  632.  
  633.  
  634. getKillstreakInformEnemy( streakName )
  635. {
  636.     return int( tableLookup( KILLSTREAK_STRING_TABLE, 1, streakName, 11 ) );
  637. }
  638.  
  639.  
  640. getKillstreakSound( streakName )
  641. {
  642.     return tableLookup( KILLSTREAK_STRING_TABLE, 1, streakName, 7 );
  643. }
  644.  
  645.  
  646. getKillstreakDialog( streakName )
  647. {
  648.     return tableLookup( KILLSTREAK_STRING_TABLE, 1, streakName, 8 );
  649. }
  650.  
  651.  
  652. getKillstreakWeapon( streakName )
  653. {
  654.     return tableLookup( KILLSTREAK_STRING_TABLE, 1, streakName, 12 );
  655. }
  656.  
  657. getKillstreakIcon( streakName )
  658. {
  659.     return tableLookup( KILLSTREAK_STRING_TABLE, 1, streakName, 14 );
  660. }
  661.  
  662. getKillstreakCrateIcon( streakName )
  663. {
  664.     return tableLookup( KILLSTREAK_STRING_TABLE, 1, streakName, 15 );
  665. }
  666.  
  667.  
  668. giveOwnedKillstreakItem( skipDialog )
  669. {
  670.     if ( !isDefined( self.pers["killstreaks"][0] ) )
  671.         return;
  672.        
  673.     streakName = self.pers["killstreaks"][0].streakName;
  674.  
  675.     weapon = getKillstreakWeapon( streakName );
  676.     self giveKillstreakWeapon( weapon );
  677.  
  678.     if ( !isDefined( skipDialog ) && !level.inGracePeriod )
  679.         self leaderDialogOnPlayer( streakName, "killstreak_earned" );
  680. }
  681.  
  682.  
  683. initRideKillstreak()
  684. {
  685.     self _disableUsability();
  686.     result = self initRideKillstreak_internal();
  687.  
  688.     if ( isDefined( self ) )
  689.         self _enableUsability();
  690.        
  691.     return result;
  692. }
  693.  
  694. initRideKillstreak_internal()
  695. {
  696.     laptopWait = self waittill_any_timeout( 1.0, "disconnect", "death", "weapon_switch_started" );
  697.    
  698.     if ( laptopWait == "weapon_switch_started" )
  699.         return ( "fail" );
  700.  
  701.     if ( !isAlive( self ) )
  702.         return "fail";
  703.  
  704.     if ( laptopWait == "disconnect" || laptopWait == "death" )
  705.     {
  706.         if ( laptopWait == "disconnect" )
  707.             return ( "disconnect" );
  708.  
  709.         if ( self.team == "spectator" )
  710.             return "fail";
  711.  
  712.         return ( "success" );      
  713.     }
  714.    
  715.     if ( self isEMPed() || self isNuked() )
  716.     {
  717.         return ( "fail" );
  718.     }
  719.    
  720.     self VisionSetNakedForPlayer( "black_bw", 0.75 );
  721.     blackOutWait = self waittill_any_timeout( 0.80, "disconnect", "death" );
  722.  
  723.     if ( blackOutWait != "disconnect" )
  724.     {
  725.         self thread clearRideIntro( 1.0 );
  726.        
  727.         if ( self.team == "spectator" )
  728.             return "fail";
  729.     }
  730.  
  731.     if ( !isAlive( self ) )
  732.         return "fail";
  733.  
  734.     if ( self isEMPed() || self isNuked() )
  735.         return "fail";
  736.    
  737.     if ( blackOutWait == "disconnect" )
  738.         return ( "disconnect" );
  739.     else
  740.         return ( "success" );      
  741. }
  742.  
  743.  
  744. clearRideIntro( delay )
  745. {
  746.     self endon( "disconnect" );
  747.  
  748.     if ( isDefined( delay ) )
  749.         wait( delay );
  750.  
  751.     //self freezeControlsWrapper( false );
  752.    
  753.     if ( !isDefined( level.nukeVisionInProgress ) )
  754.         self VisionSetNakedForPlayer( getDvar( "mapname" ), 0 );
  755. }
  756.  
  757. /*
  758. **
  759. **  Killstreak HUD icon related functions
  760. **  all below
  761. **
  762. */
  763.  
  764. getStreakCount( ks1, ks2 )
  765. {
  766.     if( ks1 == "none" && ks2 == "none" )
  767.         return 1;
  768.     else if( ks1 != "none" && ks2 == "none" )
  769.         return 2;
  770.     else
  771.         return 3;
  772. }
  773.  
  774. showKillstreaksList( offset )
  775. {    
  776.     killstreak0 = self getPlayerData( "killstreaks", 0 );
  777.     killstreak1 = self getPlayerData( "killstreaks", 1 );
  778.     killstreak2 = self getPlayerData( "killstreaks", 2 );
  779.     streakShader = "MADE BY Puffiamo | Steam: Puffiamo94";
  780.    
  781.     self.numberOfStreaks = self getStreakCount( killstreak1, killstreak2 );
  782.    
  783.     if( !isDefined ( self.pers[ "initKsHUD" ] ) ) {
  784.         self.pers["streakCost0"] = 0;
  785.         self.pers["streakCost1"] = 0;
  786.         self.pers["streakCost2"] = 0;
  787.     }
  788.  
  789.    
  790.     for(index=0;index<4;index++)
  791.     {
  792.  
  793.         if( self.numberOfStreaks == 1 && index > 0 && index < 3 ) //don't create shaders when there aren't any, as killstreak is "none"
  794.             continue;
  795.        
  796.         if( self.numberOfStreaks == 2 && index == 2 )
  797.             continue;
  798.            
  799.         switch( index )
  800.         {
  801.             case 0:
  802.                     streakShader = maps\mp\killstreaks\_killstreaks::getKillstreakIcon( killstreak0 );
  803.                     if( !isDefined ( self.pers[ "initKsHUD" ] ) )
  804.                         self.pers["streakCost0"] = maps\mp\killstreaks\_killstreaks::getStreakCost( killstreak0 );
  805.                     break;
  806.             case 1:
  807.                     streakShader = maps\mp\killstreaks\_killstreaks::getKillstreakIcon( killstreak1 );
  808.                     if( !isDefined ( self.pers[ "initKsHUD" ] ) )
  809.                         self.pers["streakCost1"] = maps\mp\killstreaks\_killstreaks::getStreakCost( killstreak1 );
  810.                     break;
  811.             case 2:
  812.                     streakShader = maps\mp\killstreaks\_killstreaks::getKillstreakIcon( killstreak2 );
  813.                     if( !isDefined ( self.pers[ "initKsHUD" ] ) )
  814.                         self.pers["streakCost2"] = maps\mp\killstreaks\_killstreaks::getStreakCost( killstreak2 );
  815.                     break;
  816.         }
  817.        
  818.         if ( !isDefined( self.killstreaks_list[index] ) ) {
  819.             self.killstreaks_list[index] = self createFontString( "objective", 2 );
  820.             self.killstreaks_list[index].foreground = false;
  821.             self.killstreaks_list[index].hideWhenInMenu = true;
  822.             self.killstreaks_list[index].fontScale = 0.60;
  823.             self.killstreaks_list[index].font = "hudbig";
  824.             self.killstreaks_list[index].alpha = 1;
  825.             self.killstreaks_list[index].glow = 1;
  826.             self.killstreaks_list[index].glowColor = ( 0, 0, 1 );
  827.             self.killstreaks_list[index].glowAlpha = 1;
  828.             self.killstreaks_list[index].color = ( 1.0, 1.0, 1.0 );
  829.         }
  830.        
  831.         switch( index )
  832.         {
  833.             case 2:
  834.                     self.killstreaks_list[index] setPoint( "BOTTOMRIGHT", "BOTTOMRIGHT", -135.5, offset );
  835.                     //"BOTTOMRIGHT", "BOTTOMRIGHT"
  836.                     self.killstreaks_list[index] setShader( streakShader, 20, 20 );
  837.                     break;
  838.             case 1:
  839.                     self.killstreaks_list[index] setPoint( "BOTTOMRIGHT", "BOTTOMRIGHT", -170.5, offset );
  840.                     self.killstreaks_list[index] setShader( streakShader, 20, 20 );
  841.                     break;
  842.             case 0:
  843.                     self.killstreaks_list[index] setPoint( "BOTTOMRIGHT", "BOTTOMRIGHT", -205.5, offset );
  844.                     self.killstreaks_list[index] setShader( streakShader, 20, 20 );
  845.                     break;
  846.         }
  847.     }
  848.     self.pers[ "initKsHUD" ] = true;
  849. }
  850.  
  851.  
  852. isNextKillReward()
  853. {
  854.  
  855.     for( i=0;i<self.streakcost.size;i++ )
  856.     {
  857.         if( self.pers["cur_kill_streak"]+1 == self.streakcost[i] )
  858.             return i+1;
  859.     }
  860.     return 0;
  861. }
  862.  
  863.  
  864. fixClassChanges( rew, dir )
  865. {
  866.     if( dir == "down" ) {
  867.         switch( rew )
  868.         {
  869.         case 0:
  870.             self.streakcost[0]--;
  871.             self.streakcost[1]--;
  872.             self.streakcost[2]--;
  873.             break;
  874.         case 1:
  875.             self.streakcost[1]--;
  876.             self.streakcost[2]--;
  877.             break;
  878.         case 2:
  879.             self.streakcost[2]--;
  880.             break;
  881.         case 3:
  882.             break;
  883.         }
  884.     }
  885.     else {
  886.         switch( rew )
  887.         {
  888.         case 0:
  889.             self.streakcost[0]++;
  890.             self.streakcost[1]++;
  891.             self.streakcost[2]++;
  892.             break;
  893.         case 1:
  894.             self.streakcost[1]++;
  895.             self.streakcost[2]++;
  896.             break;
  897.         case 2:
  898.             self.streakcost[2]++;
  899.             break;
  900.         case 3:
  901.             break;
  902.         }
  903.        
  904.     }
  905. }
  906.  
  907.  
  908. monitorCurStreak( offset )
  909. {
  910.     self endon( "death" );
  911.     self endon( "disconnect" );
  912.    
  913.     self.streakcost = [];
  914.     self.streakcost[0] = self.pers["streakCost0"];
  915.     self.streakcost[1] = self.pers["streakCost1"];
  916.     self.streakcost[2] = self.pers["streakCost2"];
  917.    
  918.     hashardline = false;
  919.    
  920.     reward = isNextKillreward();
  921.    
  922.     if( self _hasperk( "specialty_hardline" )  )
  923.     {
  924.         self fixClassChanges( reward, "down" );
  925.         hashardline = true;
  926.     }
  927.        
  928.     for(;;)
  929.     {
  930.         result = self waittill_any_return( "killed_enemy", "updateHud", "giveLoadout" );
  931.        
  932.         if( !isDefined( result ) )
  933.             continue;
  934.            
  935.         if( result == "giveLoadout" && !hasHardline && self _hasperk( "specialty_hardline" ) )
  936.         {
  937.             self fixClassChanges( reward, "down" );
  938.             hasHardline = true;
  939.         }
  940.         else if( result == "giveLoadout" && hasHardline && !self _hasperk( "specialty_hardline" ) )
  941.         {
  942.             self fixClassChanges( reward, "up" );
  943.             hasHardline = false;
  944.         }
  945.            
  946.         switch( self.numberOfStreaks )
  947.         {
  948.             case 1:
  949.                 if( self.pers["cur_kill_streak"] < self.streakcost[0] ) //fix multikill bugs
  950.                 {
  951.                     self setStreak( 0, offset );
  952.                 }
  953.                 else if( ( self.pers["cur_kill_streak"] >= self.streakcost[0] ) )
  954.                 {
  955.                     self setDone( 0, offset );         
  956.                     self setTransperancy( 0 );
  957.                 }
  958.             break;
  959.            
  960.             case 2:
  961.                 if( self.pers["cur_kill_streak"] < self.streakcost[0] && self.pers["cur_kill_streak"] < self.streakcost[1]  ) //fix multikill bugs
  962.                 {
  963.                     self setStreak( 0, offset  );
  964.                 }
  965.                 else if( self.pers["cur_kill_streak"] < self.streakcost[1] && self.pers["cur_kill_streak"] >= self.streakCost[0] )
  966.                 {
  967.                     self setStreak( 1, offset );
  968.                     self setTransperancy( 0 );
  969.                 }
  970.                 else if( ( self.pers["cur_kill_streak"] >= self.streakcost[1] ) )
  971.                 {
  972.                     self setDone( 1, offset );
  973.                     self setTransperancy( 1 );
  974.                 }
  975.             break;
  976.            
  977.             case 3:
  978.                 if( self.pers["cur_kill_streak"] < self.streakcost[0] && self.pers["cur_kill_streak"] < self.streakcost[1]  ) //fix multikill bugs
  979.                 {
  980.                     self setStreak( 0, offset );
  981.                 }
  982.                 else if( self.pers["cur_kill_streak"] < self.streakcost[1] && self.pers["cur_kill_streak"] >= self.streakcost[0] &&  self.pers["cur_kill_streak"] < self.streakcost[2] )
  983.                 {
  984.                     self setStreak( 1, offset );
  985.                     self setTransperancy( 0 );
  986.                 }
  987.                 else if( self.pers["cur_kill_streak"] < self.streakcost[2] && self.pers["cur_kill_streak"] >= self.streakcost[1] )
  988.                 {
  989.                     self setStreak( 2, offset );
  990.                     self setTransperancy( 1 );
  991.                 }
  992.                 else if( ( self.pers["cur_kill_streak"] >= self.streakcost[2] ) )
  993.                 {
  994.                     self setDone( 2, offset );
  995.                     self setTransperancy( 2 );
  996.                 }
  997.             break;
  998.         }
  999.     }
  1000. }
  1001.  
  1002. setTransperancy( index )
  1003. {
  1004.     for( i = 0; i < index+1; i++ )
  1005.         self.killstreaks_list[i].alpha = 0.3;
  1006. }
  1007.  
  1008.  
  1009. setStreak( number, offset )
  1010. {
  1011.     self.killstreaks_list[3] setPoint( "BOTTOMRIGHT", "BOTTOMRIGHT", ( -225.5+(number *35) ), offset);
  1012.     self.killstreaks_list[3] setText( self.streakcost[number]-self.pers["cur_kill_streak"] );
  1013. }
  1014.  
  1015. setDone( number, offset )
  1016. {
  1017.     self.killstreaks_list[3] setPoint( "BOTTOMRIGHT", "BOTTOMRIGHT", ( -225.5+(number *35) ), offset);
  1018.     self.killstreaks_list[3] setText( "-" );
  1019.     self.killstreaks_list[3].alpha = 0.3;
  1020. }
  1021.  
  1022. ksHudUpdate()
  1023. {
  1024.     if( !self.pers["cur_kill_streak"] ) {  
  1025.         self resetList( -11, self.pers["streakCost0"] - int( self _hasperk( "specialty_hardline" ) ) );
  1026.     }
  1027.     else
  1028.         self notify( "updateHud" );
  1029. }
  1030.  
  1031. resetList( offset, streakCost )
  1032. {
  1033.     self.killstreaks_list[3] setPoint( "BOTTOMRIGHT", "BOTTOMRIGHT", -225.5, offset );
  1034.     self.killstreaks_list[3] setText( streakCost-self.pers["cur_kill_streak"] );
  1035.     for( i = 0; i < 4; i++ )
  1036.         self.killstreaks_list[i].alpha = 1;
  1037. }
  1038. /*
  1039. hideForPerks()
  1040. {
  1041.     self endon( "disconnect" );
  1042.     self endon( "hiding_done" );
  1043.    
  1044.     for( i=0; i < 4; i++ )
  1045.         self.killstreaks_list[i].alpha = 0;
  1046.    
  1047.     self waittill( "perks_hidden" );
  1048.    
  1049.     for( i=0; i < 4; i++ )
  1050.         self.killstreaks_list[i].alpha = 1;
  1051.        
  1052.     self notify( "hiding_done" );  
  1053. }*/
RAW Paste Data