JoBoz

Untitled

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