‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
mpdialog.csc
Go to the documentation of this file.
1 #insert scripts\shared\shared.gsh;
2 #insert scripts\shared\version.gsh;
3 
4 #using scripts\codescripts\struct;
5 #using scripts\shared\array_shared;
6 #using scripts\shared\callbacks_shared;
7 #using scripts\shared\clientfield_shared;
8 #using scripts\shared\system_shared;
9 #using scripts\shared\util_shared;
10 
11 #namespace mpdialog;
12 
13 ‪REGISTER_SYSTEM( "mpdialog", &‪__init__, undefined )
14 
15 function ‪__init__()
16 {
17  level.mpBoostResponse = [];
18  level.mpBoostResponse[ "assassin" ] = "Spectre";
19  level.mpBoostResponse[ "grenadier" ] = "Grenadier";
20  level.mpBoostResponse[ "outrider" ] = "Outrider";
21  level.mpBoostResponse[ "prophet" ] = "Technomancer";
22  level.mpBoostResponse[ "pyro" ] = "Firebreak";
23  level.mpBoostResponse[ "reaper" ] = "Reaper";
24  level.mpBoostResponse[ "ruin" ] ="Mercenary";
25  level.mpBoostResponse[ "seraph" ] = "Enforcer";
26  level.mpBoostResponse[ "trapper" ] = "Trapper";
27  level.mpBoostResponse[ "blackjack" ] = "Blackjack";
28 
29  level.clientVoiceSetup = &‪client_voice_setup;
30 
31  ‪clientfield::register( "world", "boost_number", ‪VERSION_SHIP, 2, "int", &‪set_boost_number, true, true );
32  ‪clientfield::register( "allplayers", "play_boost", ‪VERSION_SHIP, 2, "int", &‪play_boost_vox, true, false );
33 }
34 
35 function ‪client_voice_setup( localClientNum )
36 {
37  self thread ‪sniperVoNotify( localClientNum, "playerbreathinsound", "exertSniperHold" );
38  self thread ‪sniperVoNotify( localClientNum, "playerbreathoutsound", "exertSniperExhale" );
39  self thread ‪sniperVoNotify( localClientNum, "playerbreathgaspsound", "exertSniperGasp" );
40 }
41 
42 function ‪sniperVoNotify( localClientNum, notifyString, dialogKey )
43 {
44  self endon("entityshutdown");
45  for(;;)
46  {
47  self waittill ( notifyString );
48 
49  if ( IsUnderwater( localClientNum ) )
50  {
51  return;
52  }
53 
54  dialogAlias = self ‪mpdialog::get_player_dialog_alias( dialogKey );
55 
56  if ( isdefined( dialogAlias ) )
57  {
58  self playsound (0, dialogAlias);
59  }
60  }
61 }
62 
63 function ‪set_boost_number( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
64 {
65  level.boostNumber = newVal;
66 }
67 
68 function ‪play_boost_vox( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
69 {
70  localPlayerTeam = GetLocalPlayerTeam( localClientNum );
71  entityNumber = self GetEntityNumber();
72 
73  if ( newVal == 0 ||
74  self.team != localPlayerTeam ||
75  level._sndNextSnapshot != "mpl_prematch" ||
76  level.boostStartEntNum === entityNumber ||
77  level.boostResponseEntNum === entityNumber )
78  {
79  return;
80  }
81 
82  if ( newVal == 1 )
83  {
84  level.boostStartEntNum = entityNumber;
85 
86  self thread ‪play_boost_start_vox( localClientNum );
87  }
88  else if ( newVal == 2 )
89  {
90  level.boostResponseEntNum = entityNumber;
91 
92  self thread ‪play_boost_start_response_vox( localClientNum );
93  }
94 }
95 
96 function ‪play_boost_start_vox( localClientNum )
97 {
98  self endon( "entityshutdown" );
99  self endon( "death" );
100 
101  wait( 2 );
102 
103  playbackId = self ‪play_dialog( "boostStart" + level.boostNumber, localClientNum );
104 
105  if ( isdefined( playbackId ) && playbackId >= 0 )
106  {
107  while ( SoundPlaying( playbackId ) )
108  {
109  wait ( 0.05 );
110  }
111  }
112 
113  wait ( 0.5 ); // Pause before response
114 
115  level.boostStartResponse = "boostStartResp" + level.mpBoostResponse[ self GetMpDialogName() ] + level.boostNumber;
116 
117  if ( isdefined( level.boostResponseEntNum ) )
118  {
119  responder = GetEntByNum( localClientNum, level.boostResponseEntNum );
120 
121  if ( isdefined( responder ) )
122  {
123  responder thread ‪play_boost_start_response_vox( localClientNum );
124  }
125  }
126 }
127 
128 function ‪play_boost_start_response_vox( localClientNum )
129 {
130  self endon( "entityshutdown" );
131  self endon( "death" );
132 
133  if ( !isdefined( level.boostStartResponse ) ||
134  self.team != GetLocalPlayerTeam( localClientNum ) )
135  {
136  return;
137  }
138 
139  self ‪play_dialog( level.boostStartResponse, localClientNum );
140 }
141 
142 function ‪get_commander_dialog_alias( commanderName, dialogKey )
143 {
144  if ( !isdefined( commanderName ) )
145  {
146  return;
147  }
148 
149  commanderBundle = ‪struct::get_script_bundle( "mpdialog_commander", commanderName );
150 
151  return ‪get_dialog_bundle_alias( commanderBundle, dialogKey );
152 }
153 
154 function ‪get_player_dialog_alias( dialogKey )
155 {
156  bundleName = self GetMpDialogName();
157 
158  if ( !isdefined( bundleName ) )
159  {
160  return undefined;
161  }
162 
163  playerBundle = ‪struct::get_script_bundle( "mpdialog_player", bundleName );
164 
165  return ‪get_dialog_bundle_alias( playerBundle, dialogKey );
166 }
167 
168 
169 function ‪get_dialog_bundle_alias( dialogBundle, dialogKey )
170 {
171  if ( !isdefined( dialogBundle ) || !isdefined( dialogKey ) )
172  {
173  return undefined;
174  }
175 
176  dialogAlias = GetStructField( dialogBundle, dialogKey );
177 
178  if ( !isdefined( dialogAlias ) )
179  {
180  return;
181  }
182 
183  voicePrefix = GetStructField( dialogBundle, "voiceprefix" );
184 
185  if ( isdefined( voicePrefix ) )
186  {
187  dialogAlias = voicePrefix + dialogAlias;
188  }
189 
190  return dialogAlias;
191 }
192 
193 function ‪play_dialog( dialogKey, localClientNum )
194 {
195  if ( !isdefined( dialogKey ) ||
196  !isdefined( localClientNum ) )
197  {
198  return -1;
199  }
200 
201  dialogAlias = self ‪get_player_dialog_alias( dialogKey );
202 
203  if ( !isdefined( dialogAlias ) )
204  {
205  return -1; // SND_PLAYBACKID_NOTPLAYED
206  }
207 
208  // Standing camera height offset
209  soundPos = ( self.origin[0], self.origin[1], self.origin[2] + 60 );
210 
211  if ( !IsSpectating( localClientNum ) )
212  {
213  return self PlaySound( undefined, dialogAlias, soundPos );
214  }
215 
216  voiceBox = ‪Spawn( localClientNum, self.origin, "script_model" );
217  self thread ‪update_voice_origin( voiceBox );
218  voiceBox thread ‪delete_after( 10 );
219  return voiceBox PlaySound( undefined, dialogAlias, soundPos );
220 }
221 
222 function ‪update_voice_origin( voiceBox )
223 {
224  while(1)
225  {
226  wait( 0.1 );
227 
228  if ( !isdefined( self ) || !isdefined( voiceBox ) )
229  {
230  return;
231  }
232 
233  voiceBox.origin = self.origin;
234  }
235 }
236 
237 function ‪delete_after( waitTime )
238 {
239  wait( waitTime );
240 
241  self Delete();
242 }
‪update_voice_origin
‪function update_voice_origin(voiceBox)
Definition: mpdialog.csc:222
‪delete_after
‪function delete_after(waitTime)
Definition: mpdialog.csc:237
‪VERSION_SHIP
‪#define VERSION_SHIP
Definition: version.gsh:36
‪__init__
‪function __init__()
Definition: mpdialog.csc:15
‪play_boost_start_response_vox
‪function play_boost_start_response_vox(localClientNum)
Definition: mpdialog.csc:128
‪client_voice_setup
‪function client_voice_setup(localClientNum)
Definition: mpdialog.csc:35
‪get_dialog_bundle_alias
‪function get_dialog_bundle_alias(dialogBundle, dialogKey)
Definition: mpdialog.csc:169
‪play_dialog
‪function play_dialog(dialogKey, localClientNum)
Definition: mpdialog.csc:193
‪sniperVoNotify
‪function sniperVoNotify(localClientNum, notifyString, dialogKey)
Definition: mpdialog.csc:42
‪set_boost_number
‪function set_boost_number(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: mpdialog.csc:63
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪Spawn
‪function Spawn(parent, onDeathCallback)
Definition: _flak_drone.gsc:427
‪get_commander_dialog_alias
‪function get_commander_dialog_alias(commanderName, dialogKey)
Definition: mpdialog.csc:142
‪play_boost_vox
‪function play_boost_vox(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: mpdialog.csc:68
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪get_script_bundle
‪function get_script_bundle(str_type, str_name)
Definition: struct.csc:45
‪play_boost_start_vox
‪function play_boost_start_vox(localClientNum)
Definition: mpdialog.csc:96
‪get_player_dialog_alias
‪function get_player_dialog_alias(dialogKey)
Definition: mpdialog.csc:154