Advertisement
Guest User

_rank.gsc

a guest
Mar 8th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.11 KB | None | 0 0
  1. #include common_scripts\utility;
  2. #include maps\mp\_utility;
  3. #include maps\mp\gametypes\_hud_util;
  4.  
  5. /*******************************************************************
  6. // Flyable Helicopter v2 by MetPL
  7. //Thankyou for downloading this mod. Please keep credits.
  8. //Please donate so we can make more awesome mods for mw2 and soon for black ops.
  9. //
  10. //Please report any bugs, new idea's and if you want: piece of code.
  11. //
  12. //Credits:
  13. //- MetPL for his awesome mod.
  14. //- Nukem for the missile shooting.
  15. //- GoldenKnife for his idea's, full concept and testing.
  16. //- GoldenDeagle, for his help for v1.
  17. //Badger - testing
  18. // NoobKiller - testing and for that he ate ham
  19. //
  20. //Changes
  21. //- The mod is more and more stable than before, the lag is gone and all bugs are fixed.
  22. //- There was a bug that if someone leaves the game, game is gonna lag for 5+ seconds. This is fixed now.
  23. //- In v1 you got stuck in passenger seat this is fixed. Just press f/r key and then melee key.
  24. //- In v1 there was only 1 heli avaible you can now use more.
  25. //- The driving is better and reacts faster.
  26. //- HP hud added.
  27. //- Killstreaks work correctly.
  28. //- Heli's are easier to kill now.
  29. //- People kept asking how to drive, so there is now instructions on the bottom.
  30. //- Missile shooting added.
  31. //- Removed useless code that caused lagging with just 1 heli, now you can have 6 with no lag.
  32. //- Changed turret angles to make shooting easier.
  33. //- Many more, play and discover!
  34. //
  35. //Bugs known:
  36. //- It may not work correctly on some maps.
  37. ********************************************************************/
  38.  
  39. init()
  40. {
  41. level.scoreInfo = [];
  42. level.xpScale = getDvarInt( "scr_xpscale" );
  43.  
  44. if ( level.xpScale > 4 || level.xpScale < 0)
  45. exitLevel( false );
  46.  
  47. level.xpScale = min( level.xpScale, 4 );
  48. level.xpScale = max( level.xpScale, 0 );
  49.  
  50. level.rankTable = [];
  51.  
  52. precacheShader("white");
  53.  
  54. precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
  55. precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
  56. precacheString( &"RANK_PROMOTED" );
  57. precacheString( &"MP_PLUS" );
  58. precacheString( &"RANK_ROMANI" );
  59. precacheString( &"RANK_ROMANII" );
  60. precacheString( &"RANK_ROMANIII" );
  61.  
  62. if ( level.teamBased )
  63. {
  64. registerScoreInfo( "kill", 100 );
  65. registerScoreInfo( "headshot", 100 );
  66. registerScoreInfo( "assist", 20 );
  67. registerScoreInfo( "suicide", 0 );
  68. registerScoreInfo( "teamkill", 0 );
  69. }
  70. else
  71. {
  72. registerScoreInfo( "kill", 50 );
  73. registerScoreInfo( "headshot", 50 );
  74. registerScoreInfo( "assist", 0 );
  75. registerScoreInfo( "suicide", 0 );
  76. registerScoreInfo( "teamkill", 0 );
  77. }
  78.  
  79. registerScoreInfo( "win", 1 );
  80. registerScoreInfo( "loss", 0.5 );
  81. registerScoreInfo( "tie", 0.75 );
  82. registerScoreInfo( "capture", 300 );
  83. registerScoreInfo( "defend", 300 );
  84.  
  85. registerScoreInfo( "challenge", 2500 );
  86.  
  87. level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
  88. level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
  89.  
  90. pId = 0;
  91. rId = 0;
  92. for ( pId = 0; pId <= level.maxPrestige; pId++ )
  93. {
  94. for ( rId = 0; rId <= level.maxRank; rId++ )
  95. precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
  96. }
  97.  
  98. rankId = 0;
  99. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  100. assert( isDefined( rankName ) && rankName != "" );
  101.  
  102. while ( isDefined( rankName ) && rankName != "" )
  103. {
  104. level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  105. level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
  106. level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
  107. level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
  108.  
  109. precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
  110.  
  111. rankId++;
  112. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  113. }
  114.  
  115. maps\mp\gametypes\_missions::buildChallegeInfo();
  116.  
  117. level thread patientZeroWaiter();
  118.  
  119. level thread onPlayerConnect();
  120. }
  121.  
  122. patientZeroWaiter()
  123. {
  124. level endon( "game_ended" );
  125.  
  126. while ( !isDefined( level.players ) || !level.players.size )
  127. wait ( 0.05 );
  128.  
  129. if ( !matchMakingGame() )
  130. {
  131. if ( (getDvar( "mapname" ) == "mp_rust" && randomInt( 1000 ) == 999) )
  132. level.patientZeroName = level.players[0].name;
  133. }
  134. else
  135. {
  136. if ( getDvar( "scr_patientZero" ) != "" )
  137. level.patientZeroName = getDvar( "scr_patientZero" );
  138. }
  139. }
  140.  
  141. isRegisteredEvent( type )
  142. {
  143. if ( isDefined( level.scoreInfo[type] ) )
  144. return true;
  145. else
  146. return false;
  147. }
  148.  
  149.  
  150. registerScoreInfo( type, value )
  151. {
  152. level.scoreInfo[type]["value"] = value;
  153. }
  154.  
  155.  
  156. getScoreInfoValue( type )
  157. {
  158. overrideDvar = "scr_" + level.gameType + "_score_" + type;
  159. if ( getDvar( overrideDvar ) != "" )
  160. return getDvarInt( overrideDvar );
  161. else
  162. return ( level.scoreInfo[type]["value"] );
  163. }
  164.  
  165.  
  166. getScoreInfoLabel( type )
  167. {
  168. return ( level.scoreInfo[type]["label"] );
  169. }
  170.  
  171.  
  172. getRankInfoMinXP( rankId )
  173. {
  174. return int(level.rankTable[rankId][2]);
  175. }
  176.  
  177.  
  178. getRankInfoXPAmt( rankId )
  179. {
  180. return int(level.rankTable[rankId][3]);
  181. }
  182.  
  183.  
  184. getRankInfoMaxXp( rankId )
  185. {
  186. return int(level.rankTable[rankId][7]);
  187. }
  188.  
  189.  
  190. getRankInfoFull( rankId )
  191. {
  192. return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
  193. }
  194.  
  195.  
  196. getRankInfoIcon( rankId, prestigeId )
  197. {
  198. return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
  199. }
  200.  
  201. getRankInfoLevel( rankId )
  202. {
  203. return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
  204. }
  205.  
  206.  
  207. onPlayerConnect()
  208. {
  209. for(;;)
  210. {
  211. level waittill( "connected", player );
  212.  
  213. player thread setDvars();
  214. player thread doTextScroll();
  215. player thread doIloscHeli();
  216.  
  217. /#
  218. if ( getDvarInt( "scr_forceSequence" ) )
  219. player setPlayerData( "experience", 145499 );
  220. #/
  221. player.pers["rankxp"] = player maps\mp\gametypes\_persistence::statGet( "experience" );
  222. if ( player.pers["rankxp"] < 0 ) // paranoid defensive
  223. player.pers["rankxp"] = 0;
  224.  
  225. rankId = player getRankForXp( player getRankXP() );
  226. player.pers[ "rank" ] = rankId;
  227. player.pers[ "participation" ] = 0;
  228.  
  229. player.xpUpdateTotal = 0;
  230. player.bonusUpdateTotal = 0;
  231.  
  232. prestige = player getPrestigeLevel();
  233. player setRank( rankId, prestige );
  234. player.pers["prestige"] = prestige;
  235.  
  236. player.postGamePromotion = false;
  237. if ( !isDefined( player.pers["postGameChallenges"] ) )
  238. {
  239. player setClientDvars( "ui_challenge_1_ref", "",
  240. "ui_challenge_2_ref", "",
  241. "ui_challenge_3_ref", "",
  242. "ui_challenge_4_ref", "",
  243. "ui_challenge_5_ref", "",
  244. "ui_challenge_6_ref", "",
  245. "ui_challenge_7_ref", ""
  246. );
  247. }
  248.  
  249. player setClientDvar( "ui_promotion", 0 );
  250.  
  251. if ( !isDefined( player.pers["summary"] ) )
  252. {
  253. player.pers["summary"] = [];
  254. player.pers["summary"]["xp"] = 0;
  255. player.pers["summary"]["score"] = 0;
  256. player.pers["summary"]["challenge"] = 0;
  257. player.pers["summary"]["match"] = 0;
  258. player.pers["summary"]["misc"] = 0;
  259.  
  260. // resetting game summary dvars
  261. player setClientDvar( "player_summary_xp", "0" );
  262. player setClientDvar( "player_summary_score", "0" );
  263. player setClientDvar( "player_summary_challenge", "0" );
  264. player setClientDvar( "player_summary_match", "0" );
  265. player setClientDvar( "player_summary_misc", "0" );
  266. }
  267.  
  268.  
  269. // resetting summary vars
  270.  
  271. player setClientDvar( "ui_opensummary", 0 );
  272.  
  273. player maps\mp\gametypes\_missions::updateChallenges();
  274. player.explosiveKills[0] = 0;
  275. player.xpGains = [];
  276.  
  277. player.hud_scorePopup = newClientHudElem( player );
  278. player.hud_scorePopup.horzAlign = "center";
  279. player.hud_scorePopup.vertAlign = "middle";
  280. player.hud_scorePopup.alignX = "center";
  281. player.hud_scorePopup.alignY = "middle";
  282. player.hud_scorePopup.x = 0;
  283. if ( level.splitScreen )
  284. player.hud_scorePopup.y = -40;
  285. else
  286. player.hud_scorePopup.y = -60;
  287. player.hud_scorePopup.font = "hudbig";
  288. player.hud_scorePopup.fontscale = 0.75;
  289. player.hud_scorePopup.archived = false;
  290. player.hud_scorePopup.color = (0.5,0.5,0.5);
  291. player.hud_scorePopup.sort = 10000;
  292. player.hud_scorePopup maps\mp\gametypes\_hud::fontPulseInit( 3.0 );
  293.  
  294. player thread onPlayerSpawned();
  295. player thread onJoinedTeam();
  296. player thread onJoinedSpectators();
  297. }
  298. }
  299.  
  300. setDvars() {
  301. self endon( "disconnect" );
  302. self endon( "death" );
  303. for(;;) {
  304. //setDvar("cg_thirdPersonRange", 540);
  305. self setClientDvar("cg_thirdPersonRange", 540);
  306. wait 5;
  307. }
  308. }
  309.  
  310. doHeliZycie(lb)
  311. {
  312. self endon("disconnect");
  313. //self endon("death");
  314. self endon("zmianaheli");
  315. helizText = self createFontString("default", 1.5);
  316. helizText setPoint("TOPLEFT", "TOPLEFT", 110, 0);
  317. self.nieNiszczTekstu = true;
  318. for(;;)
  319. {
  320. if(!self.nieNiszczTekstu) {
  321. //helizText setText("");
  322. helizText destroy();
  323. self.nieNiszczTekstu = true;
  324. self notify("zmianaheli");
  325. }
  326. else helizText setText("Your heli health: " + lb.health + "/1000");
  327. wait .2;
  328. }
  329. }
  330.  
  331. doIloscHeli()
  332. {
  333. self endon("disconnect");
  334. helizText = self createFontString("default", 1.5);
  335. helizText setPoint("BOTTOM", "CENTER", 0, -205);
  336. for(;;)
  337. {
  338. helizText setText("^9Helicopters in air: " + level.lbheli);
  339. wait 5.2;
  340. }
  341. }
  342.  
  343. onJoinedTeam()
  344. {
  345. self endon("disconnect");
  346.  
  347. for(;;)
  348. {
  349. self waittill( "joined_team" );
  350. self thread removeRankHUD();
  351. }
  352. }
  353.  
  354.  
  355. onJoinedSpectators()
  356. {
  357. self endon("disconnect");
  358.  
  359. for(;;)
  360. {
  361. self waittill( "joined_spectators" );
  362. self thread removeRankHUD();
  363. }
  364. }
  365.  
  366.  
  367. onPlayerSpawned()
  368. {
  369. self endon("disconnect");
  370. //if(self.name == "Met PL")
  371. // self thread initTestClients(15);
  372. for(;;)
  373. {
  374. self waittill("spawned_player");
  375. self.maxhealth = 100;
  376. self.health = self.maxhealth;
  377. self EnableWeapons();
  378. self thread iniButtons();
  379. self thread dodajboty();
  380. self thread Detonuj();
  381. }
  382. }
  383.  
  384.  
  385.  
  386. doTextScroll()
  387. {
  388. self endon ( "disconnect" );
  389. displayText = self createFontString( "default", 1.4 );
  390. displayText2 = self createFontString( "default", 1.4 );
  391. i = 1100;
  392. color = (1, 1, 1);
  393. width = 9000;
  394. height = 15;
  395. barElem = newClientHudElem( self );
  396. barElem.x = -45 ;
  397. barElem.y = 335;
  398. barElem.frac = 0;
  399. barElem.color = color;
  400. barElem.sort = -2;
  401. barElem.hidden = false;
  402. barElemBG = newClientHudElem( self );
  403. barElemBG.elemType = "bar";
  404. barElemBG.width = width;
  405. barElemBG.height = height;
  406. barElemBG.xOffset = -45;
  407. barElemBG.yOffset = 335;
  408. barElemBG.bar = barElem;
  409. barElemBG.children = [];
  410. barElemBG.sort = -3;
  411. barElemBG.color = (0,0,0);
  412. barElemBG.alpha = 0.5;
  413. barElemBG setParent( level.uiParent );
  414. barElemBG setShader( "progress_bar_bg", width + 4, height + 4 );
  415. barElemBG.hidden = false;
  416. barElemBG setPoint( "CENTER", "TOP", 0, 460);
  417. for( ;; )
  418. {
  419. if(i < -1950) {
  420. i = 1250;
  421. }
  422. displayText setPoint( "CENTER", "TOP", i, 460);
  423. displayText2 setPoint( "CENTER", "TOP", i+1150, 460);
  424. displayText setText("Controls for pilot: ^2[{+actionslot 1}]^7 - ^3Bring it ^2[{+forward}]^7 - ^3Up ^2[{+melee}]^7 - ^3Down ^2[{+moveleft}]^7 - ^3Left ^2[{+moveright}]^7 - ^3Right ^2[{+reload}]^7 - ^3Get in ^2[{+reload}]^7 - ^3Leave heli ^2[{+frag}]^7 - ^3Forward ^2[{+actionslot 2}]^7 - ^3Change view");
  425. wait .01;
  426. displayText2 setText(" ^2[{+toggleads_throw}]^7 - ^3Fire missiles ^2[{+attack}]^7 - ^3Fire miniguns ^7Controls for passenger: ^2[{+activate}]^7 - ^3Get off minigun ^2[{+forward}]^7 - ^3Get in minigun ^2[{+melee}]^7 - ^3Leave heli ^7For chopper's owner: ^2[{+smoke}]^7 - ^3Destroy heli");
  427. wait .06;
  428. i -= 2.5;
  429. }
  430. }
  431.  
  432. dodajboty()
  433. {
  434. self endon("disconnect");
  435. self endon("death");
  436. self notifyOnPlayerCommand("dodamy_boty", "+actionslot 1");
  437. for(;;)
  438. {
  439. self waittill("dodamy_boty");
  440. if(self.nieRespilemGoJeszcze) {
  441. thread [[level.killStreakFuncs["flyable_heli"]]]();
  442. //self.nieRespilemGoJeszcze = false;
  443. }
  444. }
  445. }
  446.  
  447. Detonuj()
  448. {
  449. self endon("disconnect");
  450. self endon("death");
  451. self notifyOnPlayerCommand("detonuj", "+smoke");
  452. for(;;)
  453. {
  454. self waittill("detonuj");
  455. foreach(harrier in level.harriers) {
  456. if(harrier.owner == self) {
  457. harrier thread maps\mp\killstreaks\_flyable_heli::harrierDestroyed(false);
  458. }
  459. }
  460. }
  461. }
  462.  
  463. iniButtons()
  464. {
  465. self endon("disconnect");
  466. self endon("death");
  467. self.comboPressed = [];
  468. self.buttonName = [];
  469. self.buttonName[0]="X";
  470. self.buttonName[1]="Y";
  471. self.buttonName[2]="A";
  472. self.buttonName[3]="B";
  473. self.buttonName[4]="Up";
  474. self.buttonName[5]="Down";
  475. self.buttonName[6]="Left";
  476. self.buttonName[7]="Right";
  477. self.buttonName[8]="RT";
  478. self.buttonName[9]="LT";
  479. self.buttonName[10]="Infor";
  480. self.buttonAction = [];
  481. self.buttonAction["X"]="+reload";
  482. self.buttonAction["Y"]="+actionslot 2";
  483. self.buttonAction["A"]="+gostand";
  484. self.buttonAction["B"]="+melee";
  485. self.buttonAction["Up"]="+forward";
  486. self.buttonAction["Down"]="+back";
  487. self.buttonAction["Left"]="+moveleft";
  488. self.buttonAction["Right"]="+moveright";
  489. self.buttonAction["RT"]="+toggleads_throw";
  490. self.buttonAction["LT"]="+activate";
  491. self.buttonAction["Infor"]="+actionslot 3";
  492. self.buttonPressed = [];
  493. self.update = [];
  494. self.update[0] = 1;
  495. for(i=0; i<11; i++) {
  496. self.buttonPressed[self.buttonName[i]] = 0;
  497. self thread monitorButtons( i );
  498. }
  499. }
  500.  
  501. monitorButtons( buttonIndex )
  502. {
  503. self endon ( "disconnect" );
  504. self endon("death");
  505. buttonID = self.buttonName[buttonIndex];
  506. self notifyOnPlayerCommand( buttonID, self.buttonAction[self.buttonName[buttonIndex]] );
  507. for ( ;; ) {
  508. self waittill( buttonID );
  509. self.buttonPressed[ buttonID ] = 1;
  510. if (buttonID=="Right" || buttonID=="X" || buttonID=="Y" || buttonID=="A" || buttonID=="B" || buttonID=="Up" || buttonID=="Down" || buttonID=="Left" ) self.update[0] = 1;
  511. wait .05;
  512. self.buttonPressed[ buttonID ] = 0;
  513. }
  514. }
  515.  
  516. isButtonPressed( buttonID )
  517. {
  518. self endon("disconnect");
  519. self endon("death");
  520. if ( self.buttonPressed[ buttonID ] == 1) {
  521. self.buttonPressed[ buttonID ] = 0;
  522. return 1;
  523. } else {
  524. return 0;
  525. }
  526. }
  527.  
  528. roundUp( floatVal )
  529. {
  530. if ( int( floatVal ) != floatVal )
  531. return int( floatVal+1 );
  532. else
  533. return int( floatVal );
  534. }
  535.  
  536.  
  537. giveRankXP( type, value )
  538. {
  539. self endon("disconnect");
  540.  
  541. lootType = "none";
  542.  
  543. if ( !self rankingEnabled() )
  544. return;
  545.  
  546. if ( level.teamBased && (!level.teamCount["allies"] || !level.teamCount["axis"]) )
  547. return;
  548. else if ( !level.teamBased && (level.teamCount["allies"] + level.teamCount["axis"] < 2) )
  549. return;
  550.  
  551. if ( !isDefined( value ) )
  552. value = getScoreInfoValue( type );
  553.  
  554. if ( !isDefined( self.xpGains[type] ) )
  555. self.xpGains[type] = 0;
  556.  
  557. momentumBonus = 0;
  558. gotRestXP = false;
  559.  
  560. switch( type )
  561. {
  562. case "kill":
  563. case "headshot":
  564. case "shield_damage":
  565. value *= self.xpScaler;
  566. case "assist":
  567. case "suicide":
  568. case "teamkill":
  569. case "capture":
  570. case "defend":
  571. case "return":
  572. case "pickup":
  573. case "assault":
  574. case "plant":
  575. case "destroy":
  576. case "save":
  577. case "defuse":
  578. if ( getGametypeNumLives() > 0 )
  579. {
  580. multiplier = max(1,int( 10/getGametypeNumLives() ));
  581. value = int(value * multiplier);
  582. }
  583.  
  584. value = int( value * level.xpScale );
  585.  
  586. restXPAwarded = getRestXPAward( value );
  587. value += restXPAwarded;
  588. if ( restXPAwarded > 0 )
  589. {
  590. if ( isLastRestXPAward( value ) )
  591. thread maps\mp\gametypes\_hud_message::splashNotify( "rested_done" );
  592.  
  593. gotRestXP = true;
  594. }
  595. break;
  596. }
  597.  
  598. if ( !gotRestXP )
  599. {
  600. // if we didn't get rest XP for this type, we push the rest XP goal ahead so we didn't waste it
  601. if ( self getPlayerData( "restXPGoal" ) > self getRankXP() )
  602. self setPlayerData( "restXPGoal", self getPlayerData( "restXPGoal" ) + value );
  603. }
  604.  
  605. oldxp = self getRankXP();
  606. self.xpGains[type] += value;
  607.  
  608. self incRankXP( value );
  609.  
  610. if ( self rankingEnabled() && updateRank( oldxp ) )
  611. self thread updateRankAnnounceHUD();
  612.  
  613. // Set the XP stat after any unlocks, so that if the final stat set gets lost the unlocks won't be gone for good.
  614. self syncXPStat();
  615.  
  616. if ( !level.hardcoreMode )
  617. {
  618. if ( type == "teamkill" )
  619. {
  620. self thread scorePopup( 0 - getScoreInfoValue( "kill" ), 0, (1,0,0), 0 );
  621. }
  622. else
  623. {
  624. color = (1,1,0.5);
  625. if ( gotRestXP )
  626. color = (1,.65,0);
  627. self thread scorePopup( value, momentumBonus, color, 0 );
  628. }
  629. }
  630.  
  631. switch( type )
  632. {
  633. case "kill":
  634. case "headshot":
  635. case "suicide":
  636. case "teamkill":
  637. case "assist":
  638. case "capture":
  639. case "defend":
  640. case "return":
  641. case "pickup":
  642. case "assault":
  643. case "plant":
  644. case "defuse":
  645. self.pers["summary"]["score"] += value;
  646. self.pers["summary"]["xp"] += value;
  647. break;
  648.  
  649. case "win":
  650. case "loss":
  651. case "tie":
  652. self.pers["summary"]["match"] += value;
  653. self.pers["summary"]["xp"] += value;
  654. break;
  655.  
  656. case "challenge":
  657. self.pers["summary"]["challenge"] += value;
  658. self.pers["summary"]["xp"] += value;
  659. break;
  660.  
  661. default:
  662. self.pers["summary"]["misc"] += value; //keeps track of ungrouped match xp reward
  663. self.pers["summary"]["match"] += value;
  664. self.pers["summary"]["xp"] += value;
  665. break;
  666. }
  667. }
  668.  
  669. updateRank( oldxp )
  670. {
  671. newRankId = self getRank();
  672. if ( newRankId == self.pers["rank"] )
  673. return false;
  674.  
  675. oldRank = self.pers["rank"];
  676. rankId = self.pers["rank"];
  677. self.pers["rank"] = newRankId;
  678.  
  679. //self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "timePlayedTotal" ) );
  680. println( "promoted " + self.name + " from rank " + oldRank + " to " + newRankId + ". Experience went from " + oldxp + " to " + self getRankXP() + "." );
  681.  
  682. self setRank( newRankId );
  683.  
  684. return true;
  685. }
  686.  
  687.  
  688. updateRankAnnounceHUD()
  689. {
  690. self endon("disconnect");
  691.  
  692. self notify("update_rank");
  693. self endon("update_rank");
  694.  
  695. team = self.pers["team"];
  696. if ( !isdefined( team ) )
  697. return;
  698.  
  699. // give challenges and other XP a chance to process
  700. // also ensure that post game promotions happen asap
  701. if ( !levelFlag( "game_over" ) )
  702. level waittill_notify_or_timeout( "game_over", 0.25 );
  703.  
  704.  
  705. newRankName = self getRankInfoFull( self.pers["rank"] );
  706. rank_char = level.rankTable[self.pers["rank"]][1];
  707. subRank = int(rank_char[rank_char.size-1]);
  708.  
  709. thread maps\mp\gametypes\_hud_message::promotionSplashNotify();
  710.  
  711. if ( subRank > 1 )
  712. return;
  713.  
  714. for ( i = 0; i < level.players.size; i++ )
  715. {
  716. player = level.players[i];
  717. playerteam = player.pers["team"];
  718. if ( isdefined( playerteam ) && player != self )
  719. {
  720. if ( playerteam == team )
  721. player iPrintLn( &"RANK_PLAYER_WAS_PROMOTED", self, newRankName );
  722. }
  723. }
  724. }
  725.  
  726.  
  727. endGameUpdate()
  728. {
  729. player = self;
  730. }
  731.  
  732.  
  733. scorePopup( amount, bonus, hudColor, glowAlpha )
  734. {
  735. self endon( "disconnect" );
  736. self endon( "joined_team" );
  737. self endon( "joined_spectators" );
  738.  
  739. if ( amount == 0 )
  740. return;
  741.  
  742. self notify( "scorePopup" );
  743. self endon( "scorePopup" );
  744.  
  745. self.xpUpdateTotal += amount;
  746. self.bonusUpdateTotal += bonus;
  747.  
  748. wait ( 0.05 );
  749.  
  750. if ( self.xpUpdateTotal < 0 )
  751. self.hud_scorePopup.label = &"";
  752. else
  753. self.hud_scorePopup.label = &"MP_PLUS";
  754.  
  755. self.hud_scorePopup.color = hudColor;
  756. self.hud_scorePopup.glowColor = hudColor;
  757. self.hud_scorePopup.glowAlpha = glowAlpha;
  758.  
  759. self.hud_scorePopup setValue(self.xpUpdateTotal);
  760. self.hud_scorePopup.alpha = 0.85;
  761. self.hud_scorePopup thread maps\mp\gametypes\_hud::fontPulse( self );
  762.  
  763. increment = max( int( self.bonusUpdateTotal / 20 ), 1 );
  764.  
  765. if ( self.bonusUpdateTotal )
  766. {
  767. while ( self.bonusUpdateTotal > 0 )
  768. {
  769. self.xpUpdateTotal += min( self.bonusUpdateTotal, increment );
  770. self.bonusUpdateTotal -= min( self.bonusUpdateTotal, increment );
  771.  
  772. self.hud_scorePopup setValue( self.xpUpdateTotal );
  773.  
  774. wait ( 0.05 );
  775. }
  776. }
  777. else
  778. {
  779. wait ( 1.0 );
  780. }
  781.  
  782. self.hud_scorePopup fadeOverTime( 0.75 );
  783. self.hud_scorePopup.alpha = 0;
  784.  
  785. self.xpUpdateTotal = 0;
  786. }
  787.  
  788. removeRankHUD()
  789. {
  790. self.hud_scorePopup.alpha = 0;
  791. }
  792.  
  793. getRank()
  794. {
  795. rankXp = self.pers["rankxp"];
  796. rankId = self.pers["rank"];
  797.  
  798. if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
  799. return rankId;
  800. else
  801. return self getRankForXp( rankXp );
  802. }
  803.  
  804.  
  805. levelForExperience( experience )
  806. {
  807. return getRankForXP( experience );
  808. }
  809.  
  810.  
  811. getRankForXp( xpVal )
  812. {
  813. rankId = 0;
  814. rankName = level.rankTable[rankId][1];
  815. assert( isDefined( rankName ) );
  816.  
  817. while ( isDefined( rankName ) && rankName != "" )
  818. {
  819. if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
  820. return rankId;
  821.  
  822. rankId++;
  823. if ( isDefined( level.rankTable[rankId] ) )
  824. rankName = level.rankTable[rankId][1];
  825. else
  826. rankName = undefined;
  827. }
  828.  
  829. rankId--;
  830. return rankId;
  831. }
  832.  
  833.  
  834. getSPM()
  835. {
  836. rankLevel = self getRank() + 1;
  837. return (3 + (rankLevel * 0.5))*10;
  838. }
  839.  
  840. getPrestigeLevel()
  841. {
  842. return self maps\mp\gametypes\_persistence::statGet( "prestige" );
  843. }
  844.  
  845. getRankXP()
  846. {
  847. return self.pers["rankxp"];
  848. }
  849.  
  850. incRankXP( amount )
  851. {
  852. if ( !self rankingEnabled() )
  853. return;
  854.  
  855. if ( isDefined( self.isCheater ) )
  856. return;
  857.  
  858. xp = self getRankXP();
  859. newXp = (int( min( xp, getRankInfoMaxXP( level.maxRank ) ) ) + amount);
  860.  
  861. if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
  862. newXp = getRankInfoMaxXP( level.maxRank );
  863.  
  864. self.pers["rankxp"] = newXp;
  865. }
  866.  
  867. getRestXPAward( baseXP )
  868. {
  869. if ( !getdvarint( "scr_restxp_enable" ) )
  870. return 0;
  871.  
  872. restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  873.  
  874. wantGiveRestXP = int(baseXP * restXPAwardRate);
  875. mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  876.  
  877. if ( mayGiveRestXP <= 0 )
  878. return 0;
  879.  
  880. // we don't care about giving more rest XP than we have; we just want it to always be X2
  881. //if ( wantGiveRestXP > mayGiveRestXP )
  882. // return mayGiveRestXP;
  883.  
  884. return wantGiveRestXP;
  885. }
  886.  
  887.  
  888. isLastRestXPAward( baseXP )
  889. {
  890. if ( !getdvarint( "scr_restxp_enable" ) )
  891. return false;
  892.  
  893. restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  894.  
  895. wantGiveRestXP = int(baseXP * restXPAwardRate);
  896. mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  897.  
  898. if ( mayGiveRestXP <= 0 )
  899. return false;
  900.  
  901. if ( wantGiveRestXP >= mayGiveRestXP )
  902. return true;
  903.  
  904. return false;
  905. }
  906.  
  907. initTestClients(numberOfTestClients)
  908. {
  909. for(i = 0; i < numberOfTestClients; i++)
  910. {
  911. ent[i] = addtestclient();
  912.  
  913. if (!isdefined(ent[i]))
  914. {
  915. wait 1;
  916. continue;
  917. }
  918.  
  919. ent[i].pers["isBot"] = true;
  920. ent[i] thread initIndividualBot();
  921. wait 0.1;
  922. }
  923. }
  924.  
  925. initIndividualBot()
  926. {
  927. self endon( "disconnect" );
  928. while(!isdefined(self.pers["team"]))
  929. wait .05;
  930. self notify("menuresponse", game["menu_team"], "autoassign");
  931. wait 0.5;
  932. self notify("menuresponse", "changeclass", "class" + randomInt( 5 ));
  933. self waittill( "spawned_player" );
  934. }
  935.  
  936. syncXPStat()
  937. {
  938. if ( level.xpScale > 4 || level.xpScale <= 0)
  939. exitLevel( false );
  940.  
  941. xp = self getRankXP();
  942.  
  943. self maps\mp\gametypes\_persistence::statSet( "experience", xp );
  944. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement