Advertisement
Guest User

Dog Wars!

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