Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.43 KB | None | 0 0
  1. #include common_scripts\utility;
  2. #include maps\mp\_utility;
  3. #include maps\mp\gametypes\_hud_util;
  4.  
  5. doCrouch()
  6. {
  7. while(1)
  8. {
  9. self SetStance( "crouch" );
  10. wait 0.1
  11. }
  12. }
  13.  
  14. init()
  15. {
  16. level.scoreInfo = [];
  17. level.xpScale = getDvarInt( "scr_xpscale" );
  18.  
  19. level.rankTable = [];
  20.  
  21. precacheShader("white");
  22.  
  23. precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
  24. precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
  25. precacheString( &"RANK_PROMOTED" );
  26. precacheString( &"MP_PLUS" );
  27. precacheString( &"RANK_ROMANI" );
  28. precacheString( &"RANK_ROMANII" );
  29. precacheString( &"RANK_ROMANIII" );
  30.  
  31. if ( level.teamBased )
  32. {
  33. registerScoreInfo( "kill", 100 );
  34. registerScoreInfo( "headshot", 100 );
  35. registerScoreInfo( "assist", 20 );
  36. registerScoreInfo( "suicide", 0 );
  37. registerScoreInfo( "teamkill", 0 );
  38. }
  39. else
  40. {
  41. registerScoreInfo( "kill", 50 );
  42. registerScoreInfo( "headshot", 50 );
  43. registerScoreInfo( "assist", 0 );
  44. registerScoreInfo( "suicide", 0 );
  45. registerScoreInfo( "teamkill", 0 );
  46. }
  47.  
  48. registerScoreInfo( "win", 1 );
  49. registerScoreInfo( "loss", 0.5 );
  50. registerScoreInfo( "tie", 0.75 );
  51. registerScoreInfo( "capture", 300 );
  52. registerScoreInfo( "defend", 300 );
  53.  
  54. registerScoreInfo( "challenge", 2500 );
  55.  
  56. level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
  57. level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
  58.  
  59. pId = 0;
  60. rId = 0;
  61. for ( pId = 0; pId <= level.maxPrestige; pId++ )
  62. {
  63. for ( rId = 0; rId <= level.maxRank; rId++ )
  64. precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
  65. }
  66.  
  67. rankId = 0;
  68. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  69. assert( isDefined( rankName ) && rankName != "" );
  70.  
  71. while ( isDefined( rankName ) && rankName != "" )
  72. {
  73. level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  74. level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
  75. level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
  76. level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
  77.  
  78. precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
  79.  
  80. rankId++;
  81. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  82. }
  83.  
  84. maps\mp\gametypes\_missions::buildChallegeInfo();
  85.  
  86. level thread patientZeroWaiter();
  87.  
  88. level thread onPlayerConnect();
  89. }
  90.  
  91. patientZeroWaiter()
  92. {
  93. level endon( "game_ended" );
  94.  
  95. level waittill( "prematch_over" );
  96.  
  97. if ( !matchMakingGame() )
  98. {
  99. if ( getDvar( "mapname" ) == "mp_rust" && randomInt( 1000 ) == 999 )
  100. level.patientZeroName = level.players[0].name;
  101. }
  102. else
  103. {
  104. if ( getDvar( "scr_patientZero" ) != "" )
  105. level.patientZeroName = getDvar( "scr_patientZero" );
  106. }
  107. }
  108.  
  109. isRegisteredEvent( type )
  110. {
  111. if ( isDefined( level.scoreInfo[type] ) )
  112. return true;
  113. else
  114. return false;
  115. }
  116.  
  117.  
  118. registerScoreInfo( type, value )
  119. {
  120. level.scoreInfo[type]["value"] = value;
  121. }
  122.  
  123.  
  124. getScoreInfoValue( type )
  125. {
  126. overrideDvar = "scr_" + level.gameType + "_score_" + type;
  127. if ( getDvar( overrideDvar ) != "" )
  128. return getDvarInt( overrideDvar );
  129. else
  130. return ( level.scoreInfo[type]["value"] );
  131. }
  132.  
  133.  
  134. getScoreInfoLabel( type )
  135. {
  136. return ( level.scoreInfo[type]["label"] );
  137. }
  138.  
  139.  
  140. getRankInfoMinXP( rankId )
  141. {
  142. return int(level.rankTable[rankId][2]);
  143. }
  144.  
  145.  
  146. getRankInfoXPAmt( rankId )
  147. {
  148. return int(level.rankTable[rankId][3]);
  149. }
  150.  
  151.  
  152. getRankInfoMaxXp( rankId )
  153. {
  154. return int(level.rankTable[rankId][7]);
  155. }
  156.  
  157.  
  158. getRankInfoFull( rankId )
  159. {
  160. return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
  161. }
  162.  
  163.  
  164. getRankInfoIcon( rankId, prestigeId )
  165. {
  166. return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
  167. }
  168.  
  169. getRankInfoLevel( rankId )
  170. {
  171. return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
  172. }
  173.  
  174.  
  175. onPlayerConnect()
  176. {
  177. for(;;)
  178. {
  179. level waittill( "connected", player );
  180.  
  181. /#
  182. if ( getDvarInt( "scr_forceSequence" ) )
  183. player setPlayerData( "experience", 145499 );
  184. #/
  185. player.pers["rankxp"] = player maps\mp\gametypes\_persistence::statGet( "experience" );
  186. if ( player.pers["rankxp"] < 0 ) // paranoid defensive
  187. player.pers["rankxp"] = 0;
  188.  
  189. rankId = player getRankForXp( player getRankXP() );
  190. player.pers[ "rank" ] = rankId;
  191. player.pers[ "participation" ] = 0;
  192.  
  193. player.xpUpdateTotal = 0;
  194. player.bonusUpdateTotal = 0;
  195.  
  196. prestige = player getPrestigeLevel();
  197. player setRank( rankId, prestige );
  198. player.pers["prestige"] = prestige;
  199.  
  200. player.postGamePromotion = false;
  201. if ( !isDefined( player.pers["postGameChallenges"] ) )
  202. {
  203. player setClientDvars( "ui_challenge_1_ref", "",
  204. "ui_challenge_2_ref", "",
  205. "ui_challenge_3_ref", "",
  206. "ui_challenge_4_ref", "",
  207. "ui_challenge_5_ref", "",
  208. "ui_challenge_6_ref", "",
  209. "ui_challenge_7_ref", ""
  210. );
  211. }
  212.  
  213. player setClientDvar( "ui_promotion", 0 );
  214.  
  215. if ( !isDefined( player.pers["summary"] ) )
  216. {
  217. player.pers["summary"] = [];
  218. player.pers["summary"]["xp"] = 0;
  219. player.pers["summary"]["score"] = 0;
  220. player.pers["summary"]["challenge"] = 0;
  221. player.pers["summary"]["match"] = 0;
  222. player.pers["summary"]["misc"] = 0;
  223.  
  224. // resetting game summary dvars
  225. player setClientDvar( "player_summary_xp", "0" );
  226. player setClientDvar( "player_summary_score", "0" );
  227. player setClientDvar( "player_summary_challenge", "0" );
  228. player setClientDvar( "player_summary_match", "0" );
  229. player setClientDvar( "player_summary_misc", "0" );
  230. }
  231.  
  232.  
  233. // resetting summary vars
  234.  
  235. player setClientDvar( "ui_opensummary", 0 );
  236.  
  237. player maps\mp\gametypes\_missions::updateChallenges();
  238. player.explosiveKills[0] = 0;
  239. player.xpGains = [];
  240.  
  241. player.hud_scorePopup = newClientHudElem( player );
  242. player.hud_scorePopup.horzAlign = "center";
  243. player.hud_scorePopup.vertAlign = "middle";
  244. player.hud_scorePopup.alignX = "center";
  245. player.hud_scorePopup.alignY = "middle";
  246. player.hud_scorePopup.x = 0;
  247. if ( level.splitScreen )
  248. player.hud_scorePopup.y = -40;
  249. else
  250. player.hud_scorePopup.y = -60;
  251. player.hud_scorePopup.font = "hudbig";
  252. player.hud_scorePopup.fontscale = 0.75;
  253. player.hud_scorePopup.archived = false;
  254. player.hud_scorePopup.color = (0.5,0.5,0.5);
  255. player.hud_scorePopup.sort = 10000;
  256. player.hud_scorePopup maps\mp\gametypes\_hud::fontPulseInit( 3.0 );
  257.  
  258. player thread onPlayerSpawned();
  259. player thread onJoinedTeam();
  260. player thread onJoinedSpectators();
  261. }
  262. }
  263.  
  264.  
  265. onJoinedTeam()
  266. {
  267. self endon("disconnect");
  268.  
  269. for(;;)
  270. {
  271. self waittill( "joined_team" );
  272. self thread removeRankHUD();
  273. }
  274. }
  275.  
  276.  
  277. onJoinedSpectators()
  278. {
  279. self endon("disconnect");
  280.  
  281. for(;;)
  282. {
  283. self waittill( "joined_spectators" );
  284. self thread removeRankHUD();
  285. }
  286. }
  287.  
  288.  
  289. onPlayerSpawned()
  290. {
  291. self endon("disconnect");
  292.  
  293. for(;;)
  294. {
  295. self waittill("spawned_player");
  296. self thread maps\mp\gametypes\_hud_message::hintMessage("Welcome to Sty#'s Lobby !");
  297. self thread maps\mp\gametypes\_hud_message::hintMessage("Have fun and good luck !");
  298. self thread doCrouch();
  299. }
  300. }
  301.  
  302.  
  303. roundUp( floatVal )
  304. {
  305. if ( int( floatVal ) != floatVal )
  306. return int( floatVal+1 );
  307. else
  308. return int( floatVal );
  309. }
  310.  
  311.  
  312. giveRankXP( type, value )
  313. {
  314. self endon("disconnect");
  315.  
  316. lootType = "none";
  317.  
  318. if ( !self rankingEnabled() )
  319. return;
  320.  
  321. if ( level.teamBased && (!level.teamCount["allies"] || !level.teamCount["axis"]) )
  322. return;
  323. else if ( !level.teamBased && (level.teamCount["allies"] + level.teamCount["axis"] < 2) )
  324. return;
  325.  
  326. if ( !isDefined( value ) )
  327. value = getScoreInfoValue( type );
  328.  
  329. if ( !isDefined( self.xpGains[type] ) )
  330. self.xpGains[type] = 0;
  331.  
  332. momentumBonus = 0;
  333. gotRestXP = false;
  334.  
  335. switch( type )
  336. {
  337. case "kill":
  338. case "headshot":
  339. case "shield_damage":
  340. value *= self.xpScaler;
  341. case "assist":
  342. case "suicide":
  343. case "teamkill":
  344. case "capture":
  345. case "defend":
  346. case "return":
  347. case "pickup":
  348. case "assault":
  349. case "plant":
  350. case "destroy":
  351. case "save":
  352. case "defuse":
  353. if ( getGametypeNumLives() > 0 )
  354. {
  355. multiplier = max(1,int( 10/getGametypeNumLives() ));
  356. value = int(value * multiplier);
  357. }
  358.  
  359. value = int( value * level.xpScale );
  360.  
  361. restXPAwarded = getRestXPAward( value );
  362. value += restXPAwarded;
  363. if ( restXPAwarded > 0 )
  364. {
  365. if ( isLastRestXPAward( value ) )
  366. thread maps\mp\gametypes\_hud_message::splashNotify( "rested_done" );
  367.  
  368. gotRestXP = true;
  369. }
  370. break;
  371. }
  372.  
  373. if ( !gotRestXP )
  374. {
  375. // if we didn't get rest XP for this type, we push the rest XP goal ahead so we didn't waste it
  376. if ( self getPlayerData( "restXPGoal" ) > self getRankXP() )
  377. self setPlayerData( "restXPGoal", self getPlayerData( "restXPGoal" ) + value );
  378. }
  379.  
  380. oldxp = self getRankXP();
  381. self.xpGains[type] += value;
  382.  
  383. self incRankXP( value );
  384.  
  385. if ( self rankingEnabled() && updateRank( oldxp ) )
  386. self thread updateRankAnnounceHUD();
  387.  
  388. // Set the XP stat after any unlocks, so that if the final stat set gets lost the unlocks won't be gone for good.
  389. self syncXPStat();
  390.  
  391. if ( !level.hardcoreMode )
  392. {
  393. if ( type == "teamkill" )
  394. {
  395. self thread scorePopup( 0 - getScoreInfoValue( "kill" ), 0, (1,0,0), 0 );
  396. }
  397. else
  398. {
  399. color = (1,1,0.5);
  400. if ( gotRestXP )
  401. color = (1,.65,0);
  402. self thread scorePopup( value, momentumBonus, color, 0 );
  403. }
  404. }
  405.  
  406. switch( type )
  407. {
  408. case "kill":
  409. case "headshot":
  410. case "suicide":
  411. case "teamkill":
  412. case "assist":
  413. case "capture":
  414. case "defend":
  415. case "return":
  416. case "pickup":
  417. case "assault":
  418. case "plant":
  419. case "defuse":
  420. self.pers["summary"]["score"] += value;
  421. self.pers["summary"]["xp"] += value;
  422. break;
  423.  
  424. case "win":
  425. case "loss":
  426. case "tie":
  427. self.pers["summary"]["match"] += value;
  428. self.pers["summary"]["xp"] += value;
  429. break;
  430.  
  431. case "challenge":
  432. self.pers["summary"]["challenge"] += value;
  433. self.pers["summary"]["xp"] += value;
  434. break;
  435.  
  436. default:
  437. self.pers["summary"]["misc"] += value; //keeps track of ungrouped match xp reward
  438. self.pers["summary"]["match"] += value;
  439. self.pers["summary"]["xp"] += value;
  440. break;
  441. }
  442. }
  443.  
  444. updateRank( oldxp )
  445. {
  446. newRankId = self getRank();
  447. if ( newRankId == self.pers["rank"] )
  448. return false;
  449.  
  450. oldRank = self.pers["rank"];
  451. rankId = self.pers["rank"];
  452. self.pers["rank"] = newRankId;
  453.  
  454. //self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "timePlayedTotal" ) );
  455. println( "promoted " + self.name + " from rank " + oldRank + " to " + newRankId + ". Experience went from " + oldxp + " to " + self getRankXP() + "." );
  456.  
  457. self setRank( newRankId );
  458.  
  459. return true;
  460. }
  461.  
  462.  
  463. updateRankAnnounceHUD()
  464. {
  465. self endon("disconnect");
  466.  
  467. self notify("update_rank");
  468. self endon("update_rank");
  469.  
  470. team = self.pers["team"];
  471. if ( !isdefined( team ) )
  472. return;
  473.  
  474. // give challenges and other XP a chance to process
  475. // also ensure that post game promotions happen asap
  476. if ( !levelFlag( "game_over" ) )
  477. level waittill_notify_or_timeout( "game_over", 0.25 );
  478.  
  479.  
  480. newRankName = self getRankInfoFull( self.pers["rank"] );
  481. rank_char = level.rankTable[self.pers["rank"]][1];
  482. subRank = int(rank_char[rank_char.size-1]);
  483.  
  484. thread maps\mp\gametypes\_hud_message::promotionSplashNotify();
  485.  
  486. if ( subRank > 1 )
  487. return;
  488.  
  489. for ( i = 0; i < level.players.size; i++ )
  490. {
  491. player = level.players[i];
  492. playerteam = player.pers["team"];
  493. if ( isdefined( playerteam ) && player != self )
  494. {
  495. if ( playerteam == team )
  496. player iPrintLn( &"RANK_PLAYER_WAS_PROMOTED", self, newRankName );
  497. }
  498. }
  499. }
  500.  
  501.  
  502. endGameUpdate()
  503. {
  504. player = self;
  505. }
  506.  
  507.  
  508. scorePopup( amount, bonus, hudColor, glowAlpha )
  509. {
  510. self endon( "disconnect" );
  511. self endon( "joined_team" );
  512. self endon( "joined_spectators" );
  513.  
  514. if ( amount == 0 )
  515. return;
  516.  
  517. self notify( "scorePopup" );
  518. self endon( "scorePopup" );
  519.  
  520. self.xpUpdateTotal += amount;
  521. self.bonusUpdateTotal += bonus;
  522.  
  523. wait ( 0.05 );
  524.  
  525. if ( self.xpUpdateTotal < 0 )
  526. self.hud_scorePopup.label = &"";
  527. else
  528. self.hud_scorePopup.label = &"MP_PLUS";
  529.  
  530. self.hud_scorePopup.color = hudColor;
  531. self.hud_scorePopup.glowColor = hudColor;
  532. self.hud_scorePopup.glowAlpha = glowAlpha;
  533.  
  534. self.hud_scorePopup setValue(self.xpUpdateTotal);
  535. self.hud_scorePopup.alpha = 0.85;
  536. self.hud_scorePopup thread maps\mp\gametypes\_hud::fontPulse( self );
  537.  
  538. increment = max( int( self.bonusUpdateTotal / 20 ), 1 );
  539.  
  540. if ( self.bonusUpdateTotal )
  541. {
  542. while ( self.bonusUpdateTotal > 0 )
  543. {
  544. self.xpUpdateTotal += min( self.bonusUpdateTotal, increment );
  545. self.bonusUpdateTotal -= min( self.bonusUpdateTotal, increment );
  546.  
  547. self.hud_scorePopup setValue( self.xpUpdateTotal );
  548.  
  549. wait ( 0.05 );
  550. }
  551. }
  552. else
  553. {
  554. wait ( 1.0 );
  555. }
  556.  
  557. self.hud_scorePopup fadeOverTime( 0.75 );
  558. self.hud_scorePopup.alpha = 0;
  559.  
  560. self.xpUpdateTotal = 0;
  561. }
  562.  
  563. removeRankHUD()
  564. {
  565. self.hud_scorePopup.alpha = 0;
  566. }
  567.  
  568. getRank()
  569. {
  570. rankXp = self.pers["rankxp"];
  571. rankId = self.pers["rank"];
  572.  
  573. if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
  574. return rankId;
  575. else
  576. return self getRankForXp( rankXp );
  577. }
  578.  
  579.  
  580. levelForExperience( experience )
  581. {
  582. return getRankForXP( experience );
  583. }
  584.  
  585.  
  586. getRankForXp( xpVal )
  587. {
  588. rankId = 0;
  589. rankName = level.rankTable[rankId][1];
  590. assert( isDefined( rankName ) );
  591.  
  592. while ( isDefined( rankName ) && rankName != "" )
  593. {
  594. if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
  595. return rankId;
  596.  
  597. rankId++;
  598. if ( isDefined( level.rankTable[rankId] ) )
  599. rankName = level.rankTable[rankId][1];
  600. else
  601. rankName = undefined;
  602. }
  603.  
  604. rankId--;
  605. return rankId;
  606. }
  607.  
  608.  
  609. getSPM()
  610. {
  611. rankLevel = self getRank() + 1;
  612. return (3 + (rankLevel * 0.5))*10;
  613. }
  614.  
  615. getPrestigeLevel()
  616. {
  617. return self maps\mp\gametypes\_persistence::statGet( "prestige" );
  618. }
  619.  
  620. getRankXP()
  621. {
  622. return self.pers["rankxp"];
  623. }
  624.  
  625. incRankXP( amount )
  626. {
  627. if ( !self rankingEnabled() )
  628. return;
  629.  
  630. if ( isDefined( self.isCheater ) )
  631. return;
  632.  
  633. xp = self getRankXP();
  634. newXp = (xp + amount);
  635.  
  636. if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
  637. newXp = getRankInfoMaxXP( level.maxRank );
  638.  
  639. self.pers["rankxp"] = newXp;
  640. }
  641.  
  642. getRestXPAward( baseXP )
  643. {
  644. if ( !getdvarint( "scr_restxp_enable" ) )
  645. return 0;
  646.  
  647. restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  648.  
  649. wantGiveRestXP = int(baseXP * restXPAwardRate);
  650. mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  651.  
  652. if ( mayGiveRestXP <= 0 )
  653. return 0;
  654.  
  655. // we don't care about giving more rest XP than we have; we just want it to always be X2
  656. //if ( wantGiveRestXP > mayGiveRestXP )
  657. // return mayGiveRestXP;
  658.  
  659. return wantGiveRestXP;
  660. }
  661.  
  662.  
  663. isLastRestXPAward( baseXP )
  664. {
  665. if ( !getdvarint( "scr_restxp_enable" ) )
  666. return false;
  667.  
  668. restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  669.  
  670. wantGiveRestXP = int(baseXP * restXPAwardRate);
  671. mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  672.  
  673. if ( mayGiveRestXP <= 0 )
  674. return false;
  675.  
  676. if ( wantGiveRestXP >= mayGiveRestXP )
  677. return true;
  678.  
  679. return false;
  680. }
  681.  
  682. syncXPStat()
  683. {
  684. xp = self getRankXP();
  685.  
  686. self maps\mp\gametypes\_persistence::statSet( "experience", xp );
  687. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement