Advertisement
Guest User

jugg - Notesblok

a guest
Nov 19th, 2011
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.89 KB | None | 0 0
  1. #include common_scripts\utility;
  2. #include maps\mp\_utility;
  3. #include maps\mp\gametypes\_hud_util;
  4.  
  5. // jugg is allies
  6. // everyone else is axis
  7.  
  8. main()
  9. {
  10. maps\mp\gametypes\_globallogic::init();
  11. maps\mp\gametypes\_callbacksetup::SetupCallbacks();
  12. maps\mp\gametypes\_globallogic::SetupCallbacks();
  13.  
  14. if ( isUsingMatchRulesData() )
  15. {
  16. level.initializeMatchRules = ::initializeMatchRules;
  17. [[level.initializeMatchRules]]();
  18. level thread reInitializeMatchRulesOnMigration();
  19. }
  20. else
  21. {
  22. registerTimeLimitDvar( level.gameType, 10 );
  23. registerRoundLimitDvar( level.gameType, 1 );
  24. registerScoreLimitDvar( level.gameType, 10 );
  25. registerWinLimitDvar( level.gameType, 1 );
  26. registerNumLivesDvar( level.gameType, 0 );
  27. registerHalfTimeDvar( level.gameType, 0 );
  28.  
  29. level.matchRules_respawnNewJugg = false;
  30. level.matchRules_showJuggRadarIcon = true;
  31. level.matchRules_showJuggWorldIcon = false;
  32. level.matchRules_damageMultiplier = 0;
  33. level.matchRules_vampirism = 0;
  34. }
  35.  
  36. setSpecialLoadouts();
  37.  
  38. level.teamBased = true;
  39. level.doPrematch = true;
  40. level.onPrecacheGameType = ::onPrecacheGameType;
  41. level.onStartGameType = ::onStartGameType;
  42. level.getSpawnPoint = ::getSpawnPoint;
  43. level.onSpawnPlayer = ::onSpawnPlayer;
  44. level.onPlayerKilled = ::onPlayerKilled;
  45. level.onTimeLimit = ::onTimeLimit;
  46.  
  47. if ( level.matchRules_damageMultiplier || level.matchRules_vampirism )
  48. level.modifyPlayerDamage = maps\mp\gametypes\_damage::gamemodeModifyPlayerDamage;
  49. }
  50.  
  51.  
  52. initializeMatchRules()
  53. {
  54. // set common values
  55. setCommonRulesFromMatchRulesData();
  56.  
  57. // set everything else (private match options, default .cfg file values, and what normally is registered in the 'else' below)
  58. level.matchRules_respawnNewJugg = GetMatchRulesData( "juggData", "respawnNewJugg" );
  59. level.matchRules_showJuggRadarIcon = GetMatchRulesData( "juggData", "showJuggRadarIcon" );
  60. level.matchRules_showJuggWorldIcon = GetMatchRulesData( "juggData", "showJuggWorldIcon" );
  61.  
  62. SetDynamicDvar( "scr_jugg_roundswitch", 0 );
  63. registerRoundSwitchDvar( "jugg", 0, 0, 9 );
  64. SetDynamicDvar( "scr_jugg_roundlimit", 1 );
  65. registerRoundLimitDvar( "jugg", 1 );
  66. SetDynamicDvar( "scr_jugg_winlimit", 1 );
  67. registerWinLimitDvar( "jugg", 1 );
  68. SetDynamicDvar( "scr_jugg_halftime", 0 );
  69. registerHalfTimeDvar( "jugg", 0 );
  70.  
  71. SetDynamicDvar( "scr_jugg_promode", 0 );
  72. }
  73.  
  74.  
  75. onPrecacheGameType()
  76. {
  77. precacheString( &"MP_JUGG_NEXT_JUGG_IN" );
  78.  
  79. precacheShader( "waypoint_kill" );
  80. }
  81.  
  82.  
  83. onStartGameType()
  84. {
  85. setClientNameMode("auto_change");
  86.  
  87. setObjectiveText( "allies", &"OBJECTIVES_JUGG" );
  88. setObjectiveText( "axis", &"OBJECTIVES_JUGG" );
  89.  
  90. if ( level.splitscreen )
  91. {
  92. setObjectiveScoreText( "allies", &"OBJECTIVES_JUGG" );
  93. setObjectiveScoreText( "axis", &"OBJECTIVES_JUGG" );
  94. }
  95. else
  96. {
  97. setObjectiveScoreText( "allies", &"OBJECTIVES_JUGG_SCORE" );
  98. setObjectiveScoreText( "axis", &"OBJECTIVES_JUGG_SCORE" );
  99. }
  100. setObjectiveHintText( "allies", &"OBJECTIVES_JUGG_HINT" );
  101. setObjectiveHintText( "axis", &"OBJECTIVES_JUGG_HINT" );
  102.  
  103. level.spawnMins = ( 0, 0, 0 );
  104. level.spawnMaxs = ( 0, 0, 0 );
  105. maps\mp\gametypes\_spawnlogic::addSpawnPoints( "allies", "mp_tdm_spawn" );
  106. maps\mp\gametypes\_spawnlogic::addSpawnPoints( "axis", "mp_tdm_spawn" );
  107. level.mapCenter = maps\mp\gametypes\_spawnlogic::findBoxCenter( level.spawnMins, level.spawnMaxs );
  108. setMapCenter( level.mapCenter );
  109.  
  110. maps\mp\gametypes\_rank::registerScoreInfo( "got_juggernaut", 250 );
  111. maps\mp\gametypes\_rank::registerScoreInfo( "kill_as_juggernaut", 50 );
  112.  
  113. allowed = [];
  114. maps\mp\gametypes\_gameobjects::main(allowed);
  115.  
  116. level.QuickMessageToAll = true;
  117. level.blockWeaponDrops = true;
  118.  
  119. level.jugg_juggernaut = undefined;
  120. level.jugg_choosingJugg = false;
  121.  
  122. level thread onPlayerConnect();
  123.  
  124. level.jugg_timerDisplay = createServerTimer( "objective", 1.4 );
  125. level.jugg_timerDisplay setPoint( "TOPLEFT", "TOPLEFT", 115, 5 );
  126. level.jugg_timerDisplay.label = &"MP_JUGG_NEXT_JUGG_IN";
  127. level.jugg_timerDisplay.alpha = 0;
  128. level.jugg_timerDisplay.archived = false;
  129. level.jugg_timerDisplay.hideWhenInMenu = true;
  130. thread hideTimerDisplayOnGameEnd( level.jugg_timerDisplay );
  131.  
  132. level.killstreakRewards = false;
  133. }
  134.  
  135.  
  136. chooseInitialJugg()
  137. {
  138. level endon( "game_ended" );
  139.  
  140. gameFlagWait( "prematch_done" );
  141.  
  142. level.jugg_timerDisplay.label = &"MP_JUGG_NEXT_JUGG_IN";
  143. level.jugg_timerDisplay setTimer( 8 );
  144. level.jugg_timerDisplay.alpha = 1;
  145.  
  146. maps\mp\gametypes\_hostmigration::waitLongDurationWithHostMigrationPause( 8.0 );
  147.  
  148. level.jugg_timerDisplay.alpha = 0;
  149.  
  150. resetJugg( level.players[ randomInt( level.players.size ) ] );
  151. }
  152.  
  153.  
  154. onPlayerConnect()
  155. {
  156. for ( ;; )
  157. {
  158. level waittill( "connected", player );
  159.  
  160. player.jugg_juggScore = 0;
  161. player.jugg_firstSpawn = true;
  162. player thread onDisconnect();
  163. }
  164. }
  165.  
  166.  
  167. onSpawnPlayer()
  168. {
  169. if ( !level.jugg_choosingJugg )
  170. {
  171. level.jugg_choosingJugg = true;
  172. level thread chooseInitialJugg();
  173. }
  174.  
  175. self.pers["gamemodeLoadout"] = level.jugg_loadouts[self.pers["team"]];
  176.  
  177. level notify ( "spawned_player" );
  178. }
  179.  
  180.  
  181. getSpawnPoint()
  182. {
  183. if ( self.jugg_firstSpawn )
  184. {
  185. self.jugg_firstSpawn = false;
  186.  
  187. // everyone is a gamemode class in jugg, no class selection
  188. self.pers["class"] = "gamemode";
  189. self.pers["lastClass"] = "";
  190. self.class = self.pers["class"];
  191. self.lastClass = self.pers["lastClass"];
  192.  
  193. // everyone starts non jugg
  194. self maps\mp\gametypes\_menus::addToTeam( "axis", true );
  195. }
  196.  
  197. if ( level.inGracePeriod )
  198. {
  199. spawnPoints = maps\mp\gametypes\_spawnlogic::getSpawnpointArray( "mp_tdm_spawn" );
  200. spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_Random( spawnPoints );
  201. }
  202. else
  203. {
  204. spawnPoints = maps\mp\gametypes\_spawnlogic::getTeamSpawnPoints( self.pers["team"] );
  205. spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_NearTeam( spawnPoints );
  206. }
  207.  
  208. return spawnPoint;
  209. }
  210.  
  211.  
  212. onPlayerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration, lifeId )
  213. {
  214. if ( isDefined( attacker ) && isPlayer( attacker ) && attacker != self )
  215. {
  216. // victim is juggernaut
  217. if ( isDefined( level.jugg_juggernaut ) && level.jugg_juggernaut == self )
  218. {
  219. if ( level.matchRules_showJuggWorldIcon )
  220. self.jugg_headIcon destroy();
  221.  
  222. resetJugg( attacker, self );
  223. }
  224. // attacker is juggernaut
  225. else if ( isDefined( level.jugg_juggernaut ) && level.jugg_juggernaut == attacker )
  226. {
  227. attacker.jugg_juggScore ++;
  228. attacker maps\mp\gametypes\_gamescore::giveTeamScoreForObjective( attacker.pers["team"], 1 );
  229. attacker thread maps\mp\gametypes\_rank::xpEventPopup( &"SPLASHES_JUGGERNAUT_KILL" );
  230. maps\mp\gametypes\_gamescore::givePlayerScore( "kill_as_juggernaut", attacker, self, true );
  231. attacker thread maps\mp\gametypes\_rank::giveRankXP( "kill_as_juggernaut" );
  232. }
  233. }
  234. else if ( isDefined( level.jugg_juggernaut ) && level.jugg_juggernaut == self )
  235. {
  236. self maps\mp\gametypes\_menus::addToTeam( "axis" );
  237. level thread chooseInitialJugg();
  238. }
  239. }
  240.  
  241.  
  242. resetJugg( newJugg, oldJugg )
  243. {
  244. // clear old jugg
  245. if ( isDefined( oldJugg ) )
  246. {
  247. oldJugg maps\mp\gametypes\_menus::addToTeam( "axis" );
  248. }
  249.  
  250. if ( isDefined( level.jugg_juggernaut ) )
  251. playSoundOnPlayers( "mp_enemy_obj_captured" );
  252. else
  253. playSoundOnPlayers( "mp_obj_captured" );
  254.  
  255. // set the new jugg
  256. level.jugg_juggernaut = newJugg;
  257. newJugg maps\mp\gametypes\_menus::addToTeam( "allies" );
  258. updateJuggScores( newJugg );
  259.  
  260. // give them a point for becoming jugg
  261. newJugg.jugg_juggScore ++;
  262. newJugg maps\mp\gametypes\_gamescore::giveTeamScoreForObjective( "allies", 1 );
  263.  
  264. // give the loadout
  265. newJugg thread giveJuggLoadout();
  266. }
  267.  
  268.  
  269. giveJuggLoadout()
  270. {
  271. // wait till they've spawned if they're dead
  272. while( !isAlive( self ) )
  273. wait( 0.05 );
  274.  
  275. // suit up
  276. self.pers["gamemodeLoadout"] = level.jugg_loadouts[self.pers["team"]];
  277.  
  278. // respawn?
  279. if ( level.matchRules_respawnNewJugg )
  280. {
  281. // store chosen and set current class to the
  282. self.jugg_chosenClass = self.class;
  283. self maps\mp\gametypes\_class::setClass( "gamemode" );
  284. self thread maps\mp\gametypes\_playerlogic::spawnClient();
  285. }
  286. else
  287. self thread maps\mp\killstreaks\_juggernaut::giveJuggernaut( "jugg_juggernaut" );
  288.  
  289. // world icon?
  290. if ( level.matchRules_showJuggWorldIcon )
  291. self.jugg_headIcon = self maps\mp\_entityheadIcons::setHeadIcon( level.otherTeam[self.team], "waypoint_kill", (0,0,85), 24, 24, undefined, undefined, undefined, undefined, undefined, false );
  292.  
  293. // bonus and messaging
  294. gotJuggBonus = maps\mp\gametypes\_rank::getScoreInfoValue( "got_juggernaut" );
  295. self thread maps\mp\gametypes\_hud_message::SplashNotify( "got_juggernaut", gotJuggBonus );
  296. maps\mp\gametypes\_gamescore::givePlayerScore( "got_juggernaut", self, undefined, true );
  297. self thread maps\mp\gametypes\_rank::giveRankXP( "got_juggernaut" );
  298. level thread teamPlayerCardSplash( "callout_new_juggernaut", self, level.otherTeam[self.team] );
  299. }
  300.  
  301.  
  302. updateJuggScores( newJugg )
  303. {
  304. highestScore = 0;
  305. foreach ( player in level.players )
  306. {
  307. if ( player != newJugg && isDefined( player.jugg_juggScore ) && player.jugg_juggScore > highestScore )
  308. highestScore = player.jugg_juggScore;
  309. }
  310.  
  311. game["teamScores"]["allies"] = newJugg.jugg_juggScore;
  312. setTeamScore( "axis", newJugg.jugg_juggScore );
  313.  
  314. game["teamScores"]["axis"] = highestScore;
  315. setTeamScore( "allies", highestScore );
  316. }
  317.  
  318.  
  319. onDisconnect()
  320. {
  321. level endon( "game_ended" );
  322.  
  323. for(;;)
  324. {
  325. self waittill( "disconnected" );
  326.  
  327. if ( isDefined( level.jugg_juggernaut ) && level.jugg_juggernaut == self )
  328. {
  329. // if jugg disconnects, give jugg to lowest scoring player
  330. newJugg = undefined;
  331. lowestScore = 999999;
  332. foreach( player in level.players )
  333. {
  334. if ( player != self )
  335. {
  336. if ( isDefined( player.score ) && player.score < lowestScore )
  337. {
  338. lowestScore = player.score;
  339. newJugg = player;
  340. }
  341. }
  342. }
  343. // give away the new loadout
  344. if ( isDefined( newJugg ) )
  345. {
  346. resetJugg( newJugg );
  347. }
  348. }
  349. }
  350. }
  351.  
  352.  
  353. onTimeLimit()
  354. {
  355. // peasants win if they last the time limit
  356. level.finalKillCam_winner = "axis";
  357. level thread maps\mp\gametypes\_gamelogic::endGame( "axis", game["strings"]["time_limit_reached"] );
  358. }
  359.  
  360.  
  361. hideTimerDisplayOnGameEnd( timerDisplay )
  362. {
  363. level waittill("game_ended");
  364. timerDisplay.alpha = 0;
  365. }
  366.  
  367.  
  368. setSpecialLoadouts()
  369. {
  370. // everyone else
  371. if ( isUsingMatchRulesData() && GetMatchRulesData( "defaultClasses", "axis", 0, "class", "inUse" ) )
  372. {
  373. level.jugg_loadouts["axis"] = getMatchRulesSpecialClass( "axis", 0 );
  374. level.jugg_loadouts["axis"]["loadoutJuggernaut"] = 0;
  375. }
  376. else
  377. {
  378. // no killstreaks defined for special classes
  379. level.jugg_loadouts["axis"]["loadoutPrimary"] = "iw5_usas12";
  380. level.jugg_loadouts["axis"]["loadoutPrimaryAttachment"] = "none";
  381. level.jugg_loadouts["axis"]["loadoutPrimaryAttachment2"] = "none";
  382. level.jugg_loadouts["axis"]["loadoutPrimaryBuff"] = "specialty_longerrange";
  383. level.jugg_loadouts["axis"]["loadoutPrimaryCamo"] = "none";
  384. level.jugg_loadouts["axis"]["loadoutPrimaryReticle"] = "none";
  385. level.jugg_loadouts["axis"]["loadoutSecondary"] = "iw5_44magnum";
  386.  
  387. level.jugg_loadouts["axis"]["loadoutSecondaryAttachment"] = "none";
  388. level.jugg_loadouts["axis"]["loadoutSecondaryAttachment2"] = "none";
  389. level.jugg_loadouts["axis"]["loadoutSecondaryBuff"] = "specialty_null";
  390. level.jugg_loadouts["axis"]["loadoutSecondaryCamo"] = "none";
  391. level.jugg_loadouts["axis"]["loadoutSecondaryReticle"] = "none";
  392.  
  393. level.jugg_loadouts["axis"]["loadoutEquipment"] = "claymore_mp";
  394. level.jugg_loadouts["axis"]["loadoutOffhand"] = "flash_grenade_mp";
  395.  
  396. level.jugg_loadouts["axis"]["loadoutPerk1"] = "specialty_longersprint";
  397. level.jugg_loadouts["axis"]["loadoutPerk2"] = "specialty_quickdraw";
  398. level.jugg_loadouts["axis"]["loadoutPerk3"] = "specialty_bulletaccuracy";
  399.  
  400. level.jugg_loadouts["axis"]["loadoutDeathstreak"] = "specialty_grenadepulldeath";
  401. level.jugg_loadouts["axis"]["loadoutJuggernaut"] = 0;
  402. }
  403.  
  404. // the jugg
  405. if ( isUsingMatchRulesData() && GetMatchRulesData( "defaultClasses", "allies", 5, "class", "inUse" ) )
  406. {
  407. level.jugg_loadouts["allies"] = getMatchRulesSpecialClass( "allies", 5 );
  408. level.jugg_loadouts["allies"]["loadoutJuggernaut"] = 1; // needed because we might spawn jugg instead of calling giveJugg()
  409. }
  410. else
  411. {
  412. // no killstreaks defined for special classes
  413. level.jugg_loadouts["allies"]["loadoutPrimary"] = "iw5_scar";
  414. level.jugg_loadouts["allies"]["loadoutPrimaryAttachment"] = "none";
  415. level.jugg_loadouts["allies"]["loadoutPrimaryAttachment2"] = "none";
  416. level.jugg_loadouts["allies"]["loadoutPrimaryBuff"] = "specialty_bulletpenetration";
  417. level.jugg_loadouts["allies"]["loadoutPrimaryCamo"] = "none";
  418. level.jugg_loadouts["allies"]["loadoutPrimaryReticle"] = "none";
  419.  
  420. level.jugg_loadouts["allies"]["loadoutSecondary"] = "rpg";
  421. level.jugg_loadouts["allies"]["loadoutSecondaryAttachment"] = "none";
  422. level.jugg_loadouts["allies"]["loadoutSecondaryAttachment2"] = "none";
  423. level.jugg_loadouts["allies"]["loadoutSecondaryBuff"] = "specialty_null";
  424. level.jugg_loadouts["allies"]["loadoutSecondaryCamo"] = "none";
  425. level.jugg_loadouts["allies"]["loadoutSecondaryReticle"] = "none";
  426.  
  427. level.jugg_loadouts["allies"]["loadoutEquipment"] = "frag_grenade_mp";
  428. level.jugg_loadouts["allies"]["loadoutOffhand"] = "smoke_grenade_mp";
  429.  
  430. level.jugg_loadouts["allies"]["loadoutPerk1"] = "specialty_scavenger";
  431. level.jugg_loadouts["allies"]["loadoutPerk2"] = "_specialty_blastshield";
  432. level.jugg_loadouts["allies"]["loadoutPerk3"] = "specialty_bulletaccuracy";
  433.  
  434. level.jugg_loadouts["allies"]["loadoutDeathstreak"] = "specialty_null";
  435. level.jugg_loadouts["allies"]["loadoutJuggernaut"] = 1; // needed because we might spawn jugg instead of calling giveJugg()
  436. }
  437. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement