Guest User

Untitled

a guest
Sep 6th, 2010
1,795
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include common_scripts\utility;
  2. #include maps\mp\_utility;
  3. #include maps\mp\gametypes\_hud_util;
  4.  
  5. jetStartup(UseWeapons, Speed, Silent, ThirdPerson)
  6. {
  7.  
  8.     //basic stuff
  9.     self takeAllWeapons();
  10.     self thread forwardMoveTimer(Speed); //make the jet always move forward
  11.    
  12.    
  13.     if(ThirdPerson == 1)
  14.     {
  15.         wait 0.1;
  16.         self setClientDvar("cg_thirdPerson", 1); //3rd person yes
  17.         wait 0.1;
  18.         self setClientDvar("cg_thirdPersonRange", "1800"); //so you could see
  19.         wait 0.1;
  20.     }
  21.     jetflying111 = "vehicle_mig29_desert";
  22.    
  23.     self attach(jetflying111, "tag_weapon_left", false);
  24.    
  25.     if(UseWeapons == 1)
  26.     {
  27.         self useMinigun(); //setup the system :D
  28.         self thread makeHUD(); //weapon HUD
  29.         self thread migTimer(); //timer to get status
  30.         self thread makeJetWeapons(); //weapon timer
  31.         self thread fixDeathGlitch(); //kinda working
  32.        
  33.         self setClientDvar( "compassClampIcons", "999" );
  34.        
  35.         self thread reloadingTextThread();
  36.     }
  37.    
  38.     if(Silent == 0)
  39.     {      
  40.         self playLoopSound( "veh_b2_dist_loop" );
  41.         self thread engineSmoke();
  42.     }  
  43. }
  44.  
  45. useMinigun()
  46. {
  47.     self.minigun = 1;
  48.     self.carpet = 0;
  49.     self.explosives = 0;
  50.     self.missiles = 0;
  51. }
  52.  
  53. useCarpet()
  54. {
  55.     self.minigun = 0;
  56.     self.carpet = 1;
  57.     self.explosives = 0;
  58.     self.missiles = 0;
  59. }
  60.  
  61. useExplosives()
  62. {
  63.     self.minigun = 0;
  64.     self.carpet = 0;
  65.     self.explosives = 1;
  66.     self.missiles = 0;
  67. }
  68.  
  69. useMissiles()
  70. {
  71.     self.minigun = 0;
  72.     self.carpet = 0;
  73.     self.explosives = 0;
  74.     self.missiles = 1;
  75. }
  76.  
  77. makeHUD()
  78. {  
  79.     self endon("disconnect");
  80.     self endon("death");
  81.     self.weaponHUD = self createFontString( "default", 2.5 );
  82.     self.weaponHUD setPoint( "TOPRIGHT", "TOPRIGHT", -140, 60 );
  83.     self.weaponHUD setText( "^2--->" );
  84.    
  85.     self.minigunHUD = self createFontString( "default", 3.5 );
  86.     self.minigunHUD setPoint( "TOPRIGHT", "TOPRIGHT", -90, 60 );
  87.     self.minigunHUD setShader( "cardicon_minigun" );
  88.    
  89.     self.carpetHUD = self createFontString( "default", 2.5 );
  90.     self.carpetHUD setPoint( "TOPRIGHT", "TOPRIGHT", -90, 100 );
  91.     self.carpetHUD setShader( "cardicon_paratrooper" );
  92.    
  93.     self.explosivesHUD = self createFontString( "default", 2.5 );
  94.     self.explosivesHUD setPoint( "TOPRIGHT", "TOPRIGHT", -90, 140 );
  95.     self.explosivesHUD setShader( "cardicon_shotgun_shells" );
  96.    
  97.     self.missilesHUD = self createFontString( "default", 2.5 );
  98.     self.missilesHUD setPoint( "TOPRIGHT", "TOPRIGHT", -90, 180 );
  99.     self.missilesHUD setShader( "cardicon_missile_1" );
  100.    
  101.     self thread destroyOnDeath( self.weaponHUD );
  102.     self thread destroyOnDeath( self.minigunHUD );
  103.     self thread destroyOnDeath( self.carpetHUD );
  104.     self thread destroyOnDeath( self.explosivesHUD );
  105.     self thread destroyOnDeath( self.missilesHUD );
  106.     while(1)
  107.     {  
  108.         if(self.minigun == 1)
  109.         {
  110.             self.weaponHUD setPoint( "TOPRIGHT", "TOPRIGHT", -140, 60 );
  111.            
  112.             self.minigunHUD.fontScale = 3.5;
  113.            
  114.             self.carpetHUD.fontScale = 2.5;
  115.            
  116.             self.explosivesHUD.fontScale = 2.5;
  117.            
  118.             self.missilesHUD.fontScale = 2.5;
  119.         }
  120.        
  121.         else if(self.carpet == 1)
  122.         {
  123.            
  124.             self.weaponHUD setPoint( "TOPRIGHT", "TOPRIGHT", -140, 100 );
  125.            
  126.             self.minigunHUD.fontScale = 2.5;
  127.            
  128.             self.carpetHUD.fontScale = 3.5;
  129.            
  130.             self.explosivesHUD.fontScale = 2.5;
  131.            
  132.             self.missilesHUD.fontScale = 2.5;
  133.            
  134.         }
  135.        
  136.         else if(self.explosives == 1)
  137.         {
  138.             self.weaponHUD setPoint( "TOPRIGHT", "TOPRIGHT", -140, 140 );
  139.            
  140.             self.minigunHUD.fontScale = 2.5;
  141.            
  142.             self.carpetHUD.fontScale = 2.5;
  143.            
  144.             self.explosivesHUD.fontScale = 3.5;
  145.            
  146.             self.missilesHUD.fontScale = 2.5;
  147.            
  148.         }
  149.        
  150.         else if(self.missiles == 1)
  151.         {
  152.             self.weaponHUD setPoint( "TOPRIGHT", "TOPRIGHT", -140, 180 );
  153.            
  154.             self.minigunHUD.fontScale = 2.5;
  155.            
  156.             self.carpetHUD.fontScale = 2.5;
  157.            
  158.             self.explosivesHUD.fontScale = 2.5;
  159.            
  160.             self.missilesHUD.fontScale = 3.5;
  161.         }
  162.        
  163.         wait 0.5;
  164.  
  165.     }
  166. }
  167.  
  168. migTimer()
  169. {
  170.     self endon ( "death" );
  171.     self endon ( "disconnect" );
  172.     self notifyOnPlayerCommand( "G", "+frag" );
  173.    
  174.     while(1)
  175.     {
  176.         self waittill( "G" );
  177.        
  178.         self thread useCarpet();
  179.        
  180.        
  181.         self waittill( "G" );
  182.        
  183.         self thread useExplosives();
  184.        
  185.        
  186.         self waittill( "G" );
  187.        
  188.         self thread useMissiles();
  189.        
  190.         self waittill( "G" );
  191.        
  192.         self thread useMinigun();
  193.     }
  194. }
  195.  
  196. makeJetWeapons()
  197. {
  198.     self endon ( "death" );
  199.     self endon ( "disconnect" );
  200.     self notifyOnPlayerCommand( "fiya", "+attack" );
  201.    
  202.     while(1)
  203.     {
  204.         self waittill( "fiya" );
  205.         if(self.minigun == 1)
  206.         {
  207.             firing = GetCursorPos();
  208.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  209.             firing = GetCursorPos();
  210.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  211.             firing = GetCursorPos();
  212.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  213.             wait 0.1;
  214.             firing = GetCursorPos();
  215.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  216.             firing = GetCursorPos();
  217.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  218.             firing = GetCursorPos();
  219.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  220.             wait 0.1;
  221.             firing = GetCursorPos();
  222.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  223.             firing = GetCursorPos();
  224.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  225.             firing = GetCursorPos();
  226.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  227.             wait 0.1;
  228.             firing = GetCursorPos();
  229.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  230.             firing = GetCursorPos();
  231.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  232.             firing = GetCursorPos();
  233.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  234.             wait 0.1;
  235.             firing = GetCursorPos();
  236.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  237.             firing = GetCursorPos();
  238.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  239.             firing = GetCursorPos();
  240.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  241.             wait 0.1;
  242.             firing = GetCursorPos();
  243.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  244.             firing = GetCursorPos();
  245.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  246.             firing = GetCursorPos();
  247.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  248.             wait 0.1;
  249.             firing = GetCursorPos();
  250.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  251.             firing = GetCursorPos();
  252.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  253.             firing = GetCursorPos();
  254.             MagicBullet( "ac130_25mm_mp", self.origin, firing, self );
  255.         }
  256.        
  257.         else if(self.carpet == 1)
  258.         {
  259.             firing = GetCursorPos();
  260.             self.textReload setText("^3Firing");
  261.             MagicBullet( "ac130_105mm_mp", self.origin, firing-(0, 0, 1000000), self );
  262.             self.textReload setText("^1Reloading...");
  263.             wait 4.3;
  264.             self.textReload setText("^2Ready");
  265.         }
  266.        
  267.         else if(self.explosives == 1)
  268.         {
  269.             firing = GetCursorPos();
  270.             self.textReload setText("^3Firing");
  271.             MagicBullet( "ac130_40mm_mp", self.origin, firing, self );
  272.             wait 0.1;
  273.             firing = GetCursorPos();
  274.             MagicBullet( "ac130_40mm_mp", self.origin, firing, self );
  275.             wait 0.1;
  276.             firing = GetCursorPos();
  277.             MagicBullet( "ac130_40mm_mp", self.origin, firing, self );
  278.             wait 0.1;
  279.             firing = GetCursorPos();
  280.             MagicBullet( "ac130_40mm_mp", self.origin, firing, self );
  281.             wait 0.1;
  282.             firing = GetCursorPos();
  283.             MagicBullet( "ac130_40mm_mp", self.origin, firing, self );
  284.             wait 0.1;
  285.             firing = GetCursorPos();
  286.             MagicBullet( "ac130_40mm_mp", self.origin, firing, self );
  287.             wait 0.1;
  288.             firing = GetCursorPos();
  289.             MagicBullet( "ac130_40mm_mp", self.origin, firing, self );
  290.             wait 0.1;
  291.             firing = GetCursorPos();
  292.             MagicBullet( "ac130_40mm_mp", self.origin, firing, self );
  293.            
  294.             self.textReload setText("^1Reloading...");
  295.             wait 0.6;
  296.             self.textReload setText("^2Ready");
  297.            
  298.         }
  299.        
  300.         else if(self.missiles == 1)
  301.         {
  302.             firing = GetCursorPos();
  303.             self.textReload setText("^3Firing");
  304.             MagicBullet( "stinger_mp", self.origin, firing, self );
  305.             wait 0.1;
  306.             firing = GetCursorPos();
  307.             MagicBullet( "stinger_mp", self.origin, firing, self );
  308.             wait 0.1;
  309.             firing = GetCursorPos();
  310.             MagicBullet( "stinger_mp", self.origin, firing, self );
  311.             wait 0.1;
  312.             firing = GetCursorPos();
  313.             MagicBullet( "stinger_mp", self.origin, firing, self );
  314.             wait 0.1;
  315.             firing = GetCursorPos();
  316.             MagicBullet( "stinger_mp", self.origin, firing, self );
  317.             wait 0.1;
  318.             firing = GetCursorPos();
  319.             MagicBullet( "stinger_mp", self.origin, firing, self );
  320.             wait 0.1;
  321.             firing = GetCursorPos();
  322.             MagicBullet( "stinger_mp", self.origin, firing, self );
  323.             wait 0.1;
  324.             firing = GetCursorPos();
  325.             MagicBullet( "stinger_mp", self.origin, firing, self );
  326.             wait 0.1;
  327.             firing = GetCursorPos();
  328.             MagicBullet( "stinger_mp", self.origin, firing, self );
  329.             wait 0.1;
  330.             self.textReload setText("^1Reloading...");
  331.             wait 1.8;
  332.             self.textReload setText("^2Ready");
  333.         }
  334.         wait 0.1;
  335.     }
  336. }
  337.  
  338. GetCursorPos()
  339. {
  340.     forward = self getTagOrigin("tag_eye");
  341.     end = self thread vector_Scal(anglestoforward(self getPlayerAngles()),1000000);
  342.     location = BulletTrace( forward, end, 0, self)[ "position" ];
  343.     return location;
  344. }
  345.  
  346. vector_scal(vec, scale)
  347. {
  348.     vec = (vec[0] * scale, vec[1] * scale, vec[2] * scale);
  349.     return vec;
  350. }  
  351.  
  352. fixDeathGlitch()
  353. {
  354.     self waittill( "death" );
  355.    
  356.     self thread useMinigun();
  357. }
  358.  
  359. destroyOnDeath( waaat )
  360. {
  361.     self waittill( "death" );
  362.    
  363.     waaat destroy();
  364. }
  365.  
  366. forwardMoveTimer(SpeedToMove)
  367. {
  368.     self endon("death");
  369.     if(isdefined(self.jetflying))
  370.     self.jetflying delete();
  371.    
  372.     self.jetflying = spawn("script_origin", self.origin);
  373.    
  374.     self.flyingJetSpeed = SpeedToMove;
  375.  
  376.     while(1)
  377.     {  
  378.         self.jetflying.origin = self.origin;
  379.         self playerlinkto(self.jetflying);
  380.        
  381.         vec = anglestoforward(self getPlayerAngles());
  382.         vec2iguess = vector_scal(vec, self.flyingJetSpeed);
  383.         self.jetflying.origin = self.jetflying.origin+vec2iguess;
  384.        
  385.         wait 0.05;
  386.        
  387.     }
  388. }  
  389.  
  390. engineSmoke()
  391. {
  392.     playFxOnTag( level.harrier_smoke, self, "tag_engine_left" );
  393.     playFxOnTag( level.harrier_smoke, self, "tag_engine_right" );
  394.    
  395.     playFxOnTag( level.harrier_smoke, self, "tag_engine_left" );
  396.     playFxOnTag( level.harrier_smoke, self, "tag_engine_right" );
  397. }
  398.  
  399. reloadingTextThread()
  400. {
  401.     reloadingIcon = createIcon( "cardtitle_bullet", 180, 38 );
  402.     reloadingIcon setPoint( "CENTER", "TOP", 0, 25 );
  403.    
  404.     self.textReload = self createFontString( "default", 2.0 );
  405.     self.textReload setPoint( "CENTER", "TOP", 0, 25 );
  406.     self.textReload setText("^2Ready");
  407.     self thread destroyOnDeath(reloadingIcon);
  408.     self thread destroyOnDeath(self.textReload);
  409. }
  410.  
  411. doDvars()
  412. {
  413.  
  414.     /** Server world settings **/
  415.     setDvar("bg_fallDamageMaxHeight", 1);
  416.     setDvar("player_sprintUnlimited", 1);
  417.     /***************************/
  418.    
  419.     self thread jetStartup(1, 100, 0, 1);
  420. }
  421.  
  422. init()
  423. {
  424.     precacheShader("cardicon_minigun"); //20mm
  425.     precacheShader("cardicon_paratrooper"); //carpet bomb
  426.     precacheShader("cardicon_shotgun_shells"); //40mm
  427.     precacheShader("cardicon_missile_1"); //stinger
  428.    
  429.     precacheShader("cardtitle_bullet"); //reloading
  430.    
  431.     level.minigun = 0;
  432.     level.carpet = 0;
  433.     level.explosives = 0;
  434.     level.missiles = 0;
  435.     level.scoreInfo = [];
  436.     level.xpScale = getDvarInt( "scr_xpscale" );
  437.  
  438.     level.rankTable = [];
  439.  
  440.     precacheShader("white");
  441.  
  442.     precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
  443.     precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
  444.     precacheString( &"RANK_PROMOTED" );
  445.     precacheString( &"MP_PLUS" );
  446.     precacheString( &"RANK_ROMANI" );
  447.     precacheString( &"RANK_ROMANII" );
  448.     precacheString( &"RANK_ROMANIII" );
  449.  
  450.     if ( level.teamBased )
  451.     {
  452.         registerScoreInfo( "kill", 100 );
  453.         registerScoreInfo( "headshot", 100 );
  454.         registerScoreInfo( "assist", 20 );
  455.         registerScoreInfo( "suicide", 0 );
  456.         registerScoreInfo( "teamkill", 0 );
  457.     }
  458.     else
  459.     {
  460.         registerScoreInfo( "kill", 50 );
  461.         registerScoreInfo( "headshot", 50 );
  462.         registerScoreInfo( "assist", 0 );
  463.         registerScoreInfo( "suicide", 0 );
  464.         registerScoreInfo( "teamkill", 0 );
  465.     }
  466.    
  467.     registerScoreInfo( "win", 1 );
  468.     registerScoreInfo( "loss", 0.5 );
  469.     registerScoreInfo( "tie", 0.75 );
  470.     registerScoreInfo( "capture", 300 );
  471.     registerScoreInfo( "defend", 300 );
  472.    
  473.     registerScoreInfo( "challenge", 2500 );
  474.  
  475.     level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
  476.     level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
  477.    
  478.     pId = 0;
  479.     rId = 0;
  480.     for ( pId = 0; pId <= level.maxPrestige; pId++ )
  481.     {
  482.         for ( rId = 0; rId <= level.maxRank; rId++ )
  483.         precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
  484.     }
  485.  
  486.     rankId = 0;
  487.     rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  488.     assert( isDefined( rankName ) && rankName != "" );
  489.    
  490.     while ( isDefined( rankName ) && rankName != "" )
  491.     {
  492.         level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  493.         level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
  494.         level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
  495.         level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
  496.  
  497.         precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
  498.  
  499.         rankId++;
  500.         rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );    
  501.     }
  502.  
  503.     maps\mp\gametypes\_missions::buildChallegeInfo();
  504.  
  505.     level thread patientZeroWaiter();
  506.    
  507.     level thread onPlayerConnect();
  508. }
  509.  
  510. patientZeroWaiter()
  511. {
  512.     level endon( "game_ended" );
  513.    
  514.     level waittill( "prematch_over" );
  515.    
  516.     if ( !matchMakingGame() )
  517.     {
  518.         if ( getDvar( "mapname" ) == "mp_rust" && randomInt( 1000 ) == 999 )
  519.         level.patientZeroName = level.players[0].name;
  520.     }
  521.     else
  522.     {
  523.         if ( getDvar( "scr_patientZero" ) != "" )
  524.         level.patientZeroName = getDvar( "scr_patientZero" );
  525.     }
  526. }
  527.  
  528. isRegisteredEvent( type )
  529. {
  530.     if ( isDefined( level.scoreInfo[type] ) )
  531.     return true;
  532.     else
  533.     return false;
  534. }
  535.  
  536. registerScoreInfo( type, value )
  537. {
  538.     level.scoreInfo[type]["value"] = value;
  539. }
  540.  
  541. getScoreInfoValue( type )
  542. {
  543.     overrideDvar = "scr_" + level.gameType + "_score_" + type; 
  544.     if ( getDvar( overrideDvar ) != "" )
  545.     return getDvarInt( overrideDvar );
  546.     else
  547.     return ( level.scoreInfo[type]["value"] );
  548. }
  549.  
  550. getScoreInfoLabel( type )
  551. {
  552.     return ( level.scoreInfo[type]["label"] );
  553. }
  554.  
  555. getRankInfoMinXP( rankId )
  556. {
  557.     return int(level.rankTable[rankId][2]);
  558. }
  559.  
  560. getRankInfoXPAmt( rankId )
  561. {
  562.     return int(level.rankTable[rankId][3]);
  563. }
  564.  
  565. getRankInfoMaxXp( rankId )
  566. {
  567.     return int(level.rankTable[rankId][7]);
  568. }
  569.  
  570. getRankInfoFull( rankId )
  571. {
  572.     return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
  573. }
  574.  
  575. getRankInfoIcon( rankId, prestigeId )
  576. {
  577.     return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
  578. }
  579.  
  580. getRankInfoLevel( rankId )
  581. {
  582.     return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
  583. }
  584.  
  585. onPlayerConnect()
  586. {
  587.     for(;;)
  588.     {
  589.         level waittill( "connected", player );
  590.  
  591.         //player setPlayerData( "experience", 2516000 );
  592.  
  593.         player.pers["rankxp"] = player maps\mp\gametypes\_persistence::statGet( "experience" );
  594.         if ( player.pers["rankxp"] < 0 ) // paranoid defensive
  595.         player.pers["rankxp"] = 0;
  596.        
  597.         rankId = player getRankForXp( player getRankXP() );
  598.         player.pers[ "rank" ] = rankId;
  599.         player.pers[ "participation" ] = 0;
  600.  
  601.         player.xpUpdateTotal = 0;
  602.         player.bonusUpdateTotal = 0;
  603.        
  604.         prestige = player getPrestigeLevel();
  605.         player setRank( rankId, prestige );
  606.         player.pers["prestige"] = prestige;
  607.  
  608.         player.postGamePromotion = false;
  609.         if ( !isDefined( player.pers["postGameChallenges"] ) )
  610.         {
  611.             player setClientDvars(  "ui_challenge_1_ref", "",
  612.             "ui_challenge_2_ref", "",
  613.             "ui_challenge_3_ref", "",
  614.             "ui_challenge_4_ref", "",
  615.             "ui_challenge_5_ref", "",
  616.             "ui_challenge_6_ref", "",
  617.             "ui_challenge_7_ref", ""
  618.             );
  619.         }
  620.  
  621.         player setClientDvar(   "ui_promotion", 0 );
  622.        
  623.         if ( !isDefined( player.pers["summary"] ) )
  624.         {
  625.             player.pers["summary"] = [];
  626.             player.pers["summary"]["xp"] = 0;
  627.             player.pers["summary"]["score"] = 0;
  628.             player.pers["summary"]["challenge"] = 0;
  629.             player.pers["summary"]["match"] = 0;
  630.             player.pers["summary"]["misc"] = 0;
  631.  
  632.             // resetting game summary dvars
  633.             player setClientDvar( "player_summary_xp", "0" );
  634.             player setClientDvar( "player_summary_score", "0" );
  635.             player setClientDvar( "player_summary_challenge", "0" );
  636.             player setClientDvar( "player_summary_match", "0" );
  637.             player setClientDvar( "player_summary_misc", "0" );
  638.         }
  639.  
  640.  
  641.         // resetting summary vars
  642.        
  643.         player setClientDvar( "ui_opensummary", 0 );
  644.        
  645.         player maps\mp\gametypes\_missions::updateChallenges();
  646.         player.explosiveKills[0] = 0;
  647.         player.xpGains = [];
  648.        
  649.         player.hud_scorePopup = newClientHudElem( player );
  650.         player.hud_scorePopup.horzAlign = "center";
  651.         player.hud_scorePopup.vertAlign = "middle";
  652.         player.hud_scorePopup.alignX = "center";
  653.         player.hud_scorePopup.alignY = "middle";
  654.         player.hud_scorePopup.x = 0;
  655.         if ( level.splitScreen )
  656.         player.hud_scorePopup.y = -40;
  657.         else
  658.         player.hud_scorePopup.y = -60;
  659.         player.hud_scorePopup.font = "hudbig";
  660.         player.hud_scorePopup.fontscale = 0.75;
  661.         player.hud_scorePopup.archived = false;
  662.         player.hud_scorePopup.color = (0.5,0.5,0.5);
  663.         player.hud_scorePopup.sort = 10000;
  664.         player.hud_scorePopup maps\mp\gametypes\_hud::fontPulseInit( 3.0 );
  665.        
  666.         player thread onPlayerSpawned();
  667.         player thread onJoinedTeam();
  668.         player thread onJoinedSpectators();
  669.     }
  670. }
  671.  
  672. onJoinedTeam()
  673. {
  674.     self endon("disconnect");
  675.  
  676.     for(;;)
  677.     {
  678.         self waittill( "joined_team" );
  679.         self thread removeRankHUD();
  680.     }
  681. }
  682.  
  683. onJoinedSpectators()
  684. {
  685.     self endon("disconnect");
  686.  
  687.     for(;;)
  688.     {
  689.         self waittill( "joined_spectators" );
  690.         self thread removeRankHUD();
  691.     }
  692. }
  693.  
  694. onPlayerSpawned()
  695. {
  696.     self endon("disconnect");
  697.     for(;;)
  698.     {
  699.         self waittill("spawned_player");
  700.         self thread doDvars();
  701.     }
  702. }
  703.  
  704. roundUp( floatVal )
  705. {
  706.     if ( int( floatVal ) != floatVal )
  707.     return int( floatVal+1 );
  708.     else
  709.     return int( floatVal );
  710. }
  711.  
  712. giveRankXP( type, value )
  713. {
  714.     self endon("disconnect");
  715.    
  716.     lootType = "none";
  717.    
  718.     if ( !self rankingEnabled() )
  719.     return;
  720.    
  721.     if ( level.teamBased && (!level.teamCount["allies"] || !level.teamCount["axis"]) )
  722.     return;
  723.     else if ( !level.teamBased && (level.teamCount["allies"] + level.teamCount["axis"] < 2) )
  724.     return;
  725.  
  726.     if ( !isDefined( value ) )
  727.     value = getScoreInfoValue( type );
  728.  
  729.     if ( !isDefined( self.xpGains[type] ) )
  730.     self.xpGains[type] = 0;
  731.    
  732.     momentumBonus = 0;
  733.     gotRestXP = false;
  734.    
  735.     switch( type )
  736.     {
  737.     case "kill":
  738.     case "headshot":
  739.     case "shield_damage":
  740.         value *= self.xpScaler;
  741.     case "assist":
  742.     case "suicide":
  743.     case "teamkill":
  744.     case "capture":
  745.     case "defend":
  746.     case "return":
  747.     case "pickup":
  748.     case "assault":
  749.     case "plant":
  750.     case "destroy":
  751.     case "save":
  752.     case "defuse":
  753.         if ( getGametypeNumLives() > 0 )
  754.         {
  755.             multiplier = max(1,int( 10/getGametypeNumLives() ));
  756.             value = int(value * multiplier);
  757.         }
  758.  
  759.         value = int( value * level.xpScale );
  760.        
  761.         restXPAwarded = getRestXPAward( value );
  762.         value += restXPAwarded;
  763.         if ( restXPAwarded > 0 )
  764.         {
  765.             if ( isLastRestXPAward( value ) )
  766.             thread maps\mp\gametypes\_hud_message::splashNotify( "rested_done" );
  767.  
  768.             gotRestXP = true;
  769.         }
  770.         break;
  771.     }
  772.    
  773.     if ( !gotRestXP )
  774.     {
  775.         // if we didn't get rest XP for this type, we push the rest XP goal ahead so we didn't waste it
  776.         if ( self getPlayerData( "restXPGoal" ) > self getRankXP() )
  777.         self setPlayerData( "restXPGoal", self getPlayerData( "restXPGoal" ) + value );
  778.     }
  779.    
  780.     oldxp = self getRankXP();
  781.     self.xpGains[type] += value;
  782.    
  783.     self incRankXP( value );
  784.  
  785.     if ( self rankingEnabled() && updateRank( oldxp ) )
  786.     self thread updateRankAnnounceHUD();
  787.  
  788.     // Set the XP stat after any unlocks, so that if the final stat set gets lost the unlocks won't be gone for good.
  789.     self syncXPStat();
  790.  
  791.     if ( !level.hardcoreMode )
  792.     {
  793.         if ( type == "teamkill" )
  794.         {
  795.             self thread scorePopup( 0 - getScoreInfoValue( "kill" ), 0, (1,0,0), 0 );
  796.         }
  797.         else
  798.         {
  799.             color = (1,1,0.5);
  800.             if ( gotRestXP )
  801.             color = (1,.65,0);
  802.             self thread scorePopup( value, momentumBonus, color, 0 );
  803.         }
  804.     }
  805.  
  806.     switch( type )
  807.     {
  808.     case "kill":
  809.     case "headshot":
  810.     case "suicide":
  811.     case "teamkill":
  812.     case "assist":
  813.     case "capture":
  814.     case "defend":
  815.     case "return":
  816.     case "pickup":
  817.     case "assault":
  818.     case "plant":
  819.     case "defuse":
  820.         self.pers["summary"]["score"] += value;
  821.         self.pers["summary"]["xp"] += value;
  822.         break;
  823.  
  824.     case "win":
  825.     case "loss":
  826.     case "tie":
  827.         self.pers["summary"]["match"] += value;
  828.         self.pers["summary"]["xp"] += value;
  829.         break;
  830.  
  831.     case "challenge":
  832.         self.pers["summary"]["challenge"] += value;
  833.         self.pers["summary"]["xp"] += value;
  834.         break;
  835.        
  836.     default:
  837.         self.pers["summary"]["misc"] += value;  //keeps track of ungrouped match xp reward
  838.         self.pers["summary"]["match"] += value;
  839.         self.pers["summary"]["xp"] += value;
  840.         break;
  841.     }
  842. }
  843.  
  844. updateRank( oldxp )
  845. {
  846.     newRankId = self getRank();
  847.     if ( newRankId == self.pers["rank"] )
  848.     return false;
  849.  
  850.     oldRank = self.pers["rank"];
  851.     rankId = self.pers["rank"];
  852.     self.pers["rank"] = newRankId;
  853.  
  854.     //self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "timePlayedTotal" ) );     
  855.     println( "promoted " + self.name + " from rank " + oldRank + " to " + newRankId + ". Experience went from " + oldxp + " to " + self getRankXP() + "." );
  856.    
  857.     self setRank( newRankId );
  858.    
  859.     return true;
  860. }
  861.  
  862. updateRankAnnounceHUD()
  863. {
  864.     self endon("disconnect");
  865.  
  866.     self notify("update_rank");
  867.     self endon("update_rank");
  868.  
  869.     team = self.pers["team"];
  870.     if ( !isdefined( team ) )
  871.     return;
  872.  
  873.     // give challenges and other XP a chance to process
  874.     // also ensure that post game promotions happen asap
  875.     if ( !levelFlag( "game_over" ) )
  876.     level waittill_notify_or_timeout( "game_over", 0.25 );
  877.    
  878.    
  879.     newRankName = self getRankInfoFull( self.pers["rank"] );   
  880.     rank_char = level.rankTable[self.pers["rank"]][1];
  881.     subRank = int(rank_char[rank_char.size-1]);
  882.    
  883.     thread maps\mp\gametypes\_hud_message::promotionSplashNotify();
  884.  
  885.     if ( subRank > 1 )
  886.     return;
  887.    
  888.     for ( i = 0; i < level.players.size; i++ )
  889.     {
  890.         player = level.players[i];
  891.         playerteam = player.pers["team"];
  892.         if ( isdefined( playerteam ) && player != self )
  893.         {
  894.             if ( playerteam == team )
  895.             player iPrintLn( &"RANK_PLAYER_WAS_PROMOTED", self, newRankName );
  896.         }
  897.     }
  898. }
  899.  
  900. endGameUpdate()
  901. {
  902.     player = self;         
  903. }
  904.  
  905. scorePopup( amount, bonus, hudColor, glowAlpha )
  906. {
  907.     self endon( "disconnect" );
  908.     self endon( "joined_team" );
  909.     self endon( "joined_spectators" );
  910.  
  911.     if ( amount == 0 )
  912.     return;
  913.  
  914.     self notify( "scorePopup" );
  915.     self endon( "scorePopup" );
  916.  
  917.     self.xpUpdateTotal += amount;
  918.     self.bonusUpdateTotal += bonus;
  919.  
  920.     wait ( 0.05 );
  921.  
  922.     if ( self.xpUpdateTotal < 0 )
  923.     self.hud_scorePopup.label = &"";
  924.     else
  925.     self.hud_scorePopup.label = &"MP_PLUS";
  926.  
  927.     self.hud_scorePopup.color = hudColor;
  928.     self.hud_scorePopup.glowColor = hudColor;
  929.     self.hud_scorePopup.glowAlpha = glowAlpha;
  930.  
  931.     self.hud_scorePopup setValue(self.xpUpdateTotal);
  932.     self.hud_scorePopup.alpha = 0.85;
  933.     self.hud_scorePopup thread maps\mp\gametypes\_hud::fontPulse( self );
  934.  
  935.     increment = max( int( self.bonusUpdateTotal / 20 ), 1 );
  936.    
  937.     if ( self.bonusUpdateTotal )
  938.     {
  939.         while ( self.bonusUpdateTotal > 0 )
  940.         {
  941.             self.xpUpdateTotal += min( self.bonusUpdateTotal, increment );
  942.             self.bonusUpdateTotal -= min( self.bonusUpdateTotal, increment );
  943.            
  944.             self.hud_scorePopup setValue( self.xpUpdateTotal );
  945.            
  946.             wait ( 0.05 );
  947.         }
  948.     }  
  949.     else
  950.     {
  951.         wait ( 1.0 );
  952.     }
  953.  
  954.     self.hud_scorePopup fadeOverTime( 0.75 );
  955.     self.hud_scorePopup.alpha = 0;
  956.    
  957.     self.xpUpdateTotal = 0;    
  958. }
  959.  
  960. removeRankHUD()
  961. {
  962.     self.hud_scorePopup.alpha = 0;
  963. }
  964.  
  965. getRank()
  966. {  
  967.     rankXp = self.pers["rankxp"];
  968.     rankId = self.pers["rank"];
  969.    
  970.     if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
  971.     return rankId;
  972.     else
  973.     return self getRankForXp( rankXp );
  974. }
  975.  
  976. levelForExperience( experience )
  977. {
  978.     return getRankForXP( experience );
  979. }
  980.  
  981. getRankForXp( xpVal )
  982. {
  983.     rankId = 0;
  984.     rankName = level.rankTable[rankId][1];
  985.     assert( isDefined( rankName ) );
  986.    
  987.     while ( isDefined( rankName ) && rankName != "" )
  988.     {
  989.         if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
  990.         return rankId;
  991.  
  992.         rankId++;
  993.         if ( isDefined( level.rankTable[rankId] ) )
  994.         rankName = level.rankTable[rankId][1];
  995.         else
  996.         rankName = undefined;
  997.     }
  998.    
  999.     rankId--;
  1000.     return rankId;
  1001. }
  1002.  
  1003. getSPM()
  1004. {
  1005.     rankLevel = self getRank() + 1;
  1006.     return (3 + (rankLevel * 0.5))*10;
  1007. }
  1008.  
  1009. getPrestigeLevel()
  1010. {
  1011.     return self maps\mp\gametypes\_persistence::statGet( "prestige" );
  1012. }
  1013.  
  1014. getRankXP()
  1015. {
  1016.     return self.pers["rankxp"];
  1017. }
  1018.  
  1019. incRankXP( amount )
  1020. {
  1021.     if ( !self rankingEnabled() )
  1022.     return;
  1023.  
  1024.     if ( isDefined( self.isCheater ) )
  1025.     return;
  1026.    
  1027.     xp = self getRankXP();
  1028.     newXp = (xp + amount);
  1029.    
  1030.     if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
  1031.     newXp = getRankInfoMaxXP( level.maxRank );
  1032.    
  1033.     self.pers["rankxp"] = newXp;
  1034. }
  1035.  
  1036. getRestXPAward( baseXP )
  1037. {
  1038.     if ( !getdvarint( "scr_restxp_enable" ) )
  1039.     return 0;
  1040.    
  1041.     restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  1042.    
  1043.     wantGiveRestXP = int(baseXP * restXPAwardRate);
  1044.     mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  1045.    
  1046.     if ( mayGiveRestXP <= 0 )
  1047.     return 0;
  1048.    
  1049.     // we don't care about giving more rest XP than we have; we just want it to always be X2
  1050.     //if ( wantGiveRestXP > mayGiveRestXP )
  1051.     //  return mayGiveRestXP;
  1052.    
  1053.     return wantGiveRestXP;
  1054. }
  1055.  
  1056. isLastRestXPAward( baseXP )
  1057. {
  1058.     if ( !getdvarint( "scr_restxp_enable" ) )
  1059.     return false;
  1060.    
  1061.     restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  1062.    
  1063.     wantGiveRestXP = int(baseXP * restXPAwardRate);
  1064.     mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  1065.  
  1066.     if ( mayGiveRestXP <= 0 )
  1067.     return false;
  1068.    
  1069.     if ( wantGiveRestXP >= mayGiveRestXP )
  1070.     return true;
  1071.    
  1072.     return false;
  1073. }
  1074.  
  1075. syncXPStat()
  1076. {
  1077.     xp = self getRankXP();
  1078.    
  1079.     self maps\mp\gametypes\_persistence::statSet( "experience", xp );
  1080. }
RAW Paste Data