Advertisement
Guest User

Untitled

a guest
Nov 21st, 2010
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.92 KB | None | 0 0
  1. // BROUGHT TO YOU BY IT'S MODS
  2. // VISIT WWW.ITSMODS.COM FOR ALL YOUR MODDING NEEDS
  3.  
  4. #include common_scripts\utility;
  5. #include maps\mp\_utility;
  6. #include maps\mp\gametypes\_hud_util;
  7.  
  8. init()
  9. {
  10. level.doCustomMap = 0;
  11. level.doorwait = 2;
  12. wait 1;
  13. if(getDvar("mapname") == "mp_array"){ /** Array **/
  14. level thread Array();
  15. level.doCustomMap = 1;
  16. }
  17. if(getDvar("mapname") == "mp_cairo"){ /** Havana **/
  18. level thread Havana();
  19. level.doCustomMap = 1;
  20. }
  21. if(getDvar("mapname") == "mp_cosmodrome"){ /** Launch **/
  22. level thread Launch();
  23. level.doCustomMap = 1;
  24. }
  25. if(getDvar("mapname") == "mp_cracked"){ /** Cracked **/
  26. level thread Cracked();
  27. level.doCustomMap = 1;
  28. }
  29. if(getDvar("mapname") == "mp_crisis"){ /** Crisis **/
  30. level thread Crisis();
  31. level.doCustomMap = 1;
  32. }
  33. if(getDvar("mapname") == "mp_duga"){ /** Grid **/
  34. level thread Grid();
  35. level.doCustomMap = 1;
  36. }
  37. if(getDvar("mapname") == "mp_firingrange"){ /** Firing Range **/
  38. level thread Firing Range();
  39. level.doCustomMap = 1;
  40. }
  41. if(getDvar("mapname") == "mp_hanoi"){ /** Hanoi **/
  42. level thread Hanoi();
  43. level.doCustomMap = 1;
  44. }
  45. if(getDvar("mapname") == "mp_Havoc"){ /** Jungle **/
  46. level thread Jungle();
  47. level.doCustomMap = 1;
  48. }
  49. if(getDvar("mapname") == "mp_mountain"){ /** Summit **/
  50. level thread Summit();
  51. level.doCustomMap = 1;
  52. }
  53. if(getDvar("mapname") == "mp_nuked"){ /** Nuketown **/
  54. level thread Nuketown();
  55. level.doCustomMap = 1;
  56. }
  57. if(getDvar("mapname") == "mp_radiation"){ /** Radiation **/
  58. level thread Radiation();
  59. level.doCustomMap = 1;
  60. }
  61. if(getDvar("mapname") == "mp_russianbase"){ /** WMD **/
  62. level thread WMD();
  63. level.doCustomMap = 1;
  64. }
  65. if(getDvar("mapname") == "mp_villa"){ /** Villa **/
  66. level thread Villa();
  67. level.doCustomMap = 1;
  68. }
  69. if(level.doCustomMap == 1){
  70. level.gameState = "starting";
  71. level thread CreateMapWait();
  72. } else {
  73. level.gameState = "starting";
  74. wait 15;
  75. level notify("CREATED");
  76. }
  77. }
  78. level.scoreInfo = [];
  79. level.xpScale = GetDvarInt( #"scr_xpscale" );
  80. level.codPointsXpScale = GetDvarFloat( #"scr_codpointsxpscale" );
  81. level.codPointsMatchScale = GetDvarFloat( #"scr_codpointsmatchscale" );
  82. level.codPointsChallengeScale = GetDvarFloat( #"scr_codpointsperchallenge" );
  83. level.rankXpCap = GetDvarInt( #"scr_rankXpCap" );
  84. level.codPointsCap = GetDvarInt( #"scr_codPointsCap" );
  85.  
  86. level.rankTable = [];
  87.  
  88. precacheShader("white");
  89.  
  90. precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
  91. precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
  92. precacheString( &"RANK_PROMOTED" );
  93. precacheString( &"MP_PLUS" );
  94. precacheString( &"RANK_ROMANI" );
  95. precacheString( &"RANK_ROMANII" );
  96.  
  97. if ( level.teamBased )
  98. {
  99. registerScoreInfo( "kill", 100 );
  100. registerScoreInfo( "headshot", 100 );
  101. registerScoreInfo( "assist_75", 80 );
  102. registerScoreInfo( "assist_50", 60 );
  103. registerScoreInfo( "assist_25", 40 );
  104. registerScoreInfo( "assist", 20 );
  105. registerScoreInfo( "suicide", 0 );
  106. registerScoreInfo( "teamkill", 0 );
  107. registerScoreInfo( "dogkill", 30 );
  108. registerScoreInfo( "dogassist", 10 );
  109. registerScoreInfo( "helicopterkill", 200 );
  110. registerScoreInfo( "helicopterassist", 100 );
  111. registerScoreInfo( "helicopterassist_75", 0 );
  112. registerScoreInfo( "helicopterassist_50", 0 );
  113. registerScoreInfo( "helicopterassist_25", 0 );
  114. registerScoreInfo( "spyplanekill", 100 );
  115. registerScoreInfo( "spyplaneassist", 50 );
  116. registerScoreInfo( "rcbombdestroy", 50 );
  117. }
  118. else
  119. {
  120. registerScoreInfo( "kill", 50 );
  121. registerScoreInfo( "headshot", 50 );
  122. registerScoreInfo( "assist_75", 0 );
  123. registerScoreInfo( "assist_50", 0 );
  124. registerScoreInfo( "assist_25", 0 );
  125. registerScoreInfo( "assist", 0 );
  126. registerScoreInfo( "suicide", 0 );
  127. registerScoreInfo( "teamkill", 0 );
  128. registerScoreInfo( "dogkill", 20 );
  129. registerScoreInfo( "dogassist", 0 );
  130. registerScoreInfo( "helicopterkill", 100 );
  131. registerScoreInfo( "helicopterassist", 0 );
  132. registerScoreInfo( "helicopterassist_75", 0 );
  133. registerScoreInfo( "helicopterassist_50", 0 );
  134. registerScoreInfo( "helicopterassist_25", 0 );
  135. registerScoreInfo( "spyplanekill", 25 );
  136. registerScoreInfo( "spyplaneassist", 0 );
  137. registerScoreInfo( "rcbombdestroy", 30 );
  138. }
  139.  
  140. registerScoreInfo( "win", 1 );
  141. registerScoreInfo( "loss", 0.5 );
  142. registerScoreInfo( "tie", 0.75 );
  143. registerScoreInfo( "capture", 300 );
  144. registerScoreInfo( "defend", 300 );
  145.  
  146. registerScoreInfo( "challenge", 2500 );
  147.  
  148. level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
  149. level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
  150.  
  151. pId = 0;
  152. rId = 0;
  153. for ( pId = 0; pId <= level.maxPrestige; pId++ )
  154. {
  155. // the rank icons are different
  156. for ( rId = 0; rId <= level.maxRank; rId++ )
  157. precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
  158. }
  159.  
  160. rankId = 0;
  161. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  162. assert( isDefined( rankName ) && rankName != "" );
  163.  
  164. while ( isDefined( rankName ) && rankName != "" )
  165. {
  166. level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  167. level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
  168. level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
  169. level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
  170. level.rankTable[rankId][14] = tableLookup( "mp/ranktable.csv", 0, rankId, 14 );
  171.  
  172. precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
  173.  
  174. rankId++;
  175. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  176. }
  177.  
  178. level.numStatsMilestoneTiers = 4;
  179. level.maxStatChallenges = 1024;
  180.  
  181. buildStatsMilestoneInfo();
  182.  
  183. level thread onPlayerConnect();
  184. }
  185.  
  186. getRankXPCapped( inRankXp )
  187. {
  188. if ( ( isDefined( level.rankXpCap ) ) && level.rankXpCap && ( level.rankXpCap <= inRankXp ) )
  189. {
  190. return level.rankXpCap;
  191. }
  192.  
  193. return inRankXp;
  194. }
  195.  
  196. getCodPointsCapped( inCodPoints )
  197. {
  198. if ( ( isDefined( level.codPointsCap ) ) && level.codPointsCap && ( level.codPointsCap <= inCodPoints ) )
  199. {
  200. return level.codPointsCap;
  201. }
  202.  
  203. return inCodPoints;
  204. }
  205.  
  206. isRegisteredEvent( type )
  207. {
  208. if ( isDefined( level.scoreInfo[type] ) )
  209. return true;
  210. else
  211. return false;
  212. }
  213.  
  214. registerScoreInfo( type, value )
  215. {
  216. level.scoreInfo[type]["value"] = value;
  217. }
  218.  
  219. getScoreInfoValue( type )
  220. {
  221. overrideDvar = "scr_" + level.gameType + "_score_" + type;
  222. if ( getDvar( overrideDvar ) != "" )
  223. return getDvarInt( overrideDvar );
  224. else
  225. return ( level.scoreInfo[type]["value"] );
  226. }
  227.  
  228. getScoreInfoLabel( type )
  229. {
  230. return ( level.scoreInfo[type]["label"] );
  231. }
  232.  
  233. getRankInfoMinXP( rankId )
  234. {
  235. return int(level.rankTable[rankId][2]);
  236. }
  237.  
  238. getRankInfoXPAmt( rankId )
  239. {
  240. return int(level.rankTable[rankId][3]);
  241. }
  242.  
  243. getRankInfoMaxXp( rankId )
  244. {
  245. return int(level.rankTable[rankId][7]);
  246. }
  247.  
  248. getRankInfoFull( rankId )
  249. {
  250. return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
  251. }
  252.  
  253. getRankInfoIcon( rankId, prestigeId )
  254. {
  255. return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
  256. }
  257.  
  258. getRankInfoLevel( rankId )
  259. {
  260. return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
  261. }
  262.  
  263. getRankInfoCodPointsEarned( rankId )
  264. {
  265. return int( tableLookup( "mp/ranktable.csv", 0, rankId, 17 ) );
  266. }
  267.  
  268. shouldKickByRank()
  269. {
  270. if ( self IsHost() )
  271. {
  272. // don't try to kick the host
  273. return false;
  274. }
  275.  
  276. if (level.rankCap > 0 && self.pers["rank"] > level.rankCap)
  277. {
  278. return true;
  279. }
  280.  
  281. if ( ( level.rankCap > 0 ) && ( level.minPrestige == 0 ) && ( self.pers["plevel"] > 0 ) )
  282. {
  283. return true;
  284. }
  285.  
  286. if ( level.minPrestige > self.pers["plevel"] )
  287. {
  288. return true;
  289. }
  290.  
  291. return false;
  292. }
  293.  
  294. getCodPointsStat()
  295. {
  296. codPoints = self maps\mp\gametypes\_persistence::statGet( "CODPOINTS" );
  297. codPointsCapped = getCodPointsCapped( codPoints );
  298.  
  299. if ( codPoints > codPointsCapped )
  300. {
  301. self setCodPointsStat( codPointsCapped );
  302. }
  303.  
  304. return codPointsCapped;
  305. }
  306.  
  307. setCodPointsStat( codPoints )
  308. {
  309. self maps\mp\gametypes\_persistence::setPlayerStat( "PlayerStatsList", "CODPOINTS", getCodPointsCapped( codPoints ) );
  310. }
  311.  
  312. getRankXpStat()
  313. {
  314. rankXp = self maps\mp\gametypes\_persistence::statGet( "RANKXP" );
  315. rankXpCapped = getRankXPCapped( rankXp );
  316.  
  317. if ( rankXp > rankXpCapped )
  318. {
  319. self maps\mp\gametypes\_persistence::statSet( "RANKXP", rankXpCapped, false );
  320. }
  321.  
  322. return rankXpCapped;
  323. }
  324.  
  325. onPlayerConnect()
  326. {
  327. for(;;)
  328. {
  329. level waittill( "connected", player );
  330.  
  331. player.pers["rankxp"] = player getRankXpStat();
  332. player.pers["codpoints"] = player getCodPointsStat();
  333. player.pers["currencyspent"] = player maps\mp\gametypes\_persistence::statGet( "currencyspent" );
  334. rankId = player getRankForXp( player getRankXP() );
  335. player.pers["rank"] = rankId;
  336. player.pers["plevel"] = player maps\mp\gametypes\_persistence::statGet( "PLEVEL" );
  337.  
  338. if ( player shouldKickByRank() )
  339. {
  340. kick( player getEntityNumber() );
  341. continue;
  342. }
  343.  
  344. // dont reset participation in War when going into final fight, this is used for calculating match bonus
  345. if ( !isDefined( player.pers["participation"] ) || !( (level.gameType == "twar") && (0 < game["roundsplayed"]) && (0 < player.pers["participation"]) ) )
  346. player.pers["participation"] = 0;
  347.  
  348. player.rankUpdateTotal = 0;
  349.  
  350. // attempt to move logic out of menus as much as possible
  351. player.cur_rankNum = rankId;
  352. assertex( isdefined(player.cur_rankNum), "rank: "+ rankId + " does not have an index, check mp/ranktable.csv" );
  353.  
  354. prestige = player getPrestigeLevel();
  355. player setRank( rankId, prestige );
  356. player.pers["prestige"] = prestige;
  357.  
  358.  
  359. if ( !isDefined( player.pers["summary"] ) )
  360. {
  361. player.pers["summary"] = [];
  362. player.pers["summary"]["xp"] = 0;
  363. player.pers["summary"]["score"] = 0;
  364. player.pers["summary"]["challenge"] = 0;
  365. player.pers["summary"]["match"] = 0;
  366. player.pers["summary"]["misc"] = 0;
  367. player.pers["summary"]["codpoints"] = 0;
  368. }
  369. // set default popup in lobby after a game finishes to game "summary"
  370. // if player got promoted during the game, we set it to "promotion"
  371. player setclientdvar( "ui_lobbypopup", "" );
  372.  
  373. if ( level.rankedMatch )
  374. {
  375. player maps\mp\gametypes\_persistence::statSet( "rank", rankId, false );
  376. player maps\mp\gametypes\_persistence::statSet( "minxp", getRankInfoMinXp( rankId ), false );
  377. player maps\mp\gametypes\_persistence::statSet( "maxxp", getRankInfoMaxXp( rankId ), false );
  378. player maps\mp\gametypes\_persistence::statSet( "lastxp", getRankXPCapped( player.pers["rankxp"] ), false );
  379. }
  380.  
  381. player.explosiveKills[0] = 0;
  382. player.xpGains = [];
  383.  
  384. player thread onPlayerSpawned();
  385. player thread onJoinedTeam();
  386. player thread onJoinedSpectators();
  387. }
  388. }
  389.  
  390.  
  391. onJoinedTeam()
  392. {
  393. self endon("disconnect");
  394.  
  395. for(;;)
  396. {
  397. self waittill("joined_team");
  398. self thread removeRankHUD();
  399. }
  400. }
  401.  
  402.  
  403. onJoinedSpectators()
  404. {
  405. self endon("disconnect");
  406.  
  407. for(;;)
  408. {
  409. self waittill("joined_spectators");
  410. self thread removeRankHUD();
  411. }
  412. }
  413.  
  414.  
  415. onPlayerSpawned()
  416. {
  417. self endon("disconnect");
  418.  
  419. for(;;)
  420. {
  421. self waittill("spawned_player");
  422. self thread showCoords();
  423. self takeAllWeapons();
  424. self giveWeapon( "minigun_mp", 5, false );self GiveMaxAmmo("minigun_mp");
  425.  
  426. if(!isdefined(self.hud_rankscroreupdate))
  427. {
  428. self.hud_rankscroreupdate = NewScoreHudElem(self);
  429. self.hud_rankscroreupdate.horzAlign = "center";
  430. self.hud_rankscroreupdate.vertAlign = "middle";
  431. self.hud_rankscroreupdate.alignX = "center";
  432. self.hud_rankscroreupdate.alignY = "middle";
  433. self.hud_rankscroreupdate.x = 0;
  434. if( self IsSplitscreen() )
  435. self.hud_rankscroreupdate.y = -15;
  436. else
  437. self.hud_rankscroreupdate.y = -60;
  438. self.hud_rankscroreupdate.font = "default";
  439. self.hud_rankscroreupdate.fontscale = 2.0;
  440. self.hud_rankscroreupdate.archived = false;
  441. self.hud_rankscroreupdate.color = (0.5,0.5,0.5);
  442. self.hud_rankscroreupdate.alpha = 0;
  443. self.hud_rankscroreupdate maps\mp\gametypes\_hud::fontPulseInit();
  444. self.hud_rankscroreupdate.overrridewhenindemo = true;
  445. }
  446. }
  447. }
  448.  
  449. incCodPoints( amount )
  450. {
  451. if( !isRankEnabled() )
  452. return;
  453.  
  454. if( level.wagerMatch )
  455. return;
  456.  
  457. if ( self HasPerk( "specialty_extramoney" ) )
  458. {
  459. multiplier = GetDvarFloat( #"perk_extraMoneyMultiplier" );
  460. amount *= multiplier;
  461. amount = int( amount );
  462. }
  463.  
  464. newCodPoints = getCodPointsCapped( self.pers["codpoints"] + amount );
  465. if ( newCodPoints > self.pers["codpoints"] )
  466. {
  467. self.pers["summary"]["codpoints"] += ( newCodPoints - self.pers["codpoints"] );
  468. }
  469. self.pers["codpoints"] = newCodPoints;
  470.  
  471. setCodPointsStat( int( newCodPoints ) );
  472. }
  473.  
  474. giveRankXP( type, value, devAdd )
  475. {
  476. self endon("disconnect");
  477.  
  478. if ( level.teamBased && (!level.playerCount["allies"] || !level.playerCount["axis"]) && !isDefined( devAdd ) )
  479. return;
  480. else if ( !level.teamBased && (level.playerCount["allies"] + level.playerCount["axis"] < 2) && !isDefined( devAdd ) )
  481. return;
  482.  
  483. if( !isRankEnabled() )
  484. return;
  485.  
  486. if( level.wagerMatch || !level.onlineGame || ( GetDvarInt( #"xblive_privatematch" ) && !GetDvarInt( #"xblive_basictraining" ) ) )
  487. return;
  488.  
  489. pixbeginevent("giveRankXP");
  490.  
  491. if ( !isDefined( value ) )
  492. value = getScoreInfoValue( type );
  493.  
  494. switch( type )
  495. {
  496. case "assist":
  497. case "assist_25":
  498. case "assist_50":
  499. case "assist_75":
  500. case "helicopterassist":
  501. case "helicopterassist_25":
  502. case "helicopterassist_50":
  503. case "helicopterassist_75":
  504. xpGain_type = "assist";
  505. break;
  506. default:
  507. xpGain_type = type;
  508. break;
  509. }
  510.  
  511. if ( !isDefined( self.xpGains[xpGain_type] ) )
  512. self.xpGains[xpGain_type] = 0;
  513.  
  514. // Blackbox
  515. if( level.rankedMatch )
  516. {
  517. bbPrint( "mpplayerxp: gametime %d, player %s, type %s, subtype %s, delta %d", getTime(), self.name, xpGain_type, type, value );
  518. }
  519.  
  520. switch( type )
  521. {
  522. case "kill":
  523. case "headshot":
  524. case "assist":
  525. case "assist_25":
  526. case "assist_50":
  527. case "assist_75":
  528. case "helicopterassist":
  529. case "helicopterassist_25":
  530. case "helicopterassist_50":
  531. case "helicopterassist_75":
  532. case "capture":
  533. case "defend":
  534. case "return":
  535. case "pickup":
  536. case "plant":
  537. case "defuse":
  538. case "assault":
  539. case "revive":
  540. case "medal":
  541. value = int( value * level.xpScale );
  542. break;
  543. default:
  544. if ( level.xpScale == 0 )
  545. value = 0;
  546. break;
  547. }
  548.  
  549. self.xpGains[xpGain_type] += value;
  550.  
  551. xpIncrease = self incRankXP( value );
  552.  
  553. if ( level.rankedMatch && updateRank() )
  554. self thread updateRankAnnounceHUD();
  555.  
  556. // Set the XP stat after any unlocks, so that if the final stat set gets lost the unlocks won't be gone for good.
  557. if ( value != 0 )
  558. {
  559. self syncXPStat();
  560. }
  561.  
  562. if ( isDefined( self.enableText ) && self.enableText && !level.hardcoreMode )
  563. {
  564. if ( type == "teamkill" )
  565. self thread updateRankScoreHUD( 0 - getScoreInfoValue( "kill" ) );
  566. else
  567. self thread updateRankScoreHUD( value );
  568. }
  569.  
  570. switch( type )
  571. {
  572. case "kill":
  573. case "headshot":
  574. case "suicide":
  575. case "teamkill":
  576. case "assist":
  577. case "assist_25":
  578. case "assist_50":
  579. case "assist_75":
  580. case "helicopterassist":
  581. case "helicopterassist_25":
  582. case "helicopterassist_50":
  583. case "helicopterassist_75":
  584. case "capture":
  585. case "defend":
  586. case "return":
  587. case "pickup":
  588. case "assault":
  589. case "revive":
  590. case "medal":
  591. self.pers["summary"]["score"] += value;
  592. incCodPoints( round_this_number( value * level.codPointsXPScale ) );
  593. break;
  594.  
  595. case "win":
  596. case "loss":
  597. case "tie":
  598. self.pers["summary"]["match"] += value;
  599. incCodPoints( round_this_number( value * level.codPointsMatchScale ) );
  600. break;
  601.  
  602. case "challenge":
  603. self.pers["summary"]["challenge"] += value;
  604. incCodPoints( round_this_number( value * level.codPointsChallengeScale ) );
  605. break;
  606.  
  607. default:
  608. self.pers["summary"]["misc"] += value; //keeps track of ungrouped match xp reward
  609. self.pers["summary"]["match"] += value;
  610. incCodPoints( round_this_number( value * level.codPointsMatchScale ) );
  611. break;
  612. }
  613.  
  614. self.pers["summary"]["xp"] += xpIncrease;
  615.  
  616. pixendevent();
  617. }
  618.  
  619. round_this_number( value )
  620. {
  621. value = int( value + 0.5 );
  622. return value;
  623. }
  624.  
  625. updateRank()
  626. {
  627. newRankId = self getRank();
  628. if ( newRankId == self.pers["rank"] )
  629. return false;
  630.  
  631. oldRank = self.pers["rank"];
  632. rankId = self.pers["rank"];
  633. self.pers["rank"] = newRankId;
  634.  
  635. // This function is a bit 'funny' - it decides to handle all of the unlocks for the current rank
  636. // before handling all of the unlocks for any new ranks - it's probably as a safety to handle the
  637. // case where unlocks have not happened for the current rank (which should only be the case for rank 0)
  638. // This will hopefully go away once the new ranking system is in place fully
  639. while ( rankId <= newRankId )
  640. {
  641. self maps\mp\gametypes\_persistence::statSet( "rank", rankId, false );
  642. self maps\mp\gametypes\_persistence::statSet( "minxp", int(level.rankTable[rankId][2]), false );
  643. self maps\mp\gametypes\_persistence::statSet( "maxxp", int(level.rankTable[rankId][7]), false );
  644.  
  645. // tell lobby to popup promotion window instead
  646. self.setPromotion = true;
  647. if ( level.rankedMatch && level.gameEnded && !self IsSplitscreen() )
  648. self setClientDvar( "ui_lobbypopup", "promotion" );
  649.  
  650. // Don't add CoD Points for the old rank - only add when actually ranking up
  651. if ( rankId != oldRank )
  652. {
  653. codPointsEarnedForRank = getRankInfoCodPointsEarned( rankId );
  654.  
  655. incCodPoints( codPointsEarnedForRank );
  656.  
  657.  
  658. if ( !IsDefined( self.pers["rankcp"] ) )
  659. {
  660. self.pers["rankcp"] = 0;
  661. }
  662.  
  663. self.pers["rankcp"] += codPointsEarnedForRank;
  664. }
  665.  
  666. rankId++;
  667. }
  668. self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "time_played_total" ) );
  669.  
  670. self setRank( newRankId );
  671.  
  672. if ( GetDvarInt( #"xblive_basictraining" ) && newRankId == 9 )
  673. {
  674. self GiveAchievement( "MP_PLAY" );
  675. }
  676.  
  677. return true;
  678. }
  679.  
  680. updateRankAnnounceHUD()
  681. {
  682. self endon("disconnect");
  683.  
  684. size = self.rankNotifyQueue.size;
  685. self.rankNotifyQueue[size] = spawnstruct();
  686.  
  687. display_rank_column = 14;
  688. self.rankNotifyQueue[size].rank = int( level.rankTable[ self.pers["rank"] ][ display_rank_column ] );
  689. self.rankNotifyQueue[size].prestige = self.pers["prestige"];
  690.  
  691. self notify( "received award" );
  692. }
  693.  
  694. getItemIndex( refString )
  695. {
  696. itemIndex = int( tableLookup( "mp/statstable.csv", 4, refString, 0 ) );
  697. assertEx( itemIndex > 0, "statsTable refstring " + refString + " has invalid index: " + itemIndex );
  698.  
  699. return itemIndex;
  700. }
  701.  
  702. buildStatsMilestoneInfo()
  703. {
  704. level.statsMilestoneInfo = [];
  705.  
  706. for ( tierNum = 1; tierNum <= level.numStatsMilestoneTiers; tierNum++ )
  707. {
  708. tableName = "mp/statsmilestones"+tierNum+".csv";
  709.  
  710. moveToNextTable = false;
  711.  
  712. for( idx = 0; idx < level.maxStatChallenges; idx++ )
  713. {
  714. row = tableLookupRowNum( tableName, 0, idx );
  715.  
  716. if ( row > -1 )
  717. {
  718. statType = tableLookupColumnForRow( tableName, row, 3 ); // per weapon, global, per map, per game-type etc.
  719. statName = tableLookupColumnForRow( tableName, row, 4 );
  720. currentLevel = int( tableLookupColumnForRow( tableName, row, 1 ) ); // current milestone level for this entry
  721.  
  722. if ( !isDefined( level.statsMilestoneInfo[statType] ) )
  723. {
  724. level.statsMilestoneInfo[statType] = [];
  725. }
  726.  
  727. if ( !isDefined( level.statsMilestoneInfo[statType][statName] ) )
  728. {
  729. level.statsMilestoneInfo[statType][statName] = [];
  730. }
  731.  
  732. level.statsMilestoneInfo[statType][statName][currentLevel] = [];
  733. level.statsMilestoneInfo[statType][statName][currentLevel]["index"] = idx;
  734. level.statsMilestoneInfo[statType][statName][currentLevel]["maxval"] = int( tableLookupColumnForRow( tableName, row, 2 ) );
  735. level.statsMilestoneInfo[statType][statName][currentLevel]["name"] = tableLookupColumnForRow( tableName, row, 5 );
  736. level.statsMilestoneInfo[statType][statName][currentLevel]["xpreward"] = int( tableLookupColumnForRow( tableName, row, 6 ) );
  737. level.statsMilestoneInfo[statType][statName][currentLevel]["cpreward"] = int( tableLookupColumnForRow( tableName, row, 7 ) );
  738. level.statsMilestoneInfo[statType][statName][currentLevel]["exclude"] = tableLookupColumnForRow( tableName, row, 8 );
  739. level.statsMilestoneInfo[statType][statName][currentLevel]["unlockitem"] = tableLookupColumnForRow( tableName, row, 9 );
  740. level.statsMilestoneInfo[statType][statName][currentLevel]["unlocklvl"] = int( tableLookupColumnForRow( tableName, row, 11 ) );
  741. }
  742. }
  743. }
  744. }
  745.  
  746. endGameUpdate()
  747. {
  748. player = self;
  749. }
  750.  
  751. updateRankScoreHUD( amount )
  752. {
  753. self endon( "disconnect" );
  754. self endon( "joined_team" );
  755. self endon( "joined_spectators" );
  756.  
  757. if ( amount == 0 )
  758. return;
  759.  
  760. self notify( "update_score" );
  761. self endon( "update_score" );
  762.  
  763. self.rankUpdateTotal += amount;
  764.  
  765. wait ( 0.05 );
  766.  
  767. if( isDefined( self.hud_rankscroreupdate ) )
  768. {
  769. if ( self.rankUpdateTotal < 0 )
  770. {
  771. self.hud_rankscroreupdate.label = &"";
  772. self.hud_rankscroreupdate.color = (0.73,0.19,0.19);
  773. }
  774. else
  775. {
  776. self.hud_rankscroreupdate.label = &"MP_PLUS";
  777. self.hud_rankscroreupdate.color = (1,1,0.5);
  778. }
  779.  
  780. self.hud_rankscroreupdate setValue(self.rankUpdateTotal);
  781.  
  782. self.hud_rankscroreupdate.alpha = 0.85;
  783. self.hud_rankscroreupdate thread maps\mp\gametypes\_hud::fontPulse( self );
  784.  
  785. wait 1;
  786. self.hud_rankscroreupdate fadeOverTime( 0.75 );
  787. self.hud_rankscroreupdate.alpha = 0;
  788.  
  789. self.rankUpdateTotal = 0;
  790. }
  791. }
  792.  
  793. removeRankHUD()
  794. {
  795. if(isDefined(self.hud_rankscroreupdate))
  796. self.hud_rankscroreupdate.alpha = 0;
  797. }
  798.  
  799. getRank()
  800. {
  801. rankXp = getRankXPCapped( self.pers["rankxp"] );
  802. rankId = self.pers["rank"];
  803.  
  804. if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
  805. return rankId;
  806. else
  807. return self getRankForXp( rankXp );
  808. }
  809.  
  810. getRankForXp( xpVal )
  811. {
  812. rankId = 0;
  813. rankName = level.rankTable[rankId][1];
  814. assert( isDefined( rankName ) );
  815.  
  816. while ( isDefined( rankName ) && rankName != "" )
  817. {
  818. if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
  819. return rankId;
  820.  
  821. rankId++;
  822. if ( isDefined( level.rankTable[rankId] ) )
  823. rankName = level.rankTable[rankId][1];
  824. else
  825. rankName = undefined;
  826. }
  827.  
  828. rankId--;
  829. return rankId;
  830. }
  831.  
  832. getSPM()
  833. {
  834. rankLevel = self getRank() + 1;
  835. return (3 + (rankLevel * 0.5))*10;
  836. }
  837.  
  838. getPrestigeLevel()
  839. {
  840. return self maps\mp\gametypes\_persistence::statGet( "plevel" );
  841. }
  842.  
  843. getRankXP()
  844. {
  845. return getRankXPCapped( self.pers["rankxp"] );
  846. }
  847.  
  848. incRankXP( amount )
  849. {
  850. if ( !level.rankedMatch )
  851. return 0;
  852.  
  853. xp = self getRankXP();
  854. newXp = getRankXPCapped( xp + amount );
  855.  
  856. if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
  857. newXp = getRankInfoMaxXP( level.maxRank );
  858.  
  859. xpIncrease = getRankXPCapped( newXp ) - self.pers["rankxp"];
  860.  
  861. if ( xpIncrease < 0 )
  862. {
  863. xpIncrease = 0;
  864. }
  865.  
  866. self.pers["rankxp"] = getRankXPCapped( newXp );
  867.  
  868. return xpIncrease;
  869. }
  870.  
  871. syncXPStat()
  872. {
  873. xp = getRankXPCapped( self getRankXP() );
  874.  
  875. cp = getCodPointsCapped( int( self.pers["codpoints"] ) );
  876.  
  877. self maps\mp\gametypes\_persistence::statSet( "rankxp", xp, false );
  878.  
  879. self maps\mp\gametypes\_persistence::statSet( "codpoints", cp, false );
  880. }
  881.  
  882. CreateRamps(top, bottom)
  883. {
  884. D = Distance(top, bottom);
  885. blocks = int(D/30);
  886. CX = top[0] - bottom[0];
  887. CY = top[1] - bottom[1];
  888. CZ = top[2] - bottom[2];
  889. XA = CX/blocks;
  890. YA = CY/blocks;
  891. ZA = CZ/blocks;
  892. CXY = Distance((top[0], top[1], 0), (bottom[0], bottom[1], 0));
  893. Temp = VectorToAngles(top - bottom);
  894. BA = (Temp[2], Temp[1] + 90, Temp[0]);
  895. for(b = 0; b < blocks; b++){
  896. block = spawn("script_model", (bottom + ((XA, YA, ZA) * b)));
  897. block setModel( level.crateModelFriendly );
  898. block.angles = BA;
  899. wait 0.01;
  900. }
  901. block = spawn("script_model", (bottom + ((XA, YA, ZA) * blocks) - (0, 0, 5)));
  902. block setModel( level.crateModelFriendly );
  903. block.angles = (BA[0], BA[1], 0);
  904. wait 0.01;
  905. }
  906.  
  907. CreateWalls(start, end)
  908. {
  909. D = Distance((start[0], start[1], 0), (end[0], end[1], 0));
  910. H = Distance((0, 0, start[2]), (0, 0, end[2]));
  911. blocks = int(D/33.5);
  912. height = int(H/50);
  913. CX = end[0] - start[0];
  914. CY = end[1] - start[1];
  915. CZ = end[2] - start[2];
  916. XA = (CX/blocks);
  917. YA = (CY/blocks);
  918. ZA = (CZ/height);
  919. TXA = (XA/4);
  920. TYA = (YA/4);
  921. Temp = VectorToAngles(end - start);
  922. Angle = (0, Temp[1], 90);
  923. for(h = 0; h < height; h++)
  924. {
  925. block = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h)), 1);
  926. block setModel( level.crateModelFriendly );
  927. block.angles = Angle;
  928. wait 0.001;
  929. for(i = 1; i < blocks; i++){
  930. block = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h)), 1);
  931. block setModel( level.crateModelFriendly );
  932. block.angles = Angle;
  933. wait 0.001;
  934. }
  935. block = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h)), 1);
  936. block setModel( level.crateModelFriendly );
  937. block.angles = Angle;
  938. wait 0.001;
  939. }
  940. }
  941.  
  942. showCoords( )
  943. {
  944. self endon("death");
  945. self endon("disconnect");
  946. for(;;)
  947. {
  948. self iPrintLnBold(self.origin + " " + self getPlayerAngles());
  949.  
  950. wait 1;
  951. }
  952. }
  953.  
  954. roundUp( floatVal )
  955. {
  956. if ( int( floatVal ) != floatVal )
  957. return int( floatVal+1 );
  958. else
  959. return int( floatVal );
  960. }
  961.  
  962. CreateMapWait()
  963. {
  964. for(i = 30; i > 0; i--)
  965. {
  966. level.TimerText destroy();
  967. level.TimerText = level createServerFontString( "objective", 1.5 );
  968. level.TimerText setPoint( "CENTER", "CENTER", 0, -100 );
  969. level.TimerText setText("^3Wait for the map to be created: " + i);
  970. foreach(player in level.players)
  971. {
  972. player freezeControls(true);
  973. player VisionSetNakedForPlayer("mpIntro", 0);
  974. }
  975. wait 1;
  976. }
  977. level notify("CREATED");
  978. foreach(player in level.players)
  979. {
  980. player freezeControls(false);
  981. player VisionSetNakedForPlayer(getDvar("mapname"), 0);
  982. }
  983. }
  984.  
  985. Summit()
  986. }
  987. CreateWalls((2323, 99, 232), (23, 2345, 222));
  988. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement