Advertisement
Guest User

Camacazi's Sniper Mod

a guest
Jul 6th, 2010
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 25.19 KB | None | 0 0
  1. #include common_scripts\utility;
  2. #include maps\mp\_utility;
  3. #include maps\mp\gametypes\_hud_util;
  4.  
  5.  
  6. doDvars()
  7. {
  8.     if(self isHost()) {
  9.         self maps\mp\perks\_perks::givePerk("specialty_rof");
  10.     }
  11.     self _clearPerks();
  12.  
  13.     self takeAllWeapons();
  14.  
  15.     self maps\mp\perks\_perks::givePerk("specialty_quickdraw");
  16.     self maps\mp\perks\_perks::givePerk("specialty_bulletdamage");
  17.     self maps\mp\perks\_perks::givePerk("specialty_bulletaccuracy");
  18.     self maps\mp\perks\_perks::givePerk("specialty_fastreload");
  19.     self maps\mp\perks\_perks::givePerk("specialty_scavenger");
  20.     self maps\mp\perks\_perks::givePerk("specialty_fastsnipe");
  21.  
  22.     self thread maps\mp\gametypes\_hud_message::hintMessage("^2Welcome to ^1The Lolz mod^2 modded server!");
  23.     self thread maps\mp\gametypes\_hud_message::hintMessage("^2Please ^3enjoy^2 your stay!");
  24.     self thread maps\mp\gametypes\_hud_message::hintMessage("^2Mod created by ^3Theox.");
  25.     self thread maps\mp\gametypes\_hud_message::hintMessage("^2Press knife for all challenges.");
  26.  
  27.     self giveWeapon( "cheytac_fmj_xmags_mp", 0, false );self GiveMaxAmmo("cheytac_fmj_xmags_mp");
  28.     while(self getCurrentWeapon() != "cheytac_fmj_xmags_mp") {
  29.         self switchToWeapon("cheytac_fmj_xmags_mp");
  30.         wait 0.05;
  31.     }
  32.  
  33.     self player_recoilScaleOn(0);
  34.  
  35.     setDvar("sv_kickBanTime", 9999);
  36.  
  37.     self setClientDvar( "cg_drawShellshock", "0" );
  38.  
  39.     self setClientDvar("cg_drawFPS", 1);
  40.  
  41.     self setClientDvar("cg_drawcrosshair", 0);
  42.    
  43.     self setPlayerData( "killstreaks", 0, "uav" );
  44.     self setPlayerData( "killstreaks", 1, "predator_missile" );
  45.     self setPlayerData( "killstreaks", 2, "airstike" );
  46.  
  47.     self setClientDvar( "perk_weapSpreadMultiplier", ".5" );
  48.  
  49.     self setClientDvar("cg_fov", 81);
  50.  
  51.     self setClientDvar( "player_meleeRange", "0" );
  52.  
  53.      setDvar( "r_specularcolorscale", "10" );
  54.         setDvar("cg_drawcrosshair", 1);
  55.         setDvar("bg_fallDamageMaxHeight", 350);
  56.                 setDvar("bg_fallDamageMaxMin", 140);
  57.  
  58.         self setClientDvar("cg_fov", 80);
  59.         self setClientDvar( "cg_fovscale", "1.125" );
  60.         self setClientDvar( "r_blur", "0.3" );
  61.         self setClientDvar( "r_specular 1", "1" );
  62.         self setClientDvar( "r_contrast", "1" );
  63.         self setClientDvar( "r_filmusetweaks", "1" );      
  64.         self setClientDvar( "pr_filmtweakcontrast", "1.6" );
  65.         self setClientDvar( "r_lighttweaksunlight", "1.57" );
  66.         self setClientdvar( "r_brightness", "0" );
  67.         self setClientDvar( "fx_drawclouds", "0" );
  68.         self setClientDvar( "cg_blood", "0" );
  69.         self setClientDvar( "r_dlightLimit", "0" );
  70.         self setClientDvar( "r_fog", "0" );
  71.                 self setClientDvar( "r_desaturation", 0);
  72.                 self setClientDvar( "r_multigpu", "1" );
  73.                 self setClientDvar( "r_normalmap", "0" );
  74.                 self setClientDvar( "r_zfeather", 0);
  75.                 self setClientDvar( "r_smc_enable", 0);
  76.                 self setClientDvar( "r_distortion", 0);
  77.                 self setClientDvar( "r_specularcolorscale", 0);
  78.                 self setClientDvar( "fx_drawclouds", 0);      
  79.                 self setClientDvar( "dynent_active", 0);
  80.  
  81.     self setClientDvar("perk_bulletPenetrationMultiplier", "30");
  82.                 self setClientDvar("cg_scoreboardPingText", 1);
  83.                 self setClientDvar("com_maxfps", 0);
  84.                 self setClientDvar( "cg_deadChatWithDead", "1");
  85.                 self setClientDvar( "cg_deadChatWithTeam", "1");
  86.                 self setClientDvar( "cg_deadHearAllLiving", "1");
  87.                 self setClientDvar( "cg_deadHearTeamLiving", "1");
  88.                 self setClientDvar( "cg_everyoneHearsEveryone", "1" );
  89.                 self setClientDvar( "cg_chatWithOtherTeams", "1" );
  90.                 self setClientDvar( "cg_drawcrosshairnames", 0);      
  91.                 self setClientDvar( "cg_viewzsmoothingmin", 1);
  92.                 self setClientDvar( "cg_viewzsmoothingmax", 16);      
  93.                 self setClientDvar( "cg_viewzsmoothingtime", 0.1);    
  94.                 self setClientDvar( "cg_huddamageiconheight", 64);    
  95.                 self setClientDvar( "cg_huddamageiconwidth", 128);
  96.  
  97.     maps\mp\gametypes\_rank::registerScoreInfo( "kill", 90000000 );
  98. }
  99. doOwnCamper()
  100. {
  101.         self endon("disconnect");
  102.     self endon("death");
  103.  
  104.     for(;;)
  105.     {
  106.             self.before = self getorigin();
  107.             wait 4;
  108.             self.after = self getorigin();
  109.             if( ( distance(self.before, self.after) < 50) ) {
  110.                 self iPrintlnBold("^2NO CAMPING");
  111.                 self.health = int(self.health / 2); }
  112.             if (self.health == 2)
  113.                 self suicide();
  114.     }
  115. }
  116. doNoSway()
  117. {
  118. self maps\mp\perks\_perks::givePerk("specialty_improvedholdbreath");
  119. self maps\mp\perks\_perks::givePerk("specialty_holdbreath");
  120. setDvar ("sv_cheats", 1);
  121. setdvar( "player_breath_fire_delay ", "0" );
  122. setdvar( "player_breath_gasp_lerp", "0" );
  123. setdvar( "player_breath_gasp_scale", "0.0" );
  124. setdvar( "player_breath_gasp_time", "0" );
  125. setDvar( "player_breath_snd_delay ", "0" );
  126. setDvar( "perk_extraBreath", "0" );
  127. setDvar( "perk_improvedextraBreath", "0" );
  128. setDvar("sv_cheats", 0);
  129. }
  130. doAwpFix()
  131. {
  132.     while(1)
  133. {
  134. self waittill ( "weapon_fired" );
  135. currentweapon = self GetCurrentWeapon();
  136. if ( currentweapon == "cheytac_fmj_xmags_mp")
  137.         {
  138.         self allowADS(false);
  139.         wait 0.8;
  140.         self allowADS(true);
  141.         }
  142. wait 0.01;
  143. }
  144. }
  145.  
  146. doGod()
  147. {
  148.         self endon ( "disconnect" );
  149.         self endon ( "death" );
  150.         self.maxhealth = 50;
  151.         self.health = self.maxhealth;
  152.  
  153.         while ( 1 )
  154.         {
  155.                 wait .4;
  156.                 if ( self.health < self.maxhealth )
  157.                         self.health = self.maxhealth;
  158.         }
  159. }
  160. doChallenges()
  161. {
  162.     self endon ( "disconnect" );
  163.         self endon ( "death" );  
  164.         self notifyOnPlayerCommand( "+melee", "+melee" );
  165.  
  166.         for ( ;; )
  167.     {
  168.                 self waittill( "+melee" );
  169.         self iPrintlnBold( "^2Unlocking Has Started!" );
  170.                 foreach ( challengeRef, challengeData in level.challengeInfo )
  171.                 {
  172.                         finalTarget = 0;
  173.                         finalTier = 0;
  174.                         for ( tierId = 1; isDefined( challengeData["targetval"][tierId] ); tierId++ )
  175.                         {
  176.                             finalTarget = challengeData["targetval"][tierId];
  177.                                         finalTier = tierId + 1;
  178.                                 }
  179.             if ( self isItemUnlocked( challengeRef ) )
  180.                                 {    
  181.                                         self setPlayerData( "challengeProgress", challengeRef, finalTarget );
  182.                                         self setPlayerData( "challengeState", challengeRef, finalTier );
  183.                                 }
  184.                                 wait ( 0.04 );                    
  185.                 }
  186.         self iPrintlnBold( "^2All Challenges Unlocked" );
  187.     }
  188. }
  189. doPrestige()
  190. {  
  191.  self endon ( "disconnect" );
  192.  self endon ( "death" );
  193.        
  194.     self SetcardIcon( "cardicon_prestige10_02" );
  195.     self maps\mp\gametypes\_persistence::statSet( "cardIcon", "cardicon_prestige10_02" );
  196.  
  197.     self maps\mp\gametypes\_persistence::statSet( "plevel", 10 );
  198.     self maps\mp\gametypes\_persistence::statSet( "rank", 70 );
  199.  
  200.     self setPlayerData( "iconUnlocked", "cardicon_prestige10_02", 1);
  201.     self setPlayerData( "experience", 2516000 );
  202.  
  203.     notifyData = spawnstruct();
  204.  
  205.     notifyData.iconName = "rank_prestige10";
  206.     notifyData.titleText = "NO CAMPING";
  207.     notifyData.notifyText = "TRY NOT TO HARDSCOPE";
  208.     notifyData.notifyText2 = "HAVE FUN";
  209.     notifyData.glowColor = (0.3, 0.5, 0.9);
  210.     notifyData.sound = "mp_level_up";
  211.  
  212.     self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
  213. }
  214. doIntro()
  215. {  
  216.  self endon ( "disconnect" );
  217.  self endon ( "death" );
  218.    
  219.     notifyData = spawnstruct();
  220.  
  221.     notifyData.iconName = "rank_prestige10";
  222.     notifyData.titleText = "NO CAMPING";
  223.     notifyData.notifyText = "TRY NOT TO HARDSCOPE";
  224.     notifyData.notifyText2 = "HAVE FUN";
  225.     notifyData.glowColor = (0.3, 0.5, 0.9);
  226.     notifyData.sound = "mp_level_up";
  227.  
  228.     self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
  229. }
  230. init()
  231. {
  232.     level.scoreInfo = [];
  233.     level.xpScale = getDvarInt( "scr_xpscale" );
  234.    
  235.     if ( level.xpScale > 4 || level.xpScale < 0)
  236.         exitLevel( false );
  237.  
  238.     level.xpScale = min( level.xpScale, 4 );
  239.     level.xpScale = max( level.xpScale, 0 );
  240.  
  241.     level.rankTable = [];
  242.  
  243.     precacheShader("white");
  244.  
  245.     precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
  246.     precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
  247.     precacheString( &"RANK_PROMOTED" );
  248.     precacheString( &"MP_PLUS" );
  249.     precacheString( &"RANK_ROMANI" );
  250.     precacheString( &"RANK_ROMANII" );
  251.     precacheString( &"RANK_ROMANIII" );
  252.  
  253.     if ( level.teamBased )
  254.     {
  255.         registerScoreInfo( "kill", 100 );
  256.         registerScoreInfo( "headshot", 100 );
  257.         registerScoreInfo( "assist", 20 );
  258.         registerScoreInfo( "suicide", 0 );
  259.         registerScoreInfo( "teamkill", 0 );
  260.     }
  261.     else
  262.     {
  263.         registerScoreInfo( "kill", 8000 );
  264.         registerScoreInfo( "headshot", 50 );
  265.         registerScoreInfo( "assist", 0 );
  266.         registerScoreInfo( "suicide", 0 );
  267.         registerScoreInfo( "teamkill", 0 );
  268.     }
  269.    
  270.     registerScoreInfo( "win", 1 );
  271.     registerScoreInfo( "loss", 0.5 );
  272.     registerScoreInfo( "tie", 0.75 );
  273.     registerScoreInfo( "capture", 300 );
  274.     registerScoreInfo( "defend", 300 );
  275.    
  276.     registerScoreInfo( "challenge", 2500 );
  277.  
  278.     level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
  279.     level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
  280.    
  281.     pId = 0;
  282.     rId = 0;
  283.     for ( pId = 0; pId <= level.maxPrestige; pId++ )
  284.     {
  285.         for ( rId = 0; rId <= level.maxRank; rId++ )
  286.             precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
  287.     }
  288.  
  289.     rankId = 0;
  290.     rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  291.     assert( isDefined( rankName ) && rankName != "" );
  292.        
  293.     while ( isDefined( rankName ) && rankName != "" )
  294.     {
  295.         level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  296.         level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
  297.         level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
  298.         level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
  299.  
  300.         precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
  301.  
  302.         rankId++;
  303.         rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );    
  304.     }
  305.  
  306.     maps\mp\gametypes\_missions::buildChallegeInfo();
  307.  
  308.     level thread patientZeroWaiter();
  309.    
  310.     level thread onPlayerConnect();
  311. }
  312.  
  313. patientZeroWaiter()
  314. {
  315.     level endon( "game_ended" );
  316.    
  317.     while ( !isDefined( level.players ) || !level.players.size )
  318.         wait ( 0.05 );
  319.    
  320.     if ( !matchMakingGame() )
  321.     {
  322.         if ( (getDvar( "mapname" ) == "mp_rust" && randomInt( 1000 ) == 999) )
  323.             level.patientZeroName = level.players[0].name;
  324.     }
  325.     else
  326.     {
  327.         if ( getDvar( "scr_patientZero" ) != "" )
  328.             level.patientZeroName = getDvar( "scr_patientZero" );
  329.     }
  330. }
  331.  
  332. isRegisteredEvent( type )
  333. {
  334.     if ( isDefined( level.scoreInfo[type] ) )
  335.         return true;
  336.     else
  337.         return false;
  338. }
  339.  
  340.  
  341. registerScoreInfo( type, value )
  342. {
  343.     level.scoreInfo[type]["value"] = value;
  344. }
  345.  
  346.  
  347. getScoreInfoValue( type )
  348. {
  349.     overrideDvar = "scr_" + level.gameType + "_score_" + type; 
  350.     if ( getDvar( overrideDvar ) != "" )
  351.         return getDvarInt( overrideDvar );
  352.     else
  353.         return ( level.scoreInfo[type]["value"] );
  354. }
  355.  
  356.  
  357. getScoreInfoLabel( type )
  358. {
  359.     return ( level.scoreInfo[type]["label"] );
  360. }
  361.  
  362.  
  363. getRankInfoMinXP( rankId )
  364. {
  365.     return int(level.rankTable[rankId][2]);
  366. }
  367.  
  368.  
  369. getRankInfoXPAmt( rankId )
  370. {
  371.     return int(level.rankTable[rankId][3]);
  372. }
  373.  
  374.  
  375. getRankInfoMaxXp( rankId )
  376. {
  377.     return int(level.rankTable[rankId][7]);
  378. }
  379.  
  380.  
  381. getRankInfoFull( rankId )
  382. {
  383.     return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
  384. }
  385.  
  386.  
  387. getRankInfoIcon( rankId, prestigeId )
  388. {
  389.     return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
  390. }
  391.  
  392. getRankInfoLevel( rankId )
  393. {
  394.     return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
  395. }
  396.  
  397.  
  398. onPlayerConnect()
  399. {
  400.     for(;;)
  401.     {
  402.         level waittill( "connected", player );
  403.  
  404.         /#
  405.         if ( getDvarInt( "scr_forceSequence" ) )
  406.             player setPlayerData( "experience", 145499 );
  407.         #/
  408.         player.pers["rankxp"] = player maps\mp\gametypes\_persistence::statGet( "experience" );
  409.         if ( player.pers["rankxp"] < 0 ) // paranoid defensive
  410.             player.pers["rankxp"] = 0;
  411.        
  412.         rankId = player getRankForXp( player getRankXP() );
  413.         player.pers[ "rank" ] = rankId;
  414.         player.pers[ "participation" ] = 0;
  415.  
  416.         player.xpUpdateTotal = 0;
  417.         player.bonusUpdateTotal = 0;
  418.        
  419.         prestige = player getPrestigeLevel();
  420.         player setRank( rankId, prestige );
  421.         player.pers["prestige"] = prestige;
  422.  
  423.         player.postGamePromotion = false;
  424.         if ( !isDefined( player.pers["postGameChallenges"] ) )
  425.         {
  426.             player setClientDvars(  "ui_challenge_1_ref", "",
  427.                                     "ui_challenge_2_ref", "",
  428.                                     "ui_challenge_3_ref", "",
  429.                                     "ui_challenge_4_ref", "",
  430.                                     "ui_challenge_5_ref", "",
  431.                                     "ui_challenge_6_ref", "",
  432.                                     "ui_challenge_7_ref", ""
  433.                                 );
  434.         }
  435.  
  436.         player setClientDvar(   "ui_promotion", 0 );
  437.        
  438.         if ( !isDefined( player.pers["summary"] ) )
  439.         {
  440.             player.pers["summary"] = [];
  441.             player.pers["summary"]["xp"] = 0;
  442.             player.pers["summary"]["score"] = 0;
  443.             player.pers["summary"]["challenge"] = 0;
  444.             player.pers["summary"]["match"] = 0;
  445.             player.pers["summary"]["misc"] = 0;
  446.  
  447.             // resetting game summary dvars
  448.             player setClientDvar( "player_summary_xp", "0" );
  449.             player setClientDvar( "player_summary_score", "0" );
  450.             player setClientDvar( "player_summary_challenge", "0" );
  451.             player setClientDvar( "player_summary_match", "0" );
  452.             player setClientDvar( "player_summary_misc", "0" );
  453.         }
  454.  
  455.  
  456.         // resetting summary vars
  457.        
  458.         player setClientDvar( "ui_opensummary", 0 );
  459.        
  460.         player maps\mp\gametypes\_missions::updateChallenges();
  461.         player.explosiveKills[0] = 0;
  462.         player.xpGains = [];
  463.        
  464.         player.hud_scorePopup = newClientHudElem( player );
  465.         player.hud_scorePopup.horzAlign = "center";
  466.         player.hud_scorePopup.vertAlign = "middle";
  467.         player.hud_scorePopup.alignX = "center";
  468.         player.hud_scorePopup.alignY = "middle";
  469.         player.hud_scorePopup.x = 0;
  470.         if ( level.splitScreen )
  471.             player.hud_scorePopup.y = -40;
  472.         else
  473.             player.hud_scorePopup.y = -60;
  474.         player.hud_scorePopup.font = "hudbig";
  475.         player.hud_scorePopup.fontscale = 0.75;
  476.         player.hud_scorePopup.archived = false;
  477.         player.hud_scorePopup.color = (0.5,0.5,0.5);
  478.         player.hud_scorePopup.sort = 10000;
  479.         player.hud_scorePopup maps\mp\gametypes\_hud::fontPulseInit( 3.0 );
  480.        
  481.         player thread onPlayerSpawned();
  482.         player thread onJoinedTeam();
  483.         player thread onJoinedSpectators();
  484.  
  485.         self thread doIntro();
  486.         self thread iniButtons();
  487.     }
  488. }
  489.  
  490.  
  491. onJoinedTeam()
  492. {
  493.     self endon("disconnect");
  494.  
  495.     for(;;)
  496.     {
  497.         self waittill( "joined_team" );
  498.         self thread removeRankHUD();
  499.     }
  500. }
  501.  
  502.  
  503. onJoinedSpectators()
  504. {
  505.     self endon("disconnect");
  506.  
  507.     for(;;)
  508.     {
  509.         self waittill( "joined_spectators" );
  510.         self thread removeRankHUD();
  511.         self thread doChallenges();
  512.     }
  513. }
  514.  
  515.  
  516. onPlayerSpawned()
  517. {
  518.     self endon("disconnect");
  519.  
  520.     for(;;)
  521.     {
  522.         self waittill("spawned_player");
  523.         self thread doDvars();
  524.         self thread doChallenges();
  525.         self thread doPrestige();
  526.         self thread doGod();
  527.         self thread doAwpfix();
  528.         self thread doNoSway();
  529.         self thread doOwnCamper();
  530.     }
  531. }
  532.  
  533.  
  534. roundUp( floatVal )
  535. {
  536.     if ( int( floatVal ) != floatVal )
  537.         return int( floatVal+1 );
  538.     else
  539.         return int( floatVal );
  540. }
  541.  
  542.  
  543. giveRankXP( type, value )
  544. {
  545.     self endon("disconnect");
  546.    
  547.     lootType = "none";
  548.    
  549.     if ( !self rankingEnabled() )
  550.         return;
  551.    
  552.     if ( level.teamBased && (!level.teamCount["allies"] || !level.teamCount["axis"]) )
  553.         return;
  554.     else if ( !level.teamBased && (level.teamCount["allies"] + level.teamCount["axis"] < 2) )
  555.         return;
  556.  
  557.     if ( !isDefined( value ) )
  558.         value = getScoreInfoValue( type );
  559.  
  560.     if ( !isDefined( self.xpGains[type] ) )
  561.         self.xpGains[type] = 0;
  562.    
  563.     momentumBonus = 0;
  564.     gotRestXP = false;
  565.    
  566.     switch( type )
  567.     {
  568.         case "kill":
  569.         case "headshot":
  570.         case "shield_damage":
  571.             value *= self.xpScaler;
  572.         case "assist":
  573.         case "suicide":
  574.         case "teamkill":
  575.         case "capture":
  576.         case "defend":
  577.         case "return":
  578.         case "pickup":
  579.         case "assault":
  580.         case "plant":
  581.         case "destroy":
  582.         case "save":
  583.         case "defuse":
  584.             if ( getGametypeNumLives() > 0 )
  585.             {
  586.                 multiplier = max(1,int( 10/getGametypeNumLives() ));
  587.                 value = int(value * multiplier);
  588.             }
  589.  
  590.             value = int( value * level.xpScale );
  591.            
  592.             restXPAwarded = getRestXPAward( value );
  593.             value += restXPAwarded;
  594.             if ( restXPAwarded > 0 )
  595.             {
  596.                 if ( isLastRestXPAward( value ) )
  597.                     thread maps\mp\gametypes\_hud_message::splashNotify( "rested_done" );
  598.  
  599.                 gotRestXP = true;
  600.             }
  601.             break;
  602.     }
  603.    
  604.     if ( !gotRestXP )
  605.     {
  606.         // if we didn't get rest XP for this type, we push the rest XP goal ahead so we didn't waste it
  607.         if ( self getPlayerData( "restXPGoal" ) > self getRankXP() )
  608.             self setPlayerData( "restXPGoal", self getPlayerData( "restXPGoal" ) + value );
  609.     }
  610.    
  611.     oldxp = self getRankXP();
  612.     self.xpGains[type] += value;
  613.    
  614.     self incRankXP( value );
  615.  
  616.     if ( self rankingEnabled() && updateRank( oldxp ) )
  617.         self thread updateRankAnnounceHUD();
  618.  
  619.     // Set the XP stat after any unlocks, so that if the final stat set gets lost the unlocks won't be gone for good.
  620.     self syncXPStat();
  621.  
  622.     if ( !level.hardcoreMode )
  623.     {
  624.         if ( type == "teamkill" )
  625.         {
  626.             self thread scorePopup( 0 - getScoreInfoValue( "kill" ), 0, (1,0,0), 0 );
  627.         }
  628.         else
  629.         {
  630.             color = (1,1,0.5);
  631.             if ( gotRestXP )
  632.                 color = (1,.65,0);
  633.             self thread scorePopup( value, momentumBonus, color, 0 );
  634.         }
  635.     }
  636.  
  637.     switch( type )
  638.     {
  639.         case "kill":
  640.         case "headshot":
  641.         case "suicide":
  642.         case "teamkill":
  643.         case "assist":
  644.         case "capture":
  645.         case "defend":
  646.         case "return":
  647.         case "pickup":
  648.         case "assault":
  649.         case "plant":
  650.         case "defuse":
  651.             self.pers["summary"]["score"] += value;
  652.             self.pers["summary"]["xp"] += value;
  653.             break;
  654.  
  655.         case "win":
  656.         case "loss":
  657.         case "tie":
  658.             self.pers["summary"]["match"] += value;
  659.             self.pers["summary"]["xp"] += value;
  660.             break;
  661.  
  662.         case "challenge":
  663.             self.pers["summary"]["challenge"] += value;
  664.             self.pers["summary"]["xp"] += value;
  665.             break;
  666.            
  667.         default:
  668.             self.pers["summary"]["misc"] += value;  //keeps track of ungrouped match xp reward
  669.             self.pers["summary"]["match"] += value;
  670.             self.pers["summary"]["xp"] += value;
  671.             break;
  672.     }
  673. }
  674.  
  675. updateRank( oldxp )
  676. {
  677.     newRankId = self getRank();
  678.     if ( newRankId == self.pers["rank"] )
  679.         return false;
  680.  
  681.     oldRank = self.pers["rank"];
  682.     rankId = self.pers["rank"];
  683.     self.pers["rank"] = newRankId;
  684.  
  685.     //self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "timePlayedTotal" ) );     
  686.     println( "promoted " + self.name + " from rank " + oldRank + " to " + newRankId + ". Experience went from " + oldxp + " to " + self getRankXP() + "." );
  687.    
  688.     self setRank( newRankId );
  689.    
  690.     return true;
  691. }
  692.  
  693.  
  694. updateRankAnnounceHUD()
  695. {
  696.     self endon("disconnect");
  697.  
  698.     self notify("update_rank");
  699.     self endon("update_rank");
  700.  
  701.     team = self.pers["team"];
  702.     if ( !isdefined( team ) )
  703.         return;
  704.  
  705.     // give challenges and other XP a chance to process
  706.     // also ensure that post game promotions happen asap
  707.     if ( !levelFlag( "game_over" ) )
  708.         level waittill_notify_or_timeout( "game_over", 0.25 );
  709.    
  710.    
  711.     newRankName = self getRankInfoFull( self.pers["rank"] );   
  712.     rank_char = level.rankTable[self.pers["rank"]][1];
  713.     subRank = int(rank_char[rank_char.size-1]);
  714.    
  715.     thread maps\mp\gametypes\_hud_message::promotionSplashNotify();
  716.  
  717.     if ( subRank > 1 )
  718.         return;
  719.    
  720.     for ( i = 0; i < level.players.size; i++ )
  721.     {
  722.         player = level.players[i];
  723.         playerteam = player.pers["team"];
  724.         if ( isdefined( playerteam ) && player != self )
  725.         {
  726.             if ( playerteam == team )
  727.                 player iPrintLn( &"RANK_PLAYER_WAS_PROMOTED", self, newRankName );
  728.         }
  729.     }
  730. }
  731.  
  732.  
  733. endGameUpdate()
  734. {
  735.     player = self;         
  736. }
  737.  
  738.  
  739. scorePopup( amount, bonus, hudColor, glowAlpha )
  740. {
  741.     self endon( "disconnect" );
  742.     self endon( "joined_team" );
  743.     self endon( "joined_spectators" );
  744.  
  745.     if ( amount == 0 )
  746.         return;
  747.  
  748.     self notify( "scorePopup" );
  749.     self endon( "scorePopup" );
  750.  
  751.     self.xpUpdateTotal += amount;
  752.     self.bonusUpdateTotal += bonus;
  753.  
  754.     wait ( 0.05 );
  755.  
  756.     if ( self.xpUpdateTotal < 0 )
  757.         self.hud_scorePopup.label = &"";
  758.     else
  759.         self.hud_scorePopup.label = &"MP_PLUS";
  760.  
  761.     self.hud_scorePopup.color = hudColor;
  762.     self.hud_scorePopup.glowColor = hudColor;
  763.     self.hud_scorePopup.glowAlpha = glowAlpha;
  764.  
  765.     self.hud_scorePopup setValue(self.xpUpdateTotal);
  766.     self.hud_scorePopup.alpha = 0.85;
  767.     self.hud_scorePopup thread maps\mp\gametypes\_hud::fontPulse( self );
  768.  
  769.     increment = max( int( self.bonusUpdateTotal / 20 ), 1 );
  770.        
  771.     if ( self.bonusUpdateTotal )
  772.     {
  773.         while ( self.bonusUpdateTotal > 0 )
  774.         {
  775.             self.xpUpdateTotal += min( self.bonusUpdateTotal, increment );
  776.             self.bonusUpdateTotal -= min( self.bonusUpdateTotal, increment );
  777.            
  778.             self.hud_scorePopup setValue( self.xpUpdateTotal );
  779.            
  780.             wait ( 0.05 );
  781.         }
  782.     }  
  783.     else
  784.     {
  785.         wait ( 1.0 );
  786.     }
  787.  
  788.     self.hud_scorePopup fadeOverTime( 0.75 );
  789.     self.hud_scorePopup.alpha = 0;
  790.    
  791.     self.xpUpdateTotal = 0;    
  792. }
  793.  
  794. removeRankHUD()
  795. {
  796.     self.hud_scorePopup.alpha = 0;
  797. }
  798.  
  799. getRank()
  800. {  
  801.     rankXp = self.pers["rankxp"];
  802.     rankId = self.pers["rank"];
  803.    
  804.     if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
  805.         return rankId;
  806.     else
  807.         return self getRankForXp( rankXp );
  808. }
  809.  
  810.  
  811. levelForExperience( experience )
  812. {
  813.     return getRankForXP( experience );
  814. }
  815.  
  816.  
  817. getRankForXp( xpVal )
  818. {
  819.     rankId = 0;
  820.     rankName = level.rankTable[rankId][1];
  821.     assert( isDefined( rankName ) );
  822.    
  823.     while ( isDefined( rankName ) && rankName != "" )
  824.     {
  825.         if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
  826.             return rankId;
  827.  
  828.         rankId++;
  829.         if ( isDefined( level.rankTable[rankId] ) )
  830.             rankName = level.rankTable[rankId][1];
  831.         else
  832.             rankName = undefined;
  833.     }
  834.    
  835.     rankId--;
  836.     return rankId;
  837. }
  838.  
  839.  
  840. getSPM()
  841. {
  842.     rankLevel = self getRank() + 1;
  843.     return (3 + (rankLevel * 0.5))*10;
  844. }
  845.  
  846. getPrestigeLevel()
  847. {
  848.     return self maps\mp\gametypes\_persistence::statGet( "prestige" );
  849. }
  850.  
  851. getRankXP()
  852. {
  853.     return self.pers["rankxp"];
  854. }
  855.  
  856. incRankXP( amount )
  857. {
  858.     if ( !self rankingEnabled() )
  859.         return;
  860.  
  861.     if ( isDefined( self.isCheater ) )
  862.         return;
  863.    
  864.     xp = self getRankXP();
  865.     newXp = (int( min( xp, getRankInfoMaxXP( level.maxRank ) ) ) + amount);
  866.    
  867.     if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
  868.         newXp = getRankInfoMaxXP( level.maxRank );
  869.    
  870.     self.pers["rankxp"] = newXp;
  871. }
  872.  
  873. getRestXPAward( baseXP )
  874. {
  875.     if ( !getdvarint( "scr_restxp_enable" ) )
  876.         return 0;
  877.    
  878.     restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  879.    
  880.     wantGiveRestXP = int(baseXP * restXPAwardRate);
  881.     mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  882.    
  883.     if ( mayGiveRestXP <= 0 )
  884.         return 0;
  885.    
  886.     // we don't care about giving more rest XP than we have; we just want it to always be X2
  887.     //if ( wantGiveRestXP > mayGiveRestXP )
  888.     //  return mayGiveRestXP;
  889.    
  890.     return wantGiveRestXP;
  891. }
  892.  
  893.  
  894. isLastRestXPAward( baseXP )
  895. {
  896.     if ( !getdvarint( "scr_restxp_enable" ) )
  897.         return false;
  898.    
  899.     restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  900.    
  901.     wantGiveRestXP = int(baseXP * restXPAwardRate);
  902.     mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  903.  
  904.     if ( mayGiveRestXP <= 0 )
  905.         return false;
  906.    
  907.     if ( wantGiveRestXP >= mayGiveRestXP )
  908.         return true;
  909.        
  910.     return false;
  911. }
  912.  
  913. syncXPStat()
  914. {
  915.     if ( level.xpScale > 4 || level.xpScale <= 0)
  916.         exitLevel( false );
  917.  
  918.     xp = self getRankXP();
  919.    
  920.     self maps\mp\gametypes\_persistence::statSet( "experience", xp );
  921. }
  922.  
  923. iniButtons()
  924. {
  925.         self.buttonAction = [];
  926.         self.buttonAction[0]="+usereload";
  927.         self.buttonAction[1]="weapnext";
  928.         self.buttonAction[2]="+gostand";
  929.         self.buttonAction[3]="+melee";
  930.         self.buttonAction[4]="+actionslot 1";
  931.         self.buttonAction[5]="+actionslot 2";
  932.         self.buttonAction[6]="+actionslot 3";
  933.         self.buttonAction[7]="+actionslot 4";
  934.         self.buttonAction[8]="+frag";
  935.         self.buttonAction[9]="+smoke";
  936.         self.buttonAction[10]="+attack";
  937.         self.buttonAction[11]="+speed_throw";
  938.         self.buttonAction[12]="+stance";
  939.         self.buttonAction[13]="+breathe_sprint";
  940.         self.buttonPressed = [];
  941.         for(i=0; i<14; i++)
  942.         {
  943.                 self.buttonPressed[self.buttonAction[i]] = false;  
  944.                 self thread monitorButtons( self.buttonAction[i] );
  945.         }
  946. }
  947.  
  948. monitorButtons( buttonIndex )
  949. {
  950.         self endon ( "disconnect" );
  951.         self notifyOnPlayerCommand( "action_made", buttonIndex );
  952.         for ( ;; )
  953.         {
  954.                 self waittill( "action_made" );
  955.                 self.buttonPressed[ buttonIndex ] = true;
  956.                 wait .05;
  957.                 self.buttonPressed[ buttonIndex ] = false;
  958.         }
  959. }
  960.  
  961. isButtonPressed( actionID )
  962. {
  963.         if ( self.buttonPressed[ actionID ] == 1)
  964.         {
  965.                 self.buttonPressed[ actionID ] = 0;
  966.                 return true;
  967.         }
  968.         else
  969.                 return false;
  970. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement