CSHARP 201
Sab.gsc Guest on 18th April 2021 07:30:28 PM
  1. #include maps\mp\_utility;
  2. #include maps\mp\gametypes\_hud_util;
  3. /*
  4.     Sabotage
  5.    
  6.     // ...etc...
  7. */
  8.  
  9. /*QUAKED mp_sab_spawn_axis (0.75 0.0 0.5) (-16 -16 0) (16 16 72)
  10. Axis players spawn away from enemies and near their team at one of these positions.*/
  11.  
  12. /*QUAKED mp_sab_spawn_allies (0.0 0.75 0.5) (-16 -16 0) (16 16 72)
  13. Allied players spawn away from enemies and near their team at one of these positions.*/
  14.  
  15. /*QUAKED mp_sab_spawn_axis_start (1.0 0.0 0.5) (-16 -16 0) (16 16 72)
  16. Axis players spawn away from enemies and near their team at one of these positions at the start of a round.*/
  17.  
  18. /*QUAKED mp_sab_spawn_allies_start (0.0 1.0 0.5) (-16 -16 0) (16 16 72)
  19. Allied players spawn away from enemies and near their team at one of these positions at the start of a round.*/
  20.  
  21. main()
  22. {
  23.     if ( getdvar("mapname") == "mp_background" )
  24.         return;
  25.    
  26.     maps\mp\gametypes\_globallogic::init();
  27.     maps\mp\gametypes\_callbacksetup::SetupCallbacks();
  28.     maps\mp\gametypes\_globallogic::SetupCallbacks();
  29.     if(level.ex_blackscreen) maps\mp\gametypes\_blackscreen::init();
  30.    
  31.     level.teamBased = true;
  32.     level.overrideTeamScore = true;
  33.  
  34.     maps\mp\gametypes\_globallogic::registerRoundSwitchDvar( level.gameType, 0, 0, 9 );
  35.     maps\mp\gametypes\_globallogic::registerTimeLimitDvar( level.gameType, 10, 0, 1440 );
  36.     maps\mp\gametypes\_globallogic::registerScoreLimitDvar( level.gameType, 0, 0, 500 );
  37.     maps\mp\gametypes\_globallogic::registerRoundLimitDvar( level.gameType, 1, 0, 10 );
  38.     maps\mp\gametypes\_globallogic::registerNumLivesDvar( level.gameType, 0, 0, 10 );
  39.  
  40.     if ( !game["tiebreaker"] )
  41.     {
  42.         level.onPrecacheGameType = ::onPrecacheGameType;
  43.         level.onStartGameType = ::onStartGameType;
  44.         level.onSpawnPlayer = ::onSpawnPlayer;
  45.         level.onTimeLimit = ::onTimeLimit;
  46.         level.onDeadEvent = ::onDeadEvent;
  47.         level.onRoundSwitch = ::onRoundSwitch;
  48.    
  49.         level.endGameOnScoreLimit = false;
  50.        
  51.         game["dialog"]["gametype"] = "sabotage";
  52.         game["dialog"]["offense_obj"] = "capture_objs";
  53.         game["dialog"]["defense_obj"] = "capture_objs";
  54.     }
  55.     else
  56.     {
  57.         level.onStartGameType = ::onStartGameType;
  58.         level.onSpawnPlayer = ::onSpawnPlayer;
  59.         level.onEndGame = ::onEndGame;
  60.    
  61.         level.endGameOnScoreLimit = false;
  62.        
  63.         game["dialog"]["gametype"] = "sabotage";
  64.         game["dialog"]["offense_obj"] = "boost";
  65.         game["dialog"]["defense_obj"] = "boost";
  66.  
  67.         maps\mp\gametypes\_globallogic::registerNumLivesDvar( "tb", 1, 1, 1 );
  68.         maps\mp\gametypes\_globallogic::registerTimeLimitDvar( "tb", 0, 0, 0 );
  69.     }
  70.  
  71.     badtrig = getent( "sab_bomb_defuse_allies", "targetname" );
  72.     if ( isdefined( badtrig ) )
  73.         badtrig delete();
  74.  
  75.     badtrig = getent( "sab_bomb_defuse_axis", "targetname" );
  76.     if ( isdefined( badtrig ) )
  77.         badtrig delete();
  78. }
  79.  
  80. onPrecacheGameType()
  81. {
  82.     game["bomb_dropped_sound"] = "mp_war_objective_lost";
  83.     game["bomb_recovered_sound"] = "mp_war_objective_taken";
  84.    
  85.     precacheShader("waypoint_bomb");
  86.     precacheShader("waypoint_kill");
  87.     precacheShader("waypoint_bomb_enemy");
  88.     precacheShader("waypoint_defend");
  89.     precacheShader("waypoint_defuse");
  90.     precacheShader("waypoint_target");
  91.     precacheShader("compass_waypoint_bomb");
  92.     precacheShader("compass_waypoint_defend");
  93.     precacheShader("compass_waypoint_defuse");
  94.     precacheShader("compass_waypoint_target");
  95.     precacheShader("hud_suitcase_bomb");
  96. }
  97.  
  98.  
  99. onRoundSwitch()
  100. {
  101.     if ( !isdefined( game["switchedsides"] ) )
  102.         game["switchedsides"] = false;
  103.    
  104.     if ( game["teamScores"]["allies"] == level.scorelimit - 1 && game["teamScores"]["axis"] == level.scorelimit - 1 )
  105.     {
  106.         level.halftimeType = "overtime";
  107.         level.halftimeSubCaption = &"MP_TIE_BREAKER";
  108.         game["tiebreaker"] = true;
  109.     }
  110.     else
  111.     {
  112.         level.halftimeType = "halftime";
  113.         game["switchedsides"] = !game["switchedsides"];
  114.     }
  115. }
  116.  
  117.  
  118. onStartGameType()
  119. {
  120.     if ( !isdefined( game["switchedsides"] ) )
  121.         game["switchedsides"] = false;
  122.  
  123.     setClientNameMode("auto_change");
  124.    
  125.     game["strings"]["target_destroyed"] = &"MP_TARGET_DESTROYED";
  126.  
  127.     if ( !game["tiebreaker"] )
  128.     {
  129.         maps\mp\gametypes\_globallogic::setObjectiveText( "allies", &"OBJECTIVES_SAB" );
  130.         maps\mp\gametypes\_globallogic::setObjectiveText( "axis", &"OBJECTIVES_SAB" );
  131.    
  132.         if ( level.splitscreen )
  133.         {
  134.             maps\mp\gametypes\_globallogic::setObjectiveScoreText( "allies", &"OBJECTIVES_SAB" );
  135.             maps\mp\gametypes\_globallogic::setObjectiveScoreText( "axis", &"OBJECTIVES_SAB" );
  136.         }
  137.         else
  138.         {
  139.             maps\mp\gametypes\_globallogic::setObjectiveScoreText( "allies", &"OBJECTIVES_SAB_SCORE" );
  140.             maps\mp\gametypes\_globallogic::setObjectiveScoreText( "axis", &"OBJECTIVES_SAB_SCORE" );
  141.         }
  142.         maps\mp\gametypes\_globallogic::setObjectiveHintText( "allies", &"OBJECTIVES_SAB_HINT" );
  143.         maps\mp\gametypes\_globallogic::setObjectiveHintText( "axis", &"OBJECTIVES_SAB_HINT" );
  144.     }
  145.     else
  146.     {
  147.         maps\mp\gametypes\_globallogic::setObjectiveText( "allies", &"OBJECTIVES_WAR" );
  148.         maps\mp\gametypes\_globallogic::setObjectiveText( "axis", &"OBJECTIVES_WAR" );
  149.        
  150.         if ( level.splitscreen )
  151.         {
  152.             maps\mp\gametypes\_globallogic::setObjectiveScoreText( "allies", &"OBJECTIVES_WAR" );
  153.             maps\mp\gametypes\_globallogic::setObjectiveScoreText( "axis", &"OBJECTIVES_WAR" );
  154.         }
  155.         else
  156.         {
  157.             maps\mp\gametypes\_globallogic::setObjectiveScoreText( "allies", &"OBJECTIVES_WAR_SCORE" );
  158.             maps\mp\gametypes\_globallogic::setObjectiveScoreText( "axis", &"OBJECTIVES_WAR_SCORE" );
  159.         }
  160.         maps\mp\gametypes\_globallogic::setObjectiveHintText( "allies", &"OBJECTIVES_WAR_HINT" );
  161.         maps\mp\gametypes\_globallogic::setObjectiveHintText( "axis", &"OBJECTIVES_WAR_HINT" );
  162.     }
  163.    
  164.     level.spawnMins = ( 0, 0, 0 );
  165.     level.spawnMaxs = ( 0, 0, 0 ); 
  166.     maps\mp\gametypes\_spawnlogic::placeSpawnPoints( "mp_sab_spawn_allies_start" );
  167.     maps\mp\gametypes\_spawnlogic::placeSpawnPoints( "mp_sab_spawn_axis_start" );
  168.     maps\mp\gametypes\_spawnlogic::addSpawnPoints( "allies", "mp_sab_spawn_allies" );
  169.     maps\mp\gametypes\_spawnlogic::addSpawnPoints( "axis", "mp_sab_spawn_axis" );
  170.    
  171.     level.mapCenter = maps\mp\gametypes\_spawnlogic::findBoxCenter( level.spawnMins, level.spawnMaxs );
  172.     setMapCenter( level.mapCenter );
  173.  
  174.     level.spawn_axis = getentarray("mp_sab_spawn_axis", "classname");
  175.     level.spawn_allies = getentarray("mp_sab_spawn_allies", "classname");
  176.     level.spawn_axis_start = getentarray("mp_sab_spawn_axis_start", "classname");
  177.     level.spawn_allies_start = getentarray("mp_sab_spawn_allies_start", "classname");
  178.  
  179.     maps\mp\gametypes\_rank::registerScoreInfo( "plant", 20 );
  180.     maps\mp\gametypes\_rank::registerScoreInfo( "defuse", 15 );
  181.  
  182.     if ( game["tiebreaker"] )
  183.     {
  184.         allowed[0] = "war";
  185.         maps\mp\gametypes\_gameobjects::main(allowed);
  186.         return;
  187.     }
  188.  
  189.     allowed[0] = "sab";
  190.     maps\mp\gametypes\_gameobjects::main(allowed);
  191.  
  192.     thread updateGametypeDvars();
  193.    
  194.     thread sabotage();
  195. }
  196.  
  197.  
  198. onTimeLimit()
  199. {
  200.     if ( level.inOvertime )
  201.         return;
  202.  
  203.     thread onOvertime();
  204. }
  205.  
  206.  
  207. onOvertime()
  208. {
  209.     level endon ( "game_ended" );
  210.  
  211.     level.timeLimitOverride = true;
  212.     level.inOvertime = true;
  213.  
  214.     for ( index = 0; index < level.players.size; index++ )
  215.     {
  216.         level.players[index] notify("force_spawn");
  217.         level.players[index] thread maps\mp\gametypes\_hud_message::oldNotifyMessage( &"MP_SUDDEN_DEATH", &"MP_NO_RESPAWN", undefined, (1, 0, 0), "mp_last_stand" );
  218.  
  219.         level.players[index] setClientDvars("cg_deadChatWithDead", 1,
  220.                             "cg_deadChatWithTeam", 0,
  221.                             "cg_deadHearTeamLiving", 0,
  222.                             "cg_deadHearAllLiving", 0,
  223.                             "cg_everyoneHearsEveryone", 0,
  224.                             "g_compassShowEnemies", 1 );
  225.     }
  226.  
  227.     waitTime = 0;
  228.     while ( waitTime < 90 )
  229.     {
  230.         if ( !level.bombPlanted )
  231.         {
  232.             waitTime += 1;
  233.             setGameEndTime( getTime() + ((90-waitTime)*1000) );
  234.         }
  235.         wait ( 1.0 * level.fps_multiplier );
  236.     }
  237.  
  238.     thread maps\mp\gametypes\_globallogic::endGame( "tie", game["strings"]["tie"] );
  239. }
  240.  
  241.  
  242. onDeadEvent( team )
  243. {
  244.     if ( level.bombExploded )
  245.         return;
  246.        
  247.     if ( team == "all" )
  248.     {
  249.         if ( level.bombPlanted )
  250.         {
  251.             [[level._setTeamScore]]( level.bombPlantedBy, [[level._getTeamScore]]( level.bombPlantedBy ) + 1 );
  252.             thread maps\mp\gametypes\_globallogic::endGame( level.bombPlantedBy, game["strings"][level.bombPlantedBy+"_mission_accomplished"] );
  253.         }
  254.         else
  255.         {
  256.             thread maps\mp\gametypes\_globallogic::endGame( "tie", game["strings"]["tie"] );
  257.         }
  258.     }
  259.     else if ( level.bombPlanted )
  260.     {
  261.         if ( team == level.bombPlantedBy )
  262.         {
  263.             level.plantingTeamDead = true;
  264.             return;
  265.         }
  266.            
  267.         [[level._setTeamScore]]( level.bombPlantedBy, [[level._getTeamScore]]( level.bombPlantedBy ) + 1 );
  268.         thread maps\mp\gametypes\_globallogic::endGame( level.bombPlantedBy, game["strings"][level.otherTeam[level.bombPlantedBy]+"_eliminated"] );
  269.     }
  270.     else
  271.     {
  272.         [[level._setTeamScore]]( level.otherTeam[team], [[level._getTeamScore]]( level.otherTeam[team] ) + 1 );
  273.         thread maps\mp\gametypes\_globallogic::endGame( level.otherTeam[team], game["strings"][team+"_eliminated"] );
  274.     }
  275. }
  276.  
  277.  
  278. onSpawnPlayer()
  279. {
  280.     self.isPlanting = false;
  281.     self.isDefusing = false;
  282.     self.isBombCarrier = false;
  283.  
  284.     spawnteam = self.pers["team"];
  285.     if ( game["switchedsides"] )
  286.         spawnteam = getOtherTeam( spawnteam );
  287.  
  288.     if ( level.useStartSpawns )
  289.     {
  290.         if (spawnteam == "axis")
  291.             spawnpoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_Random(level.spawn_axis_start);
  292.         else
  293.             spawnpoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_Random(level.spawn_allies_start);
  294.     }  
  295.     else
  296.     {
  297.         if (spawnteam == "axis")
  298.             spawnpoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_NearTeam(level.spawn_axis);
  299.         else
  300.             spawnpoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_NearTeam(level.spawn_allies);
  301.     }
  302.  
  303.     if ( game["tiebreaker"] )
  304.     {
  305.         self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( &"MP_TIE_BREAKER", &"MP_NO_RESPAWN", undefined, (1, 0, 0), "mp_last_stand" );
  306.    
  307.         hintMessage = maps\mp\gametypes\_globallogic::getObjectiveHintText( self.pers["team"] );
  308.         if ( isDefined( hintMessage ) )
  309.             self thread maps\mp\gametypes\_hud_message::hintMessage( hintMessage );
  310.    
  311.         self setClientDvars("cg_deadChatWithDead", 1,
  312.                             "cg_deadChatWithTeam", 0,
  313.                             "cg_deadHearTeamLiving", 0,
  314.                             "cg_deadHearAllLiving", 0,
  315.                             "cg_everyoneHearsEveryone", 0,
  316.                             "g_compassShowEnemies", 1 );
  317.     }
  318.  
  319.     assert( isDefined(spawnpoint) );
  320.  
  321.     self spawn( spawnpoint.origin, spawnpoint.angles );
  322. }
  323.  
  324.  
  325. updateGametypeDvars()
  326. {
  327.     level.plantTime = dvarFloatValue( "planttime", 5, 0, 20 );
  328.     level.defuseTime = dvarFloatValue( "defusetime", 5, 0, 20 );
  329.     level.bombTimer = dvarFloatValue( "bombtimer", 45, 1, 300 );
  330.     level.hotPotato = dvarIntValue( "hotpotato", 1, 0, 1 );
  331. }
  332.  
  333.  
  334. sabotage()
  335. {
  336.     level.bombPlanted = false;
  337.     level.bombExploded = false;
  338.        
  339.     level._effect["bombexplosion"] = loadfx("explosions/tanker_explosion");
  340.  
  341.     trigger = getEnt( "sab_bomb_pickup_trig", "targetname" );
  342.     if ( !isDefined( trigger ) )
  343.     {
  344.         error( "No sab_bomb_pickup_trig trigger found in map." );
  345.         return;
  346.     }
  347.  
  348.     visuals[0] = getEnt( "sab_bomb", "targetname" );
  349.     if ( !isDefined( visuals[0] ) )
  350.     {
  351.         error( "No sab_bomb script_model found in map." );
  352.         return;
  353.     }
  354.    
  355.     precacheModel( "prop_suitcase_bomb" ); 
  356.     visuals[0] setModel( "prop_suitcase_bomb" );
  357.     level.sabBomb = maps\mp\gametypes\_gameobjects::createCarryObject( "neutral", trigger, visuals, (0,0,32) );
  358.     level.sabBomb maps\mp\gametypes\_gameobjects::allowCarry( "any" );
  359.     level.sabBomb maps\mp\gametypes\_gameobjects::set2DIcon( "enemy", "compass_waypoint_bomb" );
  360.     level.sabBomb maps\mp\gametypes\_gameobjects::set3DIcon( "enemy", "waypoint_bomb" );
  361.     level.sabBomb maps\mp\gametypes\_gameobjects::set2DIcon( "friendly", "compass_waypoint_bomb" );
  362.     level.sabBomb maps\mp\gametypes\_gameobjects::set3DIcon( "friendly", "waypoint_bomb" );
  363.     level.sabBomb maps\mp\gametypes\_gameobjects::setCarryIcon( "hud_suitcase_bomb" );
  364.     level.sabBomb maps\mp\gametypes\_gameobjects::setVisibleTeam( "any" );
  365.     level.sabBomb.objIDPingEnemy = true;
  366.     level.sabBomb.onPickup = ::onPickup;
  367.     level.sabBomb.onDrop = ::onDrop;
  368.     level.sabBomb.allowWeapons = true;
  369.     level.sabBomb.objPoints["allies"].archived = true;
  370.     level.sabBomb.objPoints["axis"].archived = true;
  371.     level.sabBomb.autoResetTime = (60.0 * level.fps_multiplier );
  372.    
  373.     if ( !isDefined( getEnt( "sab_bomb_axis", "targetname" ) ) )
  374.     {
  375.         error("No sab_bomb_axis trigger found in map.");
  376.         return;
  377.     }
  378.     if ( !isDefined( getEnt( "sab_bomb_allies", "targetname" ) ) )
  379.     {
  380.         error("No sab_bomb_allies trigger found in map.");
  381.         return;
  382.     }
  383.  
  384.     if ( game["switchedsides"] )
  385.     {
  386.         level.bombZones["allies"] = createBombZone( "allies", getEnt( "sab_bomb_axis", "targetname" ) );
  387.         level.bombZones["axis"] = createBombZone( "axis", getEnt( "sab_bomb_allies", "targetname" ) );
  388.     }
  389.     else
  390.     {
  391.         level.bombZones["allies"] = createBombZone( "allies", getEnt( "sab_bomb_allies", "targetname" ) );
  392.         level.bombZones["axis"] = createBombZone( "axis", getEnt( "sab_bomb_axis", "targetname" ) );
  393.     }
  394. }
  395.  
  396.  
  397. createBombZone( team, trigger )
  398. {
  399.     visuals = getEntArray( trigger.target, "targetname" );
  400.    
  401.     bombZone = maps\mp\gametypes\_gameobjects::createUseObject( team, trigger, visuals, (0,0,64) );
  402.     bombZone resetBombsite();
  403.     bombZone.onUse = ::onUse;
  404.     bombZone.onBeginUse = ::onBeginUse;
  405.     bombZone.onEndUse = ::onEndUse;
  406.     bombZone.onCantUse = ::onCantUse;
  407.     bombZone.useWeapon = "briefcase_bomb_mp";
  408.    
  409.     for ( i = 0; i < visuals.size; i++ )
  410.     {
  411.         if ( isDefined( visuals[i].script_exploder ) )
  412.         {
  413.             bombZone.exploderIndex = visuals[i].script_exploder;
  414.             break;
  415.         }
  416.     }
  417.    
  418.     return bombZone;
  419. }
  420.  
  421.  
  422. onBeginUse( player )
  423. {
  424.     // planted the bomb
  425.     if ( !self maps\mp\gametypes\_gameobjects::isFriendlyTeam( player.pers["team"] ) )
  426.         player.isPlanting = true;
  427.     else
  428.         player.isDefusing = true;
  429. }
  430.  
  431. onEndUse( team, player, result )
  432. {
  433.     if ( !isAlive( player ) )
  434.         return;
  435.    
  436.     player.isPlanting = false;
  437.     player.isDefusing = false;
  438. }
  439.  
  440.  
  441. onPickup( player )
  442. {
  443.     level notify ( "bomb_picked_up" );
  444.    
  445.     self.autoResetTime = (60.0 * level.fps_multiplier );
  446.    
  447.     level.useStartSpawns = false;
  448.    
  449.     team = player.pers["team"];
  450.    
  451.     if ( team == "allies" )
  452.         otherTeam = "axis";
  453.     else
  454.         otherTeam = "allies";
  455.    
  456.     //player iPrintLnBold( &"MP_YOU_HAVE_RECOVERED_THE_BOMB" );
  457.     player playLocalSound( "mp_suitcase_pickup" );
  458.     player logString( "bomb taken" );
  459.    
  460.     player maps\mp\gametypes\_globallogic::leaderDialogOnPlayer( "obj_destroy", "bomb" );
  461.     excludeList[0] = player;
  462.     maps\mp\gametypes\_globallogic::leaderDialog( "bomb_taken", team, "bomb", excludeList );
  463.  
  464.     if ( !level.splitscreen )
  465.     {
  466.         maps\mp\gametypes\_globallogic::leaderDialog( "bomb_lost", otherTeam );
  467.         maps\mp\gametypes\_globallogic::leaderDialog( "obj_defend", otherTeam );
  468.     }
  469.     player.isBombCarrier = true;
  470.  
  471.     // recovered the bomb before abandonment timer elapsed
  472.     if ( team == self maps\mp\gametypes\_gameobjects::getOwnerTeam() )
  473.     {
  474.         printOnTeamArg( &"MP_EXPLOSIVES_RECOVERED_BY", team, player );
  475.         playSoundOnPlayers( game["bomb_recovered_sound"], team );
  476.     }
  477.     else
  478.     {
  479.         printOnTeamArg( &"MP_EXPLOSIVES_RECOVERED_BY", team, player );
  480. //      printOnTeamArg( &"MP_EXPLOSIVES_RECOVERED_BY", otherTeam, &"MP_THE_ENEMY" );
  481.         playSoundOnPlayers( game["bomb_recovered_sound"] );
  482.     }
  483.    
  484.     self maps\mp\gametypes\_gameobjects::setOwnerTeam( team );
  485.     self maps\mp\gametypes\_gameobjects::setVisibleTeam( "any" );
  486.     self maps\mp\gametypes\_gameobjects::set2DIcon( "enemy", "compass_waypoint_target" );
  487.     self maps\mp\gametypes\_gameobjects::set3DIcon( "enemy", "waypoint_kill" );
  488.     self maps\mp\gametypes\_gameobjects::set2DIcon( "friendly", "compass_waypoint_defend" );
  489.     self maps\mp\gametypes\_gameobjects::set3DIcon( "friendly", "waypoint_defend" );
  490.        
  491.     level.bombZones[team] maps\mp\gametypes\_gameobjects::setVisibleTeam( "none" );
  492.     level.bombZones[otherTeam] maps\mp\gametypes\_gameobjects::setVisibleTeam( "any" );
  493. }
  494.  
  495.  
  496. onDrop( player )
  497. {
  498.     if ( level.bombPlanted )
  499.     {
  500.        
  501.     }
  502.     else
  503.     {
  504.         if ( isDefined( player ) )
  505.             printOnTeamArg( &"MP_EXPLOSIVES_DROPPED_BY", self maps\mp\gametypes\_gameobjects::getOwnerTeam(), player );
  506. //      else
  507. //          printOnTeamArg( &"MP_EXPLOSIVES_DROPPED_BY", self maps\mp\gametypes\_gameobjects::getOwnerTeam(), &"MP_YOUR_TEAM" );
  508.    
  509.         playSoundOnPlayers( game["bomb_dropped_sound"], self maps\mp\gametypes\_gameobjects::getOwnerTeam() );
  510.         if ( isDefined( player ) )
  511.             player logString( "bomb dropped" );
  512.         else
  513.             logString( "bomb dropped" );
  514.            
  515. //      maps\mp\gametypes\_globallogic::leaderDialog( "bomb_lost", player.pers["team"] );
  516.  
  517.         thread abandonmentThink( 0.0 );
  518.     }
  519. }
  520.  
  521.  
  522. abandonmentThink( delay )
  523. {
  524.     level endon ( "bomb_picked_up" );
  525.    
  526.     wait ( delay * level.fps_multiplier );
  527.  
  528.     if ( isDefined( self.carrier ) )
  529.         return;
  530.  
  531.     if ( self maps\mp\gametypes\_gameobjects::getOwnerTeam() == "allies" )
  532.         otherTeam = "axis";
  533.     else
  534.         otherTeam = "allies";
  535.  
  536. //  printOnTeamArg( &"MP_EXPLOSIVES_DROPPED_BY", otherTeam, &"MP_THE_ENEMY" );
  537.     playSoundOnPlayers( game["bomb_dropped_sound"], otherTeam );
  538.  
  539.     self maps\mp\gametypes\_gameobjects::setOwnerTeam( "neutral" );
  540.     self maps\mp\gametypes\_gameobjects::setVisibleTeam( "any" );
  541.     self maps\mp\gametypes\_gameobjects::set2DIcon( "enemy", "compass_waypoint_bomb" );
  542.     self maps\mp\gametypes\_gameobjects::set3DIcon( "enemy", "waypoint_bomb" );
  543.     self maps\mp\gametypes\_gameobjects::set2DIcon( "friendly", "compass_waypoint_bomb" );
  544.     self maps\mp\gametypes\_gameobjects::set3DIcon( "friendly", "waypoint_bomb" );
  545.  
  546.     level.bombZones["allies"] maps\mp\gametypes\_gameobjects::setVisibleTeam( "none" );
  547.     level.bombZones["axis"] maps\mp\gametypes\_gameobjects::setVisibleTeam( "none" );      
  548. }
  549.  
  550.  
  551. onUse( player )
  552. {
  553.     team = player.pers["team"];
  554.     otherTeam = level.otherTeam[team];
  555.     // planted the bomb
  556.     if ( !self maps\mp\gametypes\_gameobjects::isFriendlyTeam( player.pers["team"] ) )
  557.     {
  558.         player notify ( "bomb_planted" );
  559.         player playSound( "mp_bomb_plant" );
  560.         player logString( "bomb planted" );
  561.         if ( !level.hardcoreMode )
  562.         {
  563.             printBoldOnTeamArg( &"MP_EXPLOSIVES_PLANTED_BY", team, player );
  564.             printBoldOnTeam( &"MP_EXPLOSIVES_PLANTED", otherTeam );
  565.         }
  566.         iPrintLn( &"MP_EXPLOSIVES_PLANTED_BY", player );
  567.         maps\mp\gametypes\_globallogic::leaderDialog( "bomb_planted" );
  568.  
  569.         maps\mp\gametypes\_globallogic::givePlayerScore( "plant", player );
  570.         player thread [[level.onXPEvent]]( "plant" );
  571.         level thread bombPlanted( self, player.pers["team"] );
  572.  
  573.         level.bombOwner = player;
  574.  
  575. //      self.keyObject maps\mp\gametypes\_gameobjects::disableObject();
  576.         level.sabBomb.autoResetTime = undefined;
  577.         level.sabBomb maps\mp\gametypes\_gameobjects::allowCarry( "none" );
  578.         level.sabBomb maps\mp\gametypes\_gameobjects::setVisibleTeam( "none" );
  579.         level.sabBomb maps\mp\gametypes\_gameobjects::setDropped();
  580.         self.useWeapon = "briefcase_bomb_defuse_mp";
  581.        
  582.         self setUpForDefusing();
  583.     }
  584.     else // defused the bomb
  585.     {
  586.         player notify ( "bomb_defused" );
  587.         player logString( "bomb defused" );
  588.         if ( !level.hardcoreMode )
  589.             iPrintLn( &"MP_EXPLOSIVES_DEFUSED_BY", player );
  590.         maps\mp\gametypes\_globallogic::leaderDialog( "bomb_defused" );
  591.  
  592.         maps\mp\gametypes\_globallogic::givePlayerScore( "defuse", player );
  593.         player thread [[level.onXPEvent]]( "defuse" );
  594.  
  595.         level thread bombDefused( self );
  596.        
  597.         if ( level.inOverTime && isDefined( level.plantingTeamDead ) )
  598.         {
  599.             thread maps\mp\gametypes\_globallogic::endGame( player.pers["team"], game["strings"][level.bombPlantedBy+"_eliminated"] );
  600.             return;
  601.         }
  602.        
  603.         self resetBombsite();
  604.        
  605.         level.sabBomb maps\mp\gametypes\_gameobjects::allowCarry( "any" );
  606.         level.sabBomb maps\mp\gametypes\_gameobjects::setPickedUp( player );
  607.     }
  608. }
  609.  
  610.  
  611. onCantUse( player )
  612. {
  613.     player iPrintLnBold( &"MP_CANT_PLANT_WITHOUT_BOMB" );
  614. }
  615.  
  616.  
  617. bombPlanted( destroyedObj, team )
  618. {
  619.     maps\mp\gametypes\_globallogic::pauseTimer();
  620.     level.bombPlanted = true;
  621.     level.bombPlantedBy = team;
  622.     level.timeLimitOverride = true;
  623.     setDvar( "ui_bomb_timer", 1 );
  624.    
  625.     // communicate timer information to menus
  626.     setGameEndTime( int( getTime() + (level.bombTimer * 1000) ) );
  627.    
  628.     destroyedObj.visuals[0] thread maps\mp\gametypes\_globallogic::playTickingSound();
  629.    
  630.     starttime = gettime();
  631.     bombTimerWait();
  632.    
  633.     setDvar( "ui_bomb_timer", 0 );
  634.     destroyedObj.visuals[0] maps\mp\gametypes\_globallogic::stopTickingSound();
  635.  
  636.     if ( !level.bombPlanted )
  637.     {
  638.         if ( level.hotPotato )
  639.         {
  640.             timePassed = (gettime() - starttime) / 1000;
  641.             level.bombTimer -= timePassed;
  642.         }
  643.         return;
  644.     }
  645.     /*
  646.     for ( index = 0; index < level.players.size; index++ )
  647.     {
  648.         player = level.players[index];
  649.         if ( player.pers["team"] == team )
  650.             player thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "Your team scored!", undefined, undefined, (0, 1, 0) );
  651.         else if ( player.pers["team"] == level.otherTeam[team] )
  652.             player thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "Enemy team scored!", undefined, undefined, (1, 0, 0) );
  653.     }
  654.     */
  655.     explosionOrigin = level.sabBomb.visuals[0].origin;
  656.     level.bombExploded = true; 
  657.    
  658.     if ( isdefined( level.bombowner ) )
  659.         destroyedObj.visuals[0] radiusDamage( explosionOrigin, 512, 200, 20, level.bombowner );
  660.     else
  661.     destroyedObj.visuals[0] radiusDamage( explosionOrigin, 512, 200, 20 );
  662.    
  663.     rot = randomfloat(360);
  664.     explosionEffect = spawnFx( level._effect["bombexplosion"], explosionOrigin + (0,0,50), (0,0,1), (cos(rot),sin(rot),0) );
  665.     triggerFx( explosionEffect );
  666.    
  667.     thread playSoundinSpace( "exp_suitcase_bomb_main", explosionOrigin );
  668.    
  669.     if ( isDefined( destroyedObj.exploderIndex ) )
  670.         exploder( destroyedObj.exploderIndex );
  671.    
  672.     [[level._setTeamScore]]( team, [[level._getTeamScore]]( team ) + 1 );
  673.    
  674.     setGameEndTime( 0 );
  675.    
  676.     wait (3 * level.fps_multiplier );
  677.    
  678.     // end the round without resetting the timer
  679.     thread maps\mp\gametypes\_globallogic::endGame( team, game["strings"]["target_destroyed"] );
  680. }
  681.  
  682.  
  683. playSoundinSpace( alias, origin )
  684. {
  685.     org = spawn( "script_origin", origin );
  686.     org.origin = origin;
  687.     org playSound( alias  );
  688.     wait (10 * level.fps_multiplier ); // MP doesn't have "sounddone" notifies =(
  689.     org delete();
  690. }
  691.  
  692.  
  693. bombTimerWait()
  694. {
  695.     level endon("bomb_defused");
  696.     wait (level.bombTimer * level.fps_multiplier );
  697. }
  698.  
  699.  
  700. resetBombsite()
  701. {
  702.     self maps\mp\gametypes\_gameobjects::allowUse( "enemy" );
  703.     self maps\mp\gametypes\_gameobjects::setUseTime( level.plantTime * level.fps_multiplier );
  704.     self maps\mp\gametypes\_gameobjects::setUseText( &"MP_PLANTING_EXPLOSIVE" );
  705.     self maps\mp\gametypes\_gameobjects::setUseHintText( &"PLATFORM_HOLD_TO_PLANT_EXPLOSIVES" );
  706.     self maps\mp\gametypes\_gameobjects::setKeyObject( level.sabBomb );
  707.     self maps\mp\gametypes\_gameobjects::set2DIcon( "friendly", "compass_waypoint_defend" );
  708.     self maps\mp\gametypes\_gameobjects::set3DIcon( "friendly", "waypoint_defend" );
  709.     self maps\mp\gametypes\_gameobjects::set2DIcon( "enemy", "compass_waypoint_target" );
  710.     self maps\mp\gametypes\_gameobjects::set3DIcon( "enemy", "waypoint_target" );
  711.     self maps\mp\gametypes\_gameobjects::setVisibleTeam( "none" );
  712.     self.useWeapon = "briefcase_bomb_mp";
  713. }
  714.  
  715. setUpForDefusing()
  716. {
  717.     self maps\mp\gametypes\_gameobjects::allowUse( "friendly" );
  718.     self maps\mp\gametypes\_gameobjects::setUseTime( level.defuseTime * level.fps_multiplier );
  719.     self maps\mp\gametypes\_gameobjects::setUseText( &"MP_DEFUSING_EXPLOSIVE" );
  720.     self maps\mp\gametypes\_gameobjects::setUseHintText( &"PLATFORM_HOLD_TO_DEFUSE_EXPLOSIVES" );
  721.     self maps\mp\gametypes\_gameobjects::setKeyObject( undefined );
  722.     self maps\mp\gametypes\_gameobjects::set2DIcon( "friendly", "compass_waypoint_defuse" );
  723.     self maps\mp\gametypes\_gameobjects::set3DIcon( "friendly", "waypoint_defuse" );
  724.     self maps\mp\gametypes\_gameobjects::set2DIcon( "enemy", "compass_waypoint_defend" );
  725.     self maps\mp\gametypes\_gameobjects::set3DIcon( "enemy", "waypoint_defend" );
  726.     self maps\mp\gametypes\_gameobjects::setVisibleTeam( "any" );
  727. }
  728.  
  729.  
  730. bombDefused( object )
  731. {
  732.     setDvar( "ui_bomb_timer", 0 );
  733.     maps\mp\gametypes\_globallogic::resumeTimer();
  734.     level.bombPlanted = false;
  735.     if ( !level.inOvertime )
  736.         level.timeLimitOverride = false;
  737.  
  738.     level notify("bomb_defused");  
  739. }
  740.  
  741.  
  742. onEndGame( winningTeam )
  743. {
  744.     if ( isdefined( winningTeam ) && (winningTeam == "allies" || winningTeam == "axis") )
  745.         [[level._setTeamScore]]( winningTeam, [[level._getTeamScore]]( winningTeam ) + 1 );
  746. }

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.