‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_tacticalinsertion.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\audio_shared;
4 #using scripts\shared\clientfield_shared;
5 #using scripts\shared\system_shared;
6 #using scripts\shared\util_shared;
7 
8 #insert scripts\shared\shared.gsh;
9 #insert scripts\shared\version.gsh;
10 
11 #precache( "client_fx", "_t6/misc/fx_equip_tac_insert_light_grn" );
12 #precache( "client_fx", "_t6/misc/fx_equip_tac_insert_light_red" );
13 
14 #namespace tacticalinsertion;
15 
16 function ‪init_shared()
17 {
18  level._effect["tacticalInsertionFriendly"] = "_t6/misc/fx_equip_tac_insert_light_grn";
19  level._effect["tacticalInsertionEnemy"] = "_t6/misc/fx_equip_tac_insert_light_red";
20 
21  ‪clientfield::register( "scriptmover", "tacticalinsertion", ‪VERSION_SHIP, 1, "int", &‪spawned, !‪CF_HOST_ONLY, !‪CF_CALLBACK_ZERO_ON_NEW_ENT );
22 
23 // Set the map's latitude and longitude
24  latLongStruct = ‪struct::get( "lat_long", "targetname" );
25  if ( isdefined( latLongStruct ) )
26  {
27  mapX = latLongStruct.origin[0];
28  mapY = latLongStruct.origin[1];
29  Lat = latLongStruct.script_vector[0];
30  Long = latLongStruct.script_vector[1];
31  }
32  else
33  {
34  if ( isdefined( level.worldMapX ) && isdefined( level.worldMapY ) )
35  {
36  mapX = level.worldMapX;
37  mapY = level.worldMapY;
38  }
39  else
40  {
41  mapX = 0.0;
42  mapY = 0.0;
43  }
44 
45  if ( isdefined( level.worldLat ) && isdefined( level.worldLong ) )
46  {
47  Lat = level.worldLat;
48  Long = level.worldLong;
49  }
50  else
51  {
52  // default is Treyarch's:
53  Lat = 34.021566;
54  Long = -118.448689;
55  }
56  }
57 
58  SetMapLatLong( mapX, mapY, Long, Lat );
59 }
60 
61 function ‪spawned( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
62 {
63  if ( !newVal )
64  return;
65 
66  self thread ‪playFlareFX( localClientNum );
67  self thread ‪checkForPlayerSwitch( localClientNum );
68 }
69 
70 function ‪playFlareFX( localClientNum )
71 {
72  self endon( "entityshutdown" );
73  level endon( "player_switch" );
74 
75  if ( ‪util::friend_not_foe(localClientNum) )
76  {
77  self.tacticalInsertionFX = PlayFXOnTag( localClientNum, level._effect["tacticalInsertionFriendly"], self, "tag_flash" );
78  }
79  else
80  {
81  self.tacticalInsertionFX = PlayFXOnTag( localClientNum, level._effect["tacticalInsertionEnemy"], self, "tag_flash" );
82  }
83 
84  self thread ‪watchTacInsertShutdown( localClientNum, self.tacticalInsertionFX );
85 
86  loopOrigin = self.origin;
87  ‪audio::playloopat( "fly_tinsert_beep", loopOrigin);
88 
89  self thread ‪stopflareloopWatcher( loopOrigin );
90 
91 }
92 
93 function ‪watchTacInsertShutdown( localClientNum, fxHandle )
94 {
95  self waittill( "entityshutdown" );
96  StopFX( localClientNum, fxHandle );
97 }
98 
99 function ‪stopflareloopWatcher( loopOrigin )
100 {
101  while (1)
102  {
103  if (!isdefined( self ) || !isdefined( self.tacticalInsertionFX ) )
104  {
105  ‪audio::stoploopat ( "fly_tinsert_beep", loopOrigin);
106  //self notify ("stoppedLoop");
107  break;
108  }
109 
110  wait .5;
111  }
112 }
113 
114 function ‪checkForPlayerSwitch( localClientNum )
115 {
116  self endon( "entityshutdown" );
117 
118  while ( true )
119  {
120  level waittill( "player_switch" );
121 
122  if ( isdefined( self.tacticalInsertionFX ) )
123  {
124  stopFx( localClientNum, self.tacticalInsertionFX );
125  self.tacticalInsertionFX = undefined;
126  }
127 
128  waittillframeend;
129 
130  self thread ‪playFlareFX( localClientNum );
131  }
132 }
‪stoploopat
‪function stoploopat(aliasname, origin)
Definition: audio_shared.csc:914
‪spawned
‪function spawned(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _tacticalinsertion.csc:61
‪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
‪friend_not_foe
‪function friend_not_foe(localClientIndex, predicted)
Definition: util_shared.csc:1164
‪checkForPlayerSwitch
‪function checkForPlayerSwitch(localClientNum)
Definition: _tacticalinsertion.csc:114
‪get
‪function get(kvp_value, kvp_key="targetname")
Definition: struct.csc:13
‪watchTacInsertShutdown
‪function watchTacInsertShutdown(localClientNum, fxHandle)
Definition: _tacticalinsertion.csc:93
‪CF_HOST_ONLY
‪#define CF_HOST_ONLY
Definition: version.gsh:102
‪stopflareloopWatcher
‪function stopflareloopWatcher(loopOrigin)
Definition: _tacticalinsertion.csc:99
‪init_shared
‪function init_shared()
Definition: _tacticalinsertion.csc:16
‪playFlareFX
‪function playFlareFX(localClientNum)
Definition: _tacticalinsertion.csc:70
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪playloopat
‪function playloopat(aliasname, origin)
Definition: audio_shared.csc:909