CSHARP 207
War.gsc Guest on 18th April 2021 07:28:10 PM
  1. #include maps\mp\_utility;
  2. #include maps\mp\gametypes\_hud_util;
  3. /*
  4.     War
  5.     Objective:  Score points for your team by eliminating players on the opposing team
  6.     Map ends:   When one team reaches the score limit, or time limit is reached
  7.     Respawning: No wait / Near teammates
  8.  
  9.     Level requirements
  10.     ------------------
  11.         Spawnpoints:
  12.             classname       mp_tdm_spawn
  13.             All players spawn from these. The spawnpoint chosen is dependent on the current locations of teammates and enemies
  14.             at the time of spawn. Players generally spawn behind their teammates relative to the direction of enemies.
  15.  
  16.         Spectator Spawnpoints:
  17.             classname       mp_global_intermission
  18.             Spectators spawn from these and intermission is viewed from these positions.
  19.             Atleast one is required, any more and they are randomly chosen between.
  20.  
  21.     Level script requirements
  22.     -------------------------
  23.         Team Definitions:
  24.             game["allies"] = "marines";
  25.             game["axis"] = "opfor";
  26.             This sets the nationalities of the teams. Allies can be american, british, or russian. Axis can be german.
  27.  
  28.         If using minefields or exploders:
  29.             maps\mp\_load::main();
  30.  
  31.     Optional level script settings
  32.     ------------------------------
  33.         Soldier Type and Variation:
  34.             game["american_soldiertype"] = "normandy";
  35.             game["german_soldiertype"] = "normandy";
  36.             This sets what character models are used for each nationality on a particular map.
  37.  
  38.             Valid settings:
  39.                 american_soldiertype    normandy
  40.                 british_soldiertype     normandy, africa
  41.                 russian_soldiertype     coats, padded
  42.                 german_soldiertype      normandy, africa, winterlight, winterdark
  43. */
  44.  
  45. /*QUAKED mp_tdm_spawn (0.0 0.0 1.0) (-16 -16 0) (16 16 72)
  46. Players spawn away from enemies and near their team at one of these positions.*/
  47.  
  48. /*QUAKED mp_tdm_spawn_axis_start (0.5 0.0 1.0) (-16 -16 0) (16 16 72)
  49. Axis players spawn away from enemies and near their team at one of these positions at the start of a round.*/
  50.  
  51. /*QUAKED mp_tdm_spawn_allies_start (0.0 0.5 1.0) (-16 -16 0) (16 16 72)
  52. Allied players spawn away from enemies and near their team at one of these positions at the start of a round.*/
  53.  
  54. main()
  55. {
  56.     if(getdvar("mapname") == "mp_background")
  57.         return;
  58.    
  59.     maps\mp\gametypes\_globallogic::init();
  60.     maps\mp\gametypes\_callbacksetup::SetupCallbacks();
  61.     maps\mp\gametypes\_globallogic::SetupCallbacks();
  62.     if(level.ex_blackscreen) maps\mp\gametypes\_blackscreen::init();
  63.  
  64.     maps\mp\gametypes\_globallogic::registerTimeLimitDvar( "war", 10, 0, 1440 );
  65.     maps\mp\gametypes\_globallogic::registerScoreLimitDvar( "war", 500, 0, 5000 );
  66.     maps\mp\gametypes\_globallogic::registerRoundLimitDvar( "war", 1, 0, 10 );
  67.     maps\mp\gametypes\_globallogic::registerNumLivesDvar( "war", 0, 0, 10 );
  68.  
  69.     level.teamBased = true;
  70.     level.onStartGameType = ::onStartGameType;
  71.     level.onSpawnPlayer = ::onSpawnPlayer;
  72.  
  73.     game["dialog"]["gametype"] = "team_deathmtch";
  74. }
  75.  
  76. onStartGameType()
  77. {
  78.     setClientNameMode("auto_change");
  79.  
  80.     maps\mp\gametypes\_globallogic::setObjectiveText( "allies", &"OBJECTIVES_WAR" );
  81.     maps\mp\gametypes\_globallogic::setObjectiveText( "axis", &"OBJECTIVES_WAR" );
  82.    
  83.     if ( level.splitscreen )
  84.     {
  85.         maps\mp\gametypes\_globallogic::setObjectiveScoreText( "allies", &"OBJECTIVES_WAR" );
  86.         maps\mp\gametypes\_globallogic::setObjectiveScoreText( "axis", &"OBJECTIVES_WAR" );
  87.     }
  88.     else
  89.     {
  90.         maps\mp\gametypes\_globallogic::setObjectiveScoreText( "allies", &"OBJECTIVES_WAR_SCORE" );
  91.         maps\mp\gametypes\_globallogic::setObjectiveScoreText( "axis", &"OBJECTIVES_WAR_SCORE" );
  92.     }
  93.     maps\mp\gametypes\_globallogic::setObjectiveHintText( "allies", &"OBJECTIVES_WAR_HINT" );
  94.     maps\mp\gametypes\_globallogic::setObjectiveHintText( "axis", &"OBJECTIVES_WAR_HINT" );
  95.            
  96.     level.spawnMins = ( 0, 0, 0 );
  97.     level.spawnMaxs = ( 0, 0, 0 ); 
  98.     maps\mp\gametypes\_spawnlogic::placeSpawnPoints( "mp_tdm_spawn_allies_start" );
  99.     maps\mp\gametypes\_spawnlogic::placeSpawnPoints( "mp_tdm_spawn_axis_start" );
  100.     maps\mp\gametypes\_spawnlogic::addSpawnPoints( "allies", "mp_tdm_spawn" );
  101.     maps\mp\gametypes\_spawnlogic::addSpawnPoints( "axis", "mp_tdm_spawn" );
  102.  
  103.     level.spawn_axis_start = getentarray("mp_tdm_spawn_axis_start", "classname");  //
  104.     level.spawn_allies_start = getentarray("mp_tdm_spawn_allies_start", "classname");  //
  105.  
  106.     level.mapCenter = maps\mp\gametypes\_spawnlogic::findBoxCenter( level.spawnMins, level.spawnMaxs );
  107.     setMapCenter( level.mapCenter );
  108.    
  109.     allowed[0] = "war";
  110.    
  111.     if ( getDvarInt( "scr_oldHardpoints" ) > 0 )
  112.         allowed[1] = "hardpoint";
  113.    
  114.     level.displayRoundEndText = false;
  115.     maps\mp\gametypes\_gameobjects::main(allowed);
  116.    
  117.     // elimination style
  118.     if ( level.roundLimit != 1 && level.numLives )
  119.     {
  120.         level.overrideTeamScore = true;
  121.         level.displayRoundEndText = true;
  122.         level.onEndGame = ::onEndGame;
  123.     }
  124. }
  125.  
  126. onSpawnPlayer()
  127. {
  128.     self.usingObj = undefined;
  129.  
  130.     if(level.ex_sniper_war)
  131.     {
  132.         if (self.pers["team"] == "axis")
  133.             spawnpoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_Random(level.spawn_axis_start);
  134.         else
  135.             spawnpoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_Random(level.spawn_allies_start);
  136.     }
  137.     else
  138.     {
  139.         if ( level.inGracePeriod )
  140.         {
  141.             spawnPoints = getentarray("mp_tdm_spawn_" + self.pers["team"] + "_start", "classname");
  142.  
  143.             if ( !spawnPoints.size )
  144.                 spawnPoints = getentarray("mp_sab_spawn_" + self.pers["team"] + "_start", "classname");
  145.  
  146.             if ( !spawnPoints.size )
  147.             {
  148.                 spawnPoints = maps\mp\gametypes\_spawnlogic::getTeamSpawnPoints( self.pers["team"] );
  149.                 spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_NearTeam( spawnPoints );
  150.             }
  151.             else
  152.             {
  153.                 spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_Random( spawnPoints );
  154.             }
  155.         }
  156.         else
  157.         {
  158.             spawnPoints = maps\mp\gametypes\_spawnlogic::getTeamSpawnPoints( self.pers["team"] );
  159.             spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_NearTeam( spawnPoints );
  160.         }
  161.     }
  162.  
  163.     self spawn( spawnPoint.origin, spawnPoint.angles );
  164. }
  165.  
  166.  
  167. onEndGame( winningTeam )
  168. {
  169.     if ( isdefined( winningTeam ) && (winningTeam == "allies" || winningTeam == "axis") )
  170.         [[level._setTeamScore]]( winningTeam, [[level._getTeamScore]]( winningTeam ) + 1 );
  171. }

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.