Advertisement
Guest User

Untitled

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