‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_zm_powerup_fire_sale.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\clientfield_shared;
4 #using scripts\shared\system_shared;
5 #using scripts\shared\util_shared;
6 
7 #insert scripts\shared\shared.gsh;
8 #insert scripts\shared\version.gsh;
9 
10 #using scripts\shared\ai\zombie_death;
11 
12 #using scripts\zm\_zm_audio;
13 #using scripts\zm\_zm_bgb;
14 #using scripts\zm\_zm_bgb_machine;
15 #using scripts\zm\_zm_magicbox;
16 #using scripts\zm\_zm_pers_upgrades_functions;
17 #using scripts\zm\_zm_powerups;
18 #using scripts\zm\_zm_score;
19 #using scripts\zm\_zm_spawner;
20 #using scripts\zm\_zm_utility;
21 
22 #insert scripts\zm\_zm_powerups.gsh;
23 #insert scripts\zm\_zm_utility.gsh;
24 
25 #precache( "material", "specialty_firesale_zombies");
26 #precache( "string", "ZOMBIE_POWERUP_MAX_AMMO" );
27 
28 #namespace zm_powerup_fire_sale;
29 
30 ‪REGISTER_SYSTEM( "zm_powerup_fire_sale", &‪__init__, undefined )
31 
32 
33 //-----------------------------------------------------------------------------------
34 // setup
35 //-----------------------------------------------------------------------------------
36 function ‪__init__()
37 {
39  if( ToLower( GetDvarString( "g_gametype" ) ) != "zcleansed" )
40  {
41  ‪zm_powerups::add_zombie_powerup( "fire_sale", "p7_zm_power_up_firesale", &"ZOMBIE_POWERUP_MAX_AMMO", &‪func_should_drop_fire_sale, !‪POWERUP_ONLY_AFFECTS_GRABBER, !‪POWERUP_ANY_TEAM, !‪POWERUP_ZOMBIE_GRABBABLE, undefined, ‪CLIENTFIELD_POWERUP_FIRE_SALE, "zombie_powerup_fire_sale_time", "zombie_powerup_fire_sale_on" );
42  }
43 }
44 
45 function ‪grab_fire_sale( player )
46 {
47  level thread ‪start_fire_sale( self );
48  player thread ‪zm_powerups::powerup_vo("firesale");
49 }
50 
51 
52 function ‪start_fire_sale( item )
53 {
54  // If chests use a special leaving wait till it is away
55  if( ‪IS_TRUE( level.custom_firesale_box_leave ) )
56  {
58  {
60  }
61  }
62 
63  if(level.zombie_vars["zombie_powerup_fire_sale_time"] > 0 && ‪IS_TRUE(level.zombie_vars["zombie_powerup_fire_sale_on"] ) ) // firesale already going when a new one is picked up ..just add time
64  {
65  level.zombie_vars["zombie_powerup_fire_sale_time"] += ‪N_POWERUP_DEFAULT_TIME;
66  return;
67  }
68 
69  level notify ("powerup fire sale");
70  level endon ("powerup fire sale");
71 
72  level thread ‪zm_audio::sndAnnouncerPlayVox("fire_sale");
73 
74  level.zombie_vars["zombie_powerup_fire_sale_on"] = true;
75  level.disable_firesale_drop = true;
76 
77  level thread ‪toggle_fire_sale_on();
78  level.zombie_vars["zombie_powerup_fire_sale_time"] = ‪N_POWERUP_DEFAULT_TIME;
79 
80  if( ‪bgb::is_team_enabled( "zm_bgb_temporal_gift" ) )
81  {
82  level.zombie_vars["zombie_powerup_fire_sale_time"] += ‪N_POWERUP_DEFAULT_TIME;//Doubles the amount of time
83  }
84 
85  while ( level.zombie_vars["zombie_powerup_fire_sale_time"] > 0)
86  {
88  level.zombie_vars["zombie_powerup_fire_sale_time"] = level.zombie_vars["zombie_powerup_fire_sale_time"] - 0.05;
89  }
90 
91  level thread ‪check_to_clear_fire_sale();
92 
93  level.zombie_vars["zombie_powerup_fire_sale_on"] = false;
94  level notify ( "fire_sale_off" );
95 }
96 
98 {
100  {
102  }
103 
104  level.disable_firesale_drop = undefined;
105 }
106 
112 {
113  // If chests use a special leaving wait till it is away
114  for( i = 0; i < level.chests.size; i++ )
115  {
116  if( i !== level.chest_index )
117  {
118  if( level.chests[ i ].zbarrier.state === "leaving" || level.chests[ i ].zbarrier.state === "open" || level.chests[ i ].zbarrier.state === "close" || level.chests[ i ].zbarrier.state === "closing" )
119  {
120  return true;
121  }
122  }
123  }
124 
125  return false;
126 }
127 
129 {
130  level endon ("powerup fire sale");
131 
132  if( !isdefined ( level.zombie_vars["zombie_powerup_fire_sale_on"] ) )
133  {
134  return;
135  }
136 
137  level thread ‪sndFiresaleMusic_Start();
138 
140 
141  for ( i = 0; i < level.chests.size; i++ )
142  {
143  show_firesale_box = level.chests[i] [[level._zombiemode_check_firesale_loc_valid_func]]();
144 
145  if ( show_firesale_box )
146  {
147  level.chests[i].zombie_cost = 10;
148 
149  if ( level.chest_index != i )
150  {
151  level.chests[i].was_temp = true;
152  if ( ‪IS_TRUE( level.chests[i].hidden ) )
153  {
154  level.chests[i] thread ‪apply_fire_sale_to_chest();
155  }
156  }
157  }
158  }
159 
160  level notify( "fire_sale_on");
161  level waittill( "fire_sale_off" );
162 
163  //allow other level logic to handle notify before removing the .was_temp value on chests
164  waittillframeend;
165 
166  level thread ‪sndFiresaleMusic_Stop();
167 
169 
170  for ( i = 0; i < level.chests.size; i++ )
171  {
172  show_firesale_box = level.chests[i] [[level._zombiemode_check_firesale_loc_valid_func]]();
173 
174  if ( show_firesale_box )
175  {
176  if ( level.chest_index != i && IsDefined( level.chests[i].was_temp ) )
177  {
178  level.chests[i].was_temp = undefined;
179  level thread ‪remove_temp_chest( i );
180  }
181 
182  level.chests[i].zombie_cost = level.chests[i].old_cost;
183  }
184  }
185 }
186 
187 // self = magic box
189 {
190  // if we're using the elaborate chest-leaving anims, wait for it to be over before showing the chest again
191  if(self.zbarrier GetZBarrierPieceState(1) == "closing")
192  {
193  while(self.zbarrier GetZBarrierPieceState(1) == "closing")
194  {
195  wait (0.1);
196  }
197  self.zbarrier waittill("left");
198  }
199 
200  wait 0.1; // need extra wait to be able to correctly set the zbarrier
201 
202  self thread ‪zm_magicbox::show_chest();
203 }
204 
205 // Bring the chests back to normal.
206 function ‪remove_temp_chest( chest_index )
207 {
208  level.chests[chest_index].being_removed = true;
209 
210  while( isdefined( level.chests[chest_index].chest_user ) || (IsDefined(level.chests[chest_index]._box_open) && level.chests[chest_index]._box_open == true))
211  {
213  }
214 
215  if ( level.zombie_vars["zombie_powerup_fire_sale_on"] ) // Grabbed a second FireSale while temp box was open and original FireSale ended
216  {
217  level.chests[chest_index].was_temp = true;
218  level.chests[chest_index].zombie_cost = 10;
219  level.chests[chest_index].being_removed = false;
220  return;
221  }
222 
223  for( i=0; i<chest_index; i++ )
224  {
226  }
227 
228  playfx(level._effect["poltergeist"], level.chests[chest_index].orig_origin);
229  level.chests[chest_index].zbarrier playsound ( "zmb_box_poof_land" );
230  level.chests[chest_index].zbarrier playsound( "zmb_couch_slam" );
232 
233  if ( ‪IS_TRUE( level.custom_firesale_box_leave ) )
234  {
235  level.chests[chest_index] ‪zm_magicbox::hide_chest( true );
236  }
237  else
238  {
239  level.chests[chest_index] ‪zm_magicbox::hide_chest();
240  }
241 
242  level.chests[chest_index].being_removed = false;
243 }
244 
246 {
247  if( level.zombie_vars["zombie_powerup_fire_sale_on"] == true || level.chest_moves < 1 || ‪IS_TRUE(level.disable_firesale_drop))
248  {
249  return false;
250  }
251  return true;
252 }
253 
255 {
256  ‪array = level.chests;
257 
258  foreach(struct in ‪array)
259  {
260  if( !isdefined( struct.sndEnt ) )
261  {
262  struct.sndEnt = ‪spawn( "script_origin", struct.origin+(0,0,100));
263  }
264 
265  if( ‪IS_TRUE( level.player_4_vox_override ) )
266  struct.sndEnt playloopsound( "mus_fire_sale_rich", 1 );
267  else
268  struct.sndEnt playloopsound( "mus_fire_sale", 1 );
269  }
270 }
272 {
273  ‪array = level.chests;
274 
275  foreach(struct in ‪array)
276  {
277  if( isdefined( struct.sndEnt ) )
278  {
279  struct.sndEnt delete();
280  struct.sndEnt = undefined;
281  }
282  }
283 }
‪turn_on_fire_sale
‪function turn_on_fire_sale()
Definition: _zm_bgb_machine.gsc:4
‪show_chest
‪function show_chest()
Definition: _zm_magicbox.gsc:418
‪start_fire_sale
‪function start_fire_sale(item)
Definition: _zm_powerup_fire_sale.gsc:52
‪remove_temp_chest
‪function remove_temp_chest(chest_index)
Definition: _zm_powerup_fire_sale.gsc:206
‪firesale_chest_is_leaving
‪function firesale_chest_is_leaving()
Definition: _zm_powerup_fire_sale.gsc:111
‪func_should_drop_fire_sale
‪function func_should_drop_fire_sale()
Definition: _zm_powerup_fire_sale.gsc:245
‪register_powerup
‪function register_powerup(str_powerup, func_grab_powerup, func_setup)
Definition: _zm_powerups.gsc:1956
‪sndAnnouncerPlayVox
‪function sndAnnouncerPlayVox(type, player)
Definition: _zm_audio.gsc:1319
‪turn_off_fire_sale
‪function turn_off_fire_sale()
Definition: _zm_bgb_machine.gsc:5
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪grab_fire_sale
‪function grab_fire_sale(player)
Definition: _zm_powerup_fire_sale.gsc:45
‪POWERUP_ONLY_AFFECTS_GRABBER
‪#define POWERUP_ONLY_AFFECTS_GRABBER
Definition: _zm_powerups.gsh:31
‪sndFiresaleMusic_Stop
‪function sndFiresaleMusic_Stop()
Definition: _zm_powerup_fire_sale.gsc:271
‪POWERUP_ZOMBIE_GRABBABLE
‪#define POWERUP_ZOMBIE_GRABBABLE
Definition: _zm_powerups.gsh:33
‪wait_network_frame
‪function wait_network_frame(n_count=1)
Definition: util_shared.gsc:64
‪powerup_vo
‪function powerup_vo(type)
Definition: _zm_powerups.gsc:1216
‪hide_chest
‪function hide_chest(doBoxLeave)
Definition: _zm_magicbox.gsc:441
‪check_to_clear_fire_sale
‪function check_to_clear_fire_sale()
Definition: _zm_powerup_fire_sale.gsc:97
‪sndFiresaleMusic_Start
‪function sndFiresaleMusic_Start()
Definition: _zm_powerup_fire_sale.gsc:254
‪is_team_enabled
‪function is_team_enabled(str_name)
Definition: _zm_bgb.gsc:13
‪__init__
‪function __init__()
Definition: _zm_powerup_fire_sale.gsc:36
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪array
‪function filter array
Definition: array_shared.csc:16
‪N_POWERUP_DEFAULT_TIME
‪#define N_POWERUP_DEFAULT_TIME
Definition: _zm_powerups.gsh:36
‪apply_fire_sale_to_chest
‪function apply_fire_sale_to_chest()
Definition: _zm_powerup_fire_sale.gsc:188
‪CLIENTFIELD_POWERUP_FIRE_SALE
‪#define CLIENTFIELD_POWERUP_FIRE_SALE
Definition: _zm_powerups.gsh:15
‪add_zombie_powerup
‪function add_zombie_powerup(powerup_name, client_field_name, clientfield_version=VERSION_SHIP)
Definition: _zm_powerups.csc:40
‪toggle_fire_sale_on
‪function toggle_fire_sale_on()
Definition: _zm_powerup_fire_sale.gsc:128
‪POWERUP_ANY_TEAM
‪#define POWERUP_ANY_TEAM
Definition: _zm_powerups.gsh:32
‪WAIT_SERVER_FRAME
‪#define WAIT_SERVER_FRAME
Definition: shared.gsh:265