Advertisement
Guest User

ioc - Notesblok

a guest
Nov 19th, 2011
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.01 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. registerScoreLimitDvar( level.gameType, 0 );
  21. registerRoundLimitDvar( level.gameType, 1 );
  22. registerWinLimitDvar( level.gameType, 1 );
  23. registerNumLivesDvar( level.gameType, 2 );
  24. registerHalfTimeDvar( level.gameType, 0 );
  25.  
  26. level.matchRules_damageMultiplier = 0;
  27. level.matchRules_vampirism = 0;
  28. level.matchRules_oneShotKill = false;
  29.  
  30. level.matchRules_initialAmmo = 2;
  31. level.matchRules_rewardAmmo = 2;
  32. }
  33. SetDynamicDvar( "scr_player_maxhealth", 100 );
  34. SetDynamicDvar( "scr_game_onlyheadshots", 0 );
  35. SetDynamicDvar( "scr_game_hardpoints", 0 );
  36. SetDynamicDvar( "scr_player_healthregentime", 5 );
  37.  
  38. setGun();
  39. setSpecialLoadouts();
  40.  
  41. level.teamBased = false;
  42. level.doPrematch = true;
  43. level.killstreakRewards = false;
  44. level.onStartGameType = ::onStartGameType;
  45. level.onSpawnPlayer = ::onSpawnPlayer;
  46. level.getSpawnPoint = ::getSpawnPoint;
  47. level.onPlayerKilled = ::onPlayerKilled;
  48. level.onOneLeftEvent = ::onOneLeftEvent;
  49. if ( level.matchRules_oneShotKill )
  50. level.modifyPlayerDamage = ::modifyPlayerDamage;
  51. }
  52.  
  53.  
  54. initializeMatchRules()
  55. {
  56. // set common values
  57. setCommonRulesFromMatchRulesData( true );
  58.  
  59. // set everything else (private match options, default .cfg file values, and what normally is registered in the 'else' below)
  60. level.matchRules_initialAmmo = GetMatchRulesData( "oicData", "initialAmmoCount" );
  61. level.matchRules_rewardAmmo = GetMatchRulesData( "oicData", "killRewardAmmoCount" );
  62. level.matchRules_oneShotKill = GetMatchRulesData( "oicData", "oneShotKill" );
  63.  
  64. // neither are accessible in game options screen for this mode but reset in case there is junk data
  65. level.matchRules_damageMultiplier = 0;
  66. level.matchRules_vampirism = 0;
  67.  
  68. SetDynamicDvar( "scr_oic_winlimit", 1 );
  69. registerWinLimitDvar( "oic", 1 );
  70. SetDynamicDvar( "scr_oic_roundlimit", 1 );
  71. registerRoundLimitDvar( "oic", 1 );
  72. SetDynamicDvar( "scr_oic_halftime", 0 );
  73. registerHalfTimeDvar( "oic", 0 );
  74.  
  75. SetDynamicDvar( "scr_oic_promode", 0 );
  76.  
  77. SetDynamicDvar( "scr_player_maxhealth", 100 );
  78. SetDynamicDvar( "scr_game_onlyheadshots", 0 );
  79. SetDynamicDvar( "scr_game_hardpoints", 0 );
  80. SetDynamicDvar( "scr_player_healthregentime", 5 );
  81. }
  82.  
  83.  
  84. onStartGameType()
  85. {
  86. setClientNameMode("auto_change");
  87.  
  88. setObjectiveText( "allies", &"OBJECTIVES_OIC" );
  89. setObjectiveText( "axis", &"OBJECTIVES_OIC" );
  90.  
  91. if ( level.splitscreen )
  92. {
  93. setObjectiveScoreText( "allies", &"OBJECTIVES_OIC" );
  94. setObjectiveScoreText( "axis", &"OBJECTIVES_OIC" );
  95. }
  96. else
  97. {
  98. setObjectiveScoreText( "allies", &"OBJECTIVES_OIC_SCORE" );
  99. setObjectiveScoreText( "axis", &"OBJECTIVES_OIC_SCORE" );
  100. }
  101. setObjectiveHintText( "allies", &"OBJECTIVES_OIC_HINT" );
  102. setObjectiveHintText( "axis", &"OBJECTIVES_OIC_HINT" );
  103.  
  104. level.spawnMins = ( 0, 0, 0 );
  105. level.spawnMaxs = ( 0, 0, 0 );
  106.  
  107. maps\mp\gametypes\_spawnlogic::addSpawnPoints( "allies", "mp_dm_spawn" );
  108. maps\mp\gametypes\_spawnlogic::addSpawnPoints( "axis", "mp_dm_spawn" );
  109.  
  110. level.mapCenter = maps\mp\gametypes\_spawnlogic::findBoxCenter( level.spawnMins, level.spawnMaxs );
  111. setMapCenter( level.mapCenter );
  112.  
  113. allowed = [];
  114. maps\mp\gametypes\_gameobjects::main(allowed);
  115.  
  116. maps\mp\gametypes\_rank::registerScoreInfo( "kill", 100 );
  117. maps\mp\gametypes\_rank::registerScoreInfo( "headshot", 0 );
  118. maps\mp\gametypes\_rank::registerScoreInfo( "assist", 0 );
  119. maps\mp\gametypes\_rank::registerScoreInfo( "suicide", 0 );
  120. maps\mp\gametypes\_rank::registerScoreInfo( "teamkill", 0 );
  121. maps\mp\gametypes\_rank::registerScoreInfo( "survivor", 25 );
  122.  
  123. level.QuickMessageToAll = true;
  124. level.blockWeaponDrops = true;
  125.  
  126. level thread onPlayerConnect();
  127.  
  128. level thread watchElimination();
  129.  
  130. level.killstreakRewards = false;
  131. }
  132.  
  133.  
  134. onPlayerConnect()
  135. {
  136. for ( ;; )
  137. {
  138. level waittill( "connected", player );
  139.  
  140. player.oic_firstSpawn = true;
  141. }
  142. }
  143.  
  144.  
  145. getSpawnPoint()
  146. {
  147. // first time here?
  148. if ( self.oic_firstSpawn )
  149. {
  150. self.oic_firstSpawn = false;
  151.  
  152. // everyone is a gamemode class in oic, no class selection
  153. self.pers["class"] = "gamemode";
  154. self.pers["lastClass"] = "";
  155. self.class = self.pers["class"];
  156. self.lastClass = self.pers["lastClass"];
  157. }
  158.  
  159. spawnPoints = maps\mp\gametypes\_spawnlogic::getTeamSpawnPoints( self.pers["team"] );
  160. spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_DM( spawnPoints );
  161.  
  162. return spawnPoint;
  163. }
  164.  
  165.  
  166. onSpawnPlayer()
  167. {
  168. // award ammo that the player might have been waiting to receive on death
  169. if ( isDefined( self.oic_rewardAmmo ) && self.oic_rewardAmmo )
  170. self giveAmmo();
  171. else
  172. self.oic_rewardAmmo = 0;
  173.  
  174. // level.onSpawnPlayer() gets called before giveLoadout()
  175. // so wait until it is done then override weapons
  176. self.pers["gamemodeLoadout"] = level.oic_loadouts[self.pers["team"]];
  177. self thread waitLoadoutDone();
  178.  
  179. level notify ( "spawned_player" );
  180. }
  181.  
  182. waitLoadoutDone()
  183. {
  184. level endon( "game_ended" );
  185. self endon( "disconnect" );
  186.  
  187. level waittill( "player_spawned" );
  188.  
  189. // clear temp data
  190. self takeAllWeapons();
  191.  
  192. // give gun
  193. newWeapon = level.oic_gun + "_mp";
  194. _giveWeapon( newWeapon );
  195. self switchToWeapon( newWeapon );
  196. self setSpawnWeapon( newWeapon );
  197.  
  198. weaponTokens = StrTok( newWeapon, "_" );
  199. if ( weaponTokens[0] == "iw5" )
  200. weaponName = weaponTokens[0] + "_" + weaponTokens[1];
  201. else if ( weaponTokens[0] == "alt" )
  202. weaponName = weaponTokens[1] + "_" + weaponTokens[2];
  203. else
  204. weaponName = weaponTokens[0];
  205. self.pers["primaryWeapon"] = weaponName;
  206.  
  207. self.primaryWeapon = newWeapon;
  208.  
  209. // give ammo
  210. clipAmmo = level.matchRules_initialAmmo;
  211. if( isDefined( self.pers["clip_ammo"] ) )
  212. {
  213. clipAmmo = self.pers["clip_ammo"];
  214. self.pers["clip_ammo"] = undefined;
  215. }
  216. self SetWeaponAmmoClip( self.primaryWeapon, clipAmmo );
  217.  
  218. stockAmmo = 0;
  219. if( isDefined( self.pers["stock_ammo"] ) )
  220. {
  221. stockAmmo = self.pers["stock_ammo"];
  222. self.pers["stock_ammo"] = undefined;
  223. }
  224. self SetWeaponAmmoStock( self.primaryWeapon, stockAmmo );
  225.  
  226. // give knife
  227. //self SetOffhandPrimaryClass( "throwingknife" );
  228. //_giveWeapon( "throwingknife_mp" );
  229. }
  230.  
  231.  
  232. modifyPlayerDamage( victim, eAttacker, iDamage, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc )
  233. {
  234. if ( ( sMeansOfDeath == "MOD_PISTOL_BULLET" ) || ( sMeansOfDeath == "MOD_RIFLE_BULLET" ) || ( sMeansOfDeath == "MOD_HEAD_SHOT" ) )
  235. iDamage = 999;
  236.  
  237. return iDamage;
  238. }
  239.  
  240.  
  241. onPlayerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration, lifeId )
  242. {
  243. if ( isDefined( attacker ) && isPlayer( attacker ) && self != attacker )
  244. {
  245. attacker.oic_rewardAmmo += level.matchRules_rewardAmmo;
  246. if ( self attackButtonPressed() )
  247. attacker thread waitGiveAmmo();
  248. else
  249. attacker giveAmmo();
  250. }
  251. }
  252.  
  253.  
  254. onOneLeftEvent( team )
  255. {
  256. lastPlayer = getLastLivingPlayer();
  257.  
  258. logString( "last one alive, win: " + lastPlayer.name );
  259. level.finalKillCam_winner = "none";
  260. level thread maps\mp\gametypes\_gamelogic::endGame( lastPlayer, &"MP_ENEMIES_ELIMINATED" );
  261. }
  262.  
  263.  
  264. waitGiveAmmo()
  265. {
  266. self endon( "death" );
  267. self endon( "disconnect" );
  268. level endon( "game_ended" );
  269.  
  270. self notify( "oic_waitGiveAmmo" );
  271. self endon( "oic_waitGiveAmmo" );
  272.  
  273.  
  274. while( self attackButtonPressed() )
  275. wait( 0.05 );
  276.  
  277. giveAmmo();
  278. }
  279.  
  280.  
  281. giveAmmo()
  282. {
  283. currentWeapon = self getCurrentWeapon();
  284. clipAmmo = self GetWeaponAmmoClip( currentWeapon );
  285. self SetWeaponAmmoClip( currentWeapon, clipAmmo + self.oic_rewardAmmo );
  286. self playLocalSound( "scavenger_pack_pickup" );
  287.  
  288. self.oic_rewardAmmo = 0;
  289. }
  290.  
  291.  
  292. watchElimination()
  293. {
  294. level endon( "game_ended" );
  295.  
  296. for ( ;; )
  297. {
  298. level waittill( "player_eliminated", player );
  299.  
  300. thread teamPlayerCardSplash( "callout_eliminated", player );
  301.  
  302. remainingPlayers = [];
  303. foreach ( player in level.players )
  304. {
  305. if ( IsDefined( player ) && ( IsAlive( player ) || player.pers["lives"] > 0 ) )
  306. {
  307. remainingPlayers[remainingPlayers.size] = player;
  308. player thread maps\mp\gametypes\_rank::xpEventPopup( &"SPLASHES_SURVIVOR" );
  309. maps\mp\gametypes\_gamescore::givePlayerScore( "survivor", player, undefined, true );
  310. player thread maps\mp\gametypes\_rank::giveRankXP( "survivor" );
  311. }
  312. }
  313.  
  314. if ( remainingPlayers.size > 2 )
  315. {
  316. playSoundOnPlayers( "mp_enemy_obj_captured" );
  317. }
  318. else if ( remainingPlayers.size == 2 )
  319. {
  320. playSoundOnPlayers( "mp_obj_captured" );
  321.  
  322. remainingPlayers[0] thread maps\mp\gametypes\_hud_message::playerCardSplashNotify( "callout_lastenemyalive", remainingPlayers[1] );
  323. remainingPlayers[1] thread maps\mp\gametypes\_hud_message::playerCardSplashNotify( "callout_lastenemyalive", remainingPlayers[0] );
  324. }
  325. }
  326. }
  327.  
  328.  
  329. setGun()
  330. {
  331. level.oic_gun = undefined;
  332.  
  333. gun = "none";
  334. if ( isUsingMatchRulesData() )
  335. gun = GetMatchRulesData( "oicData", "weapon" );
  336.  
  337. if ( isDefined( gun ) && gun != "none" )
  338. {
  339. level.oic_gun = gun;
  340. }
  341. else
  342. {
  343. level.oic_gun = "iw5_g18_mp";
  344. }
  345. }
  346.  
  347.  
  348. setSpecialLoadouts()
  349. {
  350. // no killstreaks defined for special classes
  351. level.oic_loadouts["axis"]["loadoutPrimary"] = "iw5_acr"; // can't use "none" for primary, this is replaced on spawn anyway
  352. level.oic_loadouts["axis"]["loadoutPrimaryAttachment"] = "none";
  353. level.oic_loadouts["axis"]["loadoutPrimaryAttachment2"] = "none";
  354. level.oic_loadouts["axis"]["loadoutPrimaryBuff"] = "specialty_null";
  355. level.oic_loadouts["axis"]["loadoutPrimaryCamo"] = "none";
  356. level.oic_loadouts["axis"]["loadoutPrimaryReticle"] = "none";
  357.  
  358. level.oic_loadouts["axis"]["loadoutSecondary"] = "none";
  359. level.oic_loadouts["axis"]["loadoutSecondaryAttachment"] = "none";
  360. level.oic_loadouts["axis"]["loadoutSecondaryAttachment2"] = "none";
  361. level.oic_loadouts["axis"]["loadoutSecondaryBuff"] = "specialty_null";
  362. level.oic_loadouts["axis"]["loadoutSecondaryCamo"] = "none";
  363. level.oic_loadouts["axis"]["loadoutSecondaryReticle"] = "none";
  364.  
  365. level.oic_loadouts["axis"]["loadoutEquipment"] = "specialty_null";
  366. level.oic_loadouts["axis"]["loadoutOffhand"] = "none";
  367.  
  368. level.oic_loadouts["axis"]["loadoutPerk1"] = "specialty_null";
  369. level.oic_loadouts["axis"]["loadoutPerk2"] = "specialty_null";
  370. level.oic_loadouts["axis"]["loadoutPerk3"] = "specialty_null";
  371.  
  372. level.oic_loadouts["axis"]["loadoutDeathstreak"] = "specialty_null";
  373.  
  374. level.oic_loadouts["axis"]["loadoutJuggernaut"] = false;
  375.  
  376. // FFA games don't have teams, but players are allowed to choose team on the way in
  377. // just for character model and announcer voice variety. Same loadout for both.
  378. level.oic_loadouts["allies"] = level.oic_loadouts["axis"];
  379. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement