‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_end_game_flow.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 #using scripts\shared\callbacks_shared;
3 #using scripts\shared\clientfield_shared;
4 #using scripts\shared\end_game_taunts;
5 #using scripts\shared\scene_shared;
6 #using scripts\shared\system_shared;
7 #using scripts\shared\util_shared;
8 #insert scripts\shared\shared.gsh;
9 #insert scripts\shared\version.gsh;
10 #insert scripts\shared\weapons\weapon_group_anims.gsh;
11 
12 #define HERO_HELMET_BONE ""
13 #define WEAPON_NONE "wpn_t7_none_world"
14 
15 #define RUNNER_UP_GESTURE_DELAY 3
16 
17 #using_animtree("all_player");
18 #namespace end_game_flow;
19 
20 ‪REGISTER_SYSTEM( "end_game_flow", &‪__init__, undefined )
21 
22 function ‪__init__()
23 {
29 
30  level thread ‪streamerWatcher();
31 }
32 
33 function ‪setAnimationOnModel( localClientNum, characterModel, topPlayerIndex )
34 {
35  anim_name = end_game_taunts::getidleanimname( localClientNum, characterModel, topPlayerIndex );
36 
37  if( isDefined(anim_name) )
38  {
39  characterModel ‪util::waittill_dobj( localClientNum );
40 
41  if( !characterModel HasAnimTree() )
42  {
43  characterModel UseAnimTree( #animtree );
44  }
45 
46  characterModel SetAnim( anim_name );
47  }
48 }
49 
50 
51 function ‪loadCharacterOnModel( localClientNum, characterModel, topPlayerIndex )
52 {
53  assert( isdefined( characterModel ) );
54 
55  // swap out our body
56  bodyModel = GetTopPlayersBodyModel( localClientNum, topPlayerIndex );
57  displayTopPlayerModel = CreateUIModel( GetUIModelForController( localClientNum ), "displayTopPlayer" + (topPlayerIndex+1) );
58  SetUIModelValue( displayTopPlayerModel, 1 );
59 
60  // This happens when the client has never spawned in, we should not show his model and not show his playercard as well.
61  if ( !IsDefined( bodyModel ) || bodymodel == "" )
62  {
63  SetUIModelValue( displayTopPlayerModel, 0 );
64  return;
65  }
66 
67  characterModel SetModel( bodyModel );
68 
69  // swap out our helmet
70  helmetModel = GetTopPlayersHelmetModel( localClientNum, topPlayerIndex );
71 
72  if ( !( characterModel IsAttached( helmetModel, ‪HERO_HELMET_BONE ) ) )
73  {
74  characterModel.helmetModel = helmetModel; // Keep refcount on this string because we'll need it later
75  characterModel Attach( helmetModel, ‪HERO_HELMET_BONE );
76  }
77 
78  // set up our render options
79  modeRenderOptions = GetCharacterModeRenderOptions( CurrentSessionMode() );
80  bodyRenderOptions = GetTopPlayersBodyRenderOptions( localClientNum, topPlayerIndex );
81  helmetRenderOptions = GetTopPlayersHelmetRenderOptions( localClientNum, topPlayerIndex );
82  weaponRenderOptions = GetTopPlayersWeaponRenderOptions( localClientNum, topPlayerIndex );
83 
84  // Used by epic taunts to clone the model and match skins
85  characterModel.bodyModel = bodyModel;
86  // Headmodel is attached above
87  characterModel.modeRenderOptions = modeRenderOptions;
88  characterModel.bodyRenderOptions = bodyRenderOptions;
89  characterModel.helmetRenderOptions = helmetRenderOptions;
90  characterModel.headRenderOptions = helmetRenderOptions;
91 
92  weapon_right = GetTopPlayersWeaponInfo( localClientNum, topPlayerIndex );
93 
94  if ( !isDefined( level.weaponNone ) )
95  {
96  level.weaponNone = GetWeapon( "none" );
97  }
98 
99  characterModel SetBodyRenderOptions( modeRenderOptions, bodyRenderOptions, helmetRenderOptions, helmetRenderOptions );
100 
101  if ( weapon_right["weapon"] == level.weaponNone )
102  {
103  weapon_right["weapon"] = GetWeapon("ar_standard");
104  characterModel.showcaseWeapon = weapon_right["weapon"];
105  characterModel AttachWeapon( weapon_right["weapon"] );
106  }
107  else
108  {
109  characterModel.showcaseWeapon = weapon_right["weapon"];
110  characterModel.showcaseWeaponRenderOptions = weaponRenderOptions;
111  characterModel.showcaseWeaponACVI = weapon_right["acvi"];
112 
113  characterModel AttachWeapon( weapon_right["weapon"], weaponRenderOptions, weapon_right["acvi"] );
114  characterModel UseWeaponHideTags( weapon_right["weapon"] );
115  }
116 }
117 
118 
119 
120 function ‪setupModelAndAnimation( localClientNum, characterModel, topPlayerIndex )
121 {
122  characterModel endon("entityshutdown");
123 
124  ‪loadCharacterOnModel( localClientNum, characterModel, topPlayerIndex );
125  ‪setAnimationOnModel( localClientNum, characterModel, topPlayerIndex );
126 }
127 
128 
129 
130 function ‪prepareTopThreePlayers( localClientNum )
131 {
132  numClients = GetTopScorerCount( localClientNum );
133  position = ‪struct::get( "endgame_top_players_struct", "targetname" );
134 
135  if( !isdefined( position ) )
136  {
137  return;
138  }
139 
140  for( index = 0; index < 3; index++ )
141  {
142  if ( index < numClients )
143  {
144  model = ‪Spawn( localClientNum, position.origin, "script_model" );
145  ‪loadCharacterOnModel( localClientNum, model, index );
146  model Hide();
147  model SetHighDetail( true );
148  }
149  }
150 }
151 
152 function ‪showTopThreePlayers( localClientNum )
153 {
154  level.topPlayerCharacters = [];
155  topPlayerScriptStructs = [];
156 
157  topPlayerScriptStructs[0] = ‪struct::get( "TopPlayer1", "targetname" );
158  topPlayerScriptStructs[1] = ‪struct::get( "TopPlayer2", "targetname" );
159  topPlayerScriptStructs[2] = ‪struct::get( "TopPlayer3", "targetname" );
160 
161  foreach( index, scriptStruct in topPlayerScriptStructs )
162  {
163  level.topPlayerCharacters[index] = ‪Spawn( localClientNum, scriptStruct.origin, "script_model" );
164  // level.topPlayerCharacters[index] SetDedicatedShadow( true );
165  level.topPlayerCharacters[index].angles = scriptStruct.angles;
166  }
167  numClients = GetTopScorerCount( localClientNum );
168 
169  foreach( index, characterModel in level.topPlayerCharacters )
170  {
171  if ( index < numClients )
172  {
173  thread ‪setupModelAndAnimation( localClientNum, characterModel, index );
174 
175  if ( index == 0 )
176  {
177  thread ‪end_game_taunts::playCurrentTaunt( localClientNum, characterModel, index );
178  }
179  }
180  }
181 
182  position = ‪struct::get( "endgame_top_players_struct", "targetname" );
183  PlayMainCamXCam( localClientNum, level.endGameXCamName, 0, "cam_topscorers", "topscorers", position.origin, position.angles );
184  PlayRadiantExploder( localClientNum, "exploder_mp_endgame_lights" );
185 
186  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "displayTop3Players" ), 1 );
187 
188  thread ‪spamUIModelValue( localClientNum );
189  thread ‪checkForGestures( localClientNum );
190 }
191 
192 function ‪spamUIModelValue( localClientNum )
193 {
194  while( 1 )
195  {
196  wait (0.25);
197  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "displayTop3Players" ), 1 );
198  }
199 }
200 
201 function ‪checkForGestures( localClientNum )
202 {
203  localPlayers = GetLocalPlayers();
204 
205  for ( i = 0; i < localPlayers.size; i++ )
206  {
207  thread ‪checkForPlayerGestures( localClientNum, localPlayers[i], i );
208  }
209 }
210 
211 function ‪checkForPlayerGestures( localClientNum, localPlayer, playerIndex )
212 {
213  localTopPlayerIndex = localPlayer GetTopPlayersIndex( localClientNum );
214 
215  if ( !isdefined( localTopPlayerIndex ) ||
216  !isdefined( level.topPlayerCharacters ) ||
217  localTopPlayerIndex >= level.topPlayerCharacters.size )
218  {
219  return;
220  }
221 
222  characterModel = level.topPlayerCharacters[localTopPlayerIndex];
223 
224  if ( localTopPlayerIndex > 0 )
225  {
227  }
228  else if ( isdefined( characterModel.playingTaunt ) )
229  {
230  characterModel waittill( "tauntFinished" );
231  }
232 
233  ‪showGestures( localClientNum, playerIndex );
234 }
235 
236 function ‪showGestures( localClientNum, playerIndex )
237 {
238  gesturesModel = GetUIModel( GetUIModelForController( localClientNum ), "topPlayerInfo.showGestures" );
239  if ( isdefined( gesturesModel ) )
240  {
241  SetUIModelValue( gesturesModel, true );
242  AllowActionSlotInput( playerIndex );
243  }
244 }
245 
246 function ‪handlePlayTop0Gesture( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
247 {
248  ‪handlePlayGesture( localClientNum, 0, newVal );
249 }
250 
251 function ‪handlePlayTop1Gesture( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
252 {
253  ‪handlePlayGesture( localClientNum, 1, newVal );
254 }
255 
256 function ‪handlePlayTop2Gesture( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
257 {
258  ‪handlePlayGesture( localClientNum, 2, newVal );
259 }
260 
261 function ‪handlePlayGesture( localClientNum, topPlayerIndex, gestureType )
262 {
263  if ( gestureType > 2 ||
264  !isdefined( level.topPlayerCharacters ) ||
265  topPlayerIndex >= level.topPlayerCharacters.size )
266  {
267  return;
268  }
269 
270  characterModel = level.topPlayerCharacters[topPlayerIndex];
271 
272  if ( isdefined( characterModel.playingTaunt ) ||
273  ‪IS_TRUE( characterModel.playingGesture ) )
274  {
275  return;
276  }
277 
278  thread ‪end_game_taunts::playGestureType( localClientNum, characterModel, topPlayerIndex, gestureType );
279 }
280 
282 {
283  while( true )
284  {
285  level waittill( "streamFKsl", localClientNum );
286  ‪prepareTopThreePlayers( localClientNum );
288  }
289 }
290 
291 
292 function ‪handleTopThreePlayers( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
293 {
294  if ( isdefined( newVal ) && newVal > 0 && isDefined( level.endGameXCamName ) )
295  {
296  level.showedTopThreePlayers = true;
297  ‪showTopThreePlayers( localClientNum );
298  }
299 }
300 
301 function ‪showScoreboard( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
302 {
303  if ( isdefined( newVal ) && newVal > 0 && isDefined( level.endGameXCamName ) )
304  {
307  position = ‪struct::get( "endgame_top_players_struct", "targetname" );
308  PlayMainCamXCam( localClientNum, level.endGameXCamName, 0, "cam_topscorers", "", position.origin, position.angles );
309  SetUIModelValue( CreateUIModel( GetUIModelForController( localClientNum ), "forceScoreboard" ), 1 );
310  level.inEndGameFlow = true;
311  }
312 }
313 
‪spamUIModelValue
‪function spamUIModelValue(localClientNum)
Definition: _end_game_flow.csc:192
‪deleteCameraGlass
‪function deleteCameraGlass(param)
Definition: end_game_taunts.csc:969
‪handleTopThreePlayers
‪function handleTopThreePlayers(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _end_game_flow.csc:292
‪setupModelAndAnimation
‪function setupModelAndAnimation(localClientNum, characterModel, topPlayerIndex)
Definition: _end_game_flow.csc:120
‪CF_CALLBACK_ZERO_ON_NEW_ENT
‪#define CF_CALLBACK_ZERO_ON_NEW_ENT
Definition: version.gsh:103
‪VERSION_SHIP
‪#define VERSION_SHIP
Definition: version.gsh:36
‪checkForGestures
‪function checkForGestures(localClientNum)
Definition: _end_game_flow.csc:201
‪loadCharacterOnModel
‪function loadCharacterOnModel(localClientNum, characterModel, topPlayerIndex)
Definition: _end_game_flow.csc:51
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪get
‪function get(kvp_value, kvp_key="targetname")
Definition: struct.csc:13
‪prepareTopThreePlayers
‪function prepareTopThreePlayers(localClientNum)
Definition: _end_game_flow.csc:130
‪playGestureType
‪function playGestureType(localClientNum, characterModel, topPlayerIndex, gestureType)
Definition: end_game_taunts.csc:316
‪RUNNER_UP_GESTURE_DELAY
‪#define RUNNER_UP_GESTURE_DELAY
Definition: _end_game_flow.csc:15
‪VERSION_TU1
‪#define VERSION_TU1
Definition: version.gsh:39
‪stream_epic_models
‪function stream_epic_models()
Definition: end_game_taunts.csc:813
‪showTopThreePlayers
‪function showTopThreePlayers(localClientNum)
Definition: _end_game_flow.csc:152
‪setAnimationOnModel
‪function setAnimationOnModel(localClientNum, characterModel, topPlayerIndex)
Definition: _end_game_flow.csc:33
‪CF_HOST_ONLY
‪#define CF_HOST_ONLY
Definition: version.gsh:102
‪streamerWatcher
‪function streamerWatcher()
Definition: _end_game_flow.csc:281
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪Spawn
‪function Spawn(parent, onDeathCallback)
Definition: _flak_drone.gsc:427
‪handlePlayTop1Gesture
‪function handlePlayTop1Gesture(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _end_game_flow.csc:251
‪showGestures
‪function showGestures(localClientNum, playerIndex)
Definition: _end_game_flow.csc:236
‪waittill_dobj
‪function waittill_dobj(localClientNum)
Definition: util_shared.csc:1117
‪stop_stream_epic_models
‪function stop_stream_epic_models()
Definition: end_game_taunts.csc:821
‪showScoreboard
‪function showScoreboard(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _end_game_flow.csc:301
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪playCurrentTaunt
‪function playCurrentTaunt(localClientNum, characterModel, topPlayerIndex)
Definition: end_game_taunts.csc:230
‪handlePlayTop2Gesture
‪function handlePlayTop2Gesture(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _end_game_flow.csc:256
‪HERO_HELMET_BONE
‪#define HERO_HELMET_BONE
Definition: _end_game_flow.csc:12
‪__init__
‪function __init__()
Definition: _end_game_flow.csc:22
‪handlePlayTop0Gesture
‪function handlePlayTop0Gesture(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _end_game_flow.csc:246
‪checkForPlayerGestures
‪function checkForPlayerGestures(localClientNum, localPlayer, playerIndex)
Definition: _end_game_flow.csc:211
‪handlePlayGesture
‪function handlePlayGesture(localClientNum, topPlayerIndex, gestureType)
Definition: _end_game_flow.csc:261