‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_gadget_camo.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 #using scripts\shared\callbacks_shared;
3 #using scripts\shared\clientfield_shared;
4 #using scripts\shared\flagsys_shared;
5 #using scripts\shared\abilities\_ability_gadgets;
6 #using scripts\shared\abilities\_ability_player;
7 #using scripts\shared\abilities\_ability_util;
8 
9 #insert scripts\shared\shared.gsh;
10 #insert scripts\shared\version.gsh;
11 #insert scripts\shared\abilities\_ability_util.gsh;
12 
13 #using scripts\shared\system_shared;
14 
15 ‪REGISTER_SYSTEM( "gadget_camo", &‪__init__, undefined )
16 
17 function ‪__init__()
18 {
24 
25  ‪clientfield::register( "allplayers", "camo_shader", ‪VERSION_SHIP, 3, "int" );
26  //clientfield::register( "actor", "camo_shader", VERSION_SHIP, 3, "int" );
27 
31 }
32 
33 function ‪camo_is_inuse( slot )
34 {
35  return self ‪flagsys::get( "camo_suit_on" );
36 }
37 
38 function ‪camo_is_flickering( slot )
39 {
40  // returns true when the gadget is flickering
41  return self GadgetFlickering( slot );
42 }
43 
45 {
46  if(isDefined(level.cybercom) && isDefined(level.cybercom.active_camo))
47  {
48  self [[level.cybercom.active_camo._on_connect]]();
49  }
50 }
51 
53 {
54  if ( IsDefined( self.sound_ent ) )
55  {
56  self.sound_ent stoploopsound( .05 );
57  self.sound_ent delete();
58  }
59 }
60 
61 function ‪camo_on_spawn()
62 {
63  self ‪flagsys::clear( "camo_suit_on" );
64  self notify( "camo_off" );
65  //self._gadget_camo_oldIgnoreme = undefined;
66  //self.ignoreme = false;
68  self ‪clientfield::set( "camo_shader", ‪GADGET_CAMO_SHADER_OFF );
69  if ( IsDefined( self.sound_ent ) )
70  {
71  self.sound_ent stoploopsound( .05 );
72  self.sound_ent delete();
73  }
74 }
75 
76 
78 //
79 // Player Camo Suit
80 //
82 
83 function ‪suspend_camo_suit( slot, weapon )
84 {
85  self endon( "disconnect" );
86  self endon( "camo_off" );
87 
89 
90  ‪suspend_camo_suit_wait( slot, weapon );
91 
92  if ( self ‪camo_is_inuse( slot ) )
93  {
94  self ‪clientfield::set( "camo_shader", ‪GADGET_CAMO_SHADER_ON );
95  }
96 }
97 
98 function ‪suspend_camo_suit_wait( slot, weapon )
99 {
100  self endon( "death" );
101  self endon( "camo_off" );
102 
103  while ( self ‪camo_is_flickering( slot ) )
104  {
105  wait 0.5;
106  }
107 }
108 
109 function ‪camo_on_give( slot, weapon )
110 {
111  if(isDefined(level.cybercom) && isDefined(level.cybercom.active_camo))
112  {
113  self [[level.cybercom.active_camo._on_give]](slot, weapon);
114  }
115 }
116 
117 function ‪camo_on_take( slot, weapon )
118 {
119  self notify( "camo_removed" );
120  if(isDefined(level.cybercom) && isDefined(level.cybercom.active_camo))
121  {
122  self [[level.cybercom.active_camo._on_take]](slot, weapon);
123  }
124 }
125 
126 function ‪camo_on_flicker( slot, weapon )
127 {
128  self thread ‪camo_suit_flicker( slot, weapon );
129  if(isDefined(level.cybercom) && isDefined(level.cybercom.active_camo))
130  {
131  self thread [[level.cybercom.active_camo._on_flicker]](slot, weapon);
132  }
133 }
134 
135 function ‪camo_all_actors( value )
136 {
137  str_opposite_team = "axis";
138 
139  if ( self.team == "axis" )
140  {
141  str_opposite_team = "allies";
142  }
143 
144  aiTargets = GetAIArray( str_opposite_team );
145 
146  for ( i = 0; i < aiTargets.size; i++ )
147  {
148  testTarget = aiTargets[i];
149 
150  if ( !IsDefined( testTarget ) || !IsAlive( testTarget ) )
151  {
152  continue;
153  }
154 
155  //testTarget clientfield::set( "camo_shader", value );
156  }
157 }
158 
159 
160 function ‪camo_gadget_on( slot, weapon )
161 {
162  if(isDefined(level.cybercom) && isDefined(level.cybercom.active_camo))
163  {
164  self thread [[level.cybercom.active_camo._on]](slot, weapon);
165  }
166 
167  self thread ‪camo_takedown_watch( slot, weapon );
168 
169  self._gadget_camo_oldIgnoreme = self.ignoreme;
170  self.ignoreme = true;
171 
172  self ‪clientfield::set( "camo_shader", ‪GADGET_CAMO_SHADER_ON );
173 
174  self ‪flagsys::set( "camo_suit_on" );
175  self thread ‪camo_bread_crumb( slot, weapon );
176 
177  //self camo_all_actors( GADGET_CAMO_SHADER_ON );
178  //self thread camo_loop_audio();
179 }
180 
181 /*function camo_loop_audio()
182 {
183  if ( IsDefined( self.sound_ent ) )
184  {
185  self.sound_ent stoploopsound( .05 );
186  self.sound_ent delete();
187  }
188  self.sound_ent = Spawn( "script_origin", self.origin );
189  self.sound_ent linkto( self );
190  self playsound ("gdt_camo_suit_on");
191  wait .5;
192 
193  if ( IsDefined( self.sound_ent ) )
194  {
195  self.sound_ent PlayLoopSound( "gdt_camo_suit_loop" , .1 );
196  }
197 }*/
198 
199 function ‪camo_gadget_off( slot, weapon )
200 {
201  self ‪flagsys::clear( "camo_suit_on" );
202  if(isDefined(level.cybercom) && isDefined(level.cybercom.active_camo))
203  {
204  self thread [[level.cybercom.active_camo._off]](slot, weapon);
205  }
206  if ( IsDefined( self.sound_ent ) )
207  {
208  //self.sound_ent stoploopsound( );
209  //self.sound_ent PlaySound( "gdt_camo_suit_off");
210  //self.sound_ent PlaySoundWithNotify( "gdt_camo_suit_off" , "sound_done" );
211  //self.sound_ent delete();
212  //self.sound_ent waittill( "sound_done" );
213 
214  }
215 
216  self notify( "camo_off" );
217 
218  if ( IsDefined( self._gadget_camo_oldIgnoreme ) )
219  {
220  self.ignoreme = self._gadget_camo_oldIgnoreme;
221  self._gadget_camo_oldIgnoreme = undefined;
222  }
223  else
224  {
225  self.ignoreme = false;
226  }
227 
229 
230  self.gadget_camo_off_time = GetTime();
231  self ‪clientfield::set( "camo_shader", ‪GADGET_CAMO_SHADER_OFF );
232 
233  //self camo_all_actors( GADGET_CAMO_SHADER_OFF );
234 }
235 
236 function ‪camo_bread_crumb( slot, weapon )
237 {
238  self notify( "camo_bread_crumb" );
239  self endon( "camo_bread_crumb" );
240 
242 
243  if ( !self ‪camo_is_inuse() )
244  {
245  return;
246  }
247 
248  self._camo_crumb = ‪spawn( "script_model", self.origin );
249  self._camo_crumb SetModel( "tag_origin" );
250 
251  //self GadgetSetEntity( slot, self._camo_crumb );
252  //self GadgetSetActivateTime( slot, GetTime() );
253 
254  self ‪camo_bread_crumb_wait( slot, weapon );
255 
257 }
258 
259 function ‪camo_bread_crumb_wait( slot, weapon )
260 {
261  self endon( "disconnect" );
262  self endon( "death" );
263  self endon( "camo_off" );
264  self endon( "camo_bread_crumb" );
265 
266  ‪startTime = GetTime();
267 
268  while ( 1 )
269  {
270  currentTime = GetTime();
271 
272  if ( currentTime - ‪startTime > self._gadgets_player[slot].gadget_breadCrumbDuration )
273  {
274  return;
275  }
276 
277  wait 0.5;
278  }
279 }
280 
282 {
283  if ( IsDefined( self._camo_crumb ) )
284  {
285  self._camo_crumb delete();
286  self._camo_crumb = undefined;
287  }
288 }
289 
290 function ‪camo_takedown_watch( slot, weapon )
291 {
292  self endon( "disconnect" );
293  self endon( "camo_off" );
294 
295  while( 1 )
296  {
297  self waittill( "weapon_assassination" );
298 
299  if ( self ‪camo_is_inuse() )
300  {
301  if ( self._gadgets_player[slot].gadget_takedownrevealtime > 0 )
302  {
303  self ‪ability_gadgets::SetFlickering( slot, self._gadgets_player[slot].gadget_takedownrevealtime );
304  }
305  }
306  }
307 }
308 
310 {
311  self endon( "disconnect" );
312 
313  if ( !self ‪camo_is_inuse() )
314  {
315  return;
316  }
317 
318  self notify( "temporary_dont_ignore" );
319 
320  wait(0.1);
321 
322  old_ignoreme = false;
323 
324  if ( IsDefined( self._gadget_camo_oldIgnoreme ) )
325  {
326  old_ignoreme = self._gadget_camo_oldIgnoreme;
327  }
328 
329  self.ignoreme = old_ignoreme;
330 
332 
333  self.ignoreme = ( self ‪camo_is_inuse() || old_ignoreme );
334 }
335 
337 {
338  self endon( "disconnect" );
339  self endon( "death" );
340  self endon( "camo_off" );
341  self endon( "temporary_dont_ignore" );
342 
343  while( 1 )
344  {
345  if ( !self ‪camo_is_flickering( slot ) )
346  {
347  return;
348  }
349 
350  wait( 0.25 );
351  }
352 }
353 
354 function ‪camo_suit_flicker( slot, weapon )
355 {
356  self endon( "disconnect" );
357  self endon( "death" );
358  self endon( "camo_off" );
359 
360  if ( !self ‪camo_is_inuse() )
361  {
362  return;
363  }
364 
365  // temp
366  self thread ‪camo_temporary_dont_ignore( slot );
367  self thread ‪suspend_camo_suit( slot, weapon );
368 
369  while( 1 )
370  {
371  if ( !self ‪camo_is_flickering( slot ) )
372  {
373  self thread ‪camo_bread_crumb( slot );
374  return;
375  }
376 
377  wait( 0.25 );
378  }
379 }
380 
381 function ‪set_camo_reveal_status( status, time )
382 {
383  timeStr = "";
384  self._gadget_camo_reveal_status = undefined;
385 
386  if ( IsDefined( time ) )
387  {
388  timeStr = ", ^3time: " + time;
389  self._gadget_camo_reveal_status = status;
390  }
391 
392  if ( GetDvarInt( "scr_cpower_debug_prints" ) > 0 )
393  self IPrintlnBold( "Camo Reveal: " + status + timeStr );
394 }
‪register_gadget_is_flickering_callbacks
‪function register_gadget_is_flickering_callbacks(type, flickering_func)
Definition: _ability_player.gsc:299
‪startTime
‪class AnimationAdjustmentInfoZ startTime
‪camo_on_spawn
‪function camo_on_spawn()
Definition: _gadget_camo.gsc:61
‪camo_takedown_watch
‪function camo_takedown_watch(slot, weapon)
Definition: _gadget_camo.gsc:290
‪camo_on_flicker
‪function camo_on_flicker(slot, weapon)
Definition: _gadget_camo.gsc:126
‪GADGET_CAMO_SHADER_OFF
‪#define GADGET_CAMO_SHADER_OFF
Definition: _ability_util.gsh:54
‪register_gadget_possession_callbacks
‪function register_gadget_possession_callbacks(type, on_give, on_take)
Definition: _ability_player.gsc:221
‪camo_on_disconnect
‪function camo_on_disconnect()
Definition: _gadget_camo.gsc:52
‪camo_suit_flicker
‪function camo_suit_flicker(slot, weapon)
Definition: _gadget_camo.gsc:354
‪GADGET_CAMO_SHADER_ON
‪#define GADGET_CAMO_SHADER_ON
Definition: _ability_util.gsh:55
‪clear
‪function clear(str_flag)
Definition: flag_shared.csc:130
‪camo_on_connect
‪function camo_on_connect()
Definition: _gadget_camo.gsc:44
‪register_gadget_is_inuse_callbacks
‪function register_gadget_is_inuse_callbacks(type, inuse_func)
Definition: _ability_player.gsc:289
‪GADGET_CAMO_SHADER_FLICKER
‪#define GADGET_CAMO_SHADER_FLICKER
Definition: _ability_util.gsh:56
‪VERSION_SHIP
‪#define VERSION_SHIP
Definition: version.gsh:36
‪SetFlickering
‪function SetFlickering(slot, length)
Definition: _ability_gadgets.gsc:37
‪camo_gadget_on
‪function camo_gadget_on(slot, weapon)
Definition: _gadget_camo.gsc:160
‪camo_all_actors
‪function camo_all_actors(value)
Definition: _gadget_camo.gsc:135
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪on_disconnect
‪function on_disconnect()
Definition: _wager.gsc:88
‪get
‪function get(kvp_value, kvp_key="targetname")
Definition: struct.csc:13
‪register_gadget_flicker_callbacks
‪function register_gadget_flicker_callbacks(type, on_flicker)
Definition: _ability_player.gsc:253
‪camo_gadget_off
‪function camo_gadget_off(slot, weapon)
Definition: _gadget_camo.gsc:199
‪camo_bread_crumb_delete
‪function camo_bread_crumb_delete()
Definition: _gadget_camo.gsc:281
‪camo_temporary_dont_ignore_wait
‪function camo_temporary_dont_ignore_wait(slot)
Definition: _gadget_camo.gsc:336
‪camo_bread_crumb
‪function camo_bread_crumb(slot, weapon)
Definition: _gadget_camo.gsc:236
‪__init__
‪function __init__()
Definition: _gadget_camo.gsc:17
‪suspend_camo_suit_wait
‪function suspend_camo_suit_wait(slot, weapon)
Definition: _gadget_camo.gsc:98
‪camo_is_flickering
‪function camo_is_flickering(slot)
Definition: _gadget_camo.gsc:38
‪camo_temporary_dont_ignore
‪function camo_temporary_dont_ignore(slot)
Definition: _gadget_camo.gsc:309
‪on_spawned
‪function on_spawned(func, obj)
Definition: callbacks_shared.csc:245
‪camo_is_inuse
‪function camo_is_inuse(slot)
Definition: _gadget_camo.gsc:33
‪register_gadget_activation_callbacks
‪function register_gadget_activation_callbacks(type, turn_on, turn_off)
Definition: _ability_player.gsc:237
‪suspend_camo_suit
‪function suspend_camo_suit(slot, weapon)
Definition: _gadget_camo.gsc:83
‪camo_bread_crumb_wait
‪function camo_bread_crumb_wait(slot, weapon)
Definition: _gadget_camo.gsc:259
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪set_camo_reveal_status
‪function set_camo_reveal_status(status, time)
Definition: _gadget_camo.gsc:381
‪set
‪function set(str_field_name, n_value)
Definition: clientfield_shared.gsc:34
‪camo_on_take
‪function camo_on_take(slot, weapon)
Definition: _gadget_camo.gsc:117
‪camo_on_give
‪function camo_on_give(slot, weapon)
Definition: _gadget_camo.gsc:109
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪on_connect
‪function on_connect()
Definition: _arena.gsc:20
‪GADGET_TYPE_OPTIC_CAMO
‪#define GADGET_TYPE_OPTIC_CAMO
Definition: _ability_util.gsh:6