‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_weaponobjects.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\array_shared;
4 #using scripts\shared\audio_shared;
5 #using scripts\shared\callbacks_shared;
6 #using scripts\shared\clientfield_shared;
7 #using scripts\shared\duplicaterender_mgr;
8 #using scripts\shared\filter_shared;
9 #using scripts\shared\util_shared;
10 
11 
12 #insert scripts\shared\duplicaterender.gsh;
13 #insert scripts\shared\shared.gsh;
14 #insert scripts\shared\version.gsh;
15 #insert scripts\shared\weapons\_weaponobjects.gsh;
16 
17 #using scripts\shared\system_shared;
18 
19 #precache( "client_fx", "weapon/fx_equip_light_os" );
20 
21 #namespace weaponobjects;
22 
23 function ‪init_shared()
24 {
26 
28 
34 
35  level._effect[ "powerLight" ] = "weapon/fx_equip_light_os";
36 
37  ‪DEFAULT(level.retrievable,[]);
38  ‪DEFAULT(level.enemyequip,[]);
39 }
40 
41 function ‪on_localplayer_spawned( local_client_num )
42 {
43  if( self != GetLocalPlayer( local_client_num ) )
44  return;
45 
46  self thread ‪watch_perks_changed(local_client_num);
47 
48  self thread ‪watch_killstreak_tap_activation( local_client_num );
49 }
50 
51 function ‪watch_killstreak_tap_activation( local_client_num )
52 {
53  self notify( "watch_killstreak_tap_activation" );
54  self endon( "watch_killstreak_tap_activation" );
55  self endon( "death" );
56  self endon( "disconnect" );
57  self endon( "entityshutdown" );
58 
59  while ( IsDefined( self ) )
60  {
61  self waittill( "notetrack", note );
62  if ( note == "activate_datapad" )
63  {
64  uimodel = CreateUIModel( GetUIModelForController( local_client_num ), "hudItems.killstreakActivated" );
65  SetUIModelValue( uimodel, 1 );
66  }
67 
68  if ( note == "deactivate_datapad" )
69  {
70  uimodel = CreateUIModel( GetUIModelForController( local_client_num ), "hudItems.killstreakActivated" );
71  SetUIModelValue( uimodel, 0 );
72  }
73  }
74 }
75 
76 
77 function ‪proximity_alarm_changed( local_client_num, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
78 {
79  ‪update_sound( local_client_num, bNewEnt, newVal, oldVal );
80 }
81 
82 function ‪update_sound( local_client_num, bNewEnt, newVal, oldVal )
83 {
84  if ( newVal == ‪PROXIMITY_ALARM_ON )
85  {
86  if ( !IsDefined( self._proximity_alarm_snd_ent ) )
87  {
88  self._proximity_alarm_snd_ent = ‪Spawn( local_client_num, self.origin, "script_origin" );
89  self thread ‪sndProxAlert_EntCleanup(local_client_num, self._proximity_alarm_snd_ent);
90  }
91 
92  playsound( local_client_num, "uin_c4_proximity_alarm_start", (0,0,0) );
93  self._proximity_alarm_snd_ent PlayLoopSound( "uin_c4_proximity_alarm_loop", .1 );
94  }
95  else if ( newVal == ‪PROXIMITY_ALARM_DEPLOYED )
96  {
97  //playsound( local_client_num, "uin_c4_proximity_alarm_deploy", (0,0,0) );
98  }
99  else if( newVal == ‪PROXIMITY_ALARM_OFF && isdefined( oldVal ) && oldVal != newVal )
100  {
101  playsound( local_client_num, "uin_c4_proximity_alarm_stop", (0,0,0) );
102  if ( IsDefined( self._proximity_alarm_snd_ent ) )
103  {
104  self._proximity_alarm_snd_ent StopAllLoopSounds( 0.5 );
105  }
106  }
107 }
108 
109 
110 function ‪teamequip_changed( local_client_num, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
111 {
112  self ‪updateTeamEquipment( local_client_num, newVal );
113 }
114 
115 function ‪updateTeamEquipment( local_client_num, newVal )
116 {
117  self ‪checkTeamEquipment( local_client_num );
118 }
119 
120 function ‪retrievable_changed( local_client_num, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
121 {
122  self util::add_remove_list( level.retrievable, newVal );
123 
124  self ‪updateRetrievable( local_client_num, newVal );
125 }
126 
127 function ‪updateRetrievable( local_client_num, newVal )
128 {
129  if ( IsDefined(self.owner) && self.owner == getlocalplayer( local_client_num ) )
130  {
131  self ‪duplicate_render::set_item_retrievable( local_client_num, newVal );
132  }
133  else
134  {
135  if ( IsDefined(self.currentdrfilter))
136  self ‪duplicate_render::set_item_retrievable( local_client_num, false );
137  }
138 }
139 
140 function ‪enemyequip_changed( local_client_num, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
141 {
142  newVal = ( newVal != ‪ENEMY_EQUIPMENT_SHADER_OFF );
143 
144  self util::add_remove_list( level.enemyequip, newVal );
145 
146  self ‪updateEnemyEquipment( local_client_num, newVal );
147 }
148 
149 function ‪updateEnemyEquipment( local_client_num, newVal )
150 {
151  watcher = GetLocalPlayer( local_client_num );
152  friend = self ‪util::friend_not_foe( local_client_num, true );
153 
154  if ( !friend && IsDefined( watcher ) && watcher HasPerk( local_client_num, "specialty_showenemyequipment" ) )
155  {
156  self ‪duplicate_render::set_item_friendly_equipment( local_client_num, false );
157  self ‪duplicate_render::set_item_enemy_equipment( local_client_num, newVal );
158  }
159  else if( friend && isDefined( watcher ) && watcher ‪duplicate_render::show_friendly_outlines(local_client_num) )
160  {
161  self ‪duplicate_render::set_item_enemy_equipment( local_client_num, false );
162  self ‪duplicate_render::set_item_friendly_equipment( local_client_num, newVal );
163  }
164  else
165  {
166  self ‪duplicate_render::set_item_enemy_equipment( local_client_num, false );
167  self ‪duplicate_render::set_item_friendly_equipment( local_client_num, false );
168  }
169 }
170 
171 function ‪equipmentDR( local_client_num )
172 {
173 }
174 
175 function ‪watch_perks_changed(local_client_num)
176 {
177  self notify( "watch_perks_changed" );
178  self endon( "watch_perks_changed" );
179  self endon( "death" );
180  self endon( "disconnect" );
181  self endon( "entityshutdown" );
182 
183  while(IsDefined(self))
184  {
186  util::clean_deleted(level.retrievable);
187  util::clean_deleted(level.enemyequip);
188  array::thread_all( level.retrievable, &‪updateRetrievable, local_client_num, 1 );
189  array::thread_all( level.enemyequip, &‪updateEnemyEquipment, local_client_num, 1 );
190  self waittill("perks_changed");
191  }
192 }
193 
194 
195 
196 function ‪checkTeamEquipment( localClientNum )
197 {
198  if ( !isdefined( self.owner ) )
199  {
200  return;
201  }
202  if ( !isdefined( self.equipmentOldTeam ) )
203  {
204  self.equipmentOldTeam = self.team;
205  }
206 
207  if ( !isdefined( self.equipmentOldOwnerTeam ) )
208  {
209  self.equipmentOldOwnerTeam = self.owner.team;
210  }
211 
212  watcher = GetLocalPlayer( localClientNum );
213 
214  if ( !isdefined( self.equipmentOldWatcherTeam ) )
215  {
216  self.equipmentOldWatcherTeam = watcher.team;
217  }
218 
219  if ( self.equipmentOldTeam != self.team || self.equipmentOldOwnerTeam != self.owner.team || self.equipmentOldWatcherTeam != watcher.team)
220  {
221  self.equipmentOldTeam = self.team;
222  self.equipmentOldOwnerTeam = self.owner.team;
223  self.equipmentOldWatcherTeam = watcher.team;
224 
225  self notify( "team_changed" );
226  }
227 }
228 
229 //******************************************************************
230 // *
231 // *
232 //******************************************************************
233 function ‪equipmentTeamObject( localClientNum )
234 {
235  if ( ‪IS_TRUE( level.disable_equipment_team_object ) )
236  {
237  return;
238  }
239 
240  self endon( "entityshutdown" );
241 
242  self ‪util::waittill_dobj(localClientNum);
243 
244  wait( 0.05 );
245 
246  fx_handle = self thread ‪playFlareFX( localClientNum );
247 
248  self thread ‪equipmentWatchTeamFX( localClientNum, fx_handle );
249 
250  self thread ‪equipmentWatchPlayerTeamChanged( localClientNum, fx_handle );
251 
252  self thread ‪equipmentDR();
253 }
254 
255 //******************************************************************
256 // *
257 // *
258 //******************************************************************
259 function ‪playFlareFX( localClientNum ) // self is the equipment entity
260 {
261  self endon( "entityshutdown" );
262  level endon( "player_switch" );
263 
264  if ( !isdefined( self.equipmentTagFX ) )
265  {
266  self.equipmentTagFX = "tag_origin";
267  }
268 
269  if ( !isdefined( self.equipmentFriendFX ) )
270  {
271  self.equipmentTagFX = level._effect[ "powerLightGreen" ];
272  }
273 
274  if ( !isdefined( self.equipmentEnemyFX ) )
275  {
276  self.equipmentTagFX = level._effect[ "powerLight" ];
277  }
278 
279  if ( self ‪util::friend_not_foe( localClientNum, true ) )
280  {
281  fx_handle = PlayFXOnTag( localClientNum, self.equipmentFriendFX, self, self.equipmentTagFX );
282  }
283  else
284  {
285  fx_handle = PlayFXOnTag( localClientNum, self.equipmentEnemyFX, self, self.equipmentTagFX );
286  }
287 
288  return fx_handle;
289 }
290 
291 //******************************************************************
292 // equipmentWatchTeamFX *
293 // handles notifies that may cause the FX to change *
294 //******************************************************************
295 function ‪equipmentWatchTeamFX( localClientNum, fxHandle ) // self is the equipment entity
296 {
297  msg = self ‪util::waittill_any_return( "entityshutdown", "team_changed", "player_switch" );
298 
299  if ( isdefined( fxHandle ) )
300  {
301  stopFx( localClientNum, fxHandle );
302  }
303 
304  waittillframeend;
305 
306  if ( msg != "entityshutdown" && isdefined( self ) )
307  {
308  self thread ‪equipmentTeamObject( localClientNum );
309  }
310 }
311 
312 //*****************************************************************
313 // equipmentWatchPlayerTeamChanged *
314 // handles the player changing teams and notifies the equipment *
315 //*****************************************************************
316 function ‪equipmentWatchPlayerTeamChanged( localClientNum, fxHandle ) // self is the equipment entity
317 {
318  self endon( "entityshutdown" );
319  self notify( "team_changed_watcher" );
320  self endon( "team_changed_watcher" );
321 
322  watcherPlayer = GetLocalPlayer( localClientNum );
323 
324  while ( 1 )
325  {
326  level waittill( "team_changed", clientNum );
327 
328  player = GetLocalPlayer( clientNum );
329 
330  if ( watcherPlayer == player )
331  {
332  self notify( "team_changed" );
333  }
334  }
335 }
336 
337 
338 
339 function ‪sndProxAlert_EntCleanup( localClientNum, ent )
340 {
341  level ‪util::waittill_any( "sndDEDe", "demo_jump", "player_switch", "killcam_begin", "killcam_end" );
342 
343  if ( isdefined(ent) )
344  {
345  ent StopAllLoopSounds( 0.5 );
346  ent delete();
347  }
348 }
‪init_shared
‪function init_shared()
Definition: _weaponobjects.csc:23
‪set_item_retrievable
‪function set_item_retrievable(localClientNum, on_off)
Definition: duplicaterender_mgr.csc:424
‪equipmentWatchPlayerTeamChanged
‪function equipmentWatchPlayerTeamChanged(localClientNum, fxHandle)
Definition: _weaponobjects.csc:316
‪PROXIMITY_ALARM_ON
‪#define PROXIMITY_ALARM_ON
Definition: _weaponobjects.gsh:3
‪watch_killstreak_tap_activation
‪function watch_killstreak_tap_activation(local_client_num)
Definition: _weaponobjects.csc:51
‪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
‪waittill_any_return
‪function waittill_any_return(string1, string2, string3, string4, string5, string6, string7)
Definition: util_shared.csc:212
‪friend_not_foe
‪function friend_not_foe(localClientIndex, predicted)
Definition: util_shared.csc:1164
‪ENEMY_EQUIPMENT_SHADER_OFF
‪#define ENEMY_EQUIPMENT_SHADER_OFF
Definition: _weaponobjects.gsh:5
‪updateEnemyEquipment
‪function updateEnemyEquipment(local_client_num, newVal)
Definition: _weaponobjects.csc:149
‪set_item_enemy_equipment
‪function set_item_enemy_equipment(localClientNum, on_off)
Definition: duplicaterender_mgr.csc:434
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪retrievable_changed
‪function retrievable_changed(local_client_num, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _weaponobjects.csc:120
‪PROXIMITY_ALARM_DEPLOYED
‪#define PROXIMITY_ALARM_DEPLOYED
Definition: _weaponobjects.gsh:2
‪on_localplayer_spawned
‪function on_localplayer_spawned(local_client_num)
Definition: _weaponobjects.csc:41
‪update_sound
‪function update_sound(local_client_num, bNewEnt, newVal, oldVal)
Definition: _weaponobjects.csc:82
‪updateRetrievable
‪function updateRetrievable(local_client_num, newVal)
Definition: _weaponobjects.csc:127
‪enemyequip_changed
‪function enemyequip_changed(local_client_num, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _weaponobjects.csc:140
‪DEFAULT
‪#define DEFAULT(__var, __default)
Definition: shared.gsh:270
‪teamequip_changed
‪function teamequip_changed(local_client_num, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _weaponobjects.csc:110
‪sndProxAlert_EntCleanup
‪function sndProxAlert_EntCleanup(localClientNum, ent)
Definition: _weaponobjects.csc:339
‪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
‪proximity_alarm_changed
‪function proximity_alarm_changed(local_client_num, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _weaponobjects.csc:77
‪watch_perks_changed
‪function watch_perks_changed(local_client_num)
Definition: _weaponobjects.csc:175
‪updateTeamEquipment
‪function updateTeamEquipment(local_client_num, newVal)
Definition: _weaponobjects.csc:115
‪Spawn
‪function Spawn(parent, onDeathCallback)
Definition: _flak_drone.gsc:427
‪equipmentWatchTeamFX
‪function equipmentWatchTeamFX(localClientNum, fxHandle)
Definition: _weaponobjects.csc:295
‪set_item_friendly_equipment
‪function set_item_friendly_equipment(localClientNum, on_off)
Definition: duplicaterender_mgr.csc:439
‪equipmentDR
‪function equipmentDR(local_client_num)
Definition: _weaponobjects.csc:171
‪waittill_dobj
‪function waittill_dobj(localClientNum)
Definition: util_shared.csc:1117
‪equipmentTeamObject
‪function equipmentTeamObject(localClientNum)
Definition: _weaponobjects.csc:233
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪playFlareFX
‪function playFlareFX(localClientNum)
Definition: _weaponobjects.csc:259
‪PROXIMITY_ALARM_OFF
‪#define PROXIMITY_ALARM_OFF
Definition: _weaponobjects.gsh:1
‪WAIT_CLIENT_FRAME
‪#define WAIT_CLIENT_FRAME
Definition: shared.gsh:266
‪show_friendly_outlines
‪function show_friendly_outlines(local_client_num)
Definition: duplicaterender_mgr.csc:508
‪checkTeamEquipment
‪function checkTeamEquipment(localClientNum)
Definition: _weaponobjects.csc:196