Advertisement
Guest User

Untitled

a guest
Sep 29th, 2010
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.70 KB | None | 0 0
  1. #include maps\mp\_utility;
  2. #include maps\mp\gametypes\_hud_util;
  3. #include common_scripts\utility;
  4.  
  5. init()
  6. {
  7. /*
  8. level.lootColors = [];
  9. level.lootColors["epic"] = (0.63, 0.2, 0.7) * 1.2;
  10. level.lootColors["rare"] = (0, 0.43, 0.76) * 1.2;
  11. level.lootColors["common"] = (0.11, 1, 0) * 1.0;
  12. level.lootColors["none"] = (1, 1, 0.5);
  13. */
  14. /*
  15. level.lootColors["epic"] = (0.75, 1, 0.73) * 1.0;
  16. level.lootColors["rare"] = (0.75, 1, 0.73) * 1.0;
  17. level.lootColors["common"] = (0.75, 1, 0.73) * 1.0;
  18. level.lootColors["none"] = (1, 1, 0.5);
  19. */
  20.  
  21. precacheString( &"MP_DOLLAR" );
  22.  
  23. level._effect["money"] = loadfx ("props/cash_player_drop");
  24.  
  25. maps\mp\gametypes\_rank::registerScoreInfo( "gear", 1000 );
  26. maps\mp\gametypes\_rank::registerScoreInfo( "money", 1000 );
  27.  
  28. maps\mp\gametypes\_rank::registerScoreInfo( "common", 500 );
  29. maps\mp\gametypes\_rank::registerScoreInfo( "rare", 1000 );
  30. maps\mp\gametypes\_rank::registerScoreInfo( "epic", 2000 );
  31.  
  32. level.lootMins["epic"] = 90;
  33. level.lootMins["rare"] = 70;
  34. //level.lootMins["common"] = 95;
  35.  
  36. level.lootIndices["epic"] = 2;
  37. level.lootIndices["rare"] = 1;
  38. level.lootIndices["common"] = 0;
  39.  
  40. level.lootBaseChance = 0.05;
  41. level.lootIdealTime = (15*60);
  42.  
  43. /#
  44. thread updateLootDvars();
  45. #/
  46.  
  47. thread onPlayerConnect();
  48. }
  49.  
  50.  
  51. onPlayerConnect()
  52. {
  53. for ( ;; )
  54. {
  55. level waittill( "connected", player );
  56.  
  57. player.pers["money"] = player maps\mp\gametypes\_persistence::statGet( "money" );
  58. player.displayMoney = player.pers["money"];
  59. player.moneyUpdateTotal = 0;
  60.  
  61. player.timeSinceLastLoot = player maps\mp\gametypes\_persistence::statGet( "timeSinceLastLoot" );
  62.  
  63. player thread initLootDisplay();
  64. player thread onPlayerSpawned();
  65. player thread onGameEnded();
  66. }
  67. }
  68.  
  69.  
  70. onPlayerSpawned()
  71. {
  72. for ( ;; )
  73. {
  74. self waittill( "spawned_player" );
  75.  
  76. self thread trackLastLootTime();
  77. }
  78. }
  79.  
  80.  
  81. onGameEnded()
  82. {
  83. self endon ( "disconnect" );
  84.  
  85. level waittill ( "game_ended" );
  86.  
  87. self maps\mp\gametypes\_persistence::statSet( "timeSinceLastLoot", self.timeSinceLastLoot );
  88. }
  89.  
  90.  
  91. trackLastLootTime()
  92. {
  93. self endon ( "death" );
  94. self endon ( "disconnect" );
  95.  
  96. level endon ( "game_ended" );
  97.  
  98. for ( ;; )
  99. {
  100. wait ( 1.0 );
  101.  
  102. self.timeSinceLastLoot += 1;
  103. }
  104. }
  105.  
  106.  
  107. initLootDisplay()
  108. {
  109. self.totalMoney = createFontString( "bigfixed", 0.8 );
  110. self.totalMoney setPoint( "TOPRIGHT" );
  111. self.totalMoney setValue( self.pers["money"] );
  112. self.totalMoney.label = &"MP_DOLLAR";
  113. self.totalMoney.glowColor = (0.3, 0.8, 0.3);
  114. self.totalMoney.glowAlpha = 1;
  115. self.totalMoney.alpha = 0;
  116.  
  117. self.earnedMoney = createFontString( "bigfixed", 0.7 );
  118. self.earnedMoney setParent( self.totalMoney );
  119. self.earnedMoney setPoint( "TOPRIGHT", "BOTTOMRIGHT", 0, 10 );
  120. self.earnedMoney setValue( 0 );
  121. self.earnedMoney.label = &"MP_PLUS";
  122. self.earnedMoney.glowColor = (0.3, 0.8, 0.3);
  123. self.earnedMoney.glowAlpha = 0.1;
  124. self.earnedMoney.alpha = 0;
  125. }
  126.  
  127.  
  128. moMoney()
  129. {
  130. self endon ( "disconnect" );
  131.  
  132. for ( ;; )
  133. {
  134. wait ( randomFloatRange( 8.0, 10.0 ) );
  135.  
  136. self thread giveMoney( "asdf", randomIntRange( 100, 5000 ) );
  137. }
  138. }
  139.  
  140.  
  141. giveMoney( type, amount )
  142. {
  143. if ( !self rankingEnabled() )
  144. return;
  145.  
  146. self endon ( "disconnect" );
  147. self notify( "giveMoney" );
  148. self endon( "giveMoney" );
  149.  
  150. self.displayMoney = self.pers["money"];
  151. self.pers["money"] += amount;
  152. self maps\mp\gametypes\_persistence::statSet( "money", self.pers["money"] );
  153.  
  154. self.moneyUpdateTotal += amount;
  155.  
  156. self.totalMoney fadeOverTime( 0.5 );
  157. self.totalMoney.alpha = 1;
  158.  
  159. self.earnedMoney fadeOverTime( 0.5 );
  160. self.earnedMoney.alpha = 1;
  161.  
  162. self.earnedMoney setValue( self.moneyUpdateTotal );
  163.  
  164. wait ( 1.0 );
  165.  
  166. increment = max( int( self.moneyUpdateTotal / 30 ), 1 );
  167.  
  168. while ( self.moneyUpdateTotal > 0 )
  169. {
  170. addMoney = min( self.moneyUpdateTotal, increment );
  171. self.moneyUpdateTotal -= addMoney;
  172.  
  173. self.displayMoney += addMoney;
  174. self.totalMoney setValue( self.displayMoney );
  175. self.earnedMoney setValue( self.moneyUpdateTotal );
  176.  
  177. wait ( 0.05 );
  178. }
  179.  
  180. self.earnedMoney fadeOverTime( 1.0 );
  181. self.earnedMoney.alpha = 0;
  182.  
  183. wait ( 2.0 );
  184.  
  185. self.totalMoney fadeOverTime( 1.0 );
  186. self.totalMoney.alpha = 0;
  187. }
  188.  
  189.  
  190. updateLootDvars()
  191. {
  192. if ( getDvar( "scr_loot_epicMin" ) == "" )
  193. setDvar( "scr_loot_epicMin", level.lootMins["epic"] );
  194.  
  195. if ( getDvar( "scr_loot_rareMin" ) == "" )
  196. setDvar( "scr_loot_rareMin", level.lootMins["rare"] );
  197.  
  198. //if ( getDvar( "scr_loot_commonMin" ) == "" )
  199. // setDvar( "scr_loot_commonMin", level.lootMins["common"] );
  200.  
  201. if ( getDvar( "scr_loot_baseChance" ) == "" )
  202. setDvar( "scr_loot_baseChance", level.lootBaseChance );
  203.  
  204. if ( getDvar( "scr_loot_idealTime" ) == "" )
  205. setDvar( "scr_loot_idealTime", level.lootIdealTime );
  206.  
  207. /#
  208. if ( getDvar( "scr_forceloot" ) == "" )
  209. setDvar( "scr_forceloot", "0" );
  210. #/
  211.  
  212. for ( ;; )
  213. {
  214. /#
  215. if ( getDvar( "scr_forceloot" ) != "" && getDvar( "scr_forceloot" ) != "0" )
  216. {
  217. setDvar( "scr_loot_baseChance", 1 );
  218. }
  219. #/
  220.  
  221. level.lootMins["epic"] = getDvarFloat( "scr_loot_epicMin" );
  222. level.lootMins["rare"] = getDvarFloat( "scr_loot_rareMin" );
  223. //level.lootMins["common"] = getDvarFloat( "scr_loot_commonMin" );
  224.  
  225. level.lootBaseChance = getDvarFloat( "scr_loot_baseChance" );
  226. level.lootIdealTime = getDvarFloat( "scr_loot_idealTime" );
  227.  
  228. wait ( 1.0 );
  229. }
  230. }
  231.  
  232.  
  233. unlockedCaC()
  234. {
  235. return self isItemUnlocked( "cac" );
  236. }
  237.  
  238. gotLoot()
  239. {
  240. if ( !self rankingEnabled() )
  241. return false;
  242.  
  243. if ( !self unlockedCaC() )
  244. {
  245. returnfalse = true;
  246. /#
  247. if ( getDvar( "scr_forceloot" ) != "" && getDvar( "scr_forceloot" ) != "0" )
  248. returnfalse = false;
  249. #/
  250. if ( returnfalse )
  251. return false;
  252. }
  253.  
  254. baseChance = level.lootBaseChance;
  255. idealLootTime = level.lootIdealTime;
  256. maxLootChance = 0.50; // 50%
  257.  
  258. chanceMod = min( self.timeSinceLastLoot / idealLootTime, 1 );
  259. chanceMod = chanceMod * chanceMod;
  260.  
  261. lootChance = baseChance + (maxLootChance - baseChance) * chanceMod;
  262.  
  263. return randomFloat( 1 ) < lootChance;
  264. }
  265.  
  266.  
  267. getLootTier( lootRoll )
  268. {
  269. if ( lootRoll >= level.lootMins["epic"] )
  270. return "epic";
  271. else if ( lootRoll >= level.lootMins["rare"] )
  272. return "rare";
  273. else
  274. return "common";
  275. }
  276.  
  277. getLootName( tier )
  278. {
  279. if ( !isDefined( self.droppedLootNames ) )
  280. self.droppedLootNames = [];
  281.  
  282. for ( try = 0; try < 10; try++ )
  283. {
  284. lootName = self GetRandomLoot( tier );
  285. if ( !isDefined( lootName ) )
  286. return undefined;
  287.  
  288. for ( i = 0; i < self.droppedLootNames.size; i++ )
  289. {
  290. if ( lootName == self.droppedLootNames[i] )
  291. break;
  292. }
  293. if ( i < self.droppedLootNames.size )
  294. continue;
  295.  
  296. return lootName;
  297. }
  298.  
  299. return undefined;
  300. }
  301.  
  302.  
  303. giveLoot( victim )
  304. {
  305. if ( !gotLoot() )
  306. return false;
  307.  
  308. lootTier = getLootTier( randomFloat( 100.0 ) );
  309.  
  310. tierInt = level.lootIndices[lootTier];
  311. lootName = self getLootName( tierInt );
  312.  
  313. if ( !isDefined( lootName ) )
  314. return false;
  315.  
  316. self maps\mp\gametypes\_persistence::statSet( "timeSinceLastLoot", 0 );
  317. self.timeSinceLastLoot = 0;
  318.  
  319. thread maps\mp\_loot::playMoneyFx( victim, self );
  320.  
  321. if ( lootTier == "epic" )
  322. {
  323. self CreateLootMail( lootName );
  324. self thread showLootNotify( lootTier );
  325. }
  326. else
  327. {
  328. self thread dropLoot( lootTier, lootName, victim );
  329. }
  330.  
  331. return true;
  332. }
  333.  
  334.  
  335. showLootNotify( lootTier )
  336. {
  337. /*
  338. notifyData = spawnStruct();
  339.  
  340. if ( lootTier == "epic" )
  341. {
  342. notifyData.titleText = "Target of Opportunity!";
  343. notifyData.iconName = "skull_black_plain";
  344. notifyData.iconOverlay = "skull_crosshair_white";
  345. }
  346. else
  347. {
  348. notifyData.titleText = "You've got mail!";
  349. }
  350. //notifyData.sound = "loot_drop_" + lootTier;
  351. notifyData.sound = "mp_last_stand";
  352. notifyData.glowColor = (1, 0, 0);
  353. notifyData.duration = 3.0;
  354.  
  355. thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
  356. */
  357. }
  358.  
  359.  
  360. playMoneyFx( victim, attacker, sMeansOfDeath )
  361. {
  362. /*
  363. victim endon ( "disconnect" );
  364.  
  365. origin = victim getTagOrigin( "j_spine4" );
  366. victim.fxModel.origin = origin;
  367. wait ( 0.05 );
  368. */
  369. //playFxOnTag( level._effect["money"], victim.fxModel, "tag_origin" );
  370. //playFxOnTagForClients ( level._effect["money"], victim.fxModel, "tag_origin", attacker );
  371. }
  372.  
  373.  
  374. dropLoot( lootTier, lootName, dropEnt )
  375. {
  376. trace = playerPhysicsTrace( dropEnt.origin + (0,0,20), dropEnt.origin - (0,0,2000), false, dropEnt);
  377. angleTrace = bulletTrace( dropEnt.origin + (0,0,20), dropEnt.origin - (0,0,2000), false, dropEnt );
  378.  
  379. if ( !isDefined( trace ) )
  380. return;
  381.  
  382. println( "dropping loot" );
  383.  
  384. tempAngle = randomfloat( 360 );
  385.  
  386. dropOrigin = trace;
  387.  
  388. assert( isdefined( self.droppedLootNames ) );
  389. /#
  390. foreach ( droppedLootName in self.droppedLootNames )
  391. {
  392. assert( droppedLootName != lootName );
  393. }
  394. #/
  395. if ( lootName[0] != "$" )
  396. self.droppedLootNames[ self.droppedLootNames.size ] = lootName;
  397.  
  398. fxEnt = spawn( "script_model", dropOrigin );
  399. //fxEnt.angles = (-90,0,0);
  400.  
  401. lootIcon = newClientHudElem( self );
  402. lootIcon.x = dropOrigin[0];
  403. lootIcon.y = dropOrigin[1];
  404. lootIcon.z = dropOrigin[2];
  405. lootIcon.alpha = 1;
  406.  
  407. lootTrigger = spawn( "trigger_radius", dropOrigin, 0, 32, 128 );
  408. //lootTrigger.angles = (-90,0,0);
  409. lootTrigger.fxEnt = fxEnt;
  410. lootTrigger.icon = lootIcon;
  411. lootTrigger.owner = self;
  412.  
  413. lootTrigger thread lootPickupWaiter( lootTier, lootName );
  414. lootTrigger thread lootDeleteOnDisconnect();
  415. /#
  416. if ( getdvarint( "scr_lootdebug" ) )
  417. lootTrigger thread lootDebugPrint( lootTier, lootName );
  418. #/
  419.  
  420. lootTrigger endon ( "death" );
  421.  
  422. wait ( 0.05 );
  423.  
  424. self playLocalSound( "loot_drop_" + lootTier );
  425.  
  426. switch ( lootTier )
  427. {
  428. case "epic":
  429. case "rare":
  430. default:
  431. fxEnt setModel( "gamestation_box" );
  432. lootIcon setShader( "hud_overlay_random", 10, 10 );
  433. lootIcon setWaypoint( true, false );
  434. lootIcon.alpha = 0.81;
  435. //playFxOnTagForClients( level._effect["gears"], fxEnt, "tag_origin", self );
  436. break;
  437. }
  438. }
  439.  
  440. lootDebugPrint( lootTier, lootName )
  441. {
  442. self endon("death");
  443. while ( 1 )
  444. {
  445. print3d( self.origin, "(" + lootTier + ") " + lootName );
  446. wait .05;
  447. }
  448. }
  449.  
  450. lootPickupWaiter( lootTier, lootName )
  451. {
  452. self endon ( "death" );
  453. self.owner endon ( "disconnect" );
  454.  
  455. for ( ;; )
  456. {
  457. self waittill ( "trigger", player );
  458. if ( player != self.owner )
  459. continue;
  460.  
  461. //self.owner playLocalSound( "loot_pickup_" + lootTier ); // need better sound
  462. self.owner playLocalSound( "mp_last_stand" );
  463.  
  464. /*
  465. switch ( lootTier )
  466. {
  467. case "epic":
  468. streakName = getRandomKillstreak( 7 );
  469. self.owner thread [[level.onXPEvent]]( "gear" );
  470. break;
  471. case "rare":
  472. streakName = getRandomKillstreak( 5 );
  473. self.owner thread [[level.onXPEvent]]( "gear" );
  474. break;
  475. default:
  476. streakName = getRandomKillstreak( 3 );
  477. self.owner thread [[level.onXPEvent]]( "money" );
  478. break;
  479. }
  480.  
  481. self.owner thread randomKillstreakNotify( streakName );
  482. self.owner maps\mp\killstreaks\_killstreaks::giveKillstreak( streakName );
  483. */
  484. self.owner pickupLoot( lootTier, lootName );
  485.  
  486. self.fxEnt delete();
  487. self.icon destroy();
  488. self delete();
  489. }
  490. }
  491.  
  492. pickupLoot( lootTier, lootName )
  493. {
  494. self thread showLootNotify( lootTier );
  495. self thread [[level.onXPEvent]]( lootTier );
  496. self CreateLootMail( lootName );
  497.  
  498. if ( lootName[0] != "$" )
  499. {
  500. for ( i = 0; i < self.droppedLootNames.size; i++ )
  501. {
  502. if ( self.droppedLootNames[i] == lootName )
  503. {
  504. break;
  505. }
  506. }
  507. assert( i < self.droppedLootNames.size );
  508. for ( ; i < self.droppedLootNames.size; i++ )
  509. {
  510. self.droppedLootNames[i] = self.droppedLootNames[i + 1];
  511. }
  512. }
  513. }
  514.  
  515.  
  516. lootDeleteOnDisconnect()
  517. {
  518. self endon ( "death" );
  519.  
  520. self.owner waittill ( "disconnect" );
  521.  
  522. self.fxEnt delete();
  523. //self.icon destroy(); // code seems to take care of this automatically
  524. self delete();
  525. }
  526.  
  527.  
  528.  
  529. getRandomKillstreak( minKillCount )
  530. {
  531. killStreakNames = getArrayKeys( level.killstreakFuncs );
  532. killStreaks = [];
  533. foreach ( streakName in killStreakNames )
  534. {
  535. if ( maps\mp\killstreaks\_killstreaks::getStreakCost( streakName ) < minKillCount )
  536. continue;
  537.  
  538. killStreaks[killStreaks.size] = streakName;
  539. }
  540.  
  541. return killStreaks[randomInt( killStreaks.size )];
  542. }
  543.  
  544.  
  545.  
  546. randomKillstreakNotify( streakName )
  547. {
  548. self endon("disconnect");
  549.  
  550. notifyData = spawnStruct();
  551. notifyData.titleText = "Killstreak In a Box!";
  552. notifyData.notifyText = maps\mp\killstreaks\_killstreaks::getKillstreakHint( streakName );
  553. notifyData.textIsString = true;
  554. notifyData.sound = maps\mp\killstreaks\_killstreaks::getKillstreakSound( streakName );
  555. notifyData.leaderSound = streakName;
  556. notifyData.glowColor = (1, 0.76, 0.35);
  557. notifyData.textGlowColor = (1, 1, 0.5);
  558.  
  559. self maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
  560. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement