Advertisement
Guest User

Deagle mod

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