‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
tdm.gsc
Go to the documentation of this file.
1 #using scripts\shared\gameobjects_shared;
2 #using scripts\shared\math_shared;
3 #using scripts\shared\util_shared;
4 
5 #insert scripts\shared\shared.gsh;
6 
7 #using scripts\mp\gametypes\_globallogic;
8 #using scripts\mp\gametypes\_globallogic_audio;
9 #using scripts\mp\gametypes\_globallogic_score;
10 #using scripts\mp\gametypes\_globallogic_spawn;
11 #using scripts\mp\gametypes\_spawning;
12 #using scripts\mp\gametypes\_spawnlogic;
13 #using scripts\mp\killstreaks\_killstreaks;
14 #using scripts\mp\gametypes\_dogtags;
15 
16 #using scripts\mp\_teamops;
17 
18 #using scripts\mp\_util;
19 
20 /*
21  TDM - Team Deathmatch
22  Objective: Score points for your team by eliminating players on the opposing team
23  Map ends: When one team reaches the score limit, or time limit is reached
24  Respawning: No wait / Near teammates
25 
26  Level requirements
27  ------------------
28  Spawnpoints:
29  classname mp_tdm_spawn
30  All players spawn from these. The spawnpoint chosen is dependent on the current locations of teammates and enemies
31  at the time of spawn. Players generally spawn behind their teammates relative to the direction of enemies.
32 
33  Spectator Spawnpoints:
34  classname mp_global_intermission
35  Spectators spawn from these and intermission is viewed from these positions.
36  Atleast one is required, any more and they are randomly chosen between.
37 
38  Level script requirements
39  -------------------------
40  Team Definitions:
41  game["allies"] = "marines";
42  game["axis"] = "nva";
43  game["team3"] = "guys_who_hate_both_other_teams";
44  This sets the nationalities of the teams. Allies can be american, british, or russian. Axis can be german.
45 
46  If using minefields or exploders:
47  load::main();
48 
49  Optional level script settings
50  ------------------------------
51  Soldier Type and Variation:
52  game["soldiertypeset"] = "seals";
53  This sets what character models are used for each nationality on a particular map.
54 
55  Valid settings:
56  soldiertypeset seals
57 */
58 
59 /*QUAKED mp_tdm_spawn (0.0 0.0 1.0) (-16 -16 0) (16 16 72)
60 Players spawn away from enemies and near their team at one of these positions.*/
61 
62 /*QUAKED mp_tdm_spawn_axis_start (0.5 0.0 1.0) (-16 -16 0) (16 16 72)
63 Axis players spawn away from enemies and near their team at one of these positions at the start of a round.*/
64 
65 /*QUAKED mp_tdm_spawn_allies_start (0.0 0.5 1.0) (-16 -16 0) (16 16 72)
66 Allied players spawn away from enemies and near their team at one of these positions at the start of a round.*/
67 
68 /*QUAKED mp_tdm_spawn_team1_start (0.5 0.5 1.0) (-16 -16 0) (16 16 72)
69 Allied players spawn away from enemies and near their team at one of these positions at the start of a round.*/
70 
71 /*QUAKED mp_tdm_spawn_team2_start (0.5 0.5 1.0) (-16 -16 0) (16 16 72)
72 Allied players spawn away from enemies and near their team at one of these positions at the start of a round.*/
73 
74 /*QUAKED mp_tdm_spawn_team3_start (0.5 0.5 1.0) (-16 -16 0) (16 16 72)
75 Allied players spawn away from enemies and near their team at one of these positions at the start of a round.*/
76 
77 /*QUAKED mp_tdm_spawn_team4_start (0.5 0.5 1.0) (-16 -16 0) (16 16 72)
78 Allied players spawn away from enemies and near their team at one of these positions at the start of a round.*/
79 
80 /*QUAKED mp_tdm_spawn_team5_start (0.5 0.5 1.0) (-16 -16 0) (16 16 72)
81 Allied players spawn away from enemies and near their team at one of these positions at the start of a round.*/
82 
83 /*QUAKED mp_tdm_spawn_team6_start (0.5 0.5 1.0) (-16 -16 0) (16 16 72)
84 Allied players spawn away from enemies and near their team at one of these positions at the start of a round.*/
85 
86 #precache( "string", "OBJECTIVES_TDM" );
87 #precache( "string", "OBJECTIVES_TDM_SCORE" );
88 #precache( "string", "OBJECTIVES_TDM_HINT" );
89 
90 function ‪main()
91 {
93 
95  ‪util::registerTimeLimit( 0, 1440 );
96  ‪util::registerScoreLimit( 0, 50000 );
99  ‪util::registerNumLives( 0, 100 );
100 
101  ‪globallogic::registerFriendlyFireDelay( level.gameType, 15, 0, 1440 );
102 
103  level.scoreRoundWinBased = ( GetGametypeSetting( "cumulativeRoundScores" ) == false );
104  level.teamScorePerKill = GetGametypeSetting( "teamScorePerKill" );
105  level.teamScorePerDeath = GetGametypeSetting( "teamScorePerDeath" );
106  level.teamScorePerHeadshot = GetGametypeSetting( "teamScorePerHeadshot" );
107  level.killstreaksGiveGameScore = GetGametypeSetting( "killstreaksGiveGameScore" );
108  level.teamBased = true;
109  level.overrideTeamScore = true;
110  level.onStartGameType =&‪onStartGameType;
111  level.onSpawnPlayer =&‪onSpawnPlayer;
112  level.onRoundEndGame =&‪onRoundEndGame;
113  level.onRoundSwitch =&‪onRoundSwitch;
114  level.onPlayerKilled =&‪onPlayerKilled;
115 
117 
118  ‪globallogic_audio::set_leader_gametype_dialog ( "startTeamDeathmatch", "hcStartTeamDeathmatch", "gameBoost", "gameBoost" );
119 
120  // Sets the scoreboard columns and determines with data is sent across the network
121  ‪globallogic::setvisiblescoreboardcolumns( "score", "kills", "deaths", "kdratio", "assists" );
122 }
123 
125 {
126  setClientNameMode("auto_change");
127 
128  if ( !isdefined( game["switchedsides"] ) )
129  game["switchedsides"] = false;
130 
131  if ( game["switchedsides"] )
132  {
133  oldAttackers = game["attackers"];
134  oldDefenders = game["defenders"];
135  game["attackers"] = oldDefenders;
136  game["defenders"] = oldAttackers;
137  }
138 
139  level.displayRoundEndText = false;
140 
141  // now that the game objects have been deleted place the influencers
143 
144  level.spawnMins = ( 0, 0, 0 );
145  level.spawnMaxs = ( 0, 0, 0 );
146 
147  foreach( team in level.teams )
148  {
149  ‪util::setObjectiveText( team, &"OBJECTIVES_TDM" );
150  ‪util::setObjectiveHintText( team, &"OBJECTIVES_TDM_HINT" );
151 
152  if ( level.splitscreen )
153  {
154  ‪util::setObjectiveScoreText( team, &"OBJECTIVES_TDM" );
155  }
156  else
157  {
158  ‪util::setObjectiveScoreText( team, &"OBJECTIVES_TDM_SCORE" );
159  }
160 
161  ‪spawnlogic::add_spawn_points( team, "mp_tdm_spawn" );
162 
163 
165  }
166 
168 
169  level.spawn_start = [];
170 
171  foreach( team in level.teams )
172  {
173  level.spawn_start[ team ] = ‪spawnlogic::get_spawnpoint_array( ‪spawning::getTDMStartSpawnName(team) );
174  }
175 
176  level.mapCenter = ‪math::find_box_center( level.spawnMins, level.spawnMaxs );
177  setMapCenter( level.mapCenter );
178 
180  setDemoIntermissionPoint( spawnpoint.origin, spawnpoint.angles );
181 
182 
183 
184  //removed action loop -CDC
185  level thread ‪onScoreCloseMusic();
186 
187  if ( !‪util::isOneRound() )
188  {
189  level.displayRoundEndText = true;
190  if( level.scoreRoundWinBased )
191  {
193  }
194  }
195 
196  if( ‪IS_TRUE( level.droppedTagRespawn ) )
197  level.numLives = 1;
198 }
199 
200 function ‪onSpawnPlayer(predictedSpawn)
201 {
202  self.usingObj = undefined;
203 
204  if ( level.useStartSpawns && !level.inGracePeriod && !level.playerQueuedRespawn )
205  {
206  level.useStartSpawns = false;
207  }
208 
209  ‪spawning::onSpawnPlayer(predictedSpawn);
210 }
211 
212 function ‪onEndGame( winningTeam )
213 {
214  if ( isdefined( winningTeam ) && isdefined( level.teams[winningTeam] ) )
216 }
217 
219 {
220  game["switchedsides"] = !game["switchedsides"];
221 
222  if ( level.scoreRoundWinBased )
223  {
224  foreach( team in level.teams )
225  {
226  [[level._setTeamScore]]( team, game["roundswon"][team] );
227  }
228  }
229 }
230 
231 function ‪onRoundEndGame( roundWinner )
232 {
233  if ( level.scoreRoundWinBased )
234  {
235  foreach( team in level.teams )
236  {
237  [[level._setTeamScore]]( team, game["roundswon"][team] );
238  }
239  }
240 
241  return [[level.determineWinner]]();
242 }
243 
245 {
246  teamScores = [];
247 
248  while( !level.gameEnded )
249  {
250  scoreLimit = level.scoreLimit;
251  scoreThreshold = scoreLimit * .1;
252  scoreThresholdStart = abs(scoreLimit - scoreThreshold);
253  scoreLimitCheck = scoreLimit - 10;
254 
255  topScore = 0;
256  runnerUpScore = 0;
257  foreach( team in level.teams )
258  {
259  score = [[level._getTeamScore]]( team );
260 
261  if ( score > topScore )
262  {
263  runnerUpScore = topScore;
264  topScore = score;
265  }
266  else if ( score > runnerUpScore )
267  {
268  runnerUpScore = score;
269  }
270  }
271 
272  scoreDif = (topScore - runnerUpScore);
273 
274  if( topScore >= scoreLimit*.5)
275  {
276  level notify( "sndMusicHalfway" );
277  return;
278  }
279 
280  wait(1);
281  }
282 }
283 
284 function ‪onPlayerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration )
285 {
286  if( ‪IS_TRUE( level.droppedTagRespawn ) )
287  {
289 
290  ‪should_spawn_tags = self ‪dogtags::should_spawn_tags(eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration);
291 
292  // we should spawn tags if one the previous statements were true and we may not spawn
294 
296  level thread ‪dogtags::spawn_dog_tag( self, attacker, &‪dogtags::onUseDogTag, false );
297  }
298 
299  if ( isPlayer( attacker ) == false || attacker.team == self.team )
300  return;
301 
302  if( !isdefined( ‪killstreaks::get_killstreak_for_weapon( weapon ) ) || ‪IS_TRUE( level.killstreaksGiveGameScore ) )
303  {
304  attacker ‪globallogic_score::giveTeamScoreForObjective( attacker.team, level.teamScorePerKill );
305  self ‪globallogic_score::giveTeamScoreForObjective( self.team, level.teamScorePerDeath * -1 );
306  if ( sMeansOfDeath == "MOD_HEAD_SHOT" )
307  {
308  attacker ‪globallogic_score::giveTeamScoreForObjective( attacker.team, level.teamScorePerHeadshot );
309  }
310  }
311 }
‪setObjectiveText
‪function setObjectiveText(team, text)
Definition: _util.gsc:585
‪onRoundSwitch
‪function onRoundSwitch()
Definition: tdm.gsc:218
‪setvisiblescoreboardcolumns
‪function setvisiblescoreboardcolumns(col1, col2, col3, col4, col5)
Definition: _globallogic.gsc:545
‪isOneRound
‪function isOneRound()
Definition: util_shared.gsc:3497
‪updateAllSpawnPoints
‪function updateAllSpawnPoints()
Definition: _spawning.gsc:551
‪registerRoundWinLimit
‪function registerRoundWinLimit(minValue, maxValue)
Definition: _util.gsc:630
‪register_allowed_gameobject
‪function register_allowed_gameobject(gameobject)
Definition: gameobjects_shared.gsc:67
‪onEndGame
‪function onEndGame(winningTeam)
Definition: tdm.gsc:212
‪find_box_center
‪function find_box_center(mins, maxs)
Definition: math_shared.gsc:86
‪resetTeamScores
‪function resetTeamScores()
Definition: _globallogic_score.gsc:808
‪maySpawn
‪function maySpawn()
Definition: _globallogic_spawn.gsc:93
‪registerFriendlyFireDelay
‪function registerFriendlyFireDelay(dvarString, defaultValue, minValue, maxValue)
Definition: _globallogic.gsc:3917
‪checkAllowSpectating
‪function checkAllowSpectating()
Definition: _dogtags.gsc:346
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪registerNumLives
‪function registerNumLives(minValue, maxValue, teamLivesMinValue, teamLivesMaxValue)
Definition: _util.gsc:664
‪registerScoreLimit
‪function registerScoreLimit(minValue, maxValue)
Definition: _util.gsc:638
‪add_spawn_points
‪function add_spawn_points(team, spawnPointName)
Definition: _spawnlogic.gsc:20
‪onScoreCloseMusic
‪function onScoreCloseMusic()
Definition: tdm.gsc:244
‪create_map_placed_influencers
‪function create_map_placed_influencers()
Definition: _spawning.gsc:522
‪get_killstreak_for_weapon
‪function get_killstreak_for_weapon(weapon)
Definition: _killstreaks.gsc:1357
‪should_spawn_tags
‪function should_spawn_tags(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration)
Definition: _dogtags.gsc:373
‪set_leader_gametype_dialog
‪function set_leader_gametype_dialog(startGameDialogKey, startHcGameDialogKey, offenseOrderDialogKey, defenseOrderDialogKey)
Definition: _globallogic_audio.gsc:92
‪onRoundEndGame
‪function onRoundEndGame(roundWinner)
Definition: tdm.gsc:231
‪onUseDogTag
‪function onUseDogTag(player)
Definition: _dogtags.gsc:397
‪place_spawn_points
‪function place_spawn_points(spawnPointName)
Definition: _spawnlogic.gsc:22
‪get_spawnpoint_array
‪function get_spawnpoint_array(classname)
Definition: _spawnlogic.gsc:27
‪setObjectiveHintText
‪function setObjectiveHintText(team, text)
Definition: _util.gsc:595
‪main
‪function main()
Definition: tdm.gsc:90
‪registerRoundSwitch
‪function registerRoundSwitch(minValue, maxValue)
Definition: _util.gsc:615
‪onPlayerKilled
‪function onPlayerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration)
Definition: tdm.gsc:284
‪registerRoundLimit
‪function registerRoundLimit(minValue, maxValue)
Definition: _util.gsc:622
‪init
‪function init()
Definition: struct.csc:1
‪getTDMStartSpawnName
‪function getTDMStartSpawnName(team)
Definition: _spawning.gsc:1067
‪spawn_dog_tag
‪function spawn_dog_tag(victim, attacker, on_use_function, objectives_for_attacker_and_victim_only)
Definition: _dogtags.gsc:32
‪giveTeamScoreForObjective
‪function giveTeamScoreForObjective(team, score)
Definition: _globallogic_score.gsc:773
‪setObjectiveScoreText
‪function setObjectiveScoreText(team, text)
Definition: _util.gsc:590
‪onSpawnPlayer
‪function onSpawnPlayer(predictedSpawn)
Definition: tdm.gsc:200
‪onStartGameType
‪function onStartGameType()
Definition: tdm.gsc:124
‪registerTimeLimit
‪function registerTimeLimit(minValue, maxValue)
Definition: _util.gsc:655
‪get_random_intermission_point
‪function get_random_intermission_point()
Definition: _spawnlogic.gsc:54