‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_globallogic_defaults.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\killstreaks_shared;
4 #using scripts\shared\math_shared;
5 #using scripts\shared\rank_shared;
6 
7 #insert scripts\shared\shared.gsh;
8 
9 #using scripts\mp\gametypes\_globallogic;
10 #using scripts\mp\gametypes\_globallogic_audio;
11 #using scripts\mp\gametypes\_globallogic_score;
12 #using scripts\mp\gametypes\_globallogic_utils;
13 #using scripts\mp\gametypes\_spawnlogic;
14 
15 #using scripts\mp\_util;
16 #using scripts\mp\killstreaks\_killstreaks;
17 
18 #namespace globallogic_defaults;
19 
20 function ‪getWinningTeamFromLoser( losing_team )
21 {
22  if ( level.multiTeam )
23  {
24  return "tie";
25  }
26  return util::getotherteam(losing_team);
27 }
28 
29 // when a team leaves completely, that team forfeited, team left wins round, ends game
30 function ‪default_onForfeit( team )
31 {
32  level.gameForfeited= true;
33 
34  level notify ( "forfeit in progress" ); //ends all other forfeit threads attempting to run
35  level endon( "forfeit in progress" ); //end if another forfeit thread is running
36  level endon( "abort forfeit" ); //end if the team is no longer in forfeit status
37 
38  forfeit_delay = 20.0; //forfeit wait, for switching teams and such
39 
40  announcement( game["strings"]["opponent_forfeiting_in"], forfeit_delay, 0 );
41  wait (10.0);
42  announcement( game["strings"]["opponent_forfeiting_in"], 10.0, 0 );
43  wait (10.0);
44 
45  endReason = &"";
46  if ( level.multiTeam )
47  {
48  SetDvar( "ui_text_endreason", game["strings"]["other_teams_forfeited"] );
49  endReason = game["strings"]["other_teams_forfeited"];
50  winner = team;
51  }
52  else if ( !isdefined( team ) )
53  {
54  SetDvar( "ui_text_endreason", game["strings"]["players_forfeited"] );
55  endReason = game["strings"]["players_forfeited"];
56  winner = level.players[0];
57  }
58  else if ( isdefined( level.teams[team] ) )
59  {
60  endReason = game["strings"][team+"_forfeited"];
61  SetDvar( "ui_text_endreason", endReason );
62  winner = ‪getWinningTeamFromLoser( team );
63  }
64  else
65  {
66  //shouldn't get here
67  assert( isdefined( team ), "Forfeited team is not defined" );
68  assert( 0, "Forfeited team " + team + " is not allies or axis" );
69  winner = "tie";
70  }
71  //exit game, last round, no matter if round limit reached or not
72  level.forcedEnd = true;
73  /#
74  if ( isPlayer( winner ) )
75  print( "forfeit, win: " + winner getXuid() + "(" + winner.name + ")" );
76  else
77  ‪globallogic_utils::logTeamWinString( "forfeit", winner );
78  #/
79  thread ‪globallogic::endGame( winner, endReason );
80 }
81 
82 
83 function ‪default_onDeadEvent( team )
84 {
85  if ( isdefined( level.teams[team] ) )
86  {
87  eliminatedString = game["strings"][team + "_eliminated"];
88  iPrintLn( eliminatedString );
89  //makeDvarServerInfo( "ui_text_endreason", eliminatedString );
90  SetDvar( "ui_text_endreason", eliminatedString );
91 
92  winner = ‪getWinningTeamFromLoser( team );
93  ‪globallogic_utils::logTeamWinString( "team eliminated", winner );
94 
95  thread ‪globallogic::endGame( winner, eliminatedString );
96  }
97  else
98  {
99  //makeDvarServerInfo( "ui_text_endreason", game["strings"]["tie"] );
100  SetDvar( "ui_text_endreason", game["strings"]["tie"] );
101 
103 
104  if ( level.teamBased )
105  thread ‪globallogic::endGame( "tie", game["strings"]["tie"] );
106  else
107  thread ‪globallogic::endGame( undefined, game["strings"]["tie"] );
108  }
109 }
110 
112 {
113  if ( isdefined( level.teams[team] ) )
114  {
115  eliminatedString = game["strings"]["enemies_eliminated"];
116  iPrintLn( eliminatedString );
117  //makeDvarServerInfo( "ui_text_endreason", eliminatedString );
118  SetDvar( "ui_text_endreason", eliminatedString );
119 
120  winner = ‪globallogic::determineTeamWinnerByGameStat( "teamScores" );
121  ‪globallogic_utils::logTeamWinString( "team eliminated", winner );
122 
123  thread ‪globallogic::endGame( winner, eliminatedString );
124  }
125  else
126  {
127  //makeDvarServerInfo( "ui_text_endreason", game["strings"]["tie"] );
128  SetDvar( "ui_text_endreason", game["strings"]["tie"] );
129 
131 
132  if ( level.teamBased )
133  thread ‪globallogic::endGame( "tie", game["strings"]["tie"] );
134  else
135  thread ‪globallogic::endGame( undefined, game["strings"]["tie"] );
136  }
137 }
138 
140 {
141 }
142 
143 function ‪default_onRoundEndGame( winner )
144 {
145  return winner;
146 }
147 
148 // T8 - We should get rid of the return from onRoundEndGame in favor of this
149 function ‪default_determineWinner( roundWinner )
150 {
151  if ( isdefined( game["overtime_round"] ) )
152  {
153  if ( ‪IS_TRUE( level.doubleOvertime ) &&
154  isdefined( roundWinner ) &&
155  roundWinner != "tie" )
156  {
157  return roundWinner;
158  }
159 
160  return ‪globallogic::determineTeamWinnerByGameStat( "overtimeroundswon" );
161  }
162 
163  if ( level.scoreRoundWinBased )
164  {
165  winner = ‪globallogic::determineTeamWinnerByGameStat( "roundswon" );
166  }
167  else
168  {
170  }
171 
172  return winner;
173 }
174 
176 {
177  if ( !level.teamBased )
178  {
180  /#
181  if ( isdefined( winner ) )
182  print( "last one alive, win: " + winner.name );
183  else
184  print( "last one alive, win: unknown" );
185  #/
186  thread ‪globallogic::endGame( winner, &"MP_ENEMIES_ELIMINATED" );
187  }
188  else
189  {
190  for ( index = 0; index < level.players.size; index++ )
191  {
192  player = level.players[index];
193 
194  if ( !isAlive( player ) )
195  continue;
196 
197  if ( !isdefined( player.pers["team"] ) || player.pers["team"] != team )
198  continue;
199 
200  player ‪globallogic_audio::leader_dialog_on_player( "sudden_death" );
201  }
202  }
203 }
204 
205 
207 {
208  winner = undefined;
209 
210  if ( level.teamBased )
211  {
212  winner = ‪globallogic::determineTeamWinnerByGameStat( "teamScores" );
213 
214  ‪globallogic_utils::logTeamWinString( "time limit", winner );
215  }
216  else
217  {
219  /#
220  if ( isdefined( winner ) )
221  print( "time limit, win: " + winner.name );
222  else
223  print( "time limit, tie" );
224  #/
225  }
226 
227  // i think these two lines are obsolete
228  //makeDvarServerInfo( "ui_text_endreason", game["strings"]["time_limit_reached"] );
229  SetDvar( "ui_text_endreason", game["strings"]["time_limit_reached"] );
230 
231  thread ‪globallogic::endGame( winner, game["strings"]["time_limit_reached"] );
232 }
233 
235 {
236  if ( !level.endGameOnScoreLimit )
237  return false;
238 
239  winner = undefined;
240 
241  if ( level.teamBased )
242  {
243  winner = ‪globallogic::determineTeamWinnerByGameStat( "teamScores" );
244 
245  ‪globallogic_utils::logTeamWinString( "scorelimit", winner );
246  }
247  else
248  {
250  /#
251  if ( isdefined( winner ) )
252  print( "scorelimit, win: " + winner.name );
253  else
254  print( "scorelimit, tie" );
255  #/
256  }
257 
258  //makeDvarServerInfo( "ui_text_endreason", game["strings"]["score_limit_reached"] );
259  SetDvar( "ui_text_endreason", game["strings"]["score_limit_reached"] );
260 
261  thread ‪globallogic::endGame( winner, game["strings"]["score_limit_reached"] );
262  return true;
263 }
264 
265 
267 {
268  winner = undefined;
269 
270  if ( level.teamBased )
271  {
272  winner = ‪globallogic::determineTeamWinnerByGameStat( "teamScores" );
273 
274  ‪globallogic_utils::logTeamWinString( "roundscorelimit", winner );
275  }
276  else
277  {
279  /#
280  if ( isdefined( winner ) )
281  print( "roundscorelimit, win: " + winner.name );
282  else
283  print( "roundscorelimit, tie" );
284  #/
285  }
286 
287  //makeDvarServerInfo( "ui_text_endreason", game["strings"]["round_score_limit_reached"] );
288  SetDvar( "ui_text_endreason", game["strings"]["round_score_limit_reached"] );
289 
290  thread ‪globallogic::endGame( winner, game["strings"]["round_score_limit_reached"] );
291  return true;
292 }
293 
294 
295 function ‪default_onSpawnSpectator( origin, angles)
296 {
297  if( isdefined( origin ) && isdefined( angles ) )
298  {
299  self ‪spawn(origin, angles);
300  return;
301  }
302 
303  spawnpoints = ‪spawnlogic::_get_spawnpoint_array( "mp_global_intermission" );
304  assert( spawnpoints.size, "There are no mp_global_intermission spawn points in the map. There must be at least one." );
305  spawnpoint = ‪spawnlogic::get_spawnpoint_random(spawnpoints);
306 
307  self ‪spawn(spawnpoint.origin, spawnpoint.angles);
308 }
309 
311 {
312  if ( ‪IS_TRUE( ‪endGame ) )
313  {
314  // The client camera is handled in client script via an xcam
315  return;
316  }
317 
319 
320  if( isdefined( spawnpoint ) )
321  {
322  self ‪spawn( spawnpoint.origin, spawnpoint.angles );
323  }
324  else
325  {
326  /#
327  println( "NO mp_global_intermission SPAWNPOINTS IN MAP" );
328  #/
329  }
330 }
331 
333 {
334  return ‪math::clamp( GetGametypeSetting( "timeLimit" ), level.timeLimitMin, level.timeLimitMax );
335 }
336 
337 function ‪default_getTeamKillPenalty( eInflictor, attacker, sMeansOfDeath, weapon )
338 {
339  teamkill_penalty = 1;
340 
341  if ( ‪killstreaks::is_killstreak_weapon( weapon ) )
342  {
343  teamkill_penalty *= ‪killstreaks::get_killstreak_team_kill_penalty_scale( weapon );
344  }
345 
346  return teamkill_penalty;
347 }
348 
349 function ‪default_getTeamKillScore( eInflictor, attacker, sMeansOfDeath, weapon )
350 {
351  return ‪rank::getScoreInfoValue( "team_kill" );
352 }
353 
354 
‪endGame
‪function endGame(winner, endReasonText)
Definition: _globallogic.gsc:1950
‪default_onDeadEvent
‪function default_onDeadEvent(team)
Definition: _globallogic_defaults.gsc:83
‪default_onRoundScoreLimit
‪function default_onRoundScoreLimit()
Definition: _globallogic_defaults.gsc:266
‪default_onTimeLimit
‪function default_onTimeLimit()
Definition: _globallogic_defaults.gsc:206
‪default_onRoundEndGame
‪function default_onRoundEndGame(winner)
Definition: _globallogic_defaults.gsc:143
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪default_onScoreLimit
‪function default_onScoreLimit()
Definition: _globallogic_defaults.gsc:234
‪getScoreInfoValue
‪function getScoreInfoValue(type)
Definition: rank_shared.gsc:248
‪default_getTeamKillPenalty
‪function default_getTeamKillPenalty(eInflictor, attacker, sMeansOfDeath, weapon)
Definition: _globallogic_defaults.gsc:337
‪is_killstreak_weapon
‪function is_killstreak_weapon(weapon)
Definition: killstreaks_shared.gsc:16
‪get_killstreak_team_kill_penalty_scale
‪function get_killstreak_team_kill_penalty_scale(weapon)
Definition: _killstreaks.gsc:1397
‪determineTeamWinnerByTeamScore
‪function determineTeamWinnerByTeamScore()
Definition: _globallogic.gsc:624
‪determineTeamWinnerByGameStat
‪function determineTeamWinnerByGameStat(gameStat)
Definition: _globallogic.gsc:578
‪_get_spawnpoint_array
‪function _get_spawnpoint_array(spawnpoint_name)
Definition: _spawnlogic.gsc:26
‪default_onSpawnIntermission
‪function default_onSpawnIntermission(endGame)
Definition: _globallogic_defaults.gsc:310
‪logTeamWinString
‪function logTeamWinString(wintype, winner)
Definition: _globallogic_utils.gsc:498
‪default_getTeamKillScore
‪function default_getTeamKillScore(eInflictor, attacker, sMeansOfDeath, weapon)
Definition: _globallogic_defaults.gsc:349
‪default_onOneLeftEvent
‪function default_onOneLeftEvent(team)
Definition: _globallogic_defaults.gsc:175
‪getHighestScoringPlayer
‪function getHighestScoringPlayer()
Definition: _globallogic_score.gsc:279
‪default_onForfeit
‪function default_onForfeit(team)
Definition: _globallogic_defaults.gsc:30
‪default_getTimeLimit
‪function default_getTimeLimit()
Definition: _globallogic_defaults.gsc:332
‪get_spawnpoint_random
‪function get_spawnpoint_random(spawnpoints, predictedSpawn, isIntermissionSpawn=false)
Definition: _spawnlogic.gsc:33
‪clamp
‪function clamp(val, val_min, val_max)
Definition: math_shared.csc:16
‪default_determineWinner
‪function default_determineWinner(roundWinner)
Definition: _globallogic_defaults.gsc:149
‪default_onAliveCountChange
‪function default_onAliveCountChange(team)
Definition: _globallogic_defaults.gsc:139
‪leader_dialog_on_player
‪function leader_dialog_on_player(dialogKey, objectiveKey, killstreakId, dialogBufferKey, introDialog)
Definition: _globallogic_audio.gsc:460
‪get_random_intermission_point
‪function get_random_intermission_point()
Definition: _spawnlogic.gsc:54
‪default_onSpawnSpectator
‪function default_onSpawnSpectator(origin, angles)
Definition: _globallogic_defaults.gsc:295
‪default_onLastTeamAliveEvent
‪function default_onLastTeamAliveEvent(team)
Definition: _globallogic_defaults.gsc:111
‪getWinningTeamFromLoser
‪function getWinningTeamFromLoser(losing_team)
Definition: _globallogic_defaults.gsc:20