‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_zm_daily_challenges.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #insert scripts\shared\shared.gsh;
4 
5 #using scripts\shared\array_shared;
6 #using scripts\shared\callbacks_shared;
7 #using scripts\shared\killstreaks_shared;
8 #using scripts\shared\laststand_shared;
9 #using scripts\shared\math_shared;
10 #using scripts\shared\system_shared;
11 #using scripts\shared\table_shared;
12 #using scripts\shared\util_shared;
13 #using scripts\shared\weapons_shared;
14 #using scripts\shared\flag_shared;
15 
16 #using scripts\zm\_zm;
17 #using scripts\zm\_zm_powerups;
18 #using scripts\zm\_zm_spawner;
19 #using scripts\zm\_zm_stats;
20 #using scripts\zm\_zm_utility;
21 #using scripts\zm\_zm_weapons;
22 #using scripts\zm\gametypes\_globallogic_score;
23 
24 #insert scripts\zm\_zm_daily_challenges.gsh;
25 
26 #define N_REACHED_ROUND_10 10
27 #define N_REACHED_ROUND_15 15
28 #define N_REACHED_ROUND_20 20
29 #define N_REACHED_ROUND_25 25
30 #define N_REACHED_ROUND_30 30
31 
32 #define N_HEADSHOT_KILLS_IN_A_ROW_GOAL 20
33 
34 #define STR_DAILY_CHALLENGE_FILENAME "gamedata/stats/zm/statsmilestones4.csv"
35 
36 //If these two values are updated, the associated string must be updated as well
37 #define N_BARRIERS_REBUILT 5
38 #define N_REBUILD_TIME 45
39 
40 #namespace zm_daily_challenges;
41 
42 ‪REGISTER_SYSTEM_EX( "zm_daily_challenges", &‪__init__, &‪__main__, undefined )
43 
44 function ‪__init__()
45 {
49 
51 }
52 
53 function ‪__main__()
54 {
55  level thread ‪spent_points_tracking();
56  level thread ‪earned_points_tracking();
57 }
58 
59 function ‪on_connect()//self = player
60 {
61  self thread ‪round_tracking();
62  self thread ‪perk_purchase_tracking();
63  self thread ‪perk_drink_tracking();
64 
65  self.a_daily_challenges = [];
66  self.a_daily_challenges[ ‪N_HEADSHOT_KILLS_IN_A_ROW ] = 0;
67  self.a_daily_challenges[ ‪N_POINTS_SPENT ] = 0;
68  self.a_daily_challenges[ ‪N_POINTS_EARNED ] = 0;
69  self.a_daily_challenges[ ‪N_ROUNDS_COMPLETED ] = 0;
70 }
71 
72 function ‪on_spawned()
73 {
75 }
76 
77 function ‪round_tracking()//self = player
78 {
79  self endon( "disconnect" );
80 
81  while( true )
82  {
83  level waittill( "end_of_round" );
84 
85  self.a_daily_challenges[ ‪N_ROUNDS_COMPLETED ]++;
86 
87  switch( self.a_daily_challenges[ ‪N_ROUNDS_COMPLETED ] )
88  {
89  case 10:
90  self ‪zm_stats::increment_challenge_stat( "ZM_DAILY_ROUND_10" );
91  break;
92 
93  case 15:
94  self ‪zm_stats::increment_challenge_stat( "ZM_DAILY_ROUND_15" );
95  break;
96 
97  case 20:
98  self ‪zm_stats::increment_challenge_stat( "ZM_DAILY_ROUND_20" );
99  break;
100 
101  case 25:
102  self ‪zm_stats::increment_challenge_stat( "ZM_DAILY_ROUND_25" );
103  break;
104 
105  case 30:
106  self ‪zm_stats::increment_challenge_stat( "ZM_DAILY_ROUND_30" );
107  break;
108  }
109  }
110 }
111 
112 function ‪death_check_for_challenge_updates( e_attacker )//self = zombie
113 {
114  if( !isdefined( e_attacker ) )//Make sure we aren't being recycled
115  {
116  return;
117  }
118 
119  //Check for trap kill
120  if( isdefined( e_attacker._trap_type ) )
121  {
122  if( isdefined( e_attacker.activated_by_player ) )
123  {
124  e_attacker.activated_by_player ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_TRAPS" );
125  }
126  }
127 
128  if( !IsPlayer( e_attacker ) )//Player checks only below
129  {
130  return;
131  }
132 
133  if( IsVehicle( self ) )//workaround for issues with setting damagemod/damageweapon on vehicles
134  {
135  str_damagemod = self.str_damagemod;
136  w_damage = self.w_damage;
137  }
138  else
139  {
140  str_damagemod = self.damagemod;
141  w_damage = self.damageweapon;
142  }
143 
144  if ( w_damage.isDualWield )
145  {
146  w_damage = w_damage.dualWieldWeapon;
147  }
148 
149  w_damage = ‪zm_weapons::get_nonalternate_weapon( w_damage ); //switch_from_alt_weapon( w_damage );
150 
151  //Check for headshot kills
152  if( ‪zm_utility::is_headshot( w_damage, self.damagelocation, str_damagemod ) )
153  {
154  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_HEADSHOTS" );
155 
156  e_attacker.a_daily_challenges[ ‪N_HEADSHOT_KILLS_IN_A_ROW ]++;
157  if( e_attacker.a_daily_challenges[ ‪N_HEADSHOT_KILLS_IN_A_ROW ] == ‪N_HEADSHOT_KILLS_IN_A_ROW_GOAL )
158  {
159  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_HEADSHOTS_IN_ROW" );
160  }
161  }
162  else
163  {
164  e_attacker.a_daily_challenges[ ‪N_HEADSHOT_KILLS_IN_A_ROW ] = 0;
165  }
166 
167  //Check for melee weapon kills
168  if( str_damagemod == "MOD_MELEE" )
169  {
170  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_MELEE" );
171  }
172 
173  //Check for Instakill powerup kills
174  if( isdefined( level.zombie_vars[e_attacker.team] ) && ‪IS_TRUE( level.zombie_vars[e_attacker.team]["zombie_insta_kill"] ) )
175  {
176  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_INSTAKILL" );
177  return; //Insta-Kill strips the weapon data, no need to check for other challenges
178  }
179 
180  //Check for PaP kills
181  if( ‪zm_weapons::is_weapon_upgraded( w_damage ) )
182  {
183  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_PACKED" );
184 
185  if( level.zombie_weapons[ level.start_weapon ].upgrade === w_damage )
186  {
187  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_PACKED_STARTING_PISTOL" );
188  }
189 
190  //Check by weapon class
191  switch( w_damage.weapclass )
192  {
193  case "mg":
194  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_PACKED_MG" );
195  break;
196 
197  case "pistol":
198  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_PACKED_PISTOL" );
199  break;
200 
201  case "smg":
202  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_PACKED_SMG" );
203  break;
204 
205  case "spread":
206  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_PACKED_SHOTGUN" );
207  break;
208 
209  case "rifle":
210  if( w_damage.issniperweapon )
211  {
212  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_PACKED_SNIPER" );
213  }
214  else
215  {
216  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_PACKED_RIFLE" );
217  }
218  break;
219  }
220  }
221 
222  //Check by weapon class
223  switch( w_damage.weapclass )
224  {
225  case "mg":
226  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_MG" );
227  break;
228 
229  case "pistol":
230  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_PISTOL" );
231  break;
232 
233  case "rifle":
234  if( w_damage.issniperweapon )
235  {
236  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_SNIPER" );
237  }
238  else
239  {
240  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_RIFLE" );
241  }
242  break;
243 
244  case "smg":
245  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_SMG" );
246  break;
247 
248  case "spread":
249  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_SHOTGUN" );
250  break;
251  }
252 
253  //Check for explosives
254  switch( str_damagemod )
255  {
256  case "MOD_EXPLOSIVE":
257  case "MOD_GRENADE":
258  case "MOD_GRENADE_SPLASH":
259  case "MOD_PROJECTILE":
260  case "MOD_PROJECTILE_SPLASH":
261  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_EXPLOSIVE" );
262  break;
263  }
264 
265  //Check specific weapons
266  if( w_damage == GetWeapon( "bowie_knife" ) )
267  {
268  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_BOWIE" );
269  }
270 
271  if( w_damage == GetWeapon( "bouncingbetty" ) )
272  {
273  e_attacker ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_BOUNCING_BETTY" );
274  }
275 }
276 
278 {
279  level endon( "end_game" );
280 
281  while( true )
282  {
283  level waittill( "spent_points", player, n_points );
284 
285  player.a_daily_challenges[ ‪N_POINTS_SPENT ] += n_points;
286  player ‪zm_stats::increment_challenge_stat( "ZM_DAILY_SPEND_25K", n_points );
287  player ‪zm_stats::increment_challenge_stat( "ZM_DAILY_SPEND_50K", n_points );
288  }
289 }
290 
292 {
293  level endon( "end_game" );
294 
295  while( true )
296  {
297  level waittill( "earned_points", player, n_points );
298 
299  if( level.zombie_vars[player.team]["zombie_point_scalar"] == 2 )
300  {
301  player.a_daily_challenges[ ‪N_POINTS_EARNED ] += n_points;
302  player ‪zm_stats::increment_challenge_stat( "ZM_DAILY_EARN_5K_WITH_2X", n_points );
303  }
304  }
305 }
306 
308 {
309  self endon( "disconnect" );
310  self notify("stop_challenge_ingame_time_tracking");
311  self endon("stop_challenge_ingame_time_tracking");
312 
313  level ‪flag::wait_till( "start_zombie_round_logic" );
314 
315  for ( ;; )
316  {
317  wait ( 1.0 );
318  ‪zm_stats::increment_client_stat( "ZM_DAILY_CHALLENGE_INGAME_TIME" );
319  }
320 }
321 
322 //Track windows boarded up by player
323 function ‪increment_windows_repaired( s_barrier )//self = player
324 {
325  ‪DEFAULT( self.n_dc_barriers_rebuilt, 0 );
326 
327  if( !‪IS_TRUE( self.b_dc_rebuild_timer_active ) )
328  {
329  self thread ‪rebuild_timer();
330  self.a_s_barriers_rebuilt = [];
331  }
332 
333  if( !IsInArray( self.a_s_barriers_rebuilt, s_barrier ) )
334  {
335  ‪ARRAY_ADD( self.a_s_barriers_rebuilt, s_barrier );
336  self.n_dc_barriers_rebuilt++;
337  }
338 }
339 
340 function private ‪rebuild_timer()//self = player
341 {
342  self endon( "disconnect" );
343 
344  self.b_dc_rebuild_timer_active = true;
345 
346  wait ‪N_REBUILD_TIME;//Wait for challenge time
347 
348  if( self.n_dc_barriers_rebuilt >= ‪N_BARRIERS_REBUILT )
349  {
350  self ‪zm_stats::increment_challenge_stat( "ZM_DAILY_REBUILD_WINDOWS" );
351  }
352  self.n_dc_barriers_rebuilt = 0;
353  self.a_s_barriers_rebuilt = [];
354  self.b_dc_rebuild_timer_active = undefined;
355 }
356 
357 //Track magic box usage
358 function ‪increment_magic_box()//self = player
359 {
360  if( ‪IS_TRUE( level.zombie_vars["zombie_powerup_fire_sale_on"] ) )
361  {
362  self ‪zm_stats::increment_challenge_stat( "ZM_DAILY_PURCHASE_FIRE_SALE_MAGIC_BOX" );
363  }
364  self ‪zm_stats::increment_challenge_stat( "ZM_DAILY_PURCHASE_MAGIC_BOX" );
365 }
366 
368 {
369  foreach( player in level.players )
370  {
371  if( player.sessionstate != "spectator" )
372  {
373  player ‪zm_stats::increment_challenge_stat( "ZM_DAILY_KILLS_NUKED" );
374  }
375  }
376 }
377 
378 function ‪perk_purchase_tracking()//self = player
379 {
380  self endon( "disconnect" );
381 
382  while( true )
383  {
384  self waittill( "perk_purchased", str_perk );
385 
386  self ‪zm_stats::increment_challenge_stat( "ZM_DAILY_PURCHASE_PERKS" );
387  }
388 }
389 
390 function ‪perk_drink_tracking()//self = player
391 {
392  self endon( "disconnect" );
393 
394  while( true )
395  {
396  self waittill( "perk_bought" );
397 
398  self ‪zm_stats::increment_challenge_stat( "ZM_DAILY_DRINK_PERKS" );
399  }
400 }
401 
402 function ‪debug_print( str_line )
403 {
404 }
405 
406 function ‪on_challenge_complete( params )
407 {
408  n_challenge_index = params.challengeIndex;
409  if( ‪is_daily_challenge( n_challenge_index ) )
410  {
411  if( isdefined( self ) )
412  {
413  UploadStats( self );
414  }
415 
416  a_challenges = ‪table::load( ‪STR_DAILY_CHALLENGE_FILENAME, "a0" );
417  str_current_challenge = a_challenges[ n_challenge_index ][ "e4" ];
418  n_players = level.players.size;
419  n_time_played = game["timepassed"] / 1000;
420  n_challenge_start_time = self ‪zm_stats::get_global_stat( "zm_daily_challenge_start_time" );
421  n_challenge_time_ingame = self ‪globallogic_score::getPersStat( "ZM_DAILY_CHALLENGE_INGAME_TIME" );
422  n_challenge_games_played = self ‪zm_stats::get_global_stat( "zm_daily_challenge_games_played" );
423  }
424 }
425 
426 function ‪is_daily_challenge( n_challenge_index )
427 {
428  n_row = TableLookupRowNum( ‪STR_DAILY_CHALLENGE_FILENAME, 0, n_challenge_index );
429 
430  if( n_row > -1 )//Daily Challenge Check
431  {
432  return true;
433  }
434 
435  return false;
436 }
‪perk_drink_tracking
‪function perk_drink_tracking()
Definition: _zm_daily_challenges.gsc:390
‪death_check_for_challenge_updates
‪function death_check_for_challenge_updates(e_attacker)
Definition: _zm_daily_challenges.gsc:112
‪__init__
‪function __init__()
Definition: _zm_daily_challenges.gsc:44
‪increment_client_stat
‪function increment_client_stat(stat_name, include_gametype)
Definition: _zm_stats.gsc:389
‪N_POINTS_EARNED
‪#define N_POINTS_EARNED
Definition: _zm_daily_challenges.gsh:5
‪N_HEADSHOT_KILLS_IN_A_ROW_GOAL
‪#define N_HEADSHOT_KILLS_IN_A_ROW_GOAL
Definition: _zm_daily_challenges.gsc:32
‪N_BARRIERS_REBUILT
‪#define N_BARRIERS_REBUILT
Definition: _zm_daily_challenges.gsc:37
‪increment_nuked_zombie
‪function increment_nuked_zombie()
Definition: _zm_daily_challenges.gsc:367
‪N_POINTS_SPENT
‪#define N_POINTS_SPENT
Definition: _zm_daily_challenges.gsh:4
‪debug_print
‪function debug_print(str_line)
Definition: _zm_daily_challenges.gsc:402
‪is_weapon_upgraded
‪function is_weapon_upgraded(weapon)
Definition: _zm_weapons.csc:155
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪N_ROUNDS_COMPLETED
‪#define N_ROUNDS_COMPLETED
Definition: _zm_daily_challenges.gsh:6
‪__main__
‪function __main__()
Definition: _zm_daily_challenges.gsc:53
‪on_spawned
‪function on_spawned()
Definition: _zm_daily_challenges.gsc:72
‪register_zombie_death_event_callback
‪function register_zombie_death_event_callback(func)
Definition: _zm_spawner.gsc:2463
‪perk_purchase_tracking
‪function perk_purchase_tracking()
Definition: _zm_daily_challenges.gsc:378
‪load
‪function load(str_filename, str_table_start, b_convert_numbers=true)
Definition: table_shared.gsc:14
‪increment_magic_box
‪function increment_magic_box()
Definition: _zm_daily_challenges.gsc:358
‪get_nonalternate_weapon
‪function get_nonalternate_weapon(weapon)
Definition: aat_shared.gsc:104
‪increment_challenge_stat
‪function increment_challenge_stat(stat_name, amount=1)
Definition: _zm_stats.gsc:478
‪DEFAULT
‪#define DEFAULT(__var, __default)
Definition: shared.gsh:270
‪rebuild_timer
‪function private rebuild_timer()
Definition: _zm_daily_challenges.gsc:340
‪earned_points_tracking
‪function earned_points_tracking()
Definition: _zm_daily_challenges.gsc:291
‪REGISTER_SYSTEM_EX
‪#define REGISTER_SYSTEM_EX(__sys, __func_init_preload, __func_init_postload, __reqs)
Definition: shared.gsh:209
‪ARRAY_ADD
‪#define ARRAY_ADD(__array, __item)
Definition: shared.gsh:304
‪is_headshot
‪function is_headshot(weapon, sHitLoc, sMeansOfDeath)
Definition: _zm_utility.gsc:5265
‪N_HEADSHOT_KILLS_IN_A_ROW
‪#define N_HEADSHOT_KILLS_IN_A_ROW
Definition: _zm_daily_challenges.gsh:3
‪is_daily_challenge
‪function is_daily_challenge(n_challenge_index)
Definition: _zm_daily_challenges.gsc:426
‪wait_till
‪function wait_till(str_flag)
Definition: flag_shared.csc:189
‪getPersStat
‪function getPersStat(dataName)
Definition: _globallogic_score.gsc:1018
‪increment_windows_repaired
‪function increment_windows_repaired(s_barrier)
Definition: _zm_daily_challenges.gsc:323
‪round_tracking
‪function round_tracking()
Definition: _zm_daily_challenges.gsc:77
‪get_global_stat
‪function get_global_stat(stat_name)
Definition: _zm_stats.gsc:307
‪on_connect
‪function on_connect()
Definition: _zm_daily_challenges.gsc:59
‪on_challenge_complete
‪function on_challenge_complete(params)
Definition: _zm_daily_challenges.gsc:406
‪N_REBUILD_TIME
‪#define N_REBUILD_TIME
Definition: _zm_daily_challenges.gsc:38
‪spent_points_tracking
‪function spent_points_tracking()
Definition: _zm_daily_challenges.gsc:277
‪challenge_ingame_time_tracking
‪function challenge_ingame_time_tracking()
Definition: _zm_daily_challenges.gsc:307
‪STR_DAILY_CHALLENGE_FILENAME
‪#define STR_DAILY_CHALLENGE_FILENAME
Definition: _zm_daily_challenges.gsc:34