‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_qrdrone.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\clientfield_shared;
4 #using scripts\shared\system_shared;
5 #using scripts\shared\util_shared;
6 #using scripts\shared\vehicle_shared;
7 
8 #insert scripts\shared\shared.gsh;
9 #insert scripts\shared\version.gsh;
10 
11 #using scripts\mp\_util;
12 #using scripts\mp\_vehicle;
13 
14 
15 
16 // _qrdrone.csc
17 // Sets up clientside behavior for the qrdrone
18 
19 #define UAV_REMOTE_MAX_PAST_RANGE 200
20 #define UAV_REMOTE_MIN_HELI_PROXIMITY 150
21 #define UAV_REMOTE_MAX_HELI_PROXIMITY 300
22 
23 #precache( "client_fx", "killstreaks/fx_drgnfire_light_red_3p" );
24 #precache( "client_fx", "killstreaks/fx_drgnfire_light_green_3p" );
25 #precache( "client_fx", "killstreaks/fx_drgnfire_light_green_1p" );
26 
27 #namespace qrdrone;
28 
29 ‪REGISTER_SYSTEM( "qrdrone", &‪__init__, undefined )
30 
31 function ‪__init__()
32 {
33  type = "qrdrone_mp";
34 
37 
38  level._effect["qrdrone_enemy_light"] = "killstreaks/fx_drgnfire_light_red_3p";
39  level._effect["qrdrone_friendly_light"] = "killstreaks/fx_drgnfire_light_green_3p";
40  level._effect["qrdrone_viewmodel_light"] = "killstreaks/fx_drgnfire_light_green_1p";
41 
42  // vehicle flags
45 
49 
51 }
52 
53 function ‪spawned( localClientNum ) // self == qrdrone
54 {
55  self ‪util::waittill_dobj( localClientNum );
56 
57  self thread ‪restartFX( localClientNum, ‪QRDRONE_FX_DEFAULT );
58 
59  self thread ‪collisionHandler(localClientNum);
60  self thread ‪engineStutterHandler(localClientNum);
61  self thread ‪QRDrone_watch_distance();
62 }
63 
64 //******************************************************************
65 // *
66 // *
67 //******************************************************************
68 function ‪stateChange( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
69 {
70  self endon("entityshutdown");
71  self ‪util::waittill_dobj( localClientNum );
72 
73  self ‪restartFX( localClientNum, newVal );
74 }
75 
76 //******************************************************************
77 // *
78 // *
79 //******************************************************************
80 function ‪restartFX( localClientNum, blinkStage ) // self == qrdrone
81 {
82  self notify( "restart_fx" );
83 
84  /#println( "Restart QRDrone FX: stage " + blinkStage );#/
85 
86  switch( blinkStage )
87  {
89  {
90  self ‪spawn_solid_fx( localClientNum );
91  break;
92  }
94  {
95  self.fx_interval = 1.0;
96  self ‪spawn_blinking_fx( localClientNum );
97  break;
98  }
100  {
101  self.fx_interval = .133;
102  self ‪spawn_blinking_fx( localClientNum );
103  break;
104  }
105  case ‪QRDRONE_FX_DEATH:
106  {
107  self notify( "stopfx" );
108  self notify( "fx_death" );
109  return;
110  }
111  }
112 
113  self thread ‪watchRestartFX( localClientNum );
114 }
115 
116 //******************************************************************
117 // *
118 // *
119 //******************************************************************
120 function ‪watchRestartFX( localClientNum )
121 {
122  self endon("entityshutdown");
123 
124  level ‪util::waittill_any( "demo_jump", "player_switch", "killcam_begin", "killcam_end" );
125 
126  self ‪restartFX( localClientNum, ‪clientfield::get( "qrdrone_state" ));
127 }
128 
129 //******************************************************************
130 // *
131 // *
132 //******************************************************************
133 function ‪spawn_solid_fx( localClientNum ) // self == qrdrone
134 {
135  if ( self IsLocalClientDriver( localClientNum ) )
136  {
137  fx_handle = playfxontag( localClientNum, level._effect["qrdrone_viewmodel_light"], self, "tag_body" );
138  }
139  else if ( self ‪util::friend_not_foe( localClientNum ) )
140  {
141  fx_handle = playfxontag( localClientNum, level._effect["qrdrone_friendly_light"], self, "tag_body" );
142  }
143  else
144  {
145  fx_handle = playfxontag( localClientNum, level._effect["qrdrone_enemy_light"], self, "tag_body" );
146  }
147 
148  self thread ‪cleanupFX( localClientNum, fx_handle );
149 }
150 
151 //******************************************************************
152 // *
153 // *
154 //******************************************************************
155 function ‪spawn_blinking_fx( localClientNum )
156 {
157  self thread ‪blink_fx_and_sound( localClientNum, "wpn_qr_alert" );
158 }
159 
160 //******************************************************************
161 // *
162 // *
163 //******************************************************************
164 function ‪blink_fx_and_sound( localClientNum, soundAlias )
165 {
166  self endon( "entityshutdown" );
167  self endon( "restart_fx" );
168  self endon( "fx_death" );
169 
170  if ( !isdefined( self.interval ) )
171  {
172  self.interval = 1.0;
173  }
174 
175  while(1)
176  {
177  self PlaySound( localClientNum, soundAlias );
178 
179  self ‪spawn_solid_fx( localClientNum );
180  ‪util::server_wait( localClientNum, self.interval / 2);
181 
182  self notify( "stopfx" );
183 
184  ‪util::server_wait( localClientNum, self.interval / 2);
185  self.interval = (self.interval / 1.17);
186 
187  if (self.interval < .1)
188  {
189  self.interval = .1;
190  }
191  }
192 }
193 
194 //******************************************************************
195 // *
196 // *
197 //******************************************************************
198 function ‪cleanupFX( localClientNum, handle )
199 {
200  self ‪util::waittill_any( "entityshutdown", "blink", "stopfx", "restart_fx" );
201  stopfx( localClientNum, handle );
202 }
203 
204 function ‪start_blink( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
205 {
206  if (!newVal)
207  return;
208 
209  self notify("blink");
210 }
211 
212 // this second state is necessary so killcams show the appropriate "fast blink" state
213 function ‪final_blink( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
214 {
215  if (!newVal)
216  return;
217 
218  self.interval = .133;
219 }
220 
221 function ‪out_of_range_update( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
222 {
223  model = GetUIModel( GetUIModelForController( localClientNum ), "vehicle.outOfRange" );
224  if ( isdefined( model ) )
225  {
226  SetUIModelValue( model, newVal );
227  }
228 }
229 
230 function ‪loop_local_sound( localClientNum, alias, interval, fx )
231 {
232  self endon( "entityshutdown" );
233  self endon( "stopfx" );
234 
235  level endon( "demo_jump" );
236  level endon( "player_switch" );
237 
238  // also playing the blinking light fx with the sound
239 
240  if ( !isdefined( self.interval ) )
241  {
242  self.interval = interval;
243  }
244 
245  while(1)
246  {
247  self PlaySound( localClientNum, alias );
248 
249  self ‪spawn_solid_fx( localClientNum );
250  ‪util::server_wait( localClientNum, self.interval / 2);
251 
252  self notify( "stopfx" );
253 
254  ‪util::server_wait( localClientNum, self.interval / 2);
255  self.interval = (self.interval / 1.17);
256 
257  if (self.interval < .1)
258  {
259  self.interval = .1;
260  }
261  }
262 }
263 
264 function ‪check_for_player_switch_or_time_jump( localClientNum )
265 {
266  self endon("entityshutdown");
267 
268  level ‪util::waittill_any( "demo_jump", "player_switch", "killcam_begin" );
269  self notify( "stopfx" );
270 
271  waittillframeend;
272 
273  self thread ‪blink_light( localClientNum );
274 
275  if ( isdefined( self.blinkStartTime ) && self.blinkStartTime <= level.serverTime )
276  {
277  self.interval = 1;
278  self thread ‪start_blink( localClientNum, true );
279  }
280  else
281  {
282  self ‪spawn_solid_fx( localClientNum );
283  }
284 
285  self thread ‪check_for_player_switch_or_time_jump( localClientNum );
286 }
287 
288 function ‪blink_light( localClientNum )
289 {
290  self endon("entityshutdown");
291  level endon( "demo_jump" );
292  level endon( "player_switch" );
293  level endon( "killcam_begin" );
294 
295  self waittill("blink");
296 
297  if ( !isdefined( self.blinkStartTime ) )
298  {
299  self.blinkStartTime = level.serverTime;
300  }
301 
302  if ( self IsLocalClientDriver( localClientNum ) )
303  {
304  self thread ‪loop_local_sound( localClientNum, "wpn_qr_alert", 1, level._effect["qrdrone_viewmodel_light"] );
305  }
306  else if ( self ‪util::friend_not_foe( localClientNum ) )
307  {
308  self thread ‪loop_local_sound( localClientNum, "wpn_qr_alert", 1, level._effect["qrdrone_friendly_light"] );
309  }
310  else
311  {
312  self thread ‪loop_local_sound( localClientNum, "wpn_qr_alert", 1, level._effect["qrdrone_enemy_light"] );
313  }
314 }
315 
316 
317 function ‪collisionHandler( localClientNum )
318 {
319  self endon( "entityshutdown" );
320 
321  while( 1 )
322  {
323  self waittill( "veh_collision", hip, hitn, hit_intensity );
324 
325  driver_local_client = self GetLocalClientDriver();
326 
327  if( isdefined( driver_local_client ) )
328  {
329  //println( "veh_collision " + hit_intensity );
330  player = getlocalplayer( driver_local_client );
331 
332  if( isdefined( player ) )
333  {
334  // todo - play sound here also
335  if( hit_intensity > 15 )
336  {
337  player PlayRumbleOnEntity( driver_local_client, "damage_heavy" );
338  }
339  else
340  {
341  player PlayRumbleOnEntity( driver_local_client, "damage_light" );
342  }
343  }
344  }
345  }
346 }
347 
348 function ‪engineStutterHandler( localClientNum )
349 {
350  self endon( "entityshutdown" );
351 
352  while( 1 )
353  {
354  self waittill( "veh_engine_stutter" );
355  if ( self IsLocalClientDriver( localClientNum ) )
356  {
357  player = getlocalplayer( localClientNum );
358 
359  if( isdefined( player ) )
360  {
361  player PlayRumbleOnEntity( localClientNum, "rcbomb_engine_stutter" );
362  }
363  }
364  }
365 }
366 
368 {
369  if ( !isdefined( level.airsupportHeightScale ) )
370  level.airsupportHeightScale = 1;
371 
372  airsupport_height = ‪struct::get( "air_support_height", "targetname");
373  if ( isdefined(airsupport_height) )
374  {
375  planeFlyHeight = airsupport_height.origin[2];
376  }
377  else
378  {
379 /#
380  PrintLn("WARNING: Missing air_support_height entity in the map. Using default height.");
381 #/
382  // original system
383  planeFlyHeight = 850;
384 
385  if ( isdefined( level.airsupportHeightScale ) )
386  {
387  level.airsupportHeightScale = GetDvarInt( "scr_airsupportHeightScale", level.airsupportHeightScale );
388  planeFlyHeight *= GetDvarInt( "scr_airsupportHeightScale", level.airsupportHeightScale );
389  }
390 
391  if ( isdefined( level.forceAirsupportMapHeight ) )
392  {
393  planeFlyHeight += level.forceAirsupportMapHeight;
394  }
395  }
396 
397  return planeFlyHeight;
398 }
399 
401 {
402  self endon ("entityshutdown" );
403 
404  qrdrone_height = ‪struct::get( "qrdrone_height", "targetname");
405  if ( isdefined(qrdrone_height) )
406  {
407  self.maxHeight = qrdrone_height.origin[2];
408  }
409  else
410  {
411  self.maxHeight = int(‪getMinimumFlyHeight());
412  }
413 
414  self.maxDistance = 12800;
415 
416  level.mapCenter = ‪GetMapCenter();
417 
418  self.minHeight = level.mapCenter[2] - 800;
419 
420  // shouldn't be possible to start out of range, but just in case
421  inRangePos = self.origin;
422 
423  soundent = ‪spawn (0, self.origin, "script_origin" );
424  soundent linkto(self);
425 
426  // end static on vehicle death
427  self thread ‪QRDrone_staticStopOnDeath( soundent );
428 
429  // loop
430  while ( true )
431  {
432  if ( !self ‪QRDrone_in_range() )
433  {
434  // increase static with distance from exit point or distance to heli in proximity
435  staticAlpha = 0;
436  while ( !self ‪QRDrone_in_range() )
437  {
438  if ( isdefined( self.heliInProximity ) )
439  {
440  dist = distance( self.origin, self.heliInProximity.origin );
442  }
443  else
444  {
445  dist = distance( self.origin, inRangePos );
446  staticAlpha = min( 1, dist/‪UAV_REMOTE_MAX_PAST_RANGE );
447  }
448 
449 
450  // SOUND: put sound code here to change the volume of the static while the player is
451  // in static. staticAlpha will be 0 - 1. 0 being no static, 1 being full static.
452 
453 
454  sid = soundent playloopsound ( "veh_qrdrone_static_lp", .2 );
455  self ‪vehicle::set_static_amount( staticAlpha * 2 );
456 
457  wait ( 0.05 );
458  }
459 
460 
461  // fade out static
462  self thread ‪QRDrone_staticFade( staticAlpha, soundent, sid );
463 
464  }
465  inRangePos = self.origin;
466  wait ( 0.05 );
467  }
468 }
469 
470 
472 {
473  if ( self.origin[2] < self.maxHeight && self.origin[2] > self.minHeight )
474  {
475  if ( self isInsideHeightLock() )
476  {
477  return true;
478  }
479  }
480  return false;
481 }
482 
483 
484 function ‪QRDrone_staticFade( staticAlpha, sndent, sid )
485 {
486  self endon ( "entityshutdown" );
487  while( self ‪QRDrone_in_range() )
488  {
489  staticAlpha -= 0.05;
490  if ( staticAlpha <= 0 )
491  {
492  // SOUND: Put call here to completely turn static sound off
493  sndent StopAllLoopSounds (.5);
494  //delete sid;
496  break;
497  }
498 
499  // SOUND: Put call here to change volume of static based on staticAlpha
500  setsoundvolumerate( sid, .6 );
501  setsoundvolume( sid, staticAlpha );
502 
503  self ‪vehicle::set_static_amount( staticAlpha * 2 );
504 
505 
506  wait( 0.05 );
507  }
508 }
509 
511 {
512  self waittill ( "entityshutdown" );
513  sndent StopAllLoopSounds (.1);
514  sndent delete();
515 }
‪UAV_REMOTE_MAX_HELI_PROXIMITY
‪#define UAV_REMOTE_MAX_HELI_PROXIMITY
Definition: _qrdrone.csc:21
‪spawn_blinking_fx
‪function spawn_blinking_fx(localClientNum)
Definition: _qrdrone.csc:155
‪UAV_REMOTE_MIN_HELI_PROXIMITY
‪#define UAV_REMOTE_MIN_HELI_PROXIMITY
Definition: _qrdrone.csc:20
‪getMinimumFlyHeight
‪function getMinimumFlyHeight()
Definition: _qrdrone.csc:367
‪start_blink
‪function start_blink(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _qrdrone.csc:204
‪QRDRONE_FX_FINAL_BLINK
‪#define QRDRONE_FX_FINAL_BLINK
Definition: shared.gsh:337
‪spawned
‪function spawned(localClientNum)
Definition: _qrdrone.csc:53
‪QRDrone_in_range
‪function QRDrone_in_range()
Definition: _qrdrone.csc:471
‪engineStutterHandler
‪function engineStutterHandler(localClientNum)
Definition: _qrdrone.csc:348
‪UAV_REMOTE_MAX_PAST_RANGE
‪#define UAV_REMOTE_MAX_PAST_RANGE
Definition: _qrdrone.csc:19
‪cleanupFX
‪function cleanupFX(localClientNum, handle)
Definition: _qrdrone.csc:198
‪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
‪QRDrone_staticStopOnDeath
‪function QRDrone_staticStopOnDeath(sndent)
Definition: _qrdrone.csc:510
‪friend_not_foe
‪function friend_not_foe(localClientIndex, predicted)
Definition: util_shared.csc:1164
‪set_static_amount
‪function set_static_amount(staticAmount)
Definition: _vehicle.csc:106
‪watchRestartFX
‪function watchRestartFX(localClientNum)
Definition: _qrdrone.csc:120
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪QRDRONE_FX_BLINK
‪#define QRDRONE_FX_BLINK
Definition: shared.gsh:336
‪get
‪function get(kvp_value, kvp_key="targetname")
Definition: struct.csc:13
‪QRDrone_staticFade
‪function QRDrone_staticFade(staticAlpha, sndent, sid)
Definition: _qrdrone.csc:484
‪blink_light
‪function blink_light(localClientNum)
Definition: _qrdrone.csc:288
‪GetMapCenter
‪function GetMapCenter()
Definition: _airsupport.gsc:766
‪spawn_solid_fx
‪function spawn_solid_fx(localClientNum)
Definition: _qrdrone.csc:133
‪QRDrone_watch_distance
‪function QRDrone_watch_distance()
Definition: _qrdrone.csc:400
‪check_for_player_switch_or_time_jump
‪function check_for_player_switch_or_time_jump(localClientNum)
Definition: _qrdrone.csc:264
‪stateChange
‪function stateChange(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _qrdrone.csc:68
‪restartFX
‪function restartFX(localClientNum, blinkStage)
Definition: _qrdrone.csc:80
‪CF_HOST_ONLY
‪#define CF_HOST_ONLY
Definition: version.gsh:102
‪waittill_any
‪function waittill_any(str_notify1, str_notify2, str_notify3, str_notify4, str_notify5)
Definition: util_shared.csc:375
‪out_of_range_update
‪function out_of_range_update(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _qrdrone.csc:221
‪collisionHandler
‪function collisionHandler(localClientNum)
Definition: _qrdrone.csc:317
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪add_vehicletype_callback
‪function add_vehicletype_callback(vehicletype, callback)
Definition: vehicle_shared.csc:77
‪__init__
‪function __init__()
Definition: _qrdrone.csc:31
‪waittill_dobj
‪function waittill_dobj(localClientNum)
Definition: util_shared.csc:1117
‪QRDRONE_FX_DEATH
‪#define QRDRONE_FX_DEATH
Definition: shared.gsh:338
‪QRDRONE_FX_DEFAULT
‪#define QRDRONE_FX_DEFAULT
Definition: shared.gsh:335
‪final_blink
‪function final_blink(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _qrdrone.csc:213
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪blink_fx_and_sound
‪function blink_fx_and_sound(localClientNum, soundAlias)
Definition: _qrdrone.csc:164
‪loop_local_sound
‪function loop_local_sound(localClientNum, alias, interval, fx)
Definition: _qrdrone.csc:230
‪server_wait
‪function server_wait(localClientNum, seconds, waitBetweenChecks, level_endon)
Definition: util_shared.csc:1125