‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_zm_perks.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\clientfield_shared;
5 #using scripts\shared\filter_shared;
6 #using scripts\shared\util_shared;
7 #using scripts\shared\array_shared;
8 
9 #insert scripts\shared\shared.gsh;
10 #insert scripts\shared\version.gsh;
11 
12 #using scripts\zm\_filter;
13 #using scripts\shared\util_shared;
14 
15 #insert scripts\zm\_zm_perks.gsh;
16 
17 #namespace zm_perks;
18 
19 // Client side perks functionality
20 
21 function ‪init()
22 {
24 
25  //PERKS
27 
29 
31 }
32 
34 {
35  if( ‪IS_TRUE( level.zombiemode_using_perk_intro_fx))
36  {
37 
38  ‪clientfield::register( "scriptmover", "clientfield_perk_intro_fx" , ‪VERSION_SHIP,1,"int", &‪perk_meteor_fx, !‪CF_HOST_ONLY, !‪CF_CALLBACK_ZERO_ON_NEW_ENT);
39  }
40 
41  // register all custom perk client fields
42  if ( level._custom_perks.size > 0 )
43  {
44  a_keys = GetArrayKeys( level._custom_perks );
45  for ( i = 0; i < a_keys.size; i++ )
46  {
47  if ( IsDefined( level._custom_perks[ a_keys[ i ] ].clientfield_register ) )
48  {
49  level [[ level._custom_perks[ a_keys[ i ] ].clientfield_register ]]();
50  }
51  }
52  }
53 
54  level thread ‪perk_init_code_callbacks();
55 }
56 
58 {
59  wait(0.1); // This won't run - until after all the client field registration has finished.
60 
61  // handle custom perk code callbacks
62  if ( level._custom_perks.size > 0 )
63  {
64  a_keys = GetArrayKeys( level._custom_perks );
65 
66  for ( i = 0; i < a_keys.size; i++ )
67  {
68  if ( IsDefined( level._custom_perks[ a_keys[ i ] ].clientfield_code_callback ) )
69  {
70  level [[ level._custom_perks[ a_keys[ i ] ].clientfield_code_callback ]]();
71  }
72  }
73  }
74 }
75 
77 {
78  if ( !IsDefined( level._custom_perks ) )
79  {
80  level._custom_perks = [];
81  }
82 }
83 
84 
96 function ‪register_perk_clientfields( str_perk, func_clientfield_register, func_code_callback )
97 {
98  ‪_register_undefined_perk( str_perk );
99 
100  if ( !IsDefined( level._custom_perks[ str_perk ].clientfield_register ) )
101  {
102  level._custom_perks[ str_perk ].clientfield_register = func_clientfield_register;
103  }
104 
105  if ( !IsDefined( level._custom_perks[ str_perk ].clientfield_code_callback ) )
106  {
107  level._custom_perks[ str_perk ].clientfield_code_callback = func_code_callback;
108  }
109 }
110 
122 function ‪register_perk_effects( str_perk, str_light_effect )
123 {
124  ‪_register_undefined_perk( str_perk );
125 
126  if ( !IsDefined( level._custom_perks[ str_perk ].machine_light_effect ) )
127  {
128  level._custom_perks[ str_perk ].machine_light_effect = str_light_effect;
129  }
130 }
131 
142 function ‪register_perk_init_thread( str_perk, func_init_thread )
143 {
144  ‪_register_undefined_perk( str_perk );
145 
146  if ( !IsDefined( level._custom_perks[ str_perk ].init_thread ) )
147  {
148  level._custom_perks[ str_perk ].init_thread = func_init_thread;
149  }
150 }
151 
153 {
154  if ( level._custom_perks.size > 0 )
155  {
156  a_keys = GetArrayKeys( level._custom_perks );
157  for ( i = 0; i < a_keys.size; i++ )
158  {
159  if ( IsDefined( level._custom_perks[ a_keys[ i ] ].init_thread ) )
160  {
161  level thread [[ level._custom_perks[ a_keys[ i ] ].init_thread ]]();
162  }
163  }
164  }
165 }
166 
167 function ‪_register_undefined_perk( str_perk )
168 {
169  if ( !IsDefined( level._custom_perks ) )
170  {
171  level._custom_perks = [];
172  }
173 
174  if ( !IsDefined( level._custom_perks[ str_perk ] ) )
175  {
176  level._custom_perks[ str_perk ] = SpawnStruct();
177  }
178 }
179 
180 function ‪perk_meteor_fx (localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
181 {
182  if(newVal )
183  {
184  self.meteor_fx = playfxontag( localClientNum, level._effect[ "perk_meteor" ], self, "tag_origin" );
185  }
186  else
187  {
188  if(isDefined(self.meteor_fx))
189  {
190  StopFX(localClientNum,self.meteor_fx);
191 
192  }
193  }
194 }
195 
196 function ‪init_perk_machines_fx( localclientnum )
197 {
198  if( !level.enable_magic )
199  {
200  return;
201  }
202 
203  wait 0.1;
204 
205  machines = ‪struct::get_array( "zm_perk_machine", "targetname" );
206  array::thread_all(machines, &‪perk_start_up);
207 }
208 
210 {
211  if(IsDefined(self.script_int))
212  {
213  power_zone = self.script_int;
214 
215  int = undefined;
216  while( int != power_zone)
217  {
218  level waittill("power_on", int); // Zombie power on.
219  }
220  }
221  else //doesn't care if zone controlled. global
222  {
223  level waittill("power_on"); // Zombie power on.
224  }
225 
226  ‪timer = 0;
227  duration = 0.1;
228 
229  while( true )
230  {
231  if ( IsDefined( level._custom_perks[ self.script_noteworthy ] ) && IsDefined( level._custom_perks[ self.script_noteworthy ].machine_light_effect ) )
232  {
233  self thread ‪vending_machine_flicker_light( level._custom_perks[ self.script_noteworthy ].machine_light_effect, duration );
234  }
235 
236  ‪timer += duration;
237  duration += 0.2;
238  if( ‪timer >= 3 )
239  {
240  break;
241  }
242  waitrealtime( duration );
243  }
244 }
245 
246 function ‪vending_machine_flicker_light( fx_light, duration )
247 {
248  players = level.localPlayers;
249  for( i = 0; i < players.size; i++ )
250  {
251  self thread ‪play_perk_fx_on_client( i, fx_light, duration );
252  }
253 }
254 
255 function ‪play_perk_fx_on_client( client_num, fx_light, duration )
256 {
257  fxObj = ‪spawn( client_num, self.origin +( 0, 0, -50 ), "script_model" );
258  fxobj setmodel( "tag_origin" );
259  //fxobj.angles = self.angles;
260  playfxontag( client_num, level._effect[fx_light], fxObj, "tag_origin" );
261  waitrealtime( duration );
262  fxobj delete();
263 }
264 
‪perk_meteor_fx
‪function perk_meteor_fx(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _zm_perks.csc:180
‪timer
‪function timer(n_time, str_endon, x, y, height)
Definition: lui_shared.gsc:163
‪register_perk_clientfields
‪function register_perk_clientfields(str_perk, func_clientfield_register, func_code_callback)
Definition: _zm_perks.csc:96
‪register_perk_init_thread
‪function register_perk_init_thread(str_perk, func_init_thread)
Definition: _zm_perks.csc:142
‪init_perk_custom_threads
‪function init_perk_custom_threads()
Definition: _zm_perks.csc:152
‪on_start_gametype
‪function on_start_gametype(func, obj)
Definition: callbacks_shared.csc:285
‪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
‪vending_machine_flicker_light
‪function vending_machine_flicker_light(fx_light, duration)
Definition: _zm_perks.csc:246
‪get_array
‪function get_array(kvp_value, kvp_key="targetname")
Definition: struct.csc:34
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪perk_start_up
‪function perk_start_up()
Definition: _zm_perks.csc:209
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪perks_register_clientfield
‪function perks_register_clientfield()
Definition: _zm_perks.csc:33
‪perk_init_code_callbacks
‪function perk_init_code_callbacks()
Definition: _zm_perks.csc:57
‪play_perk_fx_on_client
‪function play_perk_fx_on_client(client_num, fx_light, duration)
Definition: _zm_perks.csc:255
‪CF_HOST_ONLY
‪#define CF_HOST_ONLY
Definition: version.gsh:102
‪_register_undefined_perk
‪function _register_undefined_perk(str_perk)
Definition: _zm_perks.csc:167
‪init_perk_machines_fx
‪function init_perk_machines_fx(localclientnum)
Definition: _zm_perks.csc:196
‪init_custom_perks
‪function init_custom_perks()
Definition: _zm_perks.csc:76
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪register_perk_effects
‪function register_perk_effects(str_perk, str_light_effect)
Definition: _zm_perks.csc:122
‪init
‪function init()
Definition: _zm_perks.csc:21