Advertisement
Guest User

Juggernaut mod CSG script

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