‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_acousticsensor.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\fx_shared;
5 #using scripts\shared\system_shared;
6 #using scripts\shared\util_shared;
7 
8 #insert scripts\shared\shared.gsh;
9 
10 #namespace acousticsensor;
11 
12 #precache( "client_fx", "_t6/misc/fx_equip_light_red" );
13 #precache( "client_fx", "_t6/misc/fx_equip_light_green" );
14 
15 function ‪init_shared()
16 {
17  level._effect["acousticsensor_enemy_light"] = "_t6/misc/fx_equip_light_red";
18  level._effect["acousticsensor_friendly_light"] = "_t6/misc/fx_equip_light_green" ;
19 
20  if ( !isdefined( level.acousticSensors ) )
21  level.acousticSensors = [];
22  if ( !isdefined( level.acousticSensorHandle ) )
23  level.acousticSensorHandle = 0;
24 
26  ‪callback::add_weapon_type( "acoustic_sensor", &‪spawned );
27 }
28 
29 function ‪on_player_connect( localClientNum )
30 {
31  SetLocalRadarEnabled( localClientNum, 0 );
32  if ( localClientNum == 0 )
33  {
34  level thread ‪updateAcousticSensors();
35  }
36 }
37 
38 function ‪addAcousticSensor( handle, sensorEnt, owner/*, sndScramPingEnt*/ )
39 {
40  acousticSensor = spawnstruct();
41  acousticSensor.handle = handle;
42  acousticSensor.sensorEnt = sensorEnt;
43  acousticSensor.owner = owner;
44  //acousticSensor.sndScramPingEnt = sndScramPingEnt;
45 
46  size = level.acousticSensors.size;
47  level.acousticSensors[size] = acousticSensor;
48 }
49 
50 function ‪removeAcousticSensor( acousticSensorHandle )
51 {
52  for ( i = 0 ; i < level.acousticSensors.size ; i++ )
53  {
54  last = level.acousticSensors.size - 1;
55  if ( level.acousticSensors[i].handle == acousticSensorHandle )
56  {
57  level.acousticSensors[i].handle = level.acousticSensors[last].handle;
58  level.acousticSensors[i].sensorEnt = level.acousticSensors[last].sensorEnt;
59  level.acousticSensors[i].owner = level.acousticSensors[last].owner;
60  //level.acousticSensors[i].sndScramPingEnt = level.acousticSensors[last].sndScramPingEnt;
61  level.acousticSensors[last] = undefined;
62  return;
63  }
64  }
65 }
66 
67 function ‪spawned( localClientNum )
68 {
69  handle = level.acousticSensorHandle;
70  level.acousticSensorHandle++;
71  self thread ‪watchShutdown( handle );
72 
73  owner = self GetOwner( localClientNum );
74  ‪addAcousticSensor( handle, self, owner/*, sndScramPingEnt*/ );
75 
77 }
78 
79 function ‪spawnedPerClient(localClientNum )
80 {
81  self endon( "entityshutdown" );
82 
83  self thread ‪fx::blinky_light( localClientNum, "tag_light", level._effect["acousticsensor_friendly_light"], level._effect["acousticsensor_enemy_light"] );
84 }
85 
86 function ‪watchShutdown( handle )
87 {
88  self waittill( "entityshutdown" );
89  ‪removeAcousticSensor( handle );
90 }
91 
93 {
94  self endon( "entityshutdown" );
95  localRadarEnabled = [];
96  previousAcousticSensorCount = -1;
97 
99 
100  while ( true )
101  {
102  // NOTE: this functionality is reliant on the level.localPlayers[] being valid. First check this if anything
103  // is reported as not working here.
104  localPlayers = level.localPlayers;
105  if ( previousAcousticSensorCount != 0 || level.acousticSensors.size != 0 )
106  {
107 
108  for ( i = 0 ; i < localPlayers.size ; i++ )
109  localRadarEnabled[i] = 0;
110 
111  for ( i = 0 ; i < level.acousticSensors.size ; i++ )
112  {
113  if ( isdefined( level.acousticSensors[i].sensorEnt.stunned ) && level.acousticSensors[i].sensorEnt.stunned )
114  continue;
115 
116  for ( j = 0 ; j < localPlayers.size ; j++ )
117  {
118  if ( localPlayers[j] == level.acousticSensors[i].sensorEnt GetOwner( j ) )
119  {
120  localRadarEnabled[j] = 1;
121  SetLocalRadarPosition( j, level.acousticSensors[i].sensorEnt.origin );
122  }
123  }
124  }
125 
126  for ( i = 0 ; i < localPlayers.size ; i++ )
127  SetLocalRadarEnabled( i, localRadarEnabled[i] );
128  }
129  previousAcousticSensorCount = level.acousticSensors.size;
130  wait( 0.1 );
131  }
132 }
‪waitforclient
‪function waitforclient(client)
Definition: util_shared.csc:60
‪updateAcousticSensors
‪function updateAcousticSensors()
Definition: _acousticsensor.csc:92
‪removeAcousticSensor
‪function removeAcousticSensor(acousticSensorHandle)
Definition: _acousticsensor.csc:50
‪init_shared
‪function init_shared()
Definition: _acousticsensor.csc:15
‪local_players_entity_thread
‪function local_players_entity_thread(entity, func, arg1, arg2, arg3, arg4)
Definition: util_shared.csc:1493
‪on_localclient_connect
‪function on_localclient_connect(localClientNum)
Definition: ctf.csc:20
‪watchShutdown
‪function watchShutdown(handle)
Definition: _acousticsensor.csc:86
‪blinky_light
‪function blinky_light(localClientNum, tagName, friendlyfx, enemyfx)
Definition: fx_shared.csc:280
‪on_player_connect
‪function on_player_connect(localClientNum)
Definition: _acousticsensor.csc:29
‪add_weapon_type
‪function add_weapon_type(weapontype, callback)
Definition: callbacks_shared.csc:780
‪spawnedPerClient
‪function spawnedPerClient(localClientNum)
Definition: _acousticsensor.csc:79
‪addAcousticSensor
‪function addAcousticSensor(handle, sensorEnt, owner)
Definition: _acousticsensor.csc:38
‪spawned
‪function spawned(localClientNum)
Definition: _acousticsensor.csc:67