‪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\math_shared;
4 
5 #insert scripts\shared\shared.gsh;
6 
7 #using scripts\zm\gametypes\_globallogic;
8 #using scripts\zm\gametypes\_globallogic_audio;
9 #using scripts\zm\gametypes\_globallogic_score;
10 #using scripts\zm\gametypes\_globallogic_utils;
11 #using scripts\zm\gametypes\_spawnlogic;
12 
13 #using scripts\zm\_util;
14 
15 #namespace globallogic_defaults;
16 
17 function ‪getWinningTeamFromLoser( losing_team )
18 {
19  if ( level.multiTeam )
20  {
21  return "tie";
22  }
23  return util::getotherteam(losing_team);
24 }
25 
26 // when a team leaves completely, that team forfeited, team left wins round, ends game
27 function ‪default_onForfeit( team )
28 {
29  level.gameForfeited= true;
30 
31  level notify ( "forfeit in progress" ); //ends all other forfeit threads attempting to run
32  level endon( "forfeit in progress" ); //end if another forfeit thread is running
33  level endon( "abort forfeit" ); //end if the team is no longer in forfeit status
34 
35  forfeit_delay = 20.0; //forfeit wait, for switching teams and such
36 
37  announcement( game["strings"]["opponent_forfeiting_in"], forfeit_delay, 0 );
38  wait (10.0);
39  announcement( game["strings"]["opponent_forfeiting_in"], 10.0, 0 );
40  wait (10.0);
41 
42  endReason = &"";
43  if ( !isdefined( team ) )
44  {
45  SetDvar( "ui_text_endreason", game["strings"]["players_forfeited"] );
46  endReason = game["strings"]["players_forfeited"];
47  winner = level.players[0];
48  }
49  else if ( isdefined( level.teams[team] ) )
50  {
51  endReason = game["strings"][team+"_forfeited"];
52  SetDvar( "ui_text_endreason", endReason );
53  winner = ‪getWinningTeamFromLoser( team );
54  }
55  else
56  {
57  //shouldn't get here
58  assert( isdefined( team ), "Forfeited team is not defined" );
59  assert( 0, "Forfeited team " + team + " is not allies or axis" );
60  winner = "tie";
61  }
62  //exit game, last round, no matter if round limit reached or not
63  level.forcedEnd = true;
64  thread ‪globallogic::endGame( winner, endReason );
65 }
66 
67 
68 function ‪default_onDeadEvent( team )
69 {
70  if ( isdefined( level.teams[team] ) )
71  {
72  eliminatedString = game["strings"][team + "_eliminated"];
73  iPrintLn( eliminatedString );
74  //makeDvarServerInfo( "ui_text_endreason", eliminatedString );
75  SetDvar( "ui_text_endreason", eliminatedString );
76 
77  winner = ‪getWinningTeamFromLoser( team );
78  ‪globallogic_utils::logTeamWinString( "team eliminated", winner );
79 
80  thread ‪globallogic::endGame( winner, eliminatedString );
81  }
82  else
83  {
84  //makeDvarServerInfo( "ui_text_endreason", game["strings"]["tie"] );
85  SetDvar( "ui_text_endreason", game["strings"]["tie"] );
86 
88 
89  if ( level.teamBased )
90  thread ‪globallogic::endGame( "tie", game["strings"]["tie"] );
91  else
92  thread ‪globallogic::endGame( undefined, game["strings"]["tie"] );
93  }
94 }
95 
97 {
98 }
99 
100 function ‪default_onRoundEndGame( winner )
101 {
102  return winner;
103 }
104 
106 {
107  if ( !level.teamBased )
108  {
110 
111  thread ‪globallogic::endGame( winner, &"MP_ENEMIES_ELIMINATED" );
112  }
113  else
114  {
115  for ( index = 0; index < level.players.size; index++ )
116  {
117  player = level.players[index];
118 
119  if ( !isAlive( player ) )
120  continue;
121 
122  if ( !isdefined( player.pers["team"] ) || player.pers["team"] != team )
123  continue;
124 
125 // player globallogic_audio::leaderDialogOnPlayer( "last_alive" );
126  player ‪globallogic_audio::leaderDialogOnPlayer( "sudden_death" );
127  }
128  }
129 }
130 
131 
133 {
134  winner = undefined;
135 
136  if ( level.teamBased )
137  {
138  winner = ‪globallogic::determineTeamWinnerByGameStat( "teamScores" );
139 
140  ‪globallogic_utils::logTeamWinString( "time limit", winner );
141  }
142  else
143  {
145 
146  }
147 
148  // i think these two lines are obsolete
149  //makeDvarServerInfo( "ui_text_endreason", game["strings"]["time_limit_reached"] );
150  SetDvar( "ui_text_endreason", game["strings"]["time_limit_reached"] );
151 
152  thread ‪globallogic::endGame( winner, game["strings"]["time_limit_reached"] );
153 }
154 
156 {
157  if ( !level.endGameOnScoreLimit )
158  return false;
159 
160  winner = undefined;
161 
162  if ( level.teamBased )
163  {
164  winner = ‪globallogic::determineTeamWinnerByGameStat( "teamScores" );
165 
166  ‪globallogic_utils::logTeamWinString( "scorelimit", winner );
167  }
168  else
169  {
171  }
172 
173  //makeDvarServerInfo( "ui_text_endreason", game["strings"]["score_limit_reached"] );
174  SetDvar( "ui_text_endreason", game["strings"]["score_limit_reached"] );
175 
176  thread ‪globallogic::endGame( winner, game["strings"]["score_limit_reached"] );
177  return true;
178 }
179 
180 function ‪default_onSpawnSpectator( origin, angles)
181 {
182  if( isdefined( origin ) && isdefined( angles ) )
183  {
184  self ‪spawn(origin, angles);
185  return;
186  }
187 
188  spawnpointname = "mp_global_intermission";
189  spawnpoints = getentarray(spawnpointname, "classname");
190  assert( spawnpoints.size, "There are no mp_global_intermission spawn points in the map. There must be at least one." );
191  spawnpoint = ‪spawnlogic::getSpawnpoint_Random(spawnpoints);
192 
193  self ‪spawn(spawnpoint.origin, spawnpoint.angles);
194 }
195 
197 {
198  spawnpointname = "mp_global_intermission";
199  spawnpoints = getentarray(spawnpointname, "classname");
200 // spawnpoint = spawnlogic::getSpawnpoint_Random(spawnpoints);
201  spawnpoint = spawnPoints[0];
202 
203  if( isdefined( spawnpoint ) )
204  {
205  self ‪spawn( spawnpoint.origin, spawnpoint.angles );
206  }
207  else
208  {
209  }
210 }
211 
213 {
214  return ‪math::clamp( GetGametypeSetting( "timeLimit" ), level.timeLimitMin, level.timeLimitMax );
215 }
216 
‪endGame
‪function endGame(winner, endReasonText)
Definition: _globallogic.gsc:1950
‪default_onDeadEvent
‪function default_onDeadEvent(team)
Definition: _globallogic_defaults.gsc:83
‪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
‪default_onScoreLimit
‪function default_onScoreLimit()
Definition: _globallogic_defaults.gsc:234
‪determineTeamWinnerByGameStat
‪function determineTeamWinnerByGameStat(gameStat)
Definition: _globallogic.gsc:578
‪default_onSpawnIntermission
‪function default_onSpawnIntermission(endGame)
Definition: _globallogic_defaults.gsc:310
‪getSpawnpoint_Random
‪function getSpawnpoint_Random(spawnpoints)
Definition: _spawnlogic.gsc:396
‪logTeamWinString
‪function logTeamWinString(wintype, winner)
Definition: _globallogic_utils.gsc:498
‪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
‪clamp
‪function clamp(val, val_min, val_max)
Definition: math_shared.csc:16
‪default_onAliveCountChange
‪function default_onAliveCountChange(team)
Definition: _globallogic_defaults.gsc:139
‪default_onSpawnSpectator
‪function default_onSpawnSpectator(origin, angles)
Definition: _globallogic_defaults.gsc:295
‪leaderDialogOnPlayer
‪function leaderDialogOnPlayer(dialog, group)
Definition: _globallogic_audio.gsc:548
‪getWinningTeamFromLoser
‪function getWinningTeamFromLoser(losing_team)
Definition: _globallogic_defaults.gsc:20