Advertisement
Guest User

Untitled

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