JoBoz

Untitled

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