Advertisement
Guest User

infect - Notesblok

a guest
Nov 19th, 2011
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.31 KB | None | 0 0
  1. #include maps\mp\_utility;
  2. #include maps\mp\gametypes\_hud_util;
  3. #include maps\mp\gametypes\_class;
  4.  
  5. main()
  6. {
  7. maps\mp\gametypes\_globallogic::init();
  8. maps\mp\gametypes\_callbacksetup::SetupCallbacks();
  9. maps\mp\gametypes\_globallogic::SetupCallbacks();
  10.  
  11. if ( isUsingMatchRulesData() )
  12. {
  13. level.initializeMatchRules = ::initializeMatchRules;
  14. [[level.initializeMatchRules]]();
  15. level thread reInitializeMatchRulesOnMigration();
  16. }
  17. else
  18. {
  19. registerTimeLimitDvar( level.gameType, 10 );
  20. setOverrideWatchDvar( "scorelimit", 0 );
  21. registerRoundLimitDvar( level.gameType, 1 );
  22. registerWinLimitDvar( level.gameType, 1 );
  23. registerNumLivesDvar( level.gameType, 0 );
  24. registerHalfTimeDvar( level.gameType, 0 );
  25.  
  26. level.matchRules_numInitialInfected = 1;
  27. level.matchRules_damageMultiplier = 0;
  28. level.matchRules_vampirism = 0;
  29. }
  30.  
  31. setSpecialLoadouts();
  32.  
  33. level.teamBased = true;
  34. level.doPrematch = true;
  35. level.onPrecacheGameType = ::onPrecacheGameType;
  36. level.onStartGameType = ::onStartGameType;
  37. level.onSpawnPlayer = ::onSpawnPlayer;
  38. level.getSpawnPoint = ::getSpawnPoint;
  39. level.onPlayerKilled = ::onPlayerKilled;
  40. level.onTimeLimit = ::onTimeLimit;
  41.  
  42. if ( level.matchRules_damageMultiplier || level.matchRules_vampirism )
  43. level.modifyPlayerDamage = maps\mp\gametypes\_damage::gamemodeModifyPlayerDamage;
  44. }
  45.  
  46.  
  47. initializeMatchRules()
  48. {
  49. // set common values
  50. setCommonRulesFromMatchRulesData();
  51.  
  52. // set everything else (private match options, default .cfg file values, and what normally is registered in the 'else' below)
  53. level.matchRules_numInitialInfected = GetMatchRulesData( "infectData", "numInitialInfected" );
  54.  
  55. setOverrideWatchDvar( "scorelimit", 0 );
  56. SetDynamicDvar( "scr_infect_roundswitch", 0 );
  57. registerRoundSwitchDvar( "infect", 0, 0, 9 );
  58. SetDynamicDvar( "scr_infect_roundlimit", 1 );
  59. registerRoundLimitDvar( "infect", 1 );
  60. SetDynamicDvar( "scr_infect_winlimit", 1 );
  61. registerWinLimitDvar( "infect", 1 );
  62. SetDynamicDvar( "scr_infect_halftime", 0 );
  63. registerHalfTimeDvar( "infect", 0 );
  64.  
  65. SetDynamicDvar( "scr_infect_promode", 0 );
  66. }
  67.  
  68.  
  69. onPrecacheGameType()
  70. {
  71. precacheString( &"MP_CONSCRIPTION_STARTS_IN" );
  72. }
  73.  
  74.  
  75. onStartGameType()
  76. {
  77. setClientNameMode("auto_change");
  78.  
  79. setObjectiveText( "allies", &"OBJECTIVES_INFECT" );
  80. setObjectiveText( "axis", &"OBJECTIVES_INFECT" );
  81.  
  82. if ( level.splitscreen )
  83. {
  84. setObjectiveScoreText( "allies", &"OBJECTIVES_INFECT" );
  85. setObjectiveScoreText( "axis", &"OBJECTIVES_INFECT" );
  86. }
  87. else
  88. {
  89. setObjectiveScoreText( "allies", &"OBJECTIVES_INFECT_SCORE" );
  90. setObjectiveScoreText( "axis", &"OBJECTIVES_INFECT_SCORE" );
  91. }
  92. setObjectiveHintText( "allies", &"OBJECTIVES_INFECT_HINT" );
  93. setObjectiveHintText( "axis", &"OBJECTIVES_INFECT_HINT" );
  94.  
  95. level.spawnMins = ( 0, 0, 0 );
  96. level.spawnMaxs = ( 0, 0, 0 );
  97. maps\mp\gametypes\_spawnlogic::addSpawnPoints( "allies", "mp_tdm_spawn" );
  98. maps\mp\gametypes\_spawnlogic::addSpawnPoints( "axis", "mp_tdm_spawn" );
  99. level.mapCenter = maps\mp\gametypes\_spawnlogic::findBoxCenter( level.spawnMins, level.spawnMaxs );
  100. setMapCenter( level.mapCenter );
  101.  
  102. allowed = [];
  103. maps\mp\gametypes\_gameobjects::main(allowed);
  104.  
  105. maps\mp\gametypes\_rank::registerScoreInfo( "final_rogue", 200 );
  106. maps\mp\gametypes\_rank::registerScoreInfo( "draft_rogue", 100 );
  107. maps\mp\gametypes\_rank::registerScoreInfo( "survivor", 100 );
  108.  
  109. level.QuickMessageToAll = true;
  110. level.blockWeaponDrops = true;
  111.  
  112. level.infect_timerDisplay = createServerTimer( "objective", 1.4 );
  113. level.infect_timerDisplay setPoint( "TOPLEFT", "TOPLEFT", 115, 5 );
  114. level.infect_timerDisplay.label = &"MP_DRAFT_STARTS_IN";
  115. level.infect_timerDisplay.alpha = 0;
  116. level.infect_timerDisplay.archived = false;
  117. level.infect_timerDisplay.hideWhenInMenu = true;
  118.  
  119. level.infect_choseFirstInfected = false;
  120. level.infect_choosingFirstInfected = false;
  121.  
  122. level thread onPlayerConnect();
  123. level thread onPlayerDisconnect();
  124. }
  125.  
  126.  
  127. onPlayerConnect()
  128. {
  129. for ( ;; )
  130. {
  131. level waittill( "connected", player );
  132.  
  133. player.infect_firstSpawn = true;
  134. }
  135. }
  136.  
  137.  
  138. onSpawnPlayer()
  139. {
  140. updateTeamScores();
  141.  
  142. // let the first spawned player kick this off
  143. if ( !level.infect_choosingFirstInfected )
  144. {
  145. level.infect_choosingFirstInfected = true;
  146. level thread chooseFirstInfected();
  147. }
  148.  
  149. // onSpawnPlayer() is called before giveLoadout()
  150. // set self.pers["gamemodeLoadout"] for giveLoadout() to use
  151. if ( isDefined( self.isInitialInfected ) )
  152. self.pers["gamemodeLoadout"] = level.infect_loadouts["axis_initial"];
  153. else
  154. self.pers["gamemodeLoadout"] = level.infect_loadouts[self.pers["team"]];
  155.  
  156. level notify ( "spawned_player" );
  157. }
  158.  
  159.  
  160. getSpawnPoint()
  161. {
  162. // first time here?
  163. if ( self.infect_firstSpawn )
  164. {
  165. self.infect_firstSpawn = false;
  166.  
  167. // everyone is a gamemode class in infect, no class selection
  168. self.pers["class"] = "gamemode";
  169. self.pers["lastClass"] = "";
  170. self.class = self.pers["class"];
  171. self.lastClass = self.pers["lastClass"];
  172.  
  173. // everyone starts as survivors
  174. self maps\mp\gametypes\_menus::addToTeam( "allies", true );
  175. }
  176.  
  177. if ( level.inGracePeriod )
  178. {
  179. spawnPoints = maps\mp\gametypes\_spawnlogic::getSpawnpointArray( "mp_tdm_spawn" );
  180. spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_Random( spawnPoints );
  181. }
  182. else
  183. {
  184. spawnPoints = maps\mp\gametypes\_spawnlogic::getTeamSpawnPoints( self.pers["team"] );
  185. spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_NearTeam( spawnPoints );
  186. }
  187.  
  188. return spawnPoint;
  189. }
  190.  
  191.  
  192. chooseFirstInfected()
  193. {
  194. level endon( "game_ended" );
  195.  
  196. gameFlagWait( "prematch_done" );
  197.  
  198. level.infect_timerDisplay.label = &"MP_DRAFT_STARTS_IN";
  199. level.infect_timerDisplay setTimer( 8 );
  200. level.infect_timerDisplay.alpha = 1;
  201.  
  202. maps\mp\gametypes\_hostmigration::waitLongDurationWithHostMigrationPause( 8.0 );
  203.  
  204. level.infect_timerDisplay.alpha = 0;
  205.  
  206. first = level.players[ randomInt( level.players.size ) ];
  207. first.infect_isBeingChosen = true;
  208.  
  209. first endon( "disconnect" );
  210. while( !isAlive( first ) )
  211. wait( 0.05 );
  212.  
  213. first maps\mp\gametypes\_menus::addToTeam( "axis" );
  214. updateTeamScores();
  215. level.infect_choseFirstInfected = true;
  216. first.infect_isBeingChosen = undefined;
  217. first.isInitialInfected = true;
  218.  
  219. // remove jugg if needed before changing loadout
  220. if ( first isJuggernaut() )
  221. {
  222. first notify( "lost_juggernaut" );
  223. wait( 0.05 );
  224. }
  225. // set the gamemodeloadout to initial infected for giveLoadout() to use
  226. first.pers["gamemodeLoadout"] = level.infect_loadouts["axis_initial"];
  227. first maps\mp\gametypes\_class::giveLoadout( "axis", "gamemode", false, false );
  228.  
  229. // tell the world!
  230. thread teamPlayerCardSplash( "callout_first_mercenary", first );
  231. playSoundOnPlayers( "mp_enemy_obj_captured" );
  232. }
  233.  
  234.  
  235. setInitialToNormalInfected()
  236. {
  237. self.isInitialInfected = undefined;
  238. // remove jugg if needed before changing loadout
  239. if ( self isJuggernaut() )
  240. {
  241. self notify( "lost_juggernaut" );
  242. wait( 0.05 );
  243. }
  244. self.pers["gamemodeLoadout"] = level.infect_loadouts["axis"];
  245. self maps\mp\gametypes\_class::giveLoadout( "axis", "gamemode", false, false );
  246. }
  247.  
  248.  
  249. onPlayerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration, lifeId )
  250. {
  251. if ( isDefined( attacker ) && isPlayer( attacker ) && attacker != self && self.team == "allies" )
  252. {
  253. // move victim to infected
  254. self maps\mp\gametypes\_menus::addToTeam( "axis" );
  255. updateTeamScores();
  256.  
  257. // set attacker to regular infected if they were the first and this is their first kill
  258. if ( isDefined( attacker.isInitialInfected ) )
  259. attacker thread setInitialToNormalInfected();
  260.  
  261. // reward attacker
  262. attacker thread maps\mp\gametypes\_rank::xpEventPopup( &"SPLASHES_DRAFTED" );
  263. maps\mp\gametypes\_gamescore::givePlayerScore( "draft_rogue", attacker, self, true );
  264. attacker thread maps\mp\gametypes\_rank::giveRankXP( "draft_rogue" );
  265.  
  266. // how many left?
  267. numSurvivors = getNumSurvivors();
  268.  
  269. // generic messages/sounds, and reward survivors
  270. if ( numSurvivors > 1 )
  271. {
  272. playSoundOnPlayers( "mp_enemy_obj_captured", "allies" );
  273. playSoundOnPlayers( "mp_war_objective_taken", "axis" );
  274. thread teamPlayerCardSplash( "callout_got_drafted", self, "allies" );
  275. thread teamPlayerCardSplash( "callout_drafted_rogue", attacker, "axis" );
  276.  
  277. foreach ( player in level.players )
  278. {
  279. if ( player.team == "allies" )
  280. {
  281. player thread maps\mp\gametypes\_rank::xpEventPopup( &"SPLASHES_SURVIVOR" );
  282. maps\mp\gametypes\_gamescore::givePlayerScore( "survivor", player, undefined, true );
  283. player thread maps\mp\gametypes\_rank::giveRankXP( "survivor" );
  284. }
  285. }
  286. }
  287. // inform/reward last
  288. if ( numSurvivors == 1 )
  289. {
  290. playSoundOnPlayers( "mp_obj_captured" );
  291. foreach ( player in level.players )
  292. {
  293. if ( player.team == "allies" )
  294. {
  295. player thread maps\mp\gametypes\_rank::xpEventPopup( &"SPLASHES_FINAL_ROGUE" );
  296. maps\mp\gametypes\_gamescore::givePlayerScore( "final_rogue", player, undefined, true );
  297. player thread maps\mp\gametypes\_rank::giveRankXP( "final_rogue" );
  298. thread teamPlayerCardSplash( "callout_final_rogue", player );
  299. break;
  300. }
  301. }
  302. }
  303. // infected win
  304. else if ( numSurvivors == 0 )
  305. {
  306. level.finalKillCam_winner = "axis";
  307. level thread maps\mp\gametypes\_gamelogic::endGame( "axis", game["strings"]["allies_eliminated"] );
  308. }
  309. }
  310. }
  311.  
  312.  
  313. onPlayerDisconnect()
  314. {
  315. for(;;)
  316. {
  317. level waittill( "disconnected", player );
  318.  
  319. updateTeamScores();
  320.  
  321. if ( isDefined( player.infect_isBeingChosen ) || level.infect_choseFirstInfected )
  322. {
  323. if ( getNumSurvivors() == 0 )
  324. {
  325. level.finalKillCam_winner = "axis";
  326. level thread maps\mp\gametypes\_gamelogic::endGame( "axis", game["strings"]["allies_eliminated"] );
  327. }
  328. else if ( getNumInfected() == 0 )
  329. {
  330. // infected quit, shame them
  331. thread teamPlayerCardSplash( "callout_deserted", player );
  332.  
  333. // pick a new one and keep the game going
  334. level.infect_choseFirstInfected = false;
  335. level thread chooseFirstInfected();
  336. }
  337. }
  338. }
  339. }
  340.  
  341.  
  342. onTimeLimit()
  343. {
  344. level.finalKillCam_winner = "allies";
  345. level thread maps\mp\gametypes\_gamelogic::endGame( "allies", game["strings"]["time_limit_reached"] );
  346. }
  347.  
  348.  
  349. updateTeamScores()
  350. {
  351. game["teamScores"]["axis"] = getNumInfected();
  352. setTeamScore( "axis", getNumInfected() );
  353. game["teamScores"]["allies"] = getNumSurvivors();
  354. setTeamScore( "allies", getNumSurvivors() );
  355. }
  356.  
  357.  
  358. getNumInfected()
  359. {
  360. numInfected = 0;
  361. foreach ( player in level.players )
  362. {
  363. if ( player.team == "axis" )
  364. numInfected++;
  365. }
  366. return numInfected;
  367. }
  368.  
  369.  
  370. getNumSurvivors()
  371. {
  372. numSurvivors = 0;
  373. foreach ( player in level.players )
  374. {
  375. if ( player.team == "allies" )
  376. numSurvivors++;
  377. }
  378. return numSurvivors;
  379. }
  380.  
  381.  
  382. setSpecialLoadouts()
  383. {
  384. // Rogues in the game mode infected, are the only special class that has killstreaks.
  385. // When rogues become the initial mercenary or are drafted to mercenaries, the initial mercenary and mercenary
  386. // special classes have no killstreaks defined (because they aren't accessible for their class edit menu).
  387. // We need to assign default null data so something exists in this loadout to override whatever they had before as rogues.
  388.  
  389. // mercenaries
  390. if ( isUsingMatchRulesData() && GetMatchRulesData( "defaultClasses", "axis", 0, "class", "inUse" ) )
  391. {
  392. level.infect_loadouts["axis"] = getMatchRulesSpecialClass( "axis", 0 );
  393. level.infect_loadouts["axis"]["loadoutStreakType"] = "assault";
  394. level.infect_loadouts["axis"]["loadoutKillstreak1"] = "none";
  395. level.infect_loadouts["axis"]["loadoutKillstreak2"] = "none";
  396. level.infect_loadouts["axis"]["loadoutKillstreak3"] = "none";
  397. }
  398. else
  399. {
  400. level.infect_loadouts["axis"]["loadoutPrimary"] = "iw5_fmg9";
  401. level.infect_loadouts["axis"]["loadoutPrimaryAttachment"] = "reflex";
  402. level.infect_loadouts["axis"]["loadoutPrimaryAttachment2"] = "none";
  403. level.infect_loadouts["axis"]["loadoutPrimaryBuff"] = "specialty_null";
  404. level.infect_loadouts["axis"]["loadoutPrimaryCamo"] = "none";
  405. level.infect_loadouts["axis"]["loadoutPrimaryReticle"] = "none";
  406.  
  407. level.infect_loadouts["axis"]["loadoutSecondary"] = "none";
  408. level.infect_loadouts["axis"]["loadoutSecondaryAttachment"] = "none";
  409. level.infect_loadouts["axis"]["loadoutSecondaryAttachment2"] = "none";
  410. level.infect_loadouts["axis"]["loadoutSecondaryBuff"] = "specialty_null";
  411. level.infect_loadouts["axis"]["loadoutSecondaryCamo"] = "none";
  412. level.infect_loadouts["axis"]["loadoutSecondaryReticle"] = "none";
  413.  
  414. level.infect_loadouts["axis"]["loadoutEquipment"] = "throwingknife_mp";
  415. level.infect_loadouts["axis"]["loadoutOffhand"] = "none";
  416.  
  417. level.infect_loadouts["axis"]["loadoutPerk1"] = "specialty_longersprint";
  418. level.infect_loadouts["axis"]["loadoutPerk2"] = "specialty_quickdraw";
  419. level.infect_loadouts["axis"]["loadoutPerk3"] = "specialty_quieter";
  420.  
  421. level.infect_loadouts["axis"]["loadoutStreakType"] = "assault";
  422. level.infect_loadouts["axis"]["loadoutKillstreak1"] = "none";
  423. level.infect_loadouts["axis"]["loadoutKillstreak2"] = "none";
  424. level.infect_loadouts["axis"]["loadoutKillstreak3"] = "none";
  425.  
  426. level.infect_loadouts["axis"]["loadoutDeathstreak"] = "specialty_grenadepulldeath";
  427.  
  428. level.infect_loadouts["axis"]["loadoutJuggernaut"] = false;
  429. }
  430.  
  431. // initial mercenaries
  432. if ( isUsingMatchRulesData() && GetMatchRulesData( "defaultClasses", "axis", 5, "class", "inUse" ) )
  433. {
  434. level.infect_loadouts["axis_initial"] = getMatchRulesSpecialClass( "axis", 5 );
  435. level.infect_loadouts["axis_initial"]["loadoutStreakType"] = "assault";
  436. level.infect_loadouts["axis_initial"]["loadoutKillstreak1"] = "none";
  437. level.infect_loadouts["axis_initial"]["loadoutKillstreak2"] = "none";
  438. level.infect_loadouts["axis_initial"]["loadoutKillstreak3"] = "none";
  439. }
  440. else
  441. {
  442. level.infect_loadouts["axis_initial"]["loadoutPrimary"] = "iw5_scar";
  443. level.infect_loadouts["axis_initial"]["loadoutPrimaryAttachment"] = "reflex";
  444. level.infect_loadouts["axis_initial"]["loadoutPrimaryAttachment2"] = "xmags";
  445. level.infect_loadouts["axis_initial"]["loadoutPrimaryBuff"] = "specialty_bling";
  446. level.infect_loadouts["axis_initial"]["loadoutPrimaryCamo"] = "none";
  447. level.infect_loadouts["axis_initial"]["loadoutPrimaryReticle"] = "none";
  448.  
  449. level.infect_loadouts["axis_initial"]["loadoutSecondary"] = "none";
  450. level.infect_loadouts["axis_initial"]["loadoutSecondaryAttachment"] = "none";
  451. level.infect_loadouts["axis_initial"]["loadoutSecondaryAttachment2"] = "none";
  452. level.infect_loadouts["axis_initial"]["loadoutSecondaryBuff"] = "specialty_null";
  453. level.infect_loadouts["axis_initial"]["loadoutSecondaryCamo"] = "none";
  454. level.infect_loadouts["axis_initial"]["loadoutSecondaryReticle"] = "none";
  455.  
  456. level.infect_loadouts["axis_initial"]["loadoutEquipment"] = "specialty_null";
  457. level.infect_loadouts["axis_initial"]["loadoutOffhand"] = "none";
  458.  
  459. level.infect_loadouts["axis_initial"]["loadoutPerk1"] = "specialty_longersprint";
  460. level.infect_loadouts["axis_initial"]["loadoutPerk2"] = "specialty_quickdraw";
  461. level.infect_loadouts["axis_initial"]["loadoutPerk3"] = "specialty_bulletaccuracy";
  462.  
  463. level.infect_loadouts["axis_initial"]["loadoutStreakType"] = "assault";
  464. level.infect_loadouts["axis_initial"]["loadoutKillstreak1"] = "none";
  465. level.infect_loadouts["axis_initial"]["loadoutKillstreak2"] = "none";
  466. level.infect_loadouts["axis_initial"]["loadoutKillstreak3"] = "none";
  467.  
  468. level.infect_loadouts["axis_initial"]["loadoutDeathstreak"] = "specialty_grenadepulldeath";
  469.  
  470. level.infect_loadouts["axis_initial"]["loadoutJuggernaut"] = false;
  471. }
  472.  
  473. // rogues
  474. if ( isUsingMatchRulesData() && GetMatchRulesData( "defaultClasses", "allies", 0, "class", "inUse" ) )
  475. {
  476. level.infect_loadouts["allies"] = getMatchRulesSpecialClass( "allies", 0 );
  477. }
  478. else
  479. {
  480. level.infect_loadouts["allies"]["loadoutPrimary"] = "iw5_spas12";
  481. level.infect_loadouts["allies"]["loadoutPrimaryAttachment"] = "silencer03";
  482. level.infect_loadouts["allies"]["loadoutPrimaryAttachment2"] = "none";
  483. level.infect_loadouts["allies"]["loadoutPrimaryBuff"] = "specialty_longerrange";
  484. level.infect_loadouts["allies"]["loadoutPrimaryCamo"] = "none";
  485. level.infect_loadouts["allies"]["loadoutPrimaryReticle"] = "none";
  486.  
  487. level.infect_loadouts["allies"]["loadoutSecondary"] = "none";
  488. level.infect_loadouts["allies"]["loadoutSecondaryAttachment"] = "none";
  489. level.infect_loadouts["allies"]["loadoutSecondaryAttachment2"] = "none";
  490. level.infect_loadouts["allies"]["loadoutSecondaryBuff"] = "specialty_null";
  491. level.infect_loadouts["allies"]["loadoutSecondaryCamo"] = "none";
  492. level.infect_loadouts["allies"]["loadoutSecondaryReticle"] = "none";
  493.  
  494. level.infect_loadouts["allies"]["loadoutEquipment"] = "claymore_mp";
  495. level.infect_loadouts["allies"]["loadoutOffhand"] = "flash_grenade_mp";
  496.  
  497. level.infect_loadouts["allies"]["loadoutPerk1"] = "specialty_scavenger";
  498. level.infect_loadouts["allies"]["loadoutPerk2"] = "specialty_quickdraw";
  499. level.infect_loadouts["allies"]["loadoutPerk3"] = "specialty_quieter";
  500.  
  501. level.infect_loadouts["allies"]["loadoutDeathstreak"] = "specialty_null";
  502.  
  503. level.infect_loadouts["allies"]["loadoutJuggernaut"] = false;
  504. }
  505. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement