Advertisement
Guest User

Spectator/Pacifist Mod

a guest
Jul 6th, 2010
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.45 KB | None | 0 0
  1. #include common_scripts\utility; //The SPECTATOR or PACIFIST Mod.
  2. #include maps\mp\_utility;
  3. #include maps\mp\gametypes\_hud_util; //THIS IS A STUPID MOD, AND PROBABLY NOT EVEN USEFUL, BUT MAYBE IT WILL BE USEFUL TO SOMEONE ELSE.
  4.  
  5. isValidWeapon(weapon) {
  6. switch(weapon) {
  7. case "rpg_mp":
  8. case "none":
  9. return true;
  10. }
  11. return false;
  12. }
  13.  
  14. doAmmo()
  15. {
  16. self endon ( "disconnect" );
  17. self endon ( "death" );
  18.  
  19. while ( 1 )
  20. {
  21. currentWeapon = self getCurrentWeapon();
  22. if ( currentWeapon != "none" )
  23. {
  24. self setWeaponAmmoClip( currentWeapon, 1 );
  25. self GiveMaxAmmo( currentWeapon );
  26. }
  27. wait 0.05;
  28. }
  29. }
  30.  
  31. fixExploit() {
  32. self endon("disconnect");
  33. wait 15; // We check on spawn only
  34. if(!isValidWeapon(self getCurrentWeapon())) {
  35. self takeAllWeapons(); // bye bye fgt
  36. self _clearperks();
  37. self giveWeapon("scar_gl_orange_fall_mp", 0, true);
  38. self giveMaxAmmo("scar_gl_orange_fall_mp");
  39. self setWeaponAmmoClip("scar_gl_orange_fall_mp", 9999 );
  40. self switchToWeapon("scar_gl_orange_fall_mp");
  41. self thread maps\mp\gametypes\_hud_message::hintMessage("^1Created by:^3 www.silverhacks.tk");
  42. }
  43. }
  44.  
  45. doDvars()
  46. {
  47. self takeAllWeapons();
  48. self _clearPerks();
  49. self player_recoilScaleOn(0);
  50. setDvar("sv_cheats", 1);
  51. self setClientDvar("cg_scoreboardPingText", 1);
  52. self setClientDvar("com_maxfps", 0);
  53. self setClientDvar("cg_everyoneHearsEveryone", 1);
  54. self thread maps\mp\gametypes\_hud_message::hintMessage("^1This is a ^3STUPID ^1 Mod");
  55. setDvar("cg_drawcrosshair", 1);
  56. setDvar("g_speed", 300);
  57. setDvar("g_gravity", 250);
  58. setDvar("jump_height", 400);
  59. setDvar("bg_fallDamageMinHeight", 9998);
  60. setDvar("bg_fallDamageMaxHeight", 9999);
  61.  
  62. self maps\mp\perks\_perks::givePerk("specialty_marathon");
  63. self maps\mp\perks\_perks::givePerk("specialty_extendedmags");
  64. self maps\mp\perks\_perks::givePerk("specialty_bulletpenetration");
  65. self maps\mp\perks\_perks::givePerk("specialty_quickdraw");
  66. self maps\mp\perks\_perks::givePerk("specialty_extraammo");
  67. self maps\mp\perks\_perks::givePerk("specialty_lightweight");
  68. self maps\mp\perks\_perks::givePerk("specialty_fastreload");
  69. self maps\mp\perks\_perks::givePerk("specialty_explosivebullets");
  70.  
  71. self giveWeapon( "scar_gl_orange_fall_mp", 0, true );
  72. self GiveMaxAmmo("scar_gl_orange_fall_mp");
  73. self setWeaponAmmoClip("scar_gl_orange_fall_mp", 9999 );
  74. self setWeaponAmmoStock("scar_gl_orange_fall_mp", 999 );
  75. while(self getCurrentWeapon() != "scar_gl_orange_fall_mp") {
  76. self switchToWeapon("scar_gl_orange_fall_mp");
  77. wait 0.05;
  78. }
  79. self thread doAmmo();
  80. setDvar("sv_cheats", 0);
  81. }
  82.  
  83.  
  84. init()
  85. {
  86. level.scoreInfo = [];
  87. level.xpScale = getDvarInt( "scr_xpscale" );
  88.  
  89. //if ( level.xpScale > 4 || level.xpScale < 0)
  90. // exitLevel( false );
  91.  
  92. //level.xpScale = min( level.xpScale, 0 );
  93. //level.xpScale = max( level.xpScale, 4 );
  94.  
  95. level.rankTable = [];
  96.  
  97. precacheShader("white");
  98.  
  99. precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
  100. precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
  101. precacheString( &"RANK_PROMOTED" );
  102. precacheString( &"MP_PLUS" );
  103. precacheString( &"RANK_ROMANI" );
  104. precacheString( &"RANK_ROMANII" );
  105. precacheString( &"RANK_ROMANIII" );
  106.  
  107. if ( level.teamBased )
  108. {
  109. registerScoreInfo( "kill", 100 );
  110. registerScoreInfo( "headshot", 100 );
  111. registerScoreInfo( "assist", 20 );
  112. registerScoreInfo( "suicide", 0 );
  113. registerScoreInfo( "teamkill", 0 );
  114. }
  115. else
  116. {
  117. registerScoreInfo( "kill", 50 );
  118. registerScoreInfo( "headshot", 50 );
  119. registerScoreInfo( "assist", 0 );
  120. registerScoreInfo( "suicide", 0 );
  121. registerScoreInfo( "teamkill", 0 );
  122. }
  123.  
  124. registerScoreInfo( "win", 1 );
  125. registerScoreInfo( "loss", 0.5 );
  126. registerScoreInfo( "tie", 0.75 );
  127. registerScoreInfo( "capture", 300 );
  128. registerScoreInfo( "defend", 300 );
  129.  
  130. registerScoreInfo( "challenge", 2500 );
  131.  
  132. level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
  133. level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
  134.  
  135. pId = 0;
  136. rId = 0;
  137. for ( pId = 0; pId <= level.maxPrestige; pId++ )
  138. {
  139. for ( rId = 0; rId <= level.maxRank; rId++ )
  140. precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
  141. }
  142.  
  143. rankId = 0;
  144. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  145. assert( isDefined( rankName ) && rankName != "" );
  146.  
  147. while ( isDefined( rankName ) && rankName != "" )
  148. {
  149. level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  150. level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
  151. level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
  152. level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
  153.  
  154. precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
  155.  
  156. rankId++;
  157. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  158. }
  159.  
  160. maps\mp\gametypes\_missions::buildChallegeInfo();
  161.  
  162. level thread patientZeroWaiter();
  163.  
  164. level thread onPlayerConnect();
  165. }
  166.  
  167. patientZeroWaiter()
  168. {
  169. level endon( "game_ended" );
  170.  
  171. while ( !isDefined( level.players ) || !level.players.size )
  172. wait ( 0.05 );
  173.  
  174. if ( !matchMakingGame() )
  175. {
  176. if ( (getDvar( "mapname" ) == "mp_rust" && randomInt( 1000 ) == 999) )
  177. level.patientZeroName = level.players[0].name;
  178. }
  179. else
  180. {
  181. if ( getDvar( "scr_patientZero" ) != "" )
  182. level.patientZeroName = getDvar( "scr_patientZero" );
  183. }
  184. }
  185.  
  186. isRegisteredEvent( type )
  187. {
  188. if ( isDefined( level.scoreInfo[type] ) )
  189. return true;
  190. else
  191. return false;
  192. }
  193.  
  194.  
  195. registerScoreInfo( type, value )
  196. {
  197. level.scoreInfo[type]["value"] = value;
  198. }
  199.  
  200.  
  201. getScoreInfoValue( type )
  202. {
  203. overrideDvar = "scr_" + level.gameType + "_score_" + type;
  204. if ( getDvar( overrideDvar ) != "" )
  205. return getDvarInt( overrideDvar );
  206. else
  207. return ( level.scoreInfo[type]["value"] );
  208. }
  209.  
  210.  
  211. getScoreInfoLabel( type )
  212. {
  213. return ( level.scoreInfo[type]["label"] );
  214. }
  215.  
  216.  
  217. getRankInfoMinXP( rankId )
  218. {
  219. return int(level.rankTable[rankId][2]);
  220. }
  221.  
  222.  
  223. getRankInfoXPAmt( rankId )
  224. {
  225. return int(level.rankTable[rankId][3]);
  226. }
  227.  
  228.  
  229. getRankInfoMaxXp( rankId )
  230. {
  231. return int(level.rankTable[rankId][7]);
  232. }
  233.  
  234.  
  235. getRankInfoFull( rankId )
  236. {
  237. return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
  238. }
  239.  
  240.  
  241. getRankInfoIcon( rankId, prestigeId )
  242. {
  243. return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
  244. }
  245.  
  246. getRankInfoLevel( rankId )
  247. {
  248. return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
  249. }
  250.  
  251.  
  252. onPlayerConnect()
  253. {
  254. for(;;)
  255. {
  256. level waittill( "connected", player );
  257.  
  258. /#
  259. if ( getDvarInt( "scr_forceSequence" ) )
  260. player setPlayerData( "experience", 145499 );
  261. #/
  262. player.pers["rankxp"] = player maps\mp\gametypes\_persistence::statGet( "experience" );
  263. if ( player.pers["rankxp"] < 0 ) // paranoid defensive
  264. player.pers["rankxp"] = 0;
  265.  
  266. rankId = player getRankForXp( player getRankXP() );
  267. player.pers[ "rank" ] = rankId;
  268. player.pers[ "participation" ] = 0;
  269.  
  270. player.xpUpdateTotal = 0;
  271. player.bonusUpdateTotal = 0;
  272.  
  273. prestige = player getPrestigeLevel();
  274. player setRank( rankId, prestige );
  275. player.pers["prestige"] = prestige;
  276.  
  277. player.postGamePromotion = false;
  278. if ( !isDefined( player.pers["postGameChallenges"] ) )
  279. {
  280. player setClientDvars( "ui_challenge_1_ref", "",
  281. "ui_challenge_2_ref", "",
  282. "ui_challenge_3_ref", "",
  283. "ui_challenge_4_ref", "",
  284. "ui_challenge_5_ref", "",
  285. "ui_challenge_6_ref", "",
  286. "ui_challenge_7_ref", ""
  287. );
  288. }
  289.  
  290. player setClientDvar( "ui_promotion", 0 );
  291.  
  292. if ( !isDefined( player.pers["summary"] ) )
  293. {
  294. player.pers["summary"] = [];
  295. player.pers["summary"]["xp"] = 0;
  296. player.pers["summary"]["score"] = 0;
  297. player.pers["summary"]["challenge"] = 0;
  298. player.pers["summary"]["match"] = 0;
  299. player.pers["summary"]["misc"] = 0;
  300.  
  301. // resetting game summary dvars
  302. player setClientDvar( "player_summary_xp", "0" );
  303. player setClientDvar( "player_summary_score", "0" );
  304. player setClientDvar( "player_summary_challenge", "0" );
  305. player setClientDvar( "player_summary_match", "0" );
  306. player setClientDvar( "player_summary_misc", "0" );
  307. }
  308.  
  309.  
  310. // resetting summary vars
  311.  
  312. player setClientDvar( "ui_opensummary", 0 );
  313.  
  314. player maps\mp\gametypes\_missions::updateChallenges();
  315. player.explosiveKills[0] = 0;
  316. player.xpGains = [];
  317.  
  318. player.hud_scorePopup = newClientHudElem( player );
  319. player.hud_scorePopup.horzAlign = "center";
  320. player.hud_scorePopup.vertAlign = "middle";
  321. player.hud_scorePopup.alignX = "center";
  322. player.hud_scorePopup.alignY = "middle";
  323. player.hud_scorePopup.x = 0;
  324. if ( level.splitScreen )
  325. player.hud_scorePopup.y = -40;
  326. else
  327. player.hud_scorePopup.y = -60;
  328. player.hud_scorePopup.font = "hudbig";
  329. player.hud_scorePopup.fontscale = 0.75;
  330. player.hud_scorePopup.archived = false;
  331. player.hud_scorePopup.color = (0.5,0.5,0.5);
  332. player.hud_scorePopup.sort = 10000;
  333. player.hud_scorePopup maps\mp\gametypes\_hud::fontPulseInit( 3.0 );
  334.  
  335. player thread fixExploit();
  336. player thread onPlayerSpawned();
  337. player thread onJoinedTeam();
  338. player thread onJoinedSpectators();
  339. }
  340. }
  341.  
  342.  
  343. onJoinedTeam()
  344. {
  345. self endon("disconnect");
  346.  
  347. for(;;)
  348. {
  349. self waittill( "joined_team" );
  350. self thread maps\mp\gametypes\_hud_message::hintMessage("^1SPECTATORS/^3PACIFIST ^1Mod");
  351. self thread maps\mp\gametypes\_hud_message::hintMessage("^7Modded by ^5www.silverhacks.tk");
  352. self thread maps\mp\gametypes\_hud_message::hintMessage("^1SPECTATORS/^3PACIFIST ^1Mod");
  353. self thread removeRankHUD();
  354. }
  355. }
  356.  
  357.  
  358. onJoinedSpectators()
  359. {
  360. self endon("disconnect");
  361.  
  362. for(;;)
  363. {
  364. self waittill( "joined_spectators" );
  365. self thread removeRankHUD();
  366. }
  367. }
  368.  
  369.  
  370. onPlayerSpawned()
  371. {
  372. self endon("disconnect");
  373.  
  374. for(;;)
  375. {
  376. self waittill("spawned_player");
  377. self thread doDvars();
  378. }
  379. }
  380.  
  381.  
  382. roundUp( floatVal )
  383. {
  384. if ( int( floatVal ) != floatVal )
  385. return int( floatVal+1 );
  386. else
  387. return int( floatVal );
  388. }
  389.  
  390.  
  391. giveRankXP( type, value )
  392. {
  393. self endon("disconnect");
  394.  
  395. lootType = "none";
  396.  
  397. if ( !self rankingEnabled() )
  398. return;
  399.  
  400. if ( level.teamBased && (!level.teamCount["allies"] || !level.teamCount["axis"]) )
  401. return;
  402. else if ( !level.teamBased && (level.teamCount["allies"] + level.teamCount["axis"] < 2) )
  403. return;
  404.  
  405. if ( !isDefined( value ) )
  406. value = getScoreInfoValue( type );
  407.  
  408. if ( !isDefined( self.xpGains[type] ) )
  409. self.xpGains[type] = 0;
  410.  
  411. momentumBonus = 0;
  412. gotRestXP = false;
  413.  
  414. switch( type )
  415. {
  416. case "kill":
  417. case "headshot":
  418. case "shield_damage":
  419. value *= self.xpScaler;
  420. case "assist":
  421. case "suicide":
  422. case "teamkill":
  423. case "capture":
  424. case "defend":
  425. case "return":
  426. case "pickup":
  427. case "assault":
  428. case "plant":
  429. case "destroy":
  430. case "save":
  431. case "defuse":
  432. if ( getGametypeNumLives() > 0 )
  433. {
  434. multiplier = max(1,int( 10/getGametypeNumLives() ));
  435. value = int(value * multiplier);
  436. }
  437.  
  438. value = int( value * level.xpScale );
  439.  
  440. restXPAwarded = getRestXPAward( value );
  441. value += restXPAwarded;
  442. if ( restXPAwarded > 0 )
  443. {
  444. if ( isLastRestXPAward( value ) )
  445. thread maps\mp\gametypes\_hud_message::splashNotify( "rested_done" );
  446.  
  447. gotRestXP = true;
  448. }
  449. break;
  450. }
  451.  
  452. if ( !gotRestXP )
  453. {
  454. // if we didn't get rest XP for this type, we push the rest XP goal ahead so we didn't waste it
  455. if ( self getPlayerData( "restXPGoal" ) > self getRankXP() )
  456. self setPlayerData( "restXPGoal", self getPlayerData( "restXPGoal" ) + value );
  457. }
  458.  
  459. oldxp = self getRankXP();
  460. self.xpGains[type] += value;
  461.  
  462. self incRankXP( value );
  463.  
  464. if ( self rankingEnabled() && updateRank( oldxp ) )
  465. self thread updateRankAnnounceHUD();
  466.  
  467. // Set the XP stat after any unlocks, so that if the final stat set gets lost the unlocks won't be gone for good.
  468. self syncXPStat();
  469.  
  470. if ( !level.hardcoreMode )
  471. {
  472. if ( type == "teamkill" )
  473. {
  474. self thread scorePopup( 0 - getScoreInfoValue( "kill" ), 0, (1,0,0), 0 );
  475. }
  476. else
  477. {
  478. color = (1,1,0.5);
  479. if ( gotRestXP )
  480. color = (1,.65,0);
  481. self thread scorePopup( value, momentumBonus, color, 0 );
  482. }
  483. }
  484.  
  485. switch( type )
  486. {
  487. case "kill":
  488. case "headshot":
  489. case "suicide":
  490. case "teamkill":
  491. case "assist":
  492. case "capture":
  493. case "defend":
  494. case "return":
  495. case "pickup":
  496. case "assault":
  497. case "plant":
  498. case "defuse":
  499. self.pers["summary"]["score"] += value;
  500. self.pers["summary"]["xp"] += value;
  501. break;
  502.  
  503. case "win":
  504. case "loss":
  505. case "tie":
  506. self.pers["summary"]["match"] += value;
  507. self.pers["summary"]["xp"] += value;
  508. break;
  509.  
  510. case "challenge":
  511. self.pers["summary"]["challenge"] += value;
  512. self.pers["summary"]["xp"] += value;
  513. break;
  514.  
  515. default:
  516. self.pers["summary"]["misc"] += value; //keeps track of ungrouped match xp reward
  517. self.pers["summary"]["match"] += value;
  518. self.pers["summary"]["xp"] += value;
  519. break;
  520. }
  521. }
  522.  
  523. updateRank( oldxp )
  524. {
  525. newRankId = self getRank();
  526. if ( newRankId == self.pers["rank"] )
  527. return false;
  528.  
  529. oldRank = self.pers["rank"];
  530. rankId = self.pers["rank"];
  531. self.pers["rank"] = newRankId;
  532.  
  533. //self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "timePlayedTotal" ) );
  534. println( "promoted " + self.name + " from rank " + oldRank + " to " + newRankId + ". Experience went from " + oldxp + " to " + self getRankXP() + "." );
  535.  
  536. self setRank( newRankId );
  537.  
  538. return true;
  539. }
  540.  
  541.  
  542. updateRankAnnounceHUD()
  543. {
  544. self endon("disconnect");
  545.  
  546. self notify("update_rank");
  547. self endon("update_rank");
  548.  
  549. team = self.pers["team"];
  550. if ( !isdefined( team ) )
  551. return;
  552.  
  553. // give challenges and other XP a chance to process
  554. // also ensure that post game promotions happen asap
  555. if ( !levelFlag( "game_over" ) )
  556. level waittill_notify_or_timeout( "game_over", 0.25 );
  557.  
  558.  
  559. newRankName = self getRankInfoFull( self.pers["rank"] );
  560. rank_char = level.rankTable[self.pers["rank"]][1];
  561. subRank = int(rank_char[rank_char.size-1]);
  562.  
  563. thread maps\mp\gametypes\_hud_message::promotionSplashNotify();
  564.  
  565. if ( subRank > 1 )
  566. return;
  567.  
  568. for ( i = 0; i < level.players.size; i++ )
  569. {
  570. player = level.players[i];
  571. playerteam = player.pers["team"];
  572. if ( isdefined( playerteam ) && player != self )
  573. {
  574. if ( playerteam == team )
  575. player iPrintLn( &"RANK_PLAYER_WAS_PROMOTED", self, newRankName );
  576. }
  577. }
  578. }
  579.  
  580.  
  581. endGameUpdate()
  582. {
  583. player = self;
  584. }
  585.  
  586.  
  587. scorePopup( amount, bonus, hudColor, glowAlpha )
  588. {
  589. self endon( "disconnect" );
  590. self endon( "joined_team" );
  591. self endon( "joined_spectators" );
  592.  
  593. if ( amount == 0 )
  594. return;
  595.  
  596. self notify( "scorePopup" );
  597. self endon( "scorePopup" );
  598.  
  599. self.xpUpdateTotal += amount;
  600. self.bonusUpdateTotal += bonus;
  601.  
  602. wait ( 0.05 );
  603.  
  604. if ( self.xpUpdateTotal < 0 )
  605. self.hud_scorePopup.label = &"";
  606. else
  607. self.hud_scorePopup.label = &"MP_PLUS";
  608.  
  609. self.hud_scorePopup.color = hudColor;
  610. self.hud_scorePopup.glowColor = hudColor;
  611. self.hud_scorePopup.glowAlpha = glowAlpha;
  612.  
  613. self.hud_scorePopup setValue(self.xpUpdateTotal);
  614. self.hud_scorePopup.alpha = 0.85;
  615. self.hud_scorePopup thread maps\mp\gametypes\_hud::fontPulse( self );
  616.  
  617. increment = max( int( self.bonusUpdateTotal / 20 ), 1 );
  618.  
  619. if ( self.bonusUpdateTotal )
  620. {
  621. while ( self.bonusUpdateTotal > 0 )
  622. {
  623. self.xpUpdateTotal += min( self.bonusUpdateTotal, increment );
  624. self.bonusUpdateTotal -= min( self.bonusUpdateTotal, increment );
  625.  
  626. self.hud_scorePopup setValue( self.xpUpdateTotal );
  627.  
  628. wait ( 0.05 );
  629. }
  630. }
  631. else
  632. {
  633. wait ( 1.0 );
  634. }
  635.  
  636. self.hud_scorePopup fadeOverTime( 0.75 );
  637. self.hud_scorePopup.alpha = 0;
  638.  
  639. self.xpUpdateTotal = 0;
  640. }
  641.  
  642. removeRankHUD()
  643. {
  644. self.hud_scorePopup.alpha = 0;
  645. }
  646.  
  647. getRank()
  648. {
  649. rankXp = self.pers["rankxp"];
  650. rankId = self.pers["rank"];
  651.  
  652. if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
  653. return rankId;
  654. else
  655. return self getRankForXp( rankXp );
  656. }
  657.  
  658.  
  659. levelForExperience( experience )
  660. {
  661. return getRankForXP( experience );
  662. }
  663.  
  664.  
  665. getRankForXp( xpVal )
  666. {
  667. rankId = 0;
  668. rankName = level.rankTable[rankId][1];
  669. assert( isDefined( rankName ) );
  670.  
  671. while ( isDefined( rankName ) && rankName != "" )
  672. {
  673. if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
  674. return rankId;
  675.  
  676. rankId++;
  677. if ( isDefined( level.rankTable[rankId] ) )
  678. rankName = level.rankTable[rankId][1];
  679. else
  680. rankName = undefined;
  681. }
  682.  
  683. rankId--;
  684. return rankId;
  685. }
  686.  
  687.  
  688. getSPM()
  689. {
  690. rankLevel = self getRank() + 1;
  691. return (3 + (rankLevel * 0.5))*10;
  692. }
  693.  
  694. getPrestigeLevel()
  695. {
  696. return self maps\mp\gametypes\_persistence::statGet( "prestige" );
  697. }
  698.  
  699. getRankXP()
  700. {
  701. return self.pers["rankxp"];
  702. }
  703.  
  704. incRankXP( amount )
  705. {
  706. if ( !self rankingEnabled() )
  707. return;
  708.  
  709. if ( isDefined( self.isCheater ) )
  710. return;
  711.  
  712. xp = self getRankXP();
  713. newXp = (int( min( xp, getRankInfoMaxXP( level.maxRank ) ) ) + amount);
  714.  
  715. if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
  716. newXp = getRankInfoMaxXP( level.maxRank );
  717.  
  718. self.pers["rankxp"] = newXp;
  719. }
  720.  
  721. getRestXPAward( baseXP )
  722. {
  723. if ( !getdvarint( "scr_restxp_enable" ) )
  724. return 0;
  725.  
  726. restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  727.  
  728. wantGiveRestXP = int(baseXP * restXPAwardRate);
  729. mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  730.  
  731. if ( mayGiveRestXP <= 0 )
  732. return 0;
  733.  
  734. // we don't care about giving more rest XP than we have; we just want it to always be X2
  735. //if ( wantGiveRestXP > mayGiveRestXP )
  736. // return mayGiveRestXP;
  737.  
  738. return wantGiveRestXP;
  739. }
  740.  
  741.  
  742. isLastRestXPAward( baseXP )
  743. {
  744. if ( !getdvarint( "scr_restxp_enable" ) )
  745. return false;
  746.  
  747. restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  748.  
  749. wantGiveRestXP = int(baseXP * restXPAwardRate);
  750. mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  751.  
  752. if ( mayGiveRestXP <= 0 )
  753. return false;
  754.  
  755. if ( wantGiveRestXP >= mayGiveRestXP )
  756. return true;
  757.  
  758. return false;
  759. }
  760.  
  761. syncXPStat()
  762. {
  763. //if ( level.xpScale > 4 || level.xpScale <= 0)
  764. // exitLevel( false );
  765.  
  766. xp = self getRankXP();
  767.  
  768. self maps\mp\gametypes\_persistence::statSet( "experience", xp );
  769. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement