Advertisement
Guest User

Chicken Mod

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