‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_zm_magicbox.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\aat_shared;
4 #using scripts\shared\array_shared;
5 #using scripts\shared\clientfield_shared;
6 #using scripts\shared\demo_shared;
7 #using scripts\shared\flag_shared;
8 #using scripts\shared\system_shared;
9 #using scripts\shared\util_shared;
10 
11 #insert scripts\shared\shared.gsh;
12 #insert scripts\shared\version.gsh;
13 
14 #using scripts\zm\_bb;
15 #using scripts\zm\_zm_audio;
16 #using scripts\zm\_zm_bgb;
17 #using scripts\zm\_zm_daily_challenges;
18 #using scripts\zm\_zm_equipment;
19 #using scripts\zm\_zm_pack_a_punch_util;
20 #using scripts\zm\_zm_pers_upgrades_functions;
21 #using scripts\zm\_zm_score;
22 #using scripts\zm\_zm_stats;
23 #using scripts\zm\_zm_unitrigger;
24 #using scripts\zm\_zm_utility;
25 #using scripts\zm\_zm_weapons;
26 
27 #insert scripts\zm\_zm_perks.gsh;
28 #insert scripts\zm\_zm_utility.gsh;
29 
30 #precache( "fx", "zombie/fx_weapon_box_marker_zmb" );
31 #precache( "fx", "zombie/fx_weapon_box_marker_fl_zmb" );
32 #precache( "fx", "zombie/fx_barrier_buy_zmb" );
33 
37 // level.custom_magic_box_timer_til_despawn == Custom box movement
38 // level.custom_magic_box_do_weapon_rise == Custom weapon rise
39 // level.custom_magic_box_weapon_wait == Custom weapon wait until being taken back into the box
40 // level.custom_pandora_show_func == Custom map marker
41 // level.custom_magic_box_fx == Custom FX when box opens and closes
42 // level.custom_treasure_chest_glowfx == Custom Chest FX
43 // level.custom_magicbox_float_height == (int) custom float height
44 //
45 // If custom_pandora_show_func is defined, then a custom magicbox_host_migration() must be made in the new gsc
47 
48 #namespace zm_magicbox;
49 
50 #precache( "triggerstring", "ZOMBIE_TRADE_EQUIP_FILL" );
51 #precache( "triggerstring", "ZOMBIE_TRADE_WEAPON_FILL" );
52 
53 
54 ‪REGISTER_SYSTEM_EX( "zm_magicbox", &‪__init__, &‪__main__, undefined )
55 
56 function ‪__init__()
57 {
58  level.start_chest_name = "start_chest";
59 
60  level._effect["lght_marker"] = "zombie/fx_weapon_box_marker_zmb";
61  level._effect["lght_marker_flare"] = "zombie/fx_weapon_box_marker_fl_zmb";
62  level._effect["poltergeist"] = "zombie/fx_barrier_buy_zmb";
63 
64  ‪clientfield::register( "zbarrier", "magicbox_open_glow", ‪VERSION_SHIP, 1, "int" );
65  ‪clientfield::register( "zbarrier", "magicbox_closed_glow", ‪VERSION_SHIP, 1, "int" );
66 
67  ‪clientfield::register( "zbarrier", "zbarrier_show_sounds", ‪VERSION_SHIP, 1, "counter");
68  ‪clientfield::register( "zbarrier", "zbarrier_leave_sounds", ‪VERSION_SHIP, 1, "counter");
69 
70  ‪clientfield::register( "scriptmover", "force_stream", ‪VERSION_TU7, 1, "int" );
71 
72  level thread ‪magicbox_host_migration();
73 }
74 
75 function ‪__main__()
76 {
77  // Set values that may be overwritten by level specific scripts
78  if( !IsDefined( level.chest_joker_model ) )
79  {
80  level.chest_joker_model = "p7_zm_teddybear";
81  }
82 
83  if( !IsDefined( level.magic_box_zbarrier_state_func ) )
84  {
85  level.magic_box_zbarrier_state_func = &‪process_magic_box_zbarrier_state;
86  }
87 
88  if (!IsDefined(level.magic_box_check_equipment))
89  level.magic_box_check_equipment = &‪default_magic_box_check_equipment;
90 
91  wait(0.05);//wait for initialization stage to end so we can toggle client fields
92 
94  {
95  level.chests = ‪struct::get_array( "treasure_chest_use", "targetname" );
96  ‪treasure_chest_init( level.start_chest_name );
97  }
98 }
99 
100 // for the random weapon chest
101 //
102 // The chests need to be setup as follows:
103 // trigger_use - for the chest
104 // targets the lid
105 // lid - script_model. Flips open to reveal the items
106 // targets the script origin inside the box
107 // script_origin - inside the box, used for spawning the weapons
108 // targets the box
109 // box - script_model of the outer casing of the chest
110 // rubble - pieces that show when the box isn't there
111 // script_noteworthy should be the same as the use_trigger + "_rubble"
112 //
113 function ‪treasure_chest_init( start_chest_name )
114 {
115  level ‪flag::init("moving_chest_enabled");
116  level ‪flag::init("moving_chest_now");
117  level ‪flag::init("chest_has_been_used");
118 
119  level.chest_moves = 0;
120  level.chest_level = 0; // Level 0 = normal chest, 1 = upgraded chest
121  //level.chests = GetEntArray( "treasure_chest_use", "targetname" );
122 
123  //level.chests = struct::get_array( "treasure_chest_use", "targetname" );
124 
125  if( level.chests.size==0 )
126  return;
127 
128  for (i=0; i<level.chests.size; i++ )
129  {
130  level.chests[i].box_hacks = [];
131 
132  level.chests[i].orig_origin = level.chests[i].origin;
133  level.chests[i] ‪get_chest_pieces();
134 
135  if ( isDefined( level.chests[i].zombie_cost ) )
136  {
137  level.chests[i].old_cost = level.chests[i].zombie_cost;
138  }
139  else
140  {
141  // default chest cost
142  level.chests[i].old_cost = 950;
143  }
144  }
145 
146  if(!level.enable_magic)
147  {
148  foreach(chest in level.chests)
149  {
150  chest ‪hide_chest();
151  }
152  return;
153  }
154 
155  level.chest_accessed = 0;
156 
157  if (level.chests.size > 1)
158  {
159  level ‪flag::set("moving_chest_enabled");
160 
161  level.chests = array::randomize(level.chests);
162 
163  //determine magic box starting location at random or normal
164  //init_starting_chest_location();
165  }
166  else
167  {
168  level.chest_index = 0;
169  level.chests[0].no_fly_away = true;
170  }
171 
172  //determine magic box starting location at random or normal
173  ‪init_starting_chest_location( start_chest_name );
174 
175  array::thread_all( level.chests, &‪treasure_chest_think );
176 }
177 
178 function ‪init_starting_chest_location( start_chest_name )
179 {
180  level.chest_index = 0;
181  start_chest_found = false;
182 
183  if( level.chests.size==1 )
184  {
185  //Only 1 chest in the map
186  start_chest_found = true;
187 
188  if(isdefined(level.chests[level.chest_index].zbarrier))
189  {
190  level.chests[level.chest_index].zbarrier ‪set_magic_box_zbarrier_state("initial");
191  level.chests[level.chest_index] thread ‪box_encounter_vo();
192  }
193  }
194  else
195  {
196  for( i = 0; i < level.chests.size; i++ )
197  {
198  if( isdefined( level.random_pandora_box_start ) && level.random_pandora_box_start == true )
199  {
200  //start_exclude is a KVP, just need to add start_exclude 1 to the box script struct to exclude it from the initial random box selection
201  if ( start_chest_found || (IsDefined( level.chests[i].start_exclude ) && level.chests[i].start_exclude == 1) )
202  {
203  level.chests[i] ‪hide_chest();
204  }
205  else
206  {
207  level.chest_index = i;
208  level.chests[level.chest_index].hidden = false;
209  if(isdefined(level.chests[level.chest_index].zbarrier))
210  {
211  level.chests[level.chest_index].zbarrier ‪set_magic_box_zbarrier_state("initial");
212  level.chests[level.chest_index] thread ‪box_encounter_vo();
213  }
214  start_chest_found = true;
215  }
216 
217  }
218  else
219  {
220  // Semi-random implementation (not completely random). The list is randomized
221  // prior to getting here.
222  // Pick from any box marked as the "start_chest"
223  if ( start_chest_found || !IsDefined(level.chests[i].script_noteworthy ) || ( !IsSubStr( level.chests[i].script_noteworthy, start_chest_name ) ) )
224  {
225  level.chests[i] ‪hide_chest();
226  }
227  else
228  {
229  level.chest_index = i;
230  level.chests[level.chest_index].hidden = false;
231  if(isdefined(level.chests[level.chest_index].zbarrier))
232  {
233  level.chests[level.chest_index].zbarrier ‪set_magic_box_zbarrier_state("initial");
234  level.chests[level.chest_index] thread ‪box_encounter_vo();
235  }
236  start_chest_found = true;
237  }
238  }
239  }
240  }
241 
242  // Show the beacon
243  if( !isDefined( level.pandora_show_func ) )
244  {
245  if ( isdefined( level.custom_pandora_show_func ) )
246  {
247  level.pandora_show_func = level.custom_pandora_show_func;
248  }
249  else
250  {
251  level.pandora_show_func = &‪default_pandora_show_func;
252  }
253  }
254 
255  level.chests[level.chest_index] thread [[ level.pandora_show_func ]]();
256 }
257 
259 {
260  level.zombie_treasure_chest_cost = cost;
261 }
262 
263 //
264 // Save off the references to all of the chest pieces
265 // self = trigger
267 {
268  //self.chest_lid = GetEnt(self.target, "targetname");
269  //self.chest_origin = GetEnt(self.chest_lid.target, "targetname");
270 
271 // println( "***** LOOKING FOR: " + self.chest_origin.target );
272 
273  self.chest_box = GetEnt( self.script_noteworthy + "_zbarrier", "script_noteworthy" );
274 
275  //TODO fix temp hax to separate multiple instances
276  self.chest_rubble = [];
277  rubble = GetEntArray( self.script_noteworthy + "_rubble", "script_noteworthy" );
278  for ( i=0; i<rubble.size; i++ )
279  {
280  if ( DistanceSquared( self.origin, rubble[i].origin ) < 10000 )
281  {
282  self.chest_rubble[ self.chest_rubble.size ] = rubble[i];
283  }
284  }
285 
286  self.zbarrier = GetEnt(self.script_noteworthy + "_zbarrier", "script_noteworthy");
287  if(isdefined(self.zbarrier))
288  {
289  self.zbarrier ZBarrierPieceUseBoxRiseLogic(3);
290  self.zbarrier ZBarrierPieceUseBoxRiseLogic(4);
291  }
292 
293  self.unitrigger_stub = spawnstruct();
294  self.unitrigger_stub.origin = self.origin + (anglestoright(self.angles) * -22.5);
295  self.unitrigger_stub.angles = self.angles;
296  self.unitrigger_stub.script_unitrigger_type = "unitrigger_box_use";
297  self.unitrigger_stub.script_width = 104;
298  self.unitrigger_stub.script_height = 50;
299  self.unitrigger_stub.script_length = 45;
300  self.unitrigger_stub.trigger_target = self;
301  ‪zm_unitrigger::unitrigger_force_per_player_triggers(self.unitrigger_stub, true);
302  self.unitrigger_stub.prompt_and_visibility_func = &‪boxtrigger_update_prompt;
303  self.zbarrier.owner = self;
304 
305 }
306 
307 function ‪boxtrigger_update_prompt( player )
308 {
309  can_use = self ‪boxstub_update_prompt( player );
310  if(isdefined(self.hint_string))
311  {
312  if (IsDefined(self.hint_parm1))
313  self SetHintString( self.hint_string, self.hint_parm1 );
314  else
315  self SetHintString( self.hint_string );
316  }
317  return can_use;
318 }
319 
320 function ‪boxstub_update_prompt( player )
321 {
322  //self setCursorHint( "HINT_NOICON" );
323 
324  if (!self ‪trigger_visible_to_player( player ))
325  return false;
326 
327  if( isdefined( level.func_magicbox_update_prompt_use_override ) )
328  {
329  if( [[ level.func_magicbox_update_prompt_use_override ]]() )
330  {
331  return false;
332  }
333  }
334 
335  self.hint_parm1 = undefined;
336  if(‪IS_TRUE(self.stub.trigger_target.grab_weapon_hint))
337  {
338  cursor_hint = "HINT_WEAPON";
339  cursor_hint_weapon = self.stub.trigger_target.grab_weapon;
340  self setCursorHint( cursor_hint, cursor_hint_weapon );
341  if (IsDefined(level.magic_box_check_equipment) && [[level.magic_box_check_equipment]]( cursor_hint_weapon ) )
342  self.hint_string = &"ZOMBIE_TRADE_EQUIP_FILL";
343  else
344  self.hint_string = &"ZOMBIE_TRADE_WEAPON_FILL";
345  }
346  else
347  {
348  self setCursorHint( "HINT_NOICON" );
349  self.hint_parm1 = self.stub.trigger_target.zombie_cost;
350  self.hint_string = ‪zm_utility::get_hint_string( self, "default_treasure_chest" );
351  }
352  return true;
353 }
354 
356 {
357  return ‪zm_utility::is_offhand_weapon( weapon );
358 }
359 
360 
362 {
363  self SetInvisibleToPlayer(player);
364 
365  visible = true;
366 
367  if(IsDefined(self.stub.trigger_target.chest_user) && !IsDefined(self.stub.trigger_target.box_rerespun))
368  {
369  if( player != self.stub.trigger_target.chest_user || ‪zm_utility::is_placeable_mine( self.stub.trigger_target.chest_user GetCurrentWeapon() ) || self.stub.trigger_target.chest_user ‪zm_equipment::hacker_active())
370  {
371  visible = false;
372  }
373  }
374  else
375  {
376  if( !player ‪can_buy_weapon() )
377  {
378  visible = false;
379  }
380  }
381 
382  // PORTIZ 7/20/16: players could start spinning a weapon, acquire Disorderly Combat from a nearby BGB machine, and then take the weapon.
383  // separating out Disorderly Combat check since we never want a player to interact with the box while it's enabled
384  if ( player ‪bgb::is_enabled( "zm_bgb_disorderly_combat" ) )
385  {
386  visible = false;
387  }
388 
389  if(!visible)
390  {
391  return false;
392  }
393 
394  self SetVisibleToPlayer(player);
395  return true;
396 }
397 
399 {
400  self endon("kill_trigger");
401 
402  while ( 1 )
403  {
404  self waittill( "trigger", player );
405  self.stub.trigger_target notify("trigger", player);
406  }
407 }
408 
410 {
411  self playlocalsound( level.zmb_laugh_alias );
412 }
413 
414 //
415 // Show the chest pieces
416 // self = chest use_trigger
417 //
418 function ‪show_chest()
419 {
420  self.zbarrier ‪set_magic_box_zbarrier_state("arriving");
421  self.zbarrier ‪util::waittill_any_timeout( 5, "arrived");
422 
423  self thread [[ level.pandora_show_func ]]();
424 
425  self.zbarrier ‪clientfield::set( "magicbox_closed_glow", true );
426 
427  //self TriggerEnable( true );
429 
430  self.zbarrier ‪clientfield::increment("zbarrier_show_sounds" );
431 
432  self.hidden = false;
433 
434  if(IsDefined(self.box_hacks["summon_box"]))
435  {
436  self [[self.box_hacks["summon_box"]]](false);
437  }
438 
439 }
440 
441 function ‪hide_chest(doBoxLeave)
442 {
443  //self TriggerEnable( false );
444  if(isDefined(self.unitrigger_stub))
445  {
446  thread ‪zm_unitrigger::unregister_unitrigger(self.unitrigger_stub);
447  }
448  if ( IsDefined( self.pandora_light ) )
449  {
450  self.pandora_light delete();
451  }
452 
453  self.zbarrier ‪clientfield::set( "magicbox_closed_glow", false );
454 
455  self.hidden = true;
456 
457  if(isDefined(self.box_hacks) && IsDefined(self.box_hacks["summon_box"]))
458  {
459  self [[self.box_hacks["summon_box"]]](true);
460  }
461 
462  if(isdefined(self.zbarrier))
463  {
464  if(‪IS_TRUE(doBoxLeave))
465  {
466  self.zbarrier ‪clientfield::increment("zbarrier_leave_sounds" );
467 
468  level thread ‪zm_audio::sndAnnouncerPlayVox("boxmove");
469 
470  self.zbarrier thread ‪magic_box_zbarrier_leave();
471  self.zbarrier waittill("left");
472 
473  playfx( level._effect["poltergeist"], self.zbarrier.origin, AnglesToUp( self.zbarrier.angles ), AnglesToForward( self.zbarrier.angles ) ); // effect has X facing up, Z facing forward
474 
475  //TUEY - Play the 'disappear' sound
476  playsoundatposition ("zmb_box_poof", self.zbarrier.origin);
477  }
478  else
479  {
480  self.zbarrier thread ‪set_magic_box_zbarrier_state("away");
481  }
482  }
483 }
484 
486 {
487  self ‪set_magic_box_zbarrier_state("leaving");
488  self waittill("left");
489  self ‪set_magic_box_zbarrier_state("away");
490 }
491 
493 {
494  self endon( "death" );
495 
496  self.pandora_light = ‪Spawn( "script_model", self.zbarrier.origin );
497  self.pandora_light.angles = self.zbarrier.angles + (-90, 0, -90);
498  // level.pandora_light.angles = (-90, anchorTarget.angles[1] + 180, 0);
499  self.pandora_light SetModel( "tag_origin" );
500  if(!‪IS_TRUE(level._box_initialized))
501  {
502  level ‪flag::wait_till("start_zombie_round_logic");
503  level._box_initialized = true;
504  }
505  wait(1);
506  if ( IsDefined( self ) && IsDefined( self.pandora_light ) )
507  {
508  playfxontag(level._effect["lght_marker"], self.pandora_light, "tag_origin");
509  }
510 
511 }
512 
513 
514 //
515 // Show a column of light
516 //
517 function ‪default_pandora_show_func( anchor, anchorTarget, pieces )
518 {
519 
520  if ( !IsDefined(self.pandora_light) )
521  {
522  // Show the column light effect on the box
523  if( !IsDefined( level.pandora_fx_func ) )
524  {
525  level.pandora_fx_func = &‪default_pandora_fx_func;
526  }
527  self thread [[ level.pandora_fx_func ]]();
528  }
529 
530  playfx( level._effect["lght_marker_flare"],self.pandora_light.origin );
531 
532  //Add this location to the map
533  //Objective_Add( 0, "active", "Mystery Box", self.chest_lid.origin, "minimap_icon_mystery_box" );
534 }
535 
537 {
538  self notify( "unregister_unitrigger_on_kill_think" );
539  self endon( "unregister_unitrigger_on_kill_think" );
540 
541  self waittill("kill_chest_think");
542  thread ‪zm_unitrigger::unregister_unitrigger(self.unitrigger_stub);
543 
544 }
545 
547 {
548  self endon("kill_chest_think");
549  // waittill someuses uses this
550  user = undefined;
551  user_cost = undefined;
552  self.box_rerespun = undefined;
553  self.weapon_out = undefined;
554 
556 
557  while( 1 )
558  {
559  if(!IsDefined(self.forced_user))
560  {
561  self waittill( "trigger", user );
562  if (user == level)
563  continue;
564  }
565  else
566  {
567  user = self.forced_user;
568  }
569 
571  {
572  wait( 0.1 );
573  continue;
574  }
575 
576  if( ‪IS_DRINKING(user.is_drinking) )
577  {
578  wait( 0.1 );
579  continue;
580  }
581 
582  if ( ‪IS_TRUE( self.disabled ) )
583  {
584  wait( 0.1 );
585  continue;
586  }
587 
588  if( user GetCurrentWeapon() == level.weaponNone )
589  {
590  wait( 0.1 );
591  continue;
592  }
593 
594  // firesale is in the process of removing this box
595  if ( ‪IS_TRUE( self.being_removed ) )
596  {
597  wait( 0.1 );
598  continue;
599  }
600 
601  reduced_cost = undefined;
602 
603  // Make sure the user is a player, and that they can afford it
604  if( IsDefined(self.auto_open) && ‪zm_utility::is_player_valid( user ) )
605  {
606  if(!IsDefined(self.no_charge))
607  {
608  user ‪zm_score::minus_to_player_score( self.zombie_cost );
609  user_cost = self.zombie_cost;
610  }
611  else
612  {
613  user_cost = 0;
614  }
615 
616  self.chest_user = user;
617  break;
618  }
619  // Do we have enough money to use the box?
620  else if( ‪zm_utility::is_player_valid( user ) && user ‪zm_score::can_player_purchase( self.zombie_cost ) )
621  {
622  user ‪zm_score::minus_to_player_score( self.zombie_cost );
623  user_cost = self.zombie_cost;
624  self.chest_user = user;
625  break;
626  }
627  // Has the box cost been reduced?
628  else if( IsDefined(reduced_cost) && ( user ‪zm_score::can_player_purchase( reduced_cost ) ) )
629  {
630  user ‪zm_score::minus_to_player_score( reduced_cost );
631  user_cost = reduced_cost;
632  self.chest_user = user;
633  break;
634  }
635  // Can't afford the box purchase
636  else if ( !user ‪zm_score::can_player_purchase( self.zombie_cost ) )
637  {
638  ‪zm_utility::play_sound_at_pos( "no_purchase", self.origin );
639  user ‪zm_audio::create_and_play_dialog( "general", "outofmoney" );
640  continue;
641  }
642 
644  }
645 
646  level ‪flag::set("chest_has_been_used");
647 
648  //stat tracking
649  ‪demo::bookmark( "zm_player_use_magicbox", gettime(), user );
650  user ‪zm_stats::increment_client_stat( "use_magicbox" );
651  user ‪zm_stats::increment_player_stat( "use_magicbox" );
652  user ‪zm_stats::increment_challenge_stat( "SURVIVALIST_BUY_MAGIC_BOX" );
654 
655  if ( isDefined( level._magic_box_used_VO ) )
656  {
657  user thread [[ level._magic_box_used_VO ]]();
658  }
659 
660  self thread ‪watch_for_emp_close();
661 
662  self._box_open = true;
663  self._box_opened_by_fire_sale = false;
664  if ( ‪IS_TRUE( level.zombie_vars["zombie_powerup_fire_sale_on"] ) && !IsDefined(self.auto_open) && self [[level._zombiemode_check_firesale_loc_valid_func]]())
665  {
666  self._box_opened_by_fire_sale = true;
667  }
668 
669  //open the lid
670  if(isdefined(self.chest_lid))
671  {
672  self.chest_lid thread ‪treasure_chest_lid_open();
673  }
674 
675  if(isdefined(self.zbarrier))
676  {
677  ‪zm_utility::play_sound_at_pos( "open_chest", self.origin );
678  ‪zm_utility::play_sound_at_pos( "music_chest", self.origin );
679  self.zbarrier ‪set_magic_box_zbarrier_state("open");
680  }
681 
682  // SRS 9/3/2008: added to help other functions know if we timed out on grabbing the item
683  self.timedOut = false;
684 
685  // mario kart style weapon spawning
686  self.weapon_out = true;
687  self.zbarrier thread ‪treasure_chest_weapon_spawn( self, user );
688 
689  // the glowfx
690  if ( isdefined(level.custom_treasure_chest_glowfx ) )
691  {
692  self.zbarrier thread [[level.custom_treasure_chest_glowfx]]();
693  }
694  else
695  {
696  self.zbarrier thread ‪treasure_chest_glowfx();
697  }
698 
699  // take away usability until model is done randomizing
700  //self TriggerEnable( false );
701  thread ‪zm_unitrigger::unregister_unitrigger(self.unitrigger_stub);
702 
703  self.zbarrier ‪util::waittill_any( "randomization_done", "box_hacked_respin" );
704 
705  // refund money from teddy.
706  if ( level ‪flag::get( "moving_chest_now" ) && !self._box_opened_by_fire_sale && isdefined( user_cost ) )
707  {
708  user ‪zm_score::add_to_player_score( user_cost, false, "magicbox_bear" );
709  }
710 
711  if ( level ‪flag::get( "moving_chest_now" ) && !level.zombie_vars[ "zombie_powerup_fire_sale_on" ] && !self._box_opened_by_fire_sale )
712  {
713  //CA AUDIO: 01/12/10 - Changed dialog to use correct function
714  //self.chest_user zm_audio::create_and_play_dialog( "general", "box_move" );
715  self thread ‪treasure_chest_move( self.chest_user );
716  }
717  else
718  {
719  if( !‪IS_TRUE( self.unbearable_respin ) )
720  {
721  // Let the player grab the weapon and re-enable the box //
722  self.grab_weapon_hint = true;
723  self.grab_weapon = self.zbarrier.weapon;
724  self.chest_user = user;
725  weaponIdx = undefined;
726  if (isDefined(self.grab_weapon))
727  {
728  weaponIdx = MatchRecordGetWeaponIndex(self.grab_weapon);
729  }
730 
731  if ( isDefined(weaponIdx) )
732  {
733  user RecordMapEvent(‪ZM_MAP_EVENT_MAGIC_BOX_OFFERED, GetTime(), user.origin, level.round_number, weaponIdx);
734  }
735 
736  // Limit its visibility to the player who bought the box
737  //self TriggerEnable( true );
739 
740  if( isDefined(self.zbarrier) && !‪IS_TRUE(self.zbarrier.closed_by_emp) )
741  {
742  self thread ‪treasure_chest_timeout();
743  }
744  }
745 
746  // make sure the guy that spent the money gets the item
747  // SRS 9/3/2008: ...or item goes back into the box if we time out
748  while( !‪IS_TRUE(self.closed_by_emp) )
749  {
750  self waittill( "trigger", grabber );
751  self.weapon_out = undefined;
752 
753  if ( ‪IS_TRUE( level.magic_box_grab_by_anyone ) )
754  {
755  if( IsPlayer(grabber) )
756  {
757  user = grabber;
758  }
759  }
760 
761  if( IsDefined( grabber.is_drinking ) && ‪IS_DRINKING(grabber.is_drinking) )
762  {
763  wait( 0.1 );
764  continue;
765  }
766 
767  if ( grabber == user && user GetCurrentWeapon() == level.weaponNone )
768  {
769  wait( 0.1 );
770  continue;
771  }
772 
773  if(grabber != level && (IsDefined(self.box_rerespun) && self.box_rerespun))
774  {
775  user = grabber;
776  }
777 
778  if( grabber == user || grabber == level )
779  {
780  self.box_rerespun = undefined;
781  current_weapon = level.weaponNone;
782 
784  {
785  current_weapon = user GetCurrentWeapon();
786  }
787 
788  if( grabber == user &&
790  !‪IS_DRINKING(user.is_drinking) &&
791  !‪zm_utility::is_placeable_mine( current_weapon ) &&
792  !‪zm_equipment::is_equipment( current_weapon ) &&
793  !user ‪zm_utility::is_player_revive_tool(current_weapon) &&
794  !current_weapon.isheroweapon &&
795  !current_weapon.isgadget )
796  {
797  weaponIdx = undefined;
798  if (isDefined(self.zbarrier) && isDefined(self.zbarrier.weapon))
799  {
800  weaponIdx = MatchRecordGetWeaponIndex(self.zbarrier.weapon);
801  }
802 
803  if (isDefined(weaponidx))
804  {
805  user RecordMapEvent(‪ZM_MAP_EVENT_MAGIC_BOX_TAKEN, GetTime(), user.origin, level.round_number, weaponIdx);
806  }
807 
808  self notify( "user_grabbed_weapon" );
809  user notify( "user_grabbed_weapon" );
810  user thread ‪treasure_chest_give_weapon( self.zbarrier.weapon );
811 
812  ‪demo::bookmark( "zm_player_grabbed_magicbox", gettime(), user );
813 
814  //stat tracking
815  user ‪zm_stats::increment_client_stat( "grabbed_from_magicbox" );
816  user ‪zm_stats::increment_player_stat( "grabbed_from_magicbox" );
817 
818  break;
819  }
820  else if( grabber == level )
821  {
822  // it timed out
823  self.timedOut = true;
824  weaponIdx = undefined;
825  if (isDefined(self.zbarrier) && isDefined(self.zbarrier.weapon))
826  {
827  weaponIdx = MatchRecordGetWeaponIndex(self.zbarrier.weapon);
828  }
829  if (isDefined(weaponidx))
830  {
831  user RecordMapEvent(‪ZM_MAP_EVENT_MAGIC_BOX_RETURNED, GetTime(), user.origin, level.round_number, weaponIdx);
832  }
833  break;
834  }
835  }
836 
838  }
839 
840  self.grab_weapon_hint = false;
841  self.zbarrier notify( "weapon_grabbed" );
842 
843  if ( !‪IS_TRUE( self._box_opened_by_fire_sale ) )
844  {
845  //increase counter of amount of time weapon grabbed, but not during a fire sale
846  level.chest_accessed += 1;
847  }
848 
849  //self TriggerEnable( false );
850  thread ‪zm_unitrigger::unregister_unitrigger(self.unitrigger_stub);
851 
852  // spend cash here...
853  // give weapon here...
854  if(isdefined(self.chest_lid))
855  {
856  self.chest_lid thread ‪treasure_chest_lid_close( self.timedOut );
857  }
858 
859  if(isdefined(self.zbarrier))
860  {
861  self.zbarrier ‪set_magic_box_zbarrier_state("close");
862  ‪zm_utility::play_sound_at_pos( "close_chest", self.origin );
863  self.zbarrier waittill("closed");
864 
865  wait 1;
866  }
867  else
868  {
869  wait 3.0;
870  }
871 
872  // Magic box dissapears and moves to a new spot after a predetermined number of uses
873  if ( (‪IS_TRUE( level.zombie_vars["zombie_powerup_fire_sale_on"] ) && self [[level._zombiemode_check_firesale_loc_valid_func]]()) || self == level.chests[level.chest_index] )
874  {
875  //self TriggerEnable( true );
877 
878 // self setvisibletoall();
879  }
880  }
881 
882  self._box_open = false;
883  self._box_opened_by_fire_sale = false;
884  self.unbearable_respin = undefined;
885  self.chest_user = undefined;
886 
887  self notify( "chest_accessed" );
888 
889  self thread ‪treasure_chest_think();
890 }
891 
893 {
894  self endon( "chest_accessed" );
895  self.closed_by_emp = 0;
897  return;
898  if(isDefined(self.zbarrier))
899  {
900  self.zbarrier.closed_by_emp = 0;
901  }
902 
903  while (1)
904  {
905  level waittill("emp_detonate",origin,radius);
906  if ( DistanceSquared( origin, self.origin) < radius * radius )
907  {
908  break;
909  }
910  }
911 
912  if (level ‪flag::get("moving_chest_now"))
913  return;
914 
915  // kill the threads
916  self.closed_by_emp = 1;
917  if(isdefined(self.zbarrier))
918  {
919  self.zbarrier.closed_by_emp = 1;
920  self.zbarrier notify("box_hacked_respin");
921  if(isDefined(self.zbarrier.weapon_model))
922  {
923  self.zbarrier.weapon_model notify("kill_weapon_movement");
924  }
925  if(IsDefined(self.zbarrier.weapon_model_dw))
926  {
927  self.zbarrier.weapon_model_dw notify("kill_weapon_movement");
928  }
929  }
930 
931  wait 0.1;
932 
933  self notify( "trigger", level );
934 }
935 
936 
938 {
939  if( IsDefined( self.is_drinking ) && ‪IS_DRINKING(self.is_drinking) )
940  {
941  return false;
942  }
943 
945  {
946  return false;
947  }
948 
949  current_weapon = self GetCurrentWeapon();
951  {
952  return false;
953  }
955  {
956  return false;
957  }
958 
959  if( current_weapon == level.weaponNone )
960  {
961  return false;
962  }
963 
964  if ( current_weapon.isheroweapon || current_weapon.isgadget )
965  {
966  return false;
967  }
968 
969  return true;
970 }
971 
973 {
974  // Check to see if there's a chest selection we should use for this move
975  // This is indicated by a script_noteworthy of "moveX*"
976  // (e.g. move1_chest0, move1_chest1) We will randomly choose between
977  // one of those two chests for that move number only.
978  index = -1;
979  for ( i=0; i<level.chests.size; i++ )
980  {
981  // Check to see if there is something that we have a choice to move to for this move number
982  if ( IsSubStr( level.chests[i].script_noteworthy, ("move"+(level.chest_moves+1)) ) &&
983  i != level.chest_index )
984  {
985  index = i;
986  break;
987  }
988  }
989 
990  if ( index != -1 )
991  {
992  level.chest_index = index;
993  }
994  else
995  {
996  level.chest_index++;
997  }
998 
999  if (level.chest_index >= level.chests.size)
1000  {
1001  //PI CHANGE - this way the chests won't move in the same order the second time around
1002  temp_chest_name = level.chests[level.chest_index - 1].script_noteworthy;
1003  level.chest_index = 0;
1004  level.chests = array::randomize(level.chests);
1005  //in case it happens to randomize in such a way that the chest_index now points to the same location
1006  // JMA - want to avoid an infinite loop, so we use an if statement
1007  if (temp_chest_name == level.chests[level.chest_index].script_noteworthy)
1008  {
1009  level.chest_index++;
1010  }
1011  //END PI CHANGE
1012  }
1013 }
1014 
1015 //
1016 // Chest movement sequence, including lifting the box up and disappearing
1017 //
1018 function ‪treasure_chest_move( player_vox )
1019 {
1020  level waittill("weapon_fly_away_start");
1021 
1022  players = GetPlayers();
1023 
1024  array::thread_all(players, &‪play_crazi_sound);
1025 
1026  //Delaying the Player Vox
1027  if( IsDefined( player_vox ) )
1028  {
1029  player_vox ‪util::delay( randomintrange(2,7), undefined, &‪zm_audio::create_and_play_dialog, "general", "box_move" );
1030  }
1031 
1032  level waittill("weapon_fly_away_end");
1033 
1034  if(isdefined(self.zbarrier))
1035  {
1036  self ‪hide_chest(true);
1037  }
1038 
1039  wait(0.1);
1040 
1041  post_selection_wait_duration = 7;
1042 
1043  // DCS 072710: check if fire sale went into effect during move, reset with time left.
1044  if(level.zombie_vars["zombie_powerup_fire_sale_on"] == true && self [[level._zombiemode_check_firesale_loc_valid_func]]())
1045  {
1046  current_sale_time = level.zombie_vars["zombie_powerup_fire_sale_time"];
1047  //IPrintLnBold("need to reset this box spot! Time left is ", current_sale_time);
1048 
1050  self thread ‪fire_sale_fix();
1051  level.zombie_vars["zombie_powerup_fire_sale_time"] = current_sale_time;
1052 
1053  while(level.zombie_vars["zombie_powerup_fire_sale_time"] > 0)
1054  {
1055  wait(0.1);
1056  }
1057  }
1058  else
1059  {
1060  post_selection_wait_duration += 5;
1061  }
1062  level.verify_chest = false;
1063 
1064 
1065  if(IsDefined(level._zombiemode_custom_box_move_logic))
1066  {
1067  [[level._zombiemode_custom_box_move_logic]]();
1068  }
1069  else
1070  {
1072  }
1073 
1074  if(IsDefined(level.chests[level.chest_index].box_hacks["summon_box"]))
1075  {
1076  level.chests[level.chest_index] [[level.chests[level.chest_index].box_hacks["summon_box"]]](false);
1077  }
1078 
1079  // Now choose a new location
1080 
1081  //wait for all the chests to reset
1082  wait(post_selection_wait_duration);
1083 
1084  playfx(level._effect["poltergeist"], level.chests[level.chest_index].zbarrier.origin, AnglesToUp( level.chests[level.chest_index].zbarrier.angles ), AnglesToForward( level.chests[level.chest_index].zbarrier.angles ));
1085  level.chests[level.chest_index] ‪show_chest();
1086 
1087  level ‪flag::clear("moving_chest_now");
1088  self.zbarrier.chest_moving = false;
1089 }
1090 
1091 
1093 {
1094  if( !isdefined ( level.zombie_vars["zombie_powerup_fire_sale_on"] ) )
1095  {
1096  return;
1097  }
1098 
1099  if( level.zombie_vars["zombie_powerup_fire_sale_on"] )
1100  {
1101  self.old_cost = 950;
1102  self thread ‪show_chest();
1103  self.zombie_cost = 10;
1104  self.unitrigger_stub ‪zm_utility::unitrigger_set_hint_string( self , "default_treasure_chest", self.zombie_cost );
1105 
1107 
1108  level waittill( "fire_sale_off" );
1109 
1110  while(‪IS_TRUE(self._box_open ))
1111  {
1112  wait(.1);
1113  }
1114 
1115  self ‪hide_chest(true);
1116 
1117  self.zombie_cost = self.old_cost;
1118  }
1119 }
1120 
1122 {
1123  if( !isdefined( level.desirable_chest_location ) )
1124  return level.chest_index;
1125 
1126  if( level.chests[level.chest_index].script_noteworthy == level.desirable_chest_location )
1127  {
1128  level.desirable_chest_location = undefined;
1129  return level.chest_index;
1130  }
1131  for(i = 0 ; i < level.chests.size; i++ )
1132  {
1133  if( level.chests[i].script_noteworthy == level.desirable_chest_location )
1134  {
1135  level.desirable_chest_location = undefined;
1136  return i;
1137  }
1138  }
1139 
1140  level.desirable_chest_location = undefined;
1141  return level.chest_index;
1142 }
1143 
1144 
1146 {
1147  angles = 40;
1148  angles2 = 0;
1149  //self endon("movedone");
1150  while(isdefined(self))
1151  {
1152  self RotateRoll(angles + angles2, 0.5);
1153  wait(0.7);
1154  angles2 = 40;
1155  self RotateRoll(angles * -2, 0.5);
1156  wait(0.7);
1157  }
1158 
1159 
1160 
1161 }
1162 //verify if that magic box is open to players or not.
1164 {
1165 
1166  //for(i = 0; i < 5; i++)
1167  //PI CHANGE - altered so that there can be more than 5 valid chest locations
1168  for (i = 0; i < level.open_chest_location.size; i++)
1169  {
1170  if(isdefined(level.open_chest_location[i]))
1171  {
1172  if(level.open_chest_location[i] == level.chests[level.chest_index].script_noteworthy)
1173  {
1174  level.verify_chest = true;
1175  return;
1176  }
1177  }
1178 
1179  }
1180 
1181  level.verify_chest = false;
1182 
1183 
1184 }
1185 
1186 
1188 {
1189  self endon( "user_grabbed_weapon" );
1190  self.zbarrier endon( "box_hacked_respin" );
1191  self.zbarrier endon( "box_hacked_rerespin" );
1192 
1193  wait( 12 );
1194  self notify( "trigger", level );
1195 }
1196 
1198 {
1199  openRoll = 105;
1200  openTime = 0.5;
1201 
1202  self RotateRoll( 105, openTime, ( openTime * 0.5 ) );
1203 
1204  ‪zm_utility::play_sound_at_pos( "open_chest", self.origin );
1205  ‪zm_utility::play_sound_at_pos( "music_chest", self.origin );
1206 }
1207 
1208 function ‪treasure_chest_lid_close( timedOut )
1209 {
1210  closeRoll = -105;
1211  closeTime = 0.5;
1212 
1213  self RotateRoll( closeRoll, closeTime, ( closeTime * 0.5 ) );
1214  ‪zm_utility::play_sound_at_pos( "close_chest", self.origin );
1215 
1216  self notify("lid_closed");
1217 }
1218 
1219 
1220 function ‪treasure_chest_CanPlayerReceiveWeapon( player, weapon, pap_triggers )
1221 {
1222  if ( !‪zm_weapons::get_is_in_box( weapon ) )
1223  {
1224  return false;
1225  }
1226 
1227  if ( IsDefined( player ) && player ‪zm_weapons::has_weapon_or_upgrade( weapon ) )
1228  {
1229  return false;
1230  }
1231 
1232  if ( !‪zm_weapons::limited_weapon_below_quota( weapon, player, pap_triggers ))
1233  return false;
1234 
1235  if ( !player ‪zm_weapons::player_can_use_content( weapon ) )
1236  return false;
1237 
1238  if(isdefined(level.custom_magic_box_selection_logic))
1239  {
1240  if(![[level.custom_magic_box_selection_logic]](weapon, player, pap_triggers))
1241  {
1242  return false;
1243  }
1244  }
1245 
1246  if ( weapon.name == "ray_gun" )
1247  {
1248  if ( player ‪zm_weapons::has_weapon_or_upgrade( GetWeapon( "raygun_mark2" ) ) )
1249  {
1250  return false;
1251  }
1252  }
1253 
1254  if ( weapon.name == "raygun_mark2" )
1255  {
1256  if ( player ‪zm_weapons::has_weapon_or_upgrade( GetWeapon( "ray_gun" ) ) )
1257  {
1258  return false;
1259  }
1260  }
1261 
1262  // enable special level by level weapon checks
1263  if( IsDefined( player ) && isdefined( level.special_weapon_magicbox_check ) )
1264  {
1265  return player [[level.special_weapon_magicbox_check]]( weapon );
1266  }
1267 
1268  return true;
1269 }
1270 
1272 {
1273  keys = array::randomize( GetArrayKeys( level.zombie_weapons ) );
1274  if (IsDefined(level.CustomRandomWeaponWeights))
1275  {
1276  keys = player [[level.CustomRandomWeaponWeights]](keys);
1277  }
1278  pap_triggers = ‪zm_pap_util::get_triggers();
1279  for ( i = 0; i < keys.size; i++ )
1280  {
1281  if ( ‪treasure_chest_CanPlayerReceiveWeapon( player, keys[i], pap_triggers ) )
1282  {
1283  return keys[i];
1284  }
1285  }
1286 
1287  return keys[0];
1288 }
1289 
1290 
1292 {
1293  level._weapon_show_hint_choke = 0;
1294 
1295  while(1)
1296  {
1298  level._weapon_show_hint_choke = 0;
1299  }
1300 }
1301 
1302 function ‪decide_hide_show_hint( endon_notify, second_endon_notify, onlyplayer, can_buy_weapon_extra_check_func )
1303 {
1304  self endon("death");
1305 
1306  if( isDefined( endon_notify ) )
1307  {
1308  self endon( endon_notify );
1309  }
1310 
1311  if( isDefined( second_endon_notify ))
1312  {
1313  self endon( second_endon_notify );
1314  }
1315 
1316  if(!IsDefined(level._weapon_show_hint_choke))
1317  {
1318  level thread ‪weapon_show_hint_choke();
1319  }
1320 
1321  use_choke = false;
1322 
1323  if(IsDefined(level._use_choke_weapon_hints) && level._use_choke_weapon_hints == 1)
1324  {
1325  use_choke = true;
1326  }
1327 
1328 
1329  while( true )
1330  {
1331 
1332  last_update = GetTime();
1333 
1334  if ( IsDefined( self.chest_user ) && !IsDefined( self.box_rerespun ) )
1335  {
1336  if ( ‪zm_utility::is_placeable_mine( self.chest_user GetCurrentWeapon() ) || self.chest_user ‪zm_equipment::hacker_active() )
1337  {
1338  self SetInvisibleToPlayer( self.chest_user);
1339  }
1340  else
1341  {
1342  self SetVisibleToPlayer( self.chest_user );
1343  }
1344  }
1345  else if ( IsDefined( onlyplayer ) )
1346  {
1347  if ( onlyplayer ‪can_buy_weapon() && ( !IsDefined( can_buy_weapon_extra_check_func ) || onlyplayer [[ can_buy_weapon_extra_check_func ]]( self.weapon ) ) && !onlyplayer ‪bgb::is_enabled( "zm_bgb_disorderly_combat" ) )
1348  {
1349  self SetInvisibleToPlayer( onlyplayer, false );
1350  }
1351  else
1352  {
1353  self SetInvisibleToPlayer( onlyplayer, true );
1354  }
1355  }
1356  else // all players
1357  {
1358  players = GetPlayers();
1359  for ( i = 0; i < players.size; i++ )
1360  {
1361  if ( players[ i ] ‪can_buy_weapon() && ( !IsDefined( can_buy_weapon_extra_check_func ) || players[ i ] [[ can_buy_weapon_extra_check_func ]]( self.weapon ) ) && !players[ i ] ‪bgb::is_enabled( "zm_bgb_disorderly_combat" ) )
1362  {
1363  self SetInvisibleToPlayer( players[i], false );
1364  }
1365  else
1366  {
1367  self SetInvisibleToPlayer( players[i], true );
1368  }
1369  }
1370  }
1371 
1372  if(use_choke)
1373  {
1374  while((level._weapon_show_hint_choke > 4) && (GetTime() < (last_update + 150)))
1375  {
1377  }
1378  }
1379  else
1380  {
1381  wait(0.1);
1382  }
1383 
1384  level._weapon_show_hint_choke ++;
1385  }
1386 }
1387 
1389 {
1390  dw_weapon = weapon.dualWieldWeapon;
1391  if ( dw_weapon != level.weaponNone )
1392  {
1393  return dw_weapon.worldModel;
1394  }
1395 
1396  return weapon.worldModel;
1397 }
1398 
1400 {
1401  self waittill("box_hacked_respin");
1402  self endon("box_spin_done");
1403 
1404  if(IsDefined(self.weapon_model))
1405  {
1406  self.weapon_model Delete();
1407  self.weapon_model = undefined;
1408  }
1409 
1410  if(IsDefined(self.weapon_model_dw))
1411  {
1412  self.weapon_model_dw Delete();
1413  self.weapon_model_dw = undefined;
1414  }
1415 
1416 
1417  self HideZBarrierPiece(3);
1418  self HideZBarrierPiece(4);
1419  self SetZBarrierPieceState(3, "closed");
1420  self SetZBarrierPieceState(4, "closed");
1421 }
1422 
1423 
1425 {
1426  return ‪IS_TRUE( level.zombie_vars["zombie_powerup_fire_sale_on"] );
1427 }
1428 
1429 function ‪treasure_chest_should_move( chest, player )
1430 {
1431  // Increase the chance of joker appearing from 0-100 based on amount of the time chest has been opened.
1432  if( ( GetDvarString( "magic_chest_movable") == "1") &&
1433  !‪IS_TRUE( chest._box_opened_by_fire_sale ) &&
1435  self [[level._zombiemode_check_firesale_loc_valid_func]]() )
1436  {
1437  // random change of getting the joker that moves the box
1438  random = Randomint(100);
1439 
1440  if( !isdefined( level.chest_min_move_usage ) )
1441  {
1442  level.chest_min_move_usage = 4;
1443  }
1444 
1445  if( level.chest_accessed < level.chest_min_move_usage )
1446  {
1447  chance_of_joker = -1;
1448  }
1449  else
1450  {
1451  chance_of_joker = level.chest_accessed + 20;
1452 
1453  // make sure teddy bear appears on the 8th pull if it hasn't moved from the initial spot
1454  if ( level.chest_moves == 0 && level.chest_accessed >= 8 )
1455  {
1456  chance_of_joker = 100;
1457  }
1458 
1459  // pulls 4 thru 8, there is a 15% chance of getting the teddy bear
1460  // NOTE: this happens in all cases
1461  if( level.chest_accessed >= 4 && level.chest_accessed < 8 )
1462  {
1463  if( random < 15 )
1464  {
1465  chance_of_joker = 100;
1466  }
1467  else
1468  {
1469  chance_of_joker = -1;
1470  }
1471  }
1472 
1473  // after the first magic box move the teddy bear percentages changes
1474  if ( level.chest_moves > 0 )
1475  {
1476  // between pulls 8 thru 12, the teddy bear percent is 30%
1477  if( level.chest_accessed >= 8 && level.chest_accessed < 13 )
1478  {
1479  if( random < 30 )
1480  {
1481  chance_of_joker = 100;
1482  }
1483  else
1484  {
1485  chance_of_joker = -1;
1486  }
1487  }
1488 
1489  // after 12th pull, the teddy bear percent is 50%
1490  if( level.chest_accessed >= 13 )
1491  {
1492  if( random < 50 )
1493  {
1494  chance_of_joker = 100;
1495  }
1496  else
1497  {
1498  chance_of_joker = -1;
1499  }
1500  }
1501  }
1502  }
1503 
1504  if(IsDefined(chest.no_fly_away))
1505  {
1506  chance_of_joker = -1;
1507  }
1508 
1509  if(IsDefined(level._zombiemode_chest_joker_chance_override_func))
1510  {
1511  chance_of_joker = [[level._zombiemode_chest_joker_chance_override_func]](chance_of_joker);
1512  }
1513 
1514  if ( chance_of_joker > random )
1515  {
1516  return true;
1517  }
1518  }
1519 
1520  return false;
1521 }
1522 
1523 function ‪spawn_joker_weapon_model( player, model, origin, angles )
1524 {
1525  weapon_model = ‪spawn( "script_model", origin );
1526  if ( isdefined( angles ) )
1527  {
1528  weapon_model.angles = angles;
1529  }
1530  weapon_model SetModel(model);
1531  return weapon_model;
1532 }
1533 
1534 
1535 // lock or unlock a weapon model
1536 function ‪treasure_chest_weapon_locking( player, weapon, onOff )
1537 {
1538  if ( isdefined(self.locked_model) )
1539  {
1540  self.locked_model delete();
1541  self.locked_model = undefined;
1542  }
1543 
1544  if ( onOff )
1545  {
1546  if ( weapon == level.weaponNone )
1547  {
1548  self.locked_model = ‪spawn_joker_weapon_model( player, level.chest_joker_model, self.origin, (0,0,0) );
1549  }
1550  else
1551  {
1552  self.locked_model = ‪zm_utility::spawn_buildkit_weapon_model( player, weapon, undefined, self.origin, (0,0,0));
1553  }
1554  self.locked_model Ghost();
1555  self.locked_model ‪clientfield::set( "force_stream", 1 );
1556  }
1557 }
1558 
1559 function ‪treasure_chest_weapon_spawn( chest, player, respin )
1560 {
1561  self endon("box_hacked_respin");
1562  self thread ‪clean_up_hacked_box();
1563  assert(IsDefined(player));
1564  // spawn the model
1565 // model = spawn( "script_model", self.origin );
1566 // model.angles = self.angles +( 0, 90, 0 );
1567 
1568 // floatHeight = 40;
1569 
1570  //move it up
1571 // model moveto( model.origin +( 0, 0, floatHeight ), 3, 2, 0.9 );
1572 
1573  self.chest_moving = false;
1574  move_the_box = ‪treasure_chest_should_move( chest, player );
1575 
1576  preferred_weapon = undefined;
1577 
1578  if ( move_the_box )
1579  {
1580  preferred_weapon = level.weaponNone;
1581  }
1582  // Pick a random weapon
1583  else
1584  {
1585  preferred_weapon = ‪treasure_chest_ChooseWeightedRandomWeapon( player );
1586  }
1587 
1588  chest ‪treasure_chest_weapon_locking( player, preferred_weapon, true );
1589 
1590  // rotation would go here
1591 
1592  // make with the mario kart
1593  const FLOAT_HEIGHT = 40;
1594  const BOX_MOVE_BEAR_FLYAWAY_DISTANCE = 500;
1595  const BOX_MOVE_BEAR_FLYAWAY_TIME = 4;
1596  const BOX_MOVE_BEAR_FLYAWAY_ACCEL = 3;
1597  self.weapon = level.weaponNone;
1598  modelname = undefined;
1599  rand = undefined;
1600  number_cycles = 40;
1601 
1602  if(isdefined(chest.zbarrier))
1603  {
1604  if ( IsDefined( level.custom_magic_box_do_weapon_rise ) )
1605  {
1606  chest.zbarrier thread [[level.custom_magic_box_do_weapon_rise]]();
1607  }
1608  else
1609  {
1610  chest.zbarrier thread ‪magic_box_do_weapon_rise();
1611  }
1612  }
1613 
1614  for( i = 0; i < number_cycles; i++ )
1615  {
1616 
1617  if( i < 20 )
1618  {
1620  }
1621  else if( i < 30 )
1622  {
1623  wait( 0.1 );
1624  }
1625  else if( i < 35 )
1626  {
1627  wait( 0.2 );
1628  }
1629  else if( i < 38 )
1630  {
1631  wait( 0.3 );
1632  }
1633  }
1634 
1635  if ( IsDefined( level.custom_magic_box_weapon_wait ) )
1636  {
1637  [[level.custom_magic_box_weapon_wait]](); // wait to match up with any waits in the custom weapon rise
1638  }
1639 
1640  //**********************************
1641  // Pick a random weapon from the box
1642  //**********************************
1643 
1644  new_firesale = ( move_the_box && ‪treasure_chest_firesale_active() );
1645 
1646  // if the box was scheduled to move and a firesale has started since the box started cycling pick a real weapon
1647  if ( new_firesale )
1648  {
1649  move_the_box = false;
1650  preferred_weapon = ‪treasure_chest_ChooseWeightedRandomWeapon( player );
1651  }
1652 
1653  // make sure the player can still get the weapon we picked at the start
1654  if ( !move_the_box && ‪treasure_chest_CanPlayerReceiveWeapon( player, preferred_weapon, ‪zm_pap_util::get_triggers() ) )
1655  {
1656  rand = preferred_weapon;
1657  }
1658  // Pick a random weapon
1659  else
1660  {
1662  }
1663 
1664  // forcing box weapons from the devgui is now handled in treasure_chest_ChooseWeightedRandomWeapon
1665  // this allows us to test box weapon filtering.
1666  // if you need to give yourself a weapon without filtering you can use
1667  // set zombie_devgui_gun gunyouwant_zm
1668 
1669  // Here's where the org get it's weapon type for the give function
1670  self.weapon = rand;
1671 
1672  if ( isdefined( level.func_magicbox_weapon_spawned ) )
1673  {
1674  self thread [[ level.func_magicbox_weapon_spawned ]]( self.weapon );
1675  }
1676 
1677  //util::wait_network_frame();
1678  wait( 0.1 );
1679 
1680  // get offset for floating weapon
1681  if ( IsDefined( level.custom_magicbox_float_height ) )
1682  {
1683  v_float = AnglesToUp( self.angles ) * level.custom_magicbox_float_height;
1684  }
1685  else
1686  {
1687  v_float = AnglesToUp( self.angles ) * FLOAT_HEIGHT; // draw vector straight up with reference to the mystery box angles
1688  }
1689 
1690  self.model_dw = undefined;
1691 
1692  self.weapon_model = ‪zm_utility::spawn_buildkit_weapon_model( player, rand, undefined, self.origin + v_float, (-self.angles[0], self.angles[1] + 180, -self.angles[2]));
1693 
1694  if ( rand.isDualWield )
1695  {
1696  dweapon = rand;
1697  if ( isdefined( rand.dualwieldweapon ) && rand.dualwieldweapon != level.weaponNone )
1698  {
1699  dweapon = rand.dualwieldweapon;
1700  }
1701 
1702  self.weapon_model_dw = ‪zm_utility::spawn_buildkit_weapon_model( player, dweapon, undefined, self.weapon_model.origin - ( 3, 3, 3 ), self.weapon_model.angles );
1703  }
1704 
1705  if ( move_the_box && !(level.zombie_vars["zombie_powerup_fire_sale_on"] && self [[level._zombiemode_check_firesale_loc_valid_func]]()) )
1706  {
1707  self.weapon_model SetModel(level.chest_joker_model);
1708 
1709  if(IsDefined(self.weapon_model_dw))
1710  {
1711  self.weapon_model_dw Delete();
1712  self.weapon_model_dw = undefined;
1713  }
1714 
1715  if( IsPlayer( chest.chest_user ) && chest.chest_user ‪bgb::is_enabled( "zm_bgb_unbearable" ) )
1716  {
1717  level.chest_accessed = 0;
1718  chest.unbearable_respin = true;
1719  chest.chest_user notify( "zm_bgb_unbearable", chest );
1720  chest waittill( "forever" );
1721  }
1722 
1723  self.chest_moving = true;
1724  level ‪flag::set("moving_chest_now");
1725  level.chest_accessed = 0;
1726 
1727  level.chest_moves++;
1728  }
1729 
1730  self notify( "randomization_done" );
1731 
1732  if (‪IS_TRUE(self.chest_moving))
1733  {
1734  if( IsDefined( level.chest_joker_custom_movement ) )
1735  {
1736  self [[ level.chest_joker_custom_movement ]]();
1737  }
1738  else
1739  {
1740  //record the weapon model origin and delete it, it could have parts hidden based on what weapon spawned
1741  v_origin = self.weapon_model.origin;
1742  self.weapon_model Delete();
1743 
1744  //spawn a fresh new model with everything correct
1745  self.weapon_model = ‪Spawn( "script_model", v_origin );
1746  self.weapon_model SetModel( level.chest_joker_model );
1747  self.weapon_model.angles = self.angles + ( 0, 180, 0 );
1748 
1749  wait .5; // we need a wait here before this notify
1750  level notify("weapon_fly_away_start");
1751  wait 2;
1752  if( IsDefined( self.weapon_model ) )
1753  {
1754  v_fly_away = self.origin + ( AnglesToUp( self.angles ) * BOX_MOVE_BEAR_FLYAWAY_DISTANCE );
1755  self.weapon_model MoveTo( v_fly_away, BOX_MOVE_BEAR_FLYAWAY_TIME, BOX_MOVE_BEAR_FLYAWAY_ACCEL );
1756  }
1757 
1758  if ( IsDefined(self.weapon_model_dw ) )
1759  {
1760  v_fly_away = self.origin + ( AnglesToUp( self.angles ) * BOX_MOVE_BEAR_FLYAWAY_DISTANCE );
1761  self.weapon_model_dw MoveTo( v_fly_away, BOX_MOVE_BEAR_FLYAWAY_TIME, BOX_MOVE_BEAR_FLYAWAY_ACCEL );
1762  }
1763 
1764  self.weapon_model waittill("movedone");
1765  self.weapon_model delete();
1766 
1767  if(IsDefined(self.weapon_model_dw))
1768  {
1769  self.weapon_model_dw Delete();
1770  self.weapon_model_dw = undefined;
1771  }
1772 
1773  self notify( "box_moving" );
1774  level notify("weapon_fly_away_end");
1775  }
1776  }
1777  else
1778  {
1779  if(!IsDefined(respin))
1780  {
1781  if(IsDefined(chest.box_hacks["respin"]))
1782  {
1783  self [[chest.box_hacks["respin"]]](chest, player);
1784  }
1785  }
1786  else
1787  {
1788  if(IsDefined(chest.box_hacks["respin_respin"]))
1789  {
1790  self [[chest.box_hacks["respin_respin"]]](chest, player);
1791  }
1792  }
1793 
1794  // allow for custom back-into-box movement
1795  if(IsDefined(level.custom_magic_box_timer_til_despawn))
1796  {
1797  self.weapon_model thread [[level.custom_magic_box_timer_til_despawn]]( self );
1798  }
1799  else
1800  {
1801  // weapon re-enters box
1802  self.weapon_model thread ‪timer_til_despawn( v_float );
1803  }
1804 
1805  if(IsDefined(self.weapon_model_dw))
1806  {
1807  if(IsDefined(level.custom_magic_box_timer_til_despawn))
1808  {
1809  self.weapon_model_dw thread [[level.custom_magic_box_timer_til_despawn]]( self );
1810  }
1811  else
1812  {
1813  self.weapon_model_dw thread ‪timer_til_despawn( v_float );
1814  }
1815  }
1816 
1817  self waittill( "weapon_grabbed" );
1818 
1819  if( !chest.timedOut )
1820  {
1821  if(IsDefined(self.weapon_model))
1822  {
1823  self.weapon_model Delete();
1824  }
1825 
1826  if(IsDefined(self.weapon_model_dw))
1827  {
1828  self.weapon_model_dw Delete();
1829  }
1830  }
1831  }
1832 
1833  chest ‪treasure_chest_weapon_locking( player, preferred_weapon, false );
1834 
1835  self.weapon = level.weaponNone;
1836  self notify("box_spin_done");
1837 }
1838 
1839 //
1840 //
1842 {
1843  min_usage = 4;
1844 
1845  return( min_usage );
1846 }
1847 
1848 //
1849 //
1851 {
1852  max_usage = 6;
1853 
1854  players = GetPlayers();
1855 
1856  // Special case max box pulls before 1st box move
1857  if( level.chest_moves == 0 )
1858  {
1859  if( players.size == 1 )
1860  {
1861  max_usage = 3;
1862  }
1863  else if( players.size == 2 )
1864  {
1865  max_usage = 4;
1866  }
1867  else if( players.size == 3 )
1868  {
1869  max_usage = 5;
1870  }
1871  else
1872  {
1873  max_usage = 6;
1874  }
1875  }
1876  // Box has moved, what is the maximum number of times it can move again?
1877  else
1878  {
1879  if( players.size == 1 )
1880  {
1881  max_usage = 4;
1882  }
1883  else if( players.size == 2 )
1884  {
1885  max_usage = 4;
1886  }
1887  else if( players.size == 3 )
1888  {
1889  max_usage = 5;
1890  }
1891  else
1892  {
1893  max_usage = 7;
1894  }
1895  }
1896  return( max_usage );
1897 }
1898 
1899 
1900 function ‪timer_til_despawn( v_float )
1901 {
1902  self endon("kill_weapon_movement");
1903  // SRS 9/3/2008: if we timed out, move the weapon back into the box instead of deleting it
1904  putBackTime = 12;
1905  self MoveTo( self.origin - ( v_float * 0.85 ), putBackTime, ( putBackTime * 0.5 ) );
1906  wait( putBackTime );
1907 
1908  if(isdefined(self))
1909  {
1910  self Delete();
1911  }
1912 }
1913 
1915 {
1916  self ‪clientfield::set( "magicbox_open_glow", true );
1917  self ‪clientfield::set( "magicbox_closed_glow", false );
1918 
1919  ret_val = self ‪util::waittill_any_return( "weapon_grabbed", "box_moving" );
1920 
1921  self ‪clientfield::set( "magicbox_open_glow", false );
1922 
1923  if ( "box_moving" != ret_val )
1924  {
1925  self ‪clientfield::set( "magicbox_closed_glow", true );
1926  }
1927 }
1928 
1929 // self is the player string comes from the randomization function
1931 {
1932  self.last_box_weapon = GetTime();
1933 
1934  // this function was almost identical to weapon_give() so it calls that instead
1935 
1936  //Audio: Raygun ALWAYS plays this stinger when getting it from the magicbox
1937  if( weapon.name == "ray_gun" || weapon.name == "raygun_mark2" )
1938  {
1939  playsoundatposition( "mus_raygun_stinger", (0,0,0) );
1940  }
1941 
1942  if( ‪should_upgrade_weapon( self, weapon ) )
1943  {
1944  if( self ‪zm_weapons::can_upgrade_weapon( weapon ) )
1945  {
1946  weapon = ‪zm_weapons::get_upgrade_weapon( weapon );
1947  self notify( "zm_bgb_crate_power_used" );
1948  }
1949  }
1950 
1951  if( ‪zm_utility::is_hero_weapon( weapon ) && !self HasWeapon( weapon ) )
1952  {
1953  self ‪give_hero_weapon( weapon );
1954  }
1955  else
1956  {
1957  w_give = self ‪zm_weapons::weapon_give(weapon, false, true);
1958 
1959  // make sure no aat given from the box
1960  if( isdefined(weapon) )
1961  {
1962  self thread ‪aat::remove( w_give );
1963  }
1964  }
1965 }
1966 
1967 function ‪give_hero_weapon( weapon )//self = player
1968 {
1969  w_previous = self GetCurrentWeapon();
1970  self ‪zm_weapons::weapon_give( weapon );
1971  self GadgetPowerSet( 0, 99 );
1972  self SwitchToWeapon( weapon );
1973  self waittill( "weapon_change_complete" );
1974  self SetLowReady( true );
1975  self SwitchToWeapon( w_previous );
1976  self ‪util::waittill_any_timeout( 1.0, "weapon_change_complete" );
1977  self SetLowReady( false );
1978  self GadgetPowerSet( 0, 100 );
1979 }
1980 
1981 function ‪should_upgrade_weapon( player, weapon )
1982 {
1983  if( isdefined( level.magicbox_should_upgrade_weapon_override ) )
1984  {
1985  return [[ level.magicbox_should_upgrade_weapon_override ]]( player, weapon ); // PORTIZ 7/19/2016: pass in player and weapon to check specific conditions
1986  }
1987 
1988  if( player ‪bgb::is_enabled( "zm_bgb_crate_power" ) )
1989  {
1990  return true;
1991  }
1992 
1993  return false;
1994 }
1995 
1997 {
1998  self SetZBarrierPieceState(1, "open");
1999 
2000  self ‪clientfield::set( "magicbox_closed_glow", true );
2001 }
2002 
2004 {
2005  self SetZBarrierPieceState(1, "opening");
2006  while(self GetZBarrierPieceState(1) == "opening")
2007  {
2009  }
2010  self notify("arrived");
2011 }
2012 
2014 {
2015  self SetZBarrierPieceState(1, "closing");
2016  while(self GetZBarrierPieceState(1) == "closing")
2017  {
2018  wait (0.1);
2019  }
2020  self notify("left");
2021 }
2022 
2024 {
2025  self SetZBarrierPieceState(2, "opening");
2026  while(self GetZBarrierPieceState(2) == "opening")
2027  {
2028  wait (0.1);
2029  }
2030  self notify("opened");
2031 }
2032 
2034 {
2035  self SetZBarrierPieceState(2, "closing");
2036  while(self GetZBarrierPieceState(2) == "closing")
2037  {
2038  wait (0.1);
2039  }
2040  self notify("closed");
2041 }
2042 
2044 {
2045  self endon("box_hacked_respin");
2046 
2047  self SetZBarrierPieceState(3, "closed");
2048  self SetZBarrierPieceState(4, "closed");
2049 
2051 
2052  self ZBarrierPieceUseBoxRiseLogic(3);
2053  self ZBarrierPieceUseBoxRiseLogic(4);
2054 
2055  self ShowZBarrierPiece(3);
2056  self ShowZBarrierPiece(4);
2057  self SetZBarrierPieceState(3, "opening");
2058  self SetZBarrierPieceState(4, "opening");
2059 
2060  while(self GetZBarrierPieceState(3) != "open")
2061  {
2062  wait(0.5);
2063  }
2064 
2065  self HideZBarrierPiece(3);
2066  self HideZBarrierPiece(4);
2067 
2068 }
2069 
2071 {
2072  self ShowZBarrierPiece(3);
2073  self SetZBarrierPieceState(3, "closing");
2074 }
2075 
2077 {
2078  curr_state = self.zbarrier ‪get_magic_box_zbarrier_state();
2079 
2080  if( level ‪flag::get( "moving_chest_now" ) )
2081  {
2082  return false;
2083  }
2084 
2085  if( curr_state == "open" || curr_state == "close" )
2086  {
2087  return true;
2088  }
2089 
2090  return false;
2091 }
2092 
2094 {
2095  return self.state;
2096 }
2097 
2099 {
2100  for(i = 0; i < self GetNumZBarrierPieces(); i ++)
2101  {
2102  self HideZBarrierPiece(i);
2103  }
2104  self notify("zbarrier_state_change");
2105 
2106  self [[level.magic_box_zbarrier_state_func]](state);
2107 }
2108 
2110 {
2111  switch(state)
2112  {
2113  case "away":
2114  self ShowZBarrierPiece(0);
2115  self.state = "away";
2116  break;
2117  case "arriving":
2118  self ShowZBarrierPiece(1);
2119  self thread ‪magic_box_arrives();
2120  self.state = "arriving";
2121  break;
2122  case "initial":
2123  self ShowZBarrierPiece(1);
2124  self thread ‪magic_box_initial();
2126  self.state = "initial";
2127  break;
2128  case "open":
2129  self ShowZBarrierPiece(2);
2130  self thread ‪magic_box_opens();
2131  self.state = "open";
2132  break;
2133  case "close":
2134  self ShowZBarrierPiece(2);
2135  self thread ‪magic_box_closes();
2136  self.state = "close";
2137  break;
2138  case "leaving":
2139  self showZBarrierPiece(1);
2140  self thread ‪magic_box_leaves();
2141  self.state = "leaving";
2142  break;
2143  default:
2144  if( IsDefined( level.custom_magicbox_state_handler ) )
2145  {
2146  self [[ level.custom_magicbox_state_handler ]]( state );
2147  }
2148  break;
2149  }
2150 }
2151 
2153 {
2154  level endon("end_game");
2155 
2156  level notify("mb_hostmigration");
2157  level endon("mb_hostmigration");
2158 
2159  while(1)
2160  {
2161  level waittill("host_migration_end");
2162 
2163  if(!isDefined(level.chests))
2164  continue;
2165 
2166  foreach( chest in level.chests )
2167  {
2168  if ( !‪IS_TRUE( chest.hidden ) )
2169  {
2170  if ( IsDefined( chest ) && IsDefined( chest.pandora_light ) )
2171  {
2172  playfxontag(level._effect["lght_marker"], chest.pandora_light, "tag_origin");
2173  }
2174  }
2176  }
2177  }
2178 }
2179 
2181 {
2182  level ‪flag::wait_till( "initial_blackscreen_passed" );
2183 
2184  self endon("left");
2185 
2186  while (1)
2187  {
2188  foreach (player in getPlayers())
2189  {
2190  distanceFromPlayerToBox = distance(player.origin, self.origin);
2191 
2192  if (distanceFromPlayerToBox < 400 && player ‪zm_utility::is_player_looking_at(self.origin))
2193  {
2194  player ‪zm_audio::create_and_play_dialog( "box", "encounter" );
2195  return;
2196  }
2197  }
2198  wait 0.5;
2199  }
2200 }
2201 
‪show_chest
‪function show_chest()
Definition: _zm_magicbox.gsc:418
‪magic_box_do_teddy_flyaway
‪function magic_box_do_teddy_flyaway()
Definition: _zm_magicbox.gsc:2070
‪treasure_chest_give_weapon
‪function treasure_chest_give_weapon(weapon)
Definition: _zm_magicbox.gsc:1930
‪is_equipment
‪function is_equipment(weapon)
Definition: _zm_equipment.gsc:691
‪trigger_visible_to_player
‪function trigger_visible_to_player(player)
Definition: _zm_magicbox.gsc:361
‪treasure_chest_move
‪function treasure_chest_move(player_vox)
Definition: _zm_magicbox.gsc:1018
‪default_pandora_fx_func
‪function default_pandora_fx_func()
Definition: _zm_magicbox.gsc:492
‪check_for_desirable_chest_location
‪function check_for_desirable_chest_location()
Definition: _zm_magicbox.gsc:1121
‪treasure_chest_glowfx
‪function treasure_chest_glowfx()
Definition: _zm_magicbox.gsc:1914
‪increment_client_stat
‪function increment_client_stat(stat_name, include_gametype)
Definition: _zm_stats.gsc:389
‪magic_box_zbarrier_leave
‪function magic_box_zbarrier_leave()
Definition: _zm_magicbox.gsc:485
‪give_hero_weapon
‪function give_hero_weapon(weapon)
Definition: _zm_magicbox.gsc:1967
‪play_sound_at_pos
‪function play_sound_at_pos(ref, pos, ent)
Definition: _zm_utility.gsc:3040
‪play_crazi_sound
‪function play_crazi_sound()
Definition: _zm_magicbox.gsc:409
‪get_is_in_box
‪function get_is_in_box(weapon)
Definition: _zm_weapons.gsc:1488
‪increment_player_stat
‪function increment_player_stat(stat_name)
Definition: _zm_stats.gsc:369
‪treasure_chest_lid_close
‪function treasure_chest_lid_close(timedOut)
Definition: _zm_magicbox.gsc:1208
‪limited_weapon_below_quota
‪function limited_weapon_below_quota(weapon, ignore_player, pap_triggers)
Definition: _zm_weapons.gsc:696
‪clear
‪function clear(str_flag)
Definition: flag_shared.csc:130
‪default_box_move_logic
‪function default_box_move_logic()
Definition: _zm_magicbox.gsc:972
‪is_player_revive_tool
‪function is_player_revive_tool(weapon)
Definition: _zm_utility.gsc:4107
‪magic_box_opens
‪function magic_box_opens()
Definition: _zm_magicbox.gsc:2023
‪is_chest_active
‪function is_chest_active()
Definition: _zm_magicbox.gsc:2076
‪add_to_player_score
‪function add_to_player_score(points, b_add_to_total=true, str_awarded_by="")
Definition: _zm_score.gsc:521
‪get_triggers
‪function get_triggers()
Definition: _zm_pack_a_punch_util.gsc:77
‪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
‪weapon_show_hint_choke
‪function weapon_show_hint_choke()
Definition: _zm_magicbox.gsc:1291
‪unitrigger_set_hint_string
‪function unitrigger_set_hint_string(ent, default_ref, cost)
Definition: _zm_utility.gsc:2988
‪get_array
‪function get_array(kvp_value, kvp_key="targetname")
Definition: struct.csc:34
‪treasure_chest_weapon_locking
‪function treasure_chest_weapon_locking(player, weapon, onOff)
Definition: _zm_magicbox.gsc:1536
‪fire_sale_fix
‪function fire_sale_fix()
Definition: _zm_magicbox.gsc:1092
‪ZM_MAP_EVENT_MAGIC_BOX_OFFERED
‪#define ZM_MAP_EVENT_MAGIC_BOX_OFFERED
Definition: _zm_utility.gsh:52
‪is_Classic
‪function is_Classic()
Definition: _zm_utility.gsc:42
‪remove
‪function remove(weapon)
Definition: aat_shared.gsc:499
‪hacker_active
‪function hacker_active()
Definition: _zm_equipment.gsc:748
‪magic_box_arrives
‪function magic_box_arrives()
Definition: _zm_magicbox.gsc:2003
‪treasure_chest_lid_open
‪function treasure_chest_lid_open()
Definition: _zm_magicbox.gsc:1197
‪sndAnnouncerPlayVox
‪function sndAnnouncerPlayVox(type, player)
Definition: _zm_audio.gsc:1319
‪magicbox_unitrigger_think
‪function magicbox_unitrigger_think()
Definition: _zm_magicbox.gsc:398
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪waittill_any_timeout
‪function waittill_any_timeout(n_timeout, string1, string2, string3, string4, string5)
Definition: util_shared.csc:423
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪get
‪function get(kvp_value, kvp_key="targetname")
Definition: struct.csc:13
‪get_left_hand_weapon_model_name
‪function get_left_hand_weapon_model_name(weapon)
Definition: _zm_magicbox.gsc:1388
‪default_pandora_show_func
‪function default_pandora_show_func(anchor, anchorTarget, pieces)
Definition: _zm_magicbox.gsc:517
‪delay
‪function delay(time_or_notify, str_endon, func, arg1, arg2, arg3, arg4, arg5, arg6)
Definition: util_shared.csc:784
‪is_player_valid
‪function is_player_valid(player, checkIgnoreMeFlag, ignore_laststand_players)
Definition: skeleton.gsc:256
‪chest_get_min_usage
‪function chest_get_min_usage()
Definition: _zm_magicbox.gsc:1841
‪get_chest_pieces
‪function get_chest_pieces()
Definition: _zm_magicbox.gsc:266
‪unregister_unitrigger
‪function unregister_unitrigger(unitrigger_stub)
Definition: _zm_unitrigger.gsc:173
‪increment_magic_box
‪function increment_magic_box()
Definition: _zm_daily_challenges.gsc:358
‪unregister_unitrigger_on_kill_think
‪function unregister_unitrigger_on_kill_think()
Definition: _zm_magicbox.gsc:536
‪increment_challenge_stat
‪function increment_challenge_stat(stat_name, amount=1)
Definition: _zm_stats.gsc:478
‪boxstub_update_prompt
‪function boxstub_update_prompt(player)
Definition: _zm_magicbox.gsc:320
‪default_magic_box_check_equipment
‪function default_magic_box_check_equipment(weapon)
Definition: _zm_magicbox.gsc:355
‪treasure_chest_timeout
‪function treasure_chest_timeout()
Definition: _zm_magicbox.gsc:1187
‪get_magic_box_zbarrier_state
‪function get_magic_box_zbarrier_state()
Definition: _zm_magicbox.gsc:2093
‪magic_box_initial
‪function magic_box_initial()
Definition: _zm_magicbox.gsc:1996
‪can_upgrade_weapon
‪function can_upgrade_weapon(weapon)
Definition: _zm_weapons.gsc:1675
‪treasure_chest_think
‪function treasure_chest_think()
Definition: _zm_magicbox.gsc:546
‪minus_to_player_score
‪function minus_to_player_score(points)
Definition: _zm_score.gsc:551
‪can_player_purchase
‪function can_player_purchase(n_cost)
Definition: _zm_score.gsc:655
‪wait_network_frame
‪function wait_network_frame(n_count=1)
Definition: util_shared.gsc:64
‪VERSION_TU7
‪#define VERSION_TU7
Definition: version.gsh:52
‪verify_chest_is_open
‪function verify_chest_is_open()
Definition: _zm_magicbox.gsc:1163
‪REGISTER_SYSTEM_EX
‪#define REGISTER_SYSTEM_EX(__sys, __func_init_preload, __func_init_postload, __reqs)
Definition: shared.gsh:209
‪__main__
‪function __main__()
Definition: _zm_magicbox.gsc:75
‪magic_box_closes
‪function magic_box_closes()
Definition: _zm_magicbox.gsc:2033
‪ZM_MAP_EVENT_MAGIC_BOX_RETURNED
‪#define ZM_MAP_EVENT_MAGIC_BOX_RETURNED
Definition: _zm_utility.gsh:54
‪clean_up_hacked_box
‪function clean_up_hacked_box()
Definition: _zm_magicbox.gsc:1399
‪is_equipment_that_blocks_purchase
‪function is_equipment_that_blocks_purchase(weapon)
Definition: _zm_equipment.gsc:701
‪waittill_any
‪function waittill_any(str_notify1, str_notify2, str_notify3, str_notify4, str_notify5)
Definition: util_shared.csc:375
‪hide_chest
‪function hide_chest(doBoxLeave)
Definition: _zm_magicbox.gsc:441
‪box_encounter_vo
‪function box_encounter_vo()
Definition: _zm_magicbox.gsc:2180
‪set_magic_box_zbarrier_state
‪function set_magic_box_zbarrier_state(state)
Definition: _zm_magicbox.gsc:2098
‪is_enabled
‪function is_enabled(name)
Definition: _zm_bgb.gsc:4
‪increment
‪function increment(str_field_name, n_increment_count=1)
Definition: clientfield_shared.gsc:110
‪wait_till
‪function wait_till(str_flag)
Definition: flag_shared.csc:189
‪is_player_looking_at
‪function is_player_looking_at(origin, dot, do_trace, ignore_ent)
Definition: util_shared.gsc:1664
‪is_offhand_weapon
‪function is_offhand_weapon(weapon)
Definition: _zm_utility.gsc:4507
‪__init__
‪function __init__()
Definition: _zm_magicbox.gsc:56
‪watch_for_emp_close
‪function watch_for_emp_close()
Definition: _zm_magicbox.gsc:892
‪ZM_MAP_EVENT_MAGIC_BOX_TAKEN
‪#define ZM_MAP_EVENT_MAGIC_BOX_TAKEN
Definition: _zm_utility.gsh:53
‪process_magic_box_zbarrier_state
‪function process_magic_box_zbarrier_state(state)
Definition: _zm_magicbox.gsc:2109
‪magic_box_do_weapon_rise
‪function magic_box_do_weapon_rise()
Definition: _zm_magicbox.gsc:2043
‪bookmark
‪function bookmark(type, time, mainClientEnt, otherClientEnt, eventPriority, inflictorEnt, overrideEntityCamera, actorEnt)
Definition: demo_shared.gsc:25
‪should_watch_for_emp
‪function should_watch_for_emp()
Definition: _zm_utility.gsc:4466
‪has_weapon_or_upgrade
‪function has_weapon_or_upgrade(weapon)
Definition: _zm_weapons.gsc:1830
‪set_treasure_chest_cost
‪function set_treasure_chest_cost(cost)
Definition: _zm_magicbox.gsc:258
‪is_hero_weapon
‪function is_hero_weapon(weapon)
Definition: _zm_utility.gsc:4408
‪decide_hide_show_hint
‪function decide_hide_show_hint(endon_notify, second_endon_notify, onlyplayer, can_buy_weapon_extra_check_func)
Definition: _zm_magicbox.gsc:1302
‪treasure_chest_weapon_spawn
‪function treasure_chest_weapon_spawn(chest, player, respin)
Definition: _zm_magicbox.gsc:1559
‪Spawn
‪function Spawn(parent, onDeathCallback)
Definition: _flak_drone.gsc:427
‪init
‪function init()
Definition: struct.csc:1
‪timer_til_despawn
‪function timer_til_despawn(v_float)
Definition: _zm_magicbox.gsc:1900
‪set
‪function set(str_field_name, n_value)
Definition: clientfield_shared.gsc:34
‪should_upgrade_weapon
‪function should_upgrade_weapon(player, weapon)
Definition: _zm_magicbox.gsc:1981
‪spawn_joker_weapon_model
‪function spawn_joker_weapon_model(player, model, origin, angles)
Definition: _zm_magicbox.gsc:1523
‪get_upgrade_weapon
‪function get_upgrade_weapon(weapon, add_attachment)
Definition: _zm_weapons.gsc:1639
‪treasure_chest_should_move
‪function treasure_chest_should_move(chest, player)
Definition: _zm_magicbox.gsc:1429
‪magicbox_host_migration
‪function magicbox_host_migration()
Definition: _zm_magicbox.gsc:2152
‪weapon_give
‪function weapon_give(weapon, is_upgrade=false, magic_box=false, nosound=false, b_switch_weapon=true)
Definition: _zm_weapons.gsc:2603
‪spawn_buildkit_weapon_model
‪function spawn_buildkit_weapon_model(localClientNum, weapon, camo, origin, angles)
Definition: _zm_utility.csc:107
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪init_starting_chest_location
‪function init_starting_chest_location(start_chest_name)
Definition: _zm_magicbox.gsc:178
‪create_and_play_dialog
‪function create_and_play_dialog(category, subcategory, force_variant)
Definition: _zm_audio.gsc:603
‪unitrigger_force_per_player_triggers
‪function unitrigger_force_per_player_triggers(unitrigger_stub, opt_on_off)
Definition: _zm_unitrigger.gsc:58
‪in_revive_trigger
‪function in_revive_trigger()
Definition: _zm_utility.gsc:1684
‪magic_box_leaves
‪function magic_box_leaves()
Definition: _zm_magicbox.gsc:2013
‪boxtrigger_update_prompt
‪function boxtrigger_update_prompt(player)
Definition: _zm_magicbox.gsc:307
‪rotateroll_box
‪function rotateroll_box()
Definition: _zm_magicbox.gsc:1145
‪treasure_chest_CanPlayerReceiveWeapon
‪function treasure_chest_CanPlayerReceiveWeapon(player, weapon, pap_triggers)
Definition: _zm_magicbox.gsc:1220
‪chest_get_max_usage
‪function chest_get_max_usage()
Definition: _zm_magicbox.gsc:1850
‪treasure_chest_ChooseWeightedRandomWeapon
‪function treasure_chest_ChooseWeightedRandomWeapon(player)
Definition: _zm_magicbox.gsc:1271
‪IS_DRINKING
‪#define IS_DRINKING(_is_drinking)
Definition: _zm_utility.gsh:1
‪register_static_unitrigger
‪function register_static_unitrigger(unitrigger_stub, trigger_func, recalculate_zone)
Definition: _zm_unitrigger.gsc:236
‪is_placeable_mine
‪function is_placeable_mine(weapon)
Definition: _zm_utility.gsc:4267
‪get_hint_string
‪function get_hint_string(ent, default_ref, cost)
Definition: _zm_utility.gsc:2974
‪treasure_chest_firesale_active
‪function treasure_chest_firesale_active()
Definition: _zm_magicbox.gsc:1424
‪can_buy_weapon
‪function can_buy_weapon()
Definition: _zm_magicbox.gsc:937
‪player_can_use_content
‪function player_can_use_content(weapon)
Definition: _zm_weapons.gsc:820
‪treasure_chest_init
‪function treasure_chest_init(start_chest_name)
Definition: _zm_magicbox.gsc:113
‪WAIT_SERVER_FRAME
‪#define WAIT_SERVER_FRAME
Definition: shared.gsh:265