JoBoz

Untitled

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