Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 71.91 KB | None | 0 0
  1. #include maps\_utility;
  2. #include common_scripts\utility;
  3. #include maps\_zombiemode_utility;
  4.  
  5. init()
  6. {
  7. init_weapons();
  8. init_weapon_upgrade();
  9. init_pay_turret();
  10. init_weapon_cabinet();
  11. treasure_chest_init();
  12. level thread add_limited_tesla_gun();
  13. level.box_moved = false;
  14. }
  15.  
  16. add_zombie_weapon( weapon_name, hint, cost, weaponVO, variation_count, ammo_cost )
  17. {
  18. if( IsDefined( level.zombie_include_weapons ) && !IsDefined( level.zombie_include_weapons[weapon_name] ) )
  19. {
  20. return;
  21. }
  22.  
  23. add_weapon_to_sound_array(weaponVO,variation_count);
  24.  
  25. // Check the table first
  26. table = "mp/zombiemode.csv";
  27. table_cost = TableLookUp( table, 0, weapon_name, 1 );
  28. table_ammo_cost = TableLookUp( table, 0, weapon_name, 2 );
  29.  
  30. if( IsDefined( table_cost ) && table_cost != "" )
  31. {
  32. cost = round_up_to_ten( int( table_cost ) );
  33. }
  34.  
  35. if( IsDefined( table_ammo_cost ) && table_ammo_cost != "" )
  36. {
  37. ammo_cost = round_up_to_ten( int( table_ammo_cost ) );
  38. }
  39.  
  40. PrecacheItem( weapon_name );
  41. PrecacheString( hint );
  42.  
  43. struct = SpawnStruct();
  44.  
  45. if( !IsDefined( level.zombie_weapons ) )
  46. {
  47. level.zombie_weapons = [];
  48. }
  49.  
  50. struct.weapon_name = weapon_name;
  51. struct.weapon_classname = "weapon_" + weapon_name;
  52. struct.hint = hint;
  53. struct.cost = cost;
  54. struct.sound = weaponVO;
  55. struct.variation_count = variation_count;
  56. struct.is_in_box = level.zombie_include_weapons[weapon_name];
  57.  
  58. if( !IsDefined( ammo_cost ) )
  59. {
  60. ammo_cost = round_up_to_ten( int( cost * 0.5 ) );
  61. }
  62.  
  63. struct.ammo_cost = ammo_cost;
  64.  
  65. level.zombie_weapons[weapon_name] = struct;
  66. }
  67.  
  68. default_weighting_func()
  69. {
  70. return 1;
  71. }
  72.  
  73. default_tesla_weighting_func()
  74. {
  75. num_to_add = 1;
  76. if( isDefined( level.pulls_since_last_tesla_gun ) )
  77. {
  78. // player has dropped the tesla for another weapon, so we set all future polls to 20%
  79. if( isDefined(level.player_drops_tesla_gun) && level.player_drops_tesla_gun == true )
  80. {
  81. num_to_add += int(.2 * level.zombie_include_weapons.size);
  82. }
  83.  
  84. // player has not seen tesla gun in late rounds
  85. if( !isDefined(level.player_seen_tesla_gun) || level.player_seen_tesla_gun == false )
  86. {
  87. // after round 10 the Tesla gun percentage increases to 20%
  88. if( level.round_number > 10 )
  89. {
  90. num_to_add += int(.2 * level.zombie_include_weapons.size);
  91. }
  92. // after round 5 the Tesla gun percentage increases to 15%
  93. else if( level.round_number > 5 )
  94. {
  95. // calculate the number of times we have to add it to the array to get the desired percent
  96. num_to_add += int(.15 * level.zombie_include_weapons.size);
  97. }
  98. }
  99. }
  100. return num_to_add;
  101. }
  102.  
  103. default_ray_gun_weighting_func()
  104. {
  105. if( level.box_moved == true )
  106. {
  107. num_to_add = 1;
  108. // increase the percentage of ray gun
  109. if( isDefined( level.pulls_since_last_ray_gun ) )
  110. {
  111. // after 12 pulls the ray gun percentage increases to 15%
  112. if( level.pulls_since_last_ray_gun > 11 )
  113. {
  114. num_to_add += int(level.zombie_include_weapons.size*0.15);
  115. }
  116. // after 8 pulls the Ray Gun percentage increases to 10%
  117. else if( level.pulls_since_last_ray_gun > 7 )
  118. {
  119. num_to_add += int(.1 * level.zombie_include_weapons.size);
  120. }
  121. }
  122. return num_to_add;
  123. }
  124. else
  125. {
  126. return 0;
  127. }
  128. }
  129.  
  130.  
  131. //
  132. // Slightly elevate the chance to get it until someone has it, then make it even
  133. default_cymbal_monkey_weighting_func()
  134. {
  135. players = get_players();
  136. count = 0;
  137. for( i = 0; i < players.size; i++ )
  138. {
  139. if( players[i] has_weapon_or_upgrade( "zombie_cymbal_monkey" ) )
  140. {
  141. count++;
  142. }
  143. }
  144. if ( count > 0 )
  145. {
  146. return 1;
  147. }
  148. else
  149. {
  150. if( level.round_number < 10 )
  151. {
  152. return 3;
  153. }
  154. else
  155. {
  156. return 5;
  157. }
  158. }
  159. }
  160.  
  161.  
  162. include_zombie_weapon( weapon_name, in_box, weighting_func )
  163. {
  164. if( !IsDefined( level.zombie_include_weapons ) )
  165. {
  166. level.zombie_include_weapons = [];
  167. }
  168. if( !isDefined( in_box ) )
  169. {
  170. in_box = true;
  171. }
  172.  
  173. level.zombie_include_weapons[weapon_name] = in_box;
  174.  
  175. if( !isDefined( weighting_func ) )
  176. {
  177. level.weapon_weighting_funcs[weapon_name] = maps\_zombiemode_weapons::default_weighting_func;
  178. }
  179. else
  180. {
  181. level.weapon_weighting_funcs[weapon_name] = weighting_func;
  182. }
  183. }
  184.  
  185. init_weapons()
  186. {
  187. // Zombify
  188. PrecacheItem( "zombie_melee" );
  189.  
  190.  
  191. // Pistols
  192. add_zombie_weapon( "colt", &"ZOMBIE_WEAPON_COLT_50", 50, "vox_crappy", 8 );
  193. add_zombie_weapon( "colt_dirty_harry", &"ZOMBIE_WEAPON_COLT_DH_100", 100, "vox_357", 5 );
  194. // add_zombie_weapon( "nambu", &"ZOMBIE_WEAPON_NAMBU_50", 50, "vox_crappy", 8 );
  195. add_zombie_weapon( "sw_357", &"ZOMBIE_WEAPON_SW357_100", 100, "vox_357", 5 );
  196. add_zombie_weapon( "zombie_sw_357", &"ZOMBIE_WEAPON_SW357_100", 100, "vox_357", 5 );
  197. add_zombie_weapon( "zombie_sw_357_upgraded", &"ZOMBIE_WEAPON_SW357_100", 100, "vox_357", 5 );
  198. add_zombie_weapon( "tokarev", &"ZOMBIE_WEAPON_TOKAREV_50", 50, "vox_crappy", 8 );
  199. add_zombie_weapon( "walther", &"ZOMBIE_WEAPON_WALTHER_50", 50, "vox_crappy", 8 );
  200. add_zombie_weapon( "zombie_colt", &"ZOMBIE_WEAPON_ZOMBIECOLT_25", 25, "vox_crappy", 8 );
  201. // add_zombie_weapon( "nambu_mp", "Press and hold &&1 to buy Nambu [Cost: 750]", 750, "vox_crappy", 8 );
  202. add_zombie_weapon( "zombie_colt_upgraded", &"ZOMBIE_WEAPON_ZOMBIECOLT_25", 25, "vox_crappy", 8 );
  203. // add_zombie_weapon( "nambu_mp", "Press and hold &&1 to buy M1911 [Cost: 500]", 500, "vox_crappy", 8 );
  204.  
  205. // Bolt Action
  206. add_zombie_weapon( "kar98k", &"ZOMBIE_WEAPON_KAR98K_200", 200, "", 0);
  207. add_zombie_weapon( "zombie_kar98k", &"ZOMBIE_WEAPON_KAR98K_200", 200, "", 0);
  208. add_zombie_weapon( "zombie_kar98k_upgraded", &"ZOMBIE_WEAPON_KAR98K_200", 200, "", 0);
  209. add_zombie_weapon( "kar98k_bayonet", &"ZOMBIE_WEAPON_KAR98K_B_200", 200, "", 0);
  210. add_zombie_weapon( "mosin_rifle", &"ZOMBIE_WEAPON_MOSIN_200", 200, "", 0);
  211. add_zombie_weapon( "mosin_rifle_bayonet", &"ZOMBIE_WEAPON_MOSIN_B_200", 200, "", 0 );
  212. add_zombie_weapon( "springfield", &"ZOMBIE_WEAPON_SPRINGFIELD_200", 200, "", 0 );
  213. add_zombie_weapon( "zombie_springfield", &"ZOMBIE_WEAPON_SPRINGFIELD_200", 200, "", 0 );
  214. add_zombie_weapon( "springfield_bayonet", &"ZOMBIE_WEAPON_SPRINGFIELD_B_200", 200, "", 0 );
  215. add_zombie_weapon( "zombie_type99_rifle", &"ZOMBIE_WEAPON_TYPE99_200", 200, "", 0 );
  216. add_zombie_weapon( "zombie_type99_rifle_upgraded", &"ZOMBIE_WEAPON_TYPE99_200", 200, "", 0 );
  217. add_zombie_weapon( "type99_rifle_bayonet", &"ZOMBIE_WEAPON_TYPE99_B_200", 200, "", 0 );
  218.  
  219. // Semi Auto
  220. add_zombie_weapon( "zombie_gewehr43", &"ZOMBIE_WEAPON_GEWEHR43_600", 600, "" , 0 );
  221. add_zombie_weapon( "zombie_gewehr43_upgraded", &"ZOMBIE_WEAPON_GEWEHR43_600", 600, "" , 0 );
  222. add_zombie_weapon( "zombie_m1carbine", &"ZOMBIE_WEAPON_M1CARBINE_600", 600, "" , 0 );
  223. add_zombie_weapon( "zombie_m1carbine_upgraded", &"ZOMBIE_WEAPON_M1CARBINE_600", 600, "" , 0 );
  224. add_zombie_weapon( "m1carbine_bayonet", &"ZOMBIE_WEAPON_M1CARBINE_B_600", 600, "" , 0 );
  225. add_zombie_weapon( "zombie_m1garand", &"ZOMBIE_WEAPON_M1GARAND_600", 600, "" , 0 );
  226. add_zombie_weapon( "zombie_m1garand_upgraded", &"ZOMBIE_WEAPON_M1GARAND_600", 600, "" , 0 );
  227. add_zombie_weapon( "m1garand_bayonet", &"ZOMBIE_WEAPON_M1GARAND_B_600", 600, "" , 0 );
  228. add_zombie_weapon( "svt40", &"ZOMBIE_WEAPON_SVT40_600", 600, "" , 0 );
  229.  
  230. // Grenades
  231. add_zombie_weapon( "fraggrenade", &"ZOMBIE_WEAPON_FRAGGRENADE_250", 250, "" , 0 );
  232. add_zombie_weapon( "molotov", &"ZOMBIE_WEAPON_MOLOTOV_200", 200, "vox_crappy", 8 );
  233. add_zombie_weapon( "molotov_zombie", &"ZOMBIE_WEAPON_MOLOTOV_200", 200, "vox_crappy", 8 );
  234. add_zombie_weapon( "stick_grenade", &"ZOMBIE_WEAPON_STICKGRENADE_250", 250, "" , 0 );
  235. add_zombie_weapon( "stielhandgranate", &"ZOMBIE_WEAPON_STIELHANDGRANATE_250", 250, "" , 0, 250 );
  236. add_zombie_weapon( "type97_frag", &"ZOMBIE_WEAPON_TYPE97FRAG_250", 250, "" , 0 );
  237.  
  238. // Scoped
  239. add_zombie_weapon( "kar98k_scoped_zombie", &"ZOMBIE_WEAPON_KAR98K_S_750", 750, "vox_ppsh", 5);
  240. add_zombie_weapon( "kar98k_scoped_bayonet_zombie", &"ZOMBIE_WEAPON_KAR98K_S_B_750", 750, "vox_ppsh", 5);
  241. add_zombie_weapon( "mosin_rifle_scoped_zombie", &"ZOMBIE_WEAPON_MOSIN_S_750", 750, "vox_ppsh", 5);
  242. add_zombie_weapon( "mosin_rifle_scoped_bayonet_zombie", &"ZOMBIE_WEAPON_MOSIN_S_B_750", 750, "vox_ppsh", 5);
  243. add_zombie_weapon( "ptrs41_zombie", &"ZOMBIE_WEAPON_PTRS41_750", 750, "vox_ppsh", 5);
  244. add_zombie_weapon( "ptrs41_zombie_upgraded", &"ZOMBIE_WEAPON_PTRS41_750", 750, "vox_ppsh", 5);
  245. add_zombie_weapon( "springfield_scoped_zombie", &"ZOMBIE_WEAPON_SPRINGFIELD_S_750", 750, "vox_ppsh", 5);
  246. add_zombie_weapon( "springfield_scoped_bayonet_zombie", &"ZOMBIE_WEAPON_SPRINGFIELD_S_B_750", 750, "vox_ppsh", 5);
  247. add_zombie_weapon( "type99_rifle_scoped_zombie", &"ZOMBIE_WEAPON_TYPE99_S_750", 750, "vox_ppsh", 5);
  248. add_zombie_weapon( "type99_rifle_scoped_bayonet_zombie", &"ZOMBIE_WEAPON_TYPE99_S_B_750", 750, "vox_ppsh", 5);
  249.  
  250. // Full Auto
  251. add_zombie_weapon( "zombie_mp40", &"ZOMBIE_WEAPON_MP40_1000", 1000, "vox_mp40", 2 );
  252. add_zombie_weapon( "zombie_mp40_upgraded", &"ZOMBIE_WEAPON_MP40_1000", 1000, "vox_mp40", 2 );
  253. add_zombie_weapon( "zombie_ppsh", &"ZOMBIE_WEAPON_PPSH_2000", 2000, "vox_ppsh", 5 );
  254. add_zombie_weapon( "zombie_ppsh_upgraded", &"ZOMBIE_WEAPON_PPSH_2000", 2000, "vox_ppsh", 5 );
  255. add_zombie_weapon( "zombie_stg44", &"ZOMBIE_WEAPON_STG44_1200", 1200, "vox_mg", 9 );
  256. add_zombie_weapon( "zombie_stg44_upgraded", &"ZOMBIE_WEAPON_STG44_1200", 1200, "vox_mg", 9 );
  257. add_zombie_weapon( "zombie_thompson", &"ZOMBIE_WEAPON_THOMPSON_1200", 1200, "", 0 );
  258. add_zombie_weapon( "zombie_thompson_upgraded", &"ZOMBIE_WEAPON_THOMPSON_1200", 1200, "", 0 );
  259. add_zombie_weapon( "zombie_type100_smg", &"ZOMBIE_WEAPON_TYPE100_1000", 1000, "", 0 );
  260. add_zombie_weapon( "zombie_type100_smg_upgraded", &"ZOMBIE_WEAPON_TYPE100_1000", 1000, "", 0 );
  261. add_zombie_weapon( "thompson_mp", &"ZOMBIE_WEAPON_TYPE100_1000", 1000, "vox_ppsh", 0 );
  262.  
  263. // Shotguns
  264. add_zombie_weapon( "zombie_doublebarrel", &"ZOMBIE_WEAPON_DOUBLEBARREL_1200", 1200, "vox_shotgun", 6);
  265. add_zombie_weapon( "zombie_doublebarrel_upgraded", &"ZOMBIE_WEAPON_DOUBLEBARREL_1200", 1200, "vox_shotgun", 6);
  266. add_zombie_weapon( "zombie_doublebarrel_sawed", &"ZOMBIE_WEAPON_DOUBLEBARREL_SAWED_1200", 1200, "vox_shotgun", 6);
  267. add_zombie_weapon( "zombie_doublebarrel_sawed_upgraded", &"ZOMBIE_WEAPON_DOUBLEBARREL_SAWED_1200", 1200, "vox_shotgun", 6);
  268. add_zombie_weapon( "zombie_shotgun", &"ZOMBIE_WEAPON_SHOTGUN_1500", 1500, "vox_shotgun", 6);
  269. add_zombie_weapon( "zombie_shotgun_upgraded", &"ZOMBIE_WEAPON_SHOTGUN_1500", 1500, "vox_shotgun", 6);
  270. add_zombie_weapon( "zombie_spas", "Press amd hold &&1 to buy Dragon's Breath [Cost: 1500]", 1500, "vox_shotgun", 6);
  271.  
  272. // Heavy Machineguns
  273. add_zombie_weapon( "zombie_30cal", &"ZOMBIE_WEAPON_30CAL_3000", 3000, "vox_mg", 9 );
  274. add_zombie_weapon( "zombie_30cal_upgraded", &"ZOMBIE_WEAPON_30CAL_3000", 3000, "vox_mg", 9 );
  275. add_zombie_weapon( "zombie_bar", &"ZOMBIE_WEAPON_BAR_1800", 1800, "vox_bar", 5 );
  276. add_zombie_weapon( "zombie_bar_upgraded", &"ZOMBIE_WEAPON_BAR_1800", 1800, "vox_bar", 5 );
  277. add_zombie_weapon( "dp28", &"ZOMBIE_WEAPON_DP28_2250", 2250, "vox_mg" , 9 );
  278. add_zombie_weapon( "zombie_fg42", &"ZOMBIE_WEAPON_FG42_1500", 1500, "vox_mg" , 9 );
  279. add_zombie_weapon( "zombie_fg42_upgraded", &"ZOMBIE_WEAPON_FG42_1500", 1500, "vox_mg" , 9 );
  280. add_zombie_weapon( "fg42_scoped", &"ZOMBIE_WEAPON_FG42_S_1500", 1500, "vox_mg" , 9 );
  281. add_zombie_weapon( "zombie_mg42", &"ZOMBIE_WEAPON_MG42_3000", 3000, "vox_mg" , 9 );
  282. add_zombie_weapon( "zombie_mg42_upgraded", &"ZOMBIE_WEAPON_MG42_3000", 3000, "vox_mg" , 9 );
  283. add_zombie_weapon( "type99_lmg", &"ZOMBIE_WEAPON_TYPE99_LMG_1750", 1750, "vox_mg" , 9 );
  284.  
  285. // Grenade Launcher
  286. add_zombie_weapon( "m1garand_gl_zombie", &"ZOMBIE_WEAPON_M1GARAND_GL_1500", 1500, "", 0 );
  287. add_zombie_weapon( "m1garand_gl_zombie_upgraded", &"ZOMBIE_WEAPON_M1GARAND_GL_1500", 1500, "", 0 );
  288. add_zombie_weapon( "mosin_launcher_zombie", &"ZOMBIE_WEAPON_MOSIN_GL_1200", 1200, "", 0 );
  289.  
  290. // Bipods
  291. add_zombie_weapon( "30cal_bipod", &"ZOMBIE_WEAPON_30CAL_BIPOD_3500", 3500, "vox_mg", 5 );
  292. add_zombie_weapon( "bar_bipod", &"ZOMBIE_WEAPON_BAR_BIPOD_2500", 2500, "vox_bar", 5 );
  293. add_zombie_weapon( "dp28_bipod", &"ZOMBIE_WEAPON_DP28_BIPOD_2500", 2500, "vox_mg", 5 );
  294. add_zombie_weapon( "fg42_bipod", &"ZOMBIE_WEAPON_FG42_BIPOD_2000", 2000, "vox_mg", 5 );
  295. add_zombie_weapon( "mg42_bipod", &"ZOMBIE_WEAPON_MG42_BIPOD_3250", 3250, "vox_mg", 5 );
  296. add_zombie_weapon( "type99_lmg_bipod", &"ZOMBIE_WEAPON_TYPE99_LMG_BIPOD_2250", 2250, "vox_mg", 5 );
  297.  
  298. // Rocket Launchers
  299. add_zombie_weapon( "bazooka", &"ZOMBIE_WEAPON_BAZOOKA_2000", 2000, "", 0 );
  300. add_zombie_weapon( "panzerschrek_zombie", &"ZOMBIE_WEAPON_PANZERSCHREK_2000", 2000, "vox_panzer", 5 );
  301. add_zombie_weapon( "panzerschrek_zombie_upgraded", &"ZOMBIE_WEAPON_PANZERSCHREK_2000", 2000, "vox_panzer", 5 );
  302.  
  303. // Flamethrower
  304. add_zombie_weapon( "m2_flamethrower_zombie", &"ZOMBIE_WEAPON_M2_FLAMETHROWER_3000", 3000, "vox_flame", 7);
  305. add_zombie_weapon( "m2_flamethrower_zombie_upgraded", &"ZOMBIE_WEAPON_M2_FLAMETHROWER_3000", 3000, "vox_flame", 7);
  306.  
  307. // Special
  308. add_zombie_weapon( "mine_bouncing_betty", &"ZOMBIE_WEAPON_SATCHEL_2000", 2000, "" );
  309. add_zombie_weapon( "mortar_round", &"ZOMBIE_WEAPON_MORTARROUND_2000", 2000, "" );
  310. add_zombie_weapon( "satchel_charge", &"ZOMBIE_WEAPON_SATCHEL_2000", 2000, "vox_monkey", 3 );
  311. add_zombie_weapon( "zombie_cymbal_monkey", "Press and hold &&1 for Monkey Bombs [Cost: 1000]", 1000, "vox_monkey", 3 );
  312. add_zombie_weapon( "ray_gun", &"ZOMBIE_WEAPON_RAYGUN_10000", 10000, "vox_raygun", 6 );
  313. add_zombie_weapon( "ray_gun_upgraded", &"ZOMBIE_WEAPON_RAYGUN_10000", 10000, "vox_raygun", 6 );
  314. add_zombie_weapon( "tesla_gun", &"ZOMBIE_BUY_TESLA", 10, "vox_tesla", 5 );
  315. add_zombie_weapon( "tesla_gun_upgraded", &"ZOMBIE_BUY_TESLA", 10, "vox_tesla", 5 );
  316.  
  317. if(level.script != "nazi_zombie_prototype")
  318. {
  319. Precachemodel("zombie_teddybear");
  320. }
  321. // ONLY 1 OF THE BELOW SHOULD BE ALLOWED
  322. add_limited_weapon( "m2_flamethrower_zombie", 1 );
  323. add_limited_weapon( "tesla_gun", 1);
  324. }
  325.  
  326. //remove this function and whenever it's call for production. this is only for testing purpose.
  327. add_limited_tesla_gun()
  328. {
  329.  
  330. weapon_spawns = GetEntArray( "weapon_upgrade", "targetname" );
  331.  
  332. for( i = 0; i < weapon_spawns.size; i++ )
  333. {
  334. hint_string = weapon_spawns[i].zombie_weapon_upgrade;
  335. if(hint_string == "tesla_gun")
  336. {
  337. weapon_spawns[i] waittill("trigger");
  338. weapon_spawns[i] trigger_off();
  339. break;
  340.  
  341. }
  342.  
  343. }
  344.  
  345. }
  346.  
  347.  
  348. add_limited_weapon( weapon_name, amount )
  349. {
  350. if( !IsDefined( level.limited_weapons ) )
  351. {
  352. level.limited_weapons = [];
  353. }
  354.  
  355. level.limited_weapons[weapon_name] = amount;
  356. }
  357.  
  358. // For pay turrets
  359. init_pay_turret()
  360. {
  361. pay_turrets = [];
  362. pay_turrets = GetEntArray( "pay_turret", "targetname" );
  363.  
  364. for( i = 0; i < pay_turrets.size; i++ )
  365. {
  366. cost = level.pay_turret_cost;
  367. if( !isDefined( cost ) )
  368. {
  369. cost = 1000;
  370. }
  371. pay_turrets[i] SetHintString( &"ZOMBIE_PAY_TURRET", cost );
  372. pay_turrets[i] SetCursorHint( "HINT_NOICON" );
  373. pay_turrets[i] UseTriggerRequireLookAt();
  374.  
  375. pay_turrets[i] thread pay_turret_think( cost );
  376. }
  377. }
  378.  
  379. // For buying weapon upgrades in the environment
  380. init_weapon_upgrade()
  381. {
  382. weapon_spawns = [];
  383. weapon_spawns = GetEntArray( "weapon_upgrade", "targetname" );
  384.  
  385. for( i = 0; i < weapon_spawns.size; i++ )
  386. {
  387. hint_string = get_weapon_hint( weapon_spawns[i].zombie_weapon_upgrade );
  388.  
  389. weapon_spawns[i] SetHintString( hint_string );
  390. weapon_spawns[i] setCursorHint( "HINT_NOICON" );
  391. weapon_spawns[i] UseTriggerRequireLookAt();
  392.  
  393. weapon_spawns[i] thread weapon_spawn_think();
  394. model = getent( weapon_spawns[i].target, "targetname" );
  395. model hide();
  396. }
  397. }
  398.  
  399. // weapon cabinets which open on use
  400. init_weapon_cabinet()
  401. {
  402. // the triggers which are targeted at doors
  403. weapon_cabs = GetEntArray( "weapon_cabinet_use", "targetname" );
  404.  
  405. for( i = 0; i < weapon_cabs.size; i++ )
  406. {
  407.  
  408. weapon_cabs[i] SetHintString( &"ZOMBIE_CABINET_OPEN_1500" );
  409. weapon_cabs[i] setCursorHint( "HINT_NOICON" );
  410. weapon_cabs[i] UseTriggerRequireLookAt();
  411. }
  412.  
  413. array_thread( weapon_cabs, ::weapon_cabinet_think );
  414. }
  415.  
  416. // returns the trigger hint string for the given weapon
  417. get_weapon_hint( weapon_name )
  418. {
  419. AssertEx( IsDefined( level.zombie_weapons[weapon_name] ), weapon_name + " was not included or is not part of the zombie weapon list." );
  420.  
  421. return level.zombie_weapons[weapon_name].hint;
  422. }
  423.  
  424. get_weapon_cost( weapon_name )
  425. {
  426. AssertEx( IsDefined( level.zombie_weapons[weapon_name] ), weapon_name + " was not included or is not part of the zombie weapon list." );
  427.  
  428. return level.zombie_weapons[weapon_name].cost;
  429. }
  430.  
  431. get_ammo_cost( weapon_name )
  432. {
  433. AssertEx( IsDefined( level.zombie_weapons[weapon_name] ), weapon_name + " was not included or is not part of the zombie weapon list." );
  434.  
  435. return level.zombie_weapons[weapon_name].ammo_cost;
  436. }
  437.  
  438. get_is_in_box( weapon_name )
  439. {
  440. AssertEx( IsDefined( level.zombie_weapons[weapon_name] ), weapon_name + " was not included or is not part of the zombie weapon list." );
  441.  
  442. return level.zombie_weapons[weapon_name].is_in_box;
  443. }
  444.  
  445. is_weapon_upgraded( weaponname )
  446. {
  447. if( !isdefined( weaponname ) )
  448. {
  449. return false;
  450. }
  451.  
  452. weaponname = ToLower( weaponname );
  453.  
  454. upgraded = issubstr( weaponname, "_upgraded" );
  455.  
  456. return upgraded;
  457.  
  458. }
  459.  
  460. has_upgrade( weaponname )
  461. {
  462. has_upgrade = false;
  463. if( IsDefined( level.zombie_include_weapons[weaponname+"_upgraded"] ) )
  464. {
  465. has_upgrade = self HasWeapon( weaponname+"_upgraded" );
  466. }
  467. return has_upgrade;
  468. }
  469.  
  470. has_weapon_or_upgrade( weaponname )
  471. {
  472. has_weapon = false;
  473. if (self maps\_laststand::player_is_in_laststand())
  474. {
  475. for( m = 0; m < self.weaponInventory.size; m++ )
  476. {
  477. if (self.weaponInventory[m] == weaponname || self.weaponInventory[m] == weaponname+"_upgraded" )
  478. {
  479. has_weapon = true;
  480. }
  481. }
  482. }
  483. else
  484. {
  485. // If the weapon you're checking doesn't exist, it will return undefined
  486. if( IsDefined( level.zombie_include_weapons[weaponname] ) )
  487. {
  488. has_weapon = self HasWeapon( weaponname );
  489. }
  490.  
  491. if( !has_weapon && isdefined( level.zombie_include_weapons[weaponname+"_upgraded"] ) )
  492. {
  493. has_weapon = self HasWeapon( weaponname+"_upgraded" );
  494. }
  495. }
  496.  
  497. return has_weapon;
  498. }
  499.  
  500. using_weapon_or_upgrade( weaponname )
  501. {
  502. if( self GetCurrentWeapon() == weaponname || self GetCurrentWeapon() == weaponname+"_upgraded" )
  503. {
  504. return true;
  505. }
  506. return false;
  507. }
  508.  
  509. // for the random weapon chest
  510. treasure_chest_init()
  511. {
  512. flag_init("moving_chest_enabled");
  513. flag_init("moving_chest_now");
  514.  
  515.  
  516. level.chests = GetEntArray( "treasure_chest_use", "targetname" );
  517.  
  518. if (level.chests.size > 1)
  519. {
  520.  
  521. flag_set("moving_chest_enabled");
  522.  
  523. while ( 1 )
  524. {
  525. level.chests = array_randomize(level.chests);
  526.  
  527. if( isdefined( level.random_pandora_box_start ) )
  528. break;
  529.  
  530. if ( !IsDefined( level.chests[0].script_noteworthy ) || ( level.chests[0].script_noteworthy != "start_chest" ) )
  531. {
  532. break;
  533. }
  534.  
  535. }
  536.  
  537. level.chest_index = 0;
  538.  
  539. while(level.chest_index < level.chests.size)
  540. {
  541.  
  542. if( isdefined( level.random_pandora_box_start ) )
  543. break;
  544.  
  545. if(level.chests[level.chest_index].script_noteworthy == "start_chest")
  546. {
  547. break;
  548. }
  549.  
  550. level.chest_index++;
  551. }
  552.  
  553. //init time chest accessed amount.
  554.  
  555. if(level.script != "nazi_zombie_prototype")
  556. {
  557. level.chest_accessed = 0;
  558. }
  559.  
  560. if(level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory" )
  561. {
  562. // Anchor target will grab the weapon spawn point inside the box, so the fx will be centered on it too
  563. anchor = GetEnt(level.chests[level.chest_index].target, "targetname");
  564. anchorTarget = GetEnt(anchor.target, "targetname");
  565.  
  566. level.pandora_light = Spawn( "script_model", anchorTarget.origin );
  567. level.pandora_light.angles = anchorTarget.angles + (-90, 0, 0);
  568. //temp_fx_origin rotateto((-90, (box_origin.angles[1] * -1), 0), 0.05);
  569. level.pandora_light SetModel( "tag_origin" );
  570. playfxontag(level._effect["lght_marker"], level.pandora_light, "tag_origin");
  571. }
  572. // DCS:)
  573. {
  574. // Anchor target will grab the weapon spawn point inside the box, so the fx will be centered on it too
  575. anchor = GetEnt(level.chests[level.chest_index].target, "targetname");
  576. anchorTarget = GetEnt(anchor.target, "targetname");
  577.  
  578. level.pandora_light = Spawn( "script_model", anchorTarget.origin );
  579. level.pandora_light.angles = (-90, 0, 0);
  580. level.pandora_light SetModel( "tag_origin" );
  581. //playfxontag(level._effect["lght_marker"], level.pandora_light, "tag_origin");
  582. }
  583.  
  584. //determine magic box starting location at random or normal
  585. init_starting_chest_location();
  586.  
  587. }
  588.  
  589. array_thread( level.chests, ::treasure_chest_think );
  590.  
  591. }
  592.  
  593. init_starting_chest_location()
  594. {
  595.  
  596. for( i = 0; i < level.chests.size; i++ )
  597. {
  598.  
  599. if( isdefined( level.random_pandora_box_start ) && level.random_pandora_box_start == true )
  600. {
  601. if( i != 0 )
  602. {
  603. level.chests[i] hide_chest();
  604. }
  605. else
  606. {
  607. level.chest_index = i;
  608. unhide_magic_box( i );
  609. }
  610.  
  611. }
  612. else
  613. {
  614. if ( !IsDefined(level.chests[i].script_noteworthy ) || ( level.chests[i].script_noteworthy != "start_chest" ) )
  615. {
  616. level.chests[i] hide_chest();
  617. }
  618. else
  619. {
  620. level.chest_index = i;
  621. unhide_magic_box( i );
  622. }
  623. }
  624. }
  625.  
  626.  
  627. }
  628.  
  629. unhide_magic_box( index )
  630. {
  631.  
  632. //PI CHANGE - altered to allow for more than one piece of rubble
  633. rubble = getentarray( level.chests[index].script_noteworthy + "_rubble", "script_noteworthy" );
  634. if ( IsDefined( rubble ) )
  635. {
  636. for ( x = 0; x < rubble.size; x++ )
  637. {
  638. rubble[x] hide();
  639. }
  640. //END PI CHANGE
  641. }
  642. else
  643. {
  644. println( "^3Warning: No rubble found for magic box" );
  645. }
  646. }
  647.  
  648. set_treasure_chest_cost( cost )
  649. {
  650. level.zombie_treasure_chest_cost = cost;
  651. }
  652.  
  653. hide_chest()
  654. {
  655. pieces = self get_chest_pieces();
  656.  
  657. for(i=0;i<pieces.size;i++)
  658. {
  659. pieces[i] disable_trigger();
  660. pieces[i] hide();
  661. }
  662. }
  663.  
  664. get_chest_pieces()
  665. {
  666. // self = trigger
  667.  
  668. lid = GetEnt(self.target, "targetname");
  669. org = GetEnt(lid.target, "targetname");
  670. box = GetEnt(org.target, "targetname");
  671.  
  672. pieces = [];
  673. pieces[pieces.size] = self;
  674. pieces[pieces.size] = lid;
  675. pieces[pieces.size] = org;
  676. pieces[pieces.size] = box;
  677.  
  678. return pieces;
  679. }
  680.  
  681. play_crazi_sound()
  682. {
  683. self playlocalsound("laugh_child");
  684. }
  685.  
  686. show_magic_box()
  687. {
  688. pieces = self get_chest_pieces();
  689. for(i=0;i<pieces.size;i++)
  690. {
  691. pieces[i] enable_trigger();
  692. }
  693.  
  694. // PI_CHANGE_BEGIN - JMA - we want to play another effect on swamp
  695. anchor = GetEnt(self.target, "targetname");
  696. anchorTarget = GetEnt(anchor.target, "targetname");
  697.  
  698. if(isDefined(level.script) && (level.script != "nazi_zombie_sumpf") && (level.script != "nazi_zombie_factory") )
  699. {
  700. playfx( level._effect["poltergeist"],pieces[0].origin);
  701. }
  702. else
  703. {
  704. level.pandora_light.angles = (-90, anchorTarget.angles[1] + 180, 0);
  705. level.pandora_light moveto(anchorTarget.origin, 0.05);
  706. wait(1);
  707. playfx( level._effect["lght_marker_flare"],level.pandora_light.origin );
  708. // playfxontag(level._effect["lght_marker_flare"], level.pandora_light, "tag_origin");
  709. }
  710. // PI_CHANGE_END
  711.  
  712. playsoundatposition( "box_poof", pieces[0].origin );
  713. wait(.5);
  714. for(i=0;i<pieces.size;i++)
  715. {
  716. if( pieces[i].classname != "trigger_use" )
  717. {
  718. pieces[i] show();
  719. }
  720. }
  721. pieces[0] playsound ( "box_poof_land" );
  722. pieces[0] playsound( "couch_slam" );
  723. }
  724.  
  725. treasure_chest_think()
  726. {
  727. cost = 950;
  728. if( IsDefined( level.zombie_treasure_chest_cost ) )
  729. {
  730. cost = level.zombie_treasure_chest_cost;
  731. }
  732. else
  733. {
  734. cost = self.zombie_cost;
  735. }
  736.  
  737. self set_hint_string( self, "default_treasure_chest_" + cost );
  738. self setCursorHint( "HINT_NOICON" );
  739.  
  740. //self thread decide_hide_show_chest_hint( "move_imminent" );
  741.  
  742. // waittill someuses uses this
  743. user = undefined;
  744. while( 1 )
  745. {
  746. self waittill( "trigger", user );
  747.  
  748. if( user in_revive_trigger() )
  749. {
  750. wait( 0.1 );
  751. continue;
  752. }
  753.  
  754. // make sure the user is a player, and that they can afford it
  755. if( is_player_valid( user ) && user.score >= cost )
  756. {
  757. user maps\_zombiemode_score::minus_to_player_score( cost );
  758. break;
  759. }
  760. else if ( user.score < cost )
  761. {
  762. user thread maps\_zombiemode_perks::play_no_money_perk_dialog();
  763. continue;
  764. }
  765.  
  766. wait 0.05;
  767. }
  768.  
  769. // trigger_use->script_brushmodel lid->script_origin in radiant
  770. lid = getent( self.target, "targetname" );
  771. weapon_spawn_org = getent( lid.target, "targetname" );
  772.  
  773. //open the lid
  774. lid thread treasure_chest_lid_open();
  775.  
  776. // SRS 9/3/2008: added to help other functions know if we timed out on grabbing the item
  777. self.timedOut = false;
  778.  
  779. // mario kart style weapon spawning
  780. weapon_spawn_org thread treasure_chest_weapon_spawn( self, user );
  781.  
  782. // the glowfx
  783. weapon_spawn_org thread treasure_chest_glowfx();
  784.  
  785. // take away usability until model is done randomizing
  786. self disable_trigger();
  787.  
  788. weapon_spawn_org waittill( "randomization_done" );
  789.  
  790. if (flag("moving_chest_now"))
  791. {
  792. user thread treasure_chest_move_vo();
  793. self treasure_chest_move(lid);
  794.  
  795. }
  796. else
  797. {
  798. // Let the player grab the weapon and re-enable the box //
  799. self.grab_weapon_hint = true;
  800. self.chest_user = user;
  801. self sethintstring( &"ZOMBIE_TRADE_WEAPONS" );
  802. self setCursorHint( "HINT_NOICON" );
  803. self setvisibletoplayer( user );
  804.  
  805. // Limit its visibility to the player who bought the box
  806. self enable_trigger();
  807. self thread treasure_chest_timeout();
  808.  
  809. // make sure the guy that spent the money gets the item
  810. // SRS 9/3/2008: ...or item goes back into the box if we time out
  811. while( 1 )
  812. {
  813. self waittill( "trigger", grabber );
  814.  
  815. if( grabber == user || grabber == level )
  816. {
  817.  
  818.  
  819. if( grabber == user && is_player_valid( user ) && user GetCurrentWeapon() != "mine_bouncing_betty" )
  820. {
  821. bbPrint( "zombie_uses: playername %s playerscore %d round %d cost %d name %s x %f y %f z %f type magic_accept",
  822. user.playername, user.score, level.round_number, cost, weapon_spawn_org.weapon_string, self.origin );
  823. self notify( "user_grabbed_weapon" );
  824. user thread treasure_chest_give_weapon( weapon_spawn_org.weapon_string );
  825. break;
  826. }
  827. else if( grabber == level )
  828. {
  829. // it timed out
  830. self.timedOut = true;
  831. bbPrint( "zombie_uses: playername %s playerscore %d round %d cost %d name %s x %f y %f z %f type magic_reject",
  832. user.playername, user.score, level.round_number, cost, weapon_spawn_org.weapon_string, self.origin );
  833. break;
  834. }
  835. }
  836.  
  837. wait 0.05;
  838. }
  839.  
  840. self.grab_weapon_hint = false;
  841. self.chest_user = undefined;
  842.  
  843. weapon_spawn_org notify( "weapon_grabbed" );
  844.  
  845. //increase counter of amount of time weapon grabbed.
  846. if(level.script != "nazi_zombie_prototype")
  847. {
  848. level.chest_accessed += 1;
  849.  
  850. // PI_CHANGE_BEGIN
  851. // JMA - we only update counters when it's available
  852. if( isDefined(level.script) && (level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory") && level.box_moved == true && isDefined(level.pulls_since_last_ray_gun) )
  853. {
  854. level.pulls_since_last_ray_gun += 1;
  855. }
  856.  
  857. if( isDefined(level.script) && (level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory") && isDefined(level.pulls_since_last_tesla_gun) )
  858. {
  859. level.pulls_since_last_tesla_gun += 1;
  860. }
  861. // PI_CHANGE_END
  862. }
  863. self disable_trigger();
  864.  
  865. // spend cash here...
  866. // give weapon here...
  867. lid thread treasure_chest_lid_close( self.timedOut );
  868.  
  869. //Chris_P
  870. //magic box dissapears and moves to a new spot after a predetermined number of uses
  871.  
  872. wait 3;
  873. self enable_trigger();
  874. self setvisibletoall();
  875. }
  876.  
  877. flag_clear("moving_chest_now");
  878. self thread treasure_chest_think();
  879. }
  880.  
  881.  
  882. //
  883. // Disable trigger if can't buy weapon and also if someone else is using the chest
  884. decide_hide_show_chest_hint( endon_notify )
  885. {
  886. if( isDefined( endon_notify ) )
  887. {
  888. self endon( endon_notify );
  889. }
  890.  
  891. while( true )
  892. {
  893. players = get_players();
  894. for( i = 0; i < players.size; i++ )
  895. {
  896. // chest_user defined if someone bought a weapon spin, false when chest closed
  897. if ( (IsDefined(self.chest_user) && players[i] != self.chest_user ) ||
  898. !players[i] can_buy_weapon() )
  899. {
  900. self SetInvisibleToPlayer( players[i], true );
  901. }
  902. else
  903. {
  904. self SetInvisibleToPlayer( players[i], false );
  905. }
  906. }
  907. wait( 0.1 );
  908. }
  909. }
  910.  
  911. decide_hide_show_hint( endon_notify )
  912. {
  913. if( isDefined( endon_notify ) )
  914. {
  915. self endon( endon_notify );
  916. }
  917.  
  918. while( true )
  919. {
  920. players = get_players();
  921. for( i = 0; i < players.size; i++ )
  922. {
  923. if( players[i] can_buy_weapon() )
  924. {
  925. self SetInvisibleToPlayer( players[i], false );
  926. }
  927. else
  928. {
  929. self SetInvisibleToPlayer( players[i], true );
  930. }
  931. }
  932. wait( 0.1 );
  933. }
  934. }
  935.  
  936. can_buy_weapon()
  937. {
  938. if( isDefined( self.is_drinking ) && self.is_drinking )
  939. {
  940. return false;
  941. }
  942. if( self GetCurrentWeapon() == "mine_bouncing_betty" )
  943. {
  944. return false;
  945. }
  946. if( self in_revive_trigger() )
  947. {
  948. return false;
  949. }
  950.  
  951. return true;
  952. }
  953.  
  954. treasure_chest_move_vo()
  955. {
  956.  
  957. self endon("disconnect");
  958.  
  959. index = maps\_zombiemode_weapons::get_player_index(self);
  960. sound = undefined;
  961.  
  962. if(!isdefined (level.player_is_speaking))
  963. {
  964. level.player_is_speaking = 0;
  965. }
  966. variation_count = 5;
  967. sound = "plr_" + index + "_vox_box_move" + "_" + randomintrange(0, variation_count);
  968.  
  969.  
  970. //This keeps multiple voice overs from playing on the same player (both killstreaks and headshots).
  971. if (level.player_is_speaking != 1 && isDefined(sound))
  972. {
  973. level.player_is_speaking = 1;
  974. self playsound(sound, "sound_done");
  975. self waittill("sound_done");
  976. level.player_is_speaking = 0;
  977. }
  978.  
  979. }
  980.  
  981.  
  982. treasure_chest_move(lid)
  983. {
  984. level waittill("weapon_fly_away_start");
  985.  
  986. players = get_players();
  987.  
  988. array_thread(players, ::play_crazi_sound);
  989.  
  990. level waittill("weapon_fly_away_end");
  991.  
  992. lid thread treasure_chest_lid_close(false);
  993. self setvisibletoall();
  994.  
  995. fake_pieces = [];
  996. pieces = self get_chest_pieces();
  997.  
  998. for(i=0;i<pieces.size;i++)
  999. {
  1000. if(pieces[i].classname == "script_model")
  1001. {
  1002. fake_pieces[fake_pieces.size] = spawn("script_model",pieces[i].origin);
  1003. fake_pieces[fake_pieces.size - 1].angles = pieces[i].angles;
  1004. fake_pieces[fake_pieces.size - 1] setmodel(pieces[i].model);
  1005. pieces[i] disable_trigger();
  1006. pieces[i] hide();
  1007. }
  1008. else
  1009. {
  1010. pieces[i] disable_trigger();
  1011. pieces[i] hide();
  1012. }
  1013. }
  1014.  
  1015. anchor = spawn("script_origin",fake_pieces[0].origin);
  1016. soundpoint = spawn("script_origin", anchor.origin);
  1017. playfx( level._effect["poltergeist"],anchor.origin);
  1018.  
  1019. anchor playsound("box_move");
  1020. for(i=0;i<fake_pieces.size;i++)
  1021. {
  1022. fake_pieces[i] linkto(anchor);
  1023. }
  1024.  
  1025. playsoundatposition ("whoosh", soundpoint.origin );
  1026. playsoundatposition ("ann_vox_magicbox", soundpoint.origin );
  1027.  
  1028.  
  1029. anchor moveto(anchor.origin + (0,0,50),5);
  1030. //anchor rotateyaw(360 * 10,5,5);
  1031. if(level.chests[level.chest_index].script_noteworthy == "magic_box_south" || level.chests[level.chest_index].script_noteworthy == "magic_box_bathroom" || level.chests[level.chest_index].script_noteworthy == "magic_box_hallway")
  1032. {
  1033. anchor Vibrate( (50, 0, 0), 10, 0.5, 5 );
  1034. }
  1035. else if(level.script != "nazi_zombie_sumpf")
  1036. {
  1037. anchor Vibrate( (0, 50, 0), 10, 0.5, 5 );
  1038. }
  1039. else
  1040. {
  1041. //Get the normal of the box using the positional data of the box and lid
  1042. direction = pieces[3].origin - pieces[1].origin;
  1043. direction = (direction[1], direction[0], 0);
  1044.  
  1045. if(direction[1] < 0 || (direction[0] > 0 && direction[1] > 0))
  1046. {
  1047. direction = (direction[0], direction[1] * -1, 0);
  1048. }
  1049. else if(direction[0] < 0)
  1050. {
  1051. direction = (direction[0] * -1, direction[1], 0);
  1052. }
  1053.  
  1054. anchor Vibrate( direction, 10, 0.5, 5);
  1055. }
  1056.  
  1057. //anchor thread rotateroll_box();
  1058. anchor waittill("movedone");
  1059. //players = get_players();
  1060. //array_thread(players, ::play_crazi_sound);
  1061. //wait(3.9);
  1062.  
  1063. playfx(level._effect["poltergeist"], anchor.origin);
  1064.  
  1065. //TUEY - Play the 'disappear' sound
  1066. playsoundatposition ("box_poof", soundpoint.origin);
  1067. for(i=0;i<fake_pieces.size;i++)
  1068. {
  1069. fake_pieces[i] delete();
  1070. }
  1071.  
  1072.  
  1073. //gzheng-Show the rubble
  1074. //PI CHANGE - allow for more than one object of rubble per box
  1075. rubble = getentarray(self.script_noteworthy + "_rubble", "script_noteworthy");
  1076.  
  1077. if ( IsDefined( rubble ) )
  1078. {
  1079. for (i = 0; i < rubble.size; i++)
  1080. {
  1081. rubble[i] show();
  1082. }
  1083. }
  1084. else
  1085. {
  1086. println( "^3Warning: No rubble found for magic box" );
  1087. }
  1088.  
  1089. wait(0.1);
  1090. anchor delete();
  1091. soundpoint delete();
  1092.  
  1093. old_chest_index = level.chest_index;
  1094.  
  1095. wait(5);
  1096.  
  1097. //chest moving logic
  1098. //PI CHANGE - for sumpf, this doesn't work because chest_index is always incremented twice (here and line 724) - while this would work with an odd number of chests,
  1099. // with an even number it skips half of the chest locations in the map
  1100.  
  1101. level.verify_chest = false;
  1102. //wait(3);
  1103. //make sure level is asylum, factory, or sumpf and make magic box only appear in location player have open, it's off by default
  1104. //also make sure box doesn't respawn in old location.
  1105. //PI WJB: removed check on "magic_box_explore_only" dvar because it is only ever used here and when it is set in _zombiemode.gsc line 446
  1106. // where it is declared and set to 0, causing this while loop to never happen because the check was to see if it was equal to 1
  1107. if( level.script == "nazi_zombie_asylum" || level.script == "nazi_zombie_factory" || level.script == "nazi_zombie_sumpf")
  1108. {
  1109. level.chest_index++;
  1110.  
  1111. /* while(level.chests[level.chest_index].origin == level.chests[old_chest_index].origin)
  1112. {
  1113. level.chest_index++;
  1114. }*/
  1115.  
  1116. if (level.chest_index >= level.chests.size)
  1117. {
  1118. //PI CHANGE - this way the chests won't move in the same order the second time around
  1119. temp_chest_name = level.chests[level.chest_index - 1].script_noteworthy;
  1120. level.chest_index = 0;
  1121. level.chests = array_randomize(level.chests);
  1122. //in case it happens to randomize in such a way that the chest_index now points to the same location
  1123. // JMA - want to avoid an infinite loop, so we use an if statement
  1124. if (temp_chest_name == level.chests[level.chest_index].script_noteworthy)
  1125. {
  1126. level.chest_index++;
  1127. }
  1128. //END PI CHANGE
  1129. }
  1130.  
  1131. //verify_chest_is_open();
  1132. wait(0.01);
  1133.  
  1134. }
  1135. level.chests[level.chest_index] show_magic_box();
  1136.  
  1137. //turn off magic box light.
  1138. level notify("magic_box_light_switch");
  1139. //PI CHANGE - altered to allow for more than one object of rubble per box
  1140. unhide_magic_box( level.chest_index );
  1141.  
  1142. }
  1143.  
  1144. rotateroll_box()
  1145. {
  1146. angles = 40;
  1147. angles2 = 0;
  1148. //self endon("movedone");
  1149. while(isdefined(self))
  1150. {
  1151. self RotateRoll(angles + angles2, 0.5);
  1152. wait(0.7);
  1153. angles2 = 40;
  1154. self RotateRoll(angles * -2, 0.5);
  1155. wait(0.7);
  1156. }
  1157.  
  1158.  
  1159.  
  1160. }
  1161. //verify if that magic box is open to players or not.
  1162. verify_chest_is_open()
  1163. {
  1164.  
  1165. //for(i = 0; i < 5; i++)
  1166. //PI CHANGE - altered so that there can be more than 5 valid chest locations
  1167. for (i = 0; i < level.open_chest_location.size; i++)
  1168. {
  1169. if(isdefined(level.open_chest_location[i]))
  1170. {
  1171. if(level.open_chest_location[i] == level.chests[level.chest_index].script_noteworthy)
  1172. {
  1173. level.verify_chest = true;
  1174. return;
  1175. }
  1176. }
  1177.  
  1178. }
  1179.  
  1180. level.verify_chest = false;
  1181.  
  1182.  
  1183. }
  1184.  
  1185.  
  1186. treasure_chest_timeout()
  1187. {
  1188. self endon( "user_grabbed_weapon" );
  1189.  
  1190. wait( 12 );
  1191. self notify( "trigger", level );
  1192. }
  1193.  
  1194. treasure_chest_lid_open()
  1195. {
  1196. openRoll = 105;
  1197. openTime = 0.5;
  1198.  
  1199. self RotateRoll( 105, openTime, ( openTime * 0.5 ) );
  1200.  
  1201. play_sound_at_pos( "open_chest", self.origin );
  1202. play_sound_at_pos( "music_chest", self.origin );
  1203. }
  1204.  
  1205. treasure_chest_lid_close( timedOut )
  1206. {
  1207. closeRoll = -105;
  1208. closeTime = 0.5;
  1209.  
  1210. self RotateRoll( closeRoll, closeTime, ( closeTime * 0.5 ) );
  1211. play_sound_at_pos( "close_chest", self.origin );
  1212. }
  1213.  
  1214. treasure_chest_ChooseRandomWeapon( player )
  1215. {
  1216.  
  1217. keys = GetArrayKeys( level.zombie_weapons );
  1218.  
  1219. // Filter out any weapons the player already has
  1220. filtered = [];
  1221. for( i = 0; i < keys.size; i++ )
  1222. {
  1223. if( !get_is_in_box( keys[i] ) )
  1224. {
  1225. continue;
  1226. }
  1227.  
  1228. if( player has_weapon_or_upgrade( keys[i] ) )
  1229. {
  1230. continue;
  1231. }
  1232.  
  1233. if( !IsDefined( keys[i] ) )
  1234. {
  1235. continue;
  1236. }
  1237.  
  1238. filtered[filtered.size] = keys[i];
  1239. }
  1240.  
  1241. // Filter out the limited weapons
  1242. if( IsDefined( level.limited_weapons ) )
  1243. {
  1244. keys2 = GetArrayKeys( level.limited_weapons );
  1245. players = get_players();
  1246. pap_triggers = GetEntArray("zombie_vending_upgrade", "targetname");
  1247. for( q = 0; q < keys2.size; q++ )
  1248. {
  1249. count = 0;
  1250. for( i = 0; i < players.size; i++ )
  1251. {
  1252. if( players[i] has_weapon_or_upgrade( keys2[q] ) )
  1253. {
  1254. count++;
  1255. }
  1256. }
  1257.  
  1258. // Check the pack a punch machines to see if they are holding what we're looking for
  1259. for ( k=0; k<pap_triggers.size; k++ )
  1260. {
  1261. if ( IsDefined(pap_triggers[k].current_weapon) && pap_triggers[k].current_weapon == keys2[q] )
  1262. {
  1263. count++;
  1264. }
  1265. }
  1266.  
  1267. if( count >= level.limited_weapons[keys2[q]] )
  1268. {
  1269. filtered = array_remove( filtered, keys2[q] );
  1270. }
  1271. }
  1272. }
  1273.  
  1274. return filtered[RandomInt( filtered.size )];
  1275. }
  1276.  
  1277. treasure_chest_ChooseWeightedRandomWeapon( player )
  1278. {
  1279.  
  1280. keys = GetArrayKeys( level.zombie_weapons );
  1281.  
  1282. // Filter out any weapons the player already has
  1283. filtered = [];
  1284. for( i = 0; i < keys.size; i++ )
  1285. {
  1286. if( !get_is_in_box( keys[i] ) )
  1287. {
  1288. continue;
  1289. }
  1290.  
  1291. if( player has_weapon_or_upgrade( keys[i] ) )
  1292. {
  1293. continue;
  1294. }
  1295.  
  1296. if( !IsDefined( keys[i] ) )
  1297. {
  1298. continue;
  1299. }
  1300.  
  1301. num_entries = [[ level.weapon_weighting_funcs[keys[i]] ]]();
  1302.  
  1303. for( j = 0; j < num_entries; j++ )
  1304. {
  1305. filtered[filtered.size] = keys[i];
  1306. }
  1307. }
  1308.  
  1309. // Filter out the limited weapons
  1310. if( IsDefined( level.limited_weapons ) )
  1311. {
  1312. keys2 = GetArrayKeys( level.limited_weapons );
  1313. players = get_players();
  1314. pap_triggers = GetEntArray("zombie_vending_upgrade", "targetname");
  1315. for( q = 0; q < keys2.size; q++ )
  1316. {
  1317. count = 0;
  1318. for( i = 0; i < players.size; i++ )
  1319. {
  1320. if( players[i] has_weapon_or_upgrade( keys2[q] ) )
  1321. {
  1322. count++;
  1323. }
  1324. }
  1325.  
  1326. // Check the pack a punch machines to see if they are holding what we're looking for
  1327. for ( k=0; k<pap_triggers.size; k++ )
  1328. {
  1329. if ( IsDefined(pap_triggers[k].current_weapon) && pap_triggers[k].current_weapon == keys2[q] )
  1330. {
  1331. count++;
  1332. }
  1333. }
  1334.  
  1335. if( count >= level.limited_weapons[keys2[q]] )
  1336. {
  1337. filtered = array_remove( filtered, keys2[q] );
  1338. }
  1339. }
  1340. }
  1341.  
  1342. return filtered[RandomInt( filtered.size )];
  1343. }
  1344.  
  1345. treasure_chest_weapon_spawn( chest, player )
  1346. {
  1347. assert(IsDefined(player));
  1348. // spawn the model
  1349. model = spawn( "script_model", self.origin );
  1350. model.angles = self.angles +( 0, 90, 0 );
  1351.  
  1352. floatHeight = 40;
  1353.  
  1354. //move it up
  1355. model moveto( model.origin +( 0, 0, floatHeight ), 3, 2, 0.9 );
  1356.  
  1357. // rotation would go here
  1358.  
  1359. // make with the mario kart
  1360. modelname = undefined;
  1361. rand = undefined;
  1362. number_cycles = 40;
  1363. for( i = 0; i < number_cycles; i++ )
  1364. {
  1365.  
  1366. if( i < 20 )
  1367. {
  1368. wait( 0.05 );
  1369. }
  1370. else if( i < 30 )
  1371. {
  1372. wait( 0.1 );
  1373. }
  1374. else if( i < 35 )
  1375. {
  1376. wait( 0.2 );
  1377. }
  1378. else if( i < 38 )
  1379. {
  1380. wait( 0.3 );
  1381. }
  1382.  
  1383. if( i+1 < number_cycles )
  1384. {
  1385. rand = treasure_chest_ChooseRandomWeapon( player );
  1386. }
  1387. else
  1388. {
  1389. rand = treasure_chest_ChooseWeightedRandomWeapon( player );
  1390. }
  1391.  
  1392. /#
  1393. if( maps\_zombiemode_tesla::tesla_gun_exists() )
  1394. {
  1395. if ( i == 39 && GetDvar( "scr_spawn_tesla" ) != "" )
  1396. {
  1397. SetDvar( "scr_spawn_tesla", "" );
  1398. rand = "tesla_gun";
  1399. }
  1400. }
  1401. #/
  1402.  
  1403. modelname = GetWeaponModel( rand );
  1404. model setmodel( modelname );
  1405.  
  1406.  
  1407. }
  1408.  
  1409. self.weapon_string = rand; // here's where the org get it's weapon type for the give function
  1410.  
  1411. // random change of getting the joker that moves the box
  1412. random = Randomint(100);
  1413.  
  1414. if( !isdefined( level.chest_min_move_usage ) )
  1415. {
  1416. level.chest_min_move_usage = 4;
  1417. }
  1418.  
  1419. //increase the chance of joker appearing from 0-100 based on amount of the time chest has been opened.
  1420. if(level.script != "nazi_zombie_prototype" && getdvar("magic_chest_movable") == "1")
  1421. {
  1422.  
  1423. if(level.chest_accessed < level.chest_min_move_usage)
  1424. {
  1425. // PI_CHANGE_BEGIN - JMA - RandomInt(100) can return a number between 0-99. If it's zero and chance_of_joker is zero
  1426. // we can possibly have a teddy bear one after another.
  1427. chance_of_joker = -1;
  1428. // PI_CHANGE_END
  1429. }
  1430. else
  1431. {
  1432. chance_of_joker = level.chest_accessed + 20;
  1433.  
  1434. // make sure teddy bear appears on the 8th pull if it hasn't moved from the initial spot
  1435. if( (!isDefined(level.magic_box_first_move) || level.magic_box_first_move == false ) && level.chest_accessed >= 8)
  1436. {
  1437. chance_of_joker = 100;
  1438. }
  1439.  
  1440. // pulls 4 thru 8, there is a 15% chance of getting the teddy bear
  1441. // NOTE: this happens in all cases
  1442. if( level.chest_accessed >= 4 && level.chest_accessed < 8 )
  1443. {
  1444. if( random < 15 )
  1445. {
  1446. chance_of_joker = 100;
  1447. }
  1448. else
  1449. {
  1450. chance_of_joker = -1;
  1451. }
  1452. }
  1453.  
  1454. // after the first magic box move the teddy bear percentages changes
  1455. if( isDefined(level.magic_box_first_move) && level.magic_box_first_move == true )
  1456. {
  1457. // between pulls 8 thru 12, the teddy bear percent is 30%
  1458. if( level.chest_accessed >= 8 && level.chest_accessed < 13 )
  1459. {
  1460. if( random < 30 )
  1461. {
  1462. chance_of_joker = 100;
  1463. }
  1464. else
  1465. {
  1466. chance_of_joker = -1;
  1467. }
  1468. }
  1469.  
  1470. // after 12th pull, the teddy bear percent is 50%
  1471. if( level.chest_accessed >= 13 )
  1472. {
  1473. if( random < 50 )
  1474. {
  1475. chance_of_joker = 100;
  1476. }
  1477. else
  1478. {
  1479. chance_of_joker = -1;
  1480. }
  1481. }
  1482. }
  1483. }
  1484.  
  1485. if (random <= chance_of_joker)
  1486. {
  1487. model SetModel("zombie_teddybear");
  1488. // model rotateto(level.chests[level.chest_index].angles, 0.01);
  1489. //wait(1);
  1490. model.angles = self.angles;
  1491. wait 1;
  1492. flag_set("moving_chest_now");
  1493. self notify( "move_imminent" );
  1494. level.chest_accessed = 0;
  1495.  
  1496. player maps\_zombiemode_score::add_to_player_score( 950 );
  1497.  
  1498. //allow power weapon to be accessed.
  1499. level.box_moved = true;
  1500. }
  1501. }
  1502.  
  1503. self notify( "randomization_done" );
  1504.  
  1505. if (flag("moving_chest_now"))
  1506. {
  1507. wait .5; // we need a wait here before this notify
  1508. level notify("weapon_fly_away_start");
  1509. wait 2;
  1510. model MoveZ(500, 4, 3);
  1511. model waittill("movedone");
  1512. model delete();
  1513. self notify( "box_moving" );
  1514. level notify("weapon_fly_away_end");
  1515. }
  1516. else
  1517. {
  1518.  
  1519. //turn off power weapon, since player just got one
  1520. if( rand == "tesla_gun" || rand == "ray_gun" )
  1521. {
  1522. // PI_CHANGE_BEGIN - JMA - reset the counters for tesla gun and ray gun pulls
  1523. if( isDefined( level.script ) && (level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory") )
  1524. {
  1525. if( rand == "ray_gun" )
  1526. {
  1527. level.box_moved = false;
  1528. level.pulls_since_last_ray_gun = 0;
  1529. }
  1530.  
  1531. if( rand == "tesla_gun" )
  1532. {
  1533. level.pulls_since_last_tesla_gun = 0;
  1534. level.player_seen_tesla_gun = true;
  1535. }
  1536. }
  1537. else
  1538. {
  1539. level.box_moved = false;
  1540. }
  1541. // PI_CHANGE_END
  1542. }
  1543.  
  1544. model thread timer_til_despawn(floatHeight);
  1545. self waittill( "weapon_grabbed" );
  1546.  
  1547. if( !chest.timedOut )
  1548. {
  1549. model Delete();
  1550. }
  1551.  
  1552.  
  1553. }
  1554. }
  1555. timer_til_despawn(floatHeight)
  1556. {
  1557.  
  1558.  
  1559. // SRS 9/3/2008: if we timed out, move the weapon back into the box instead of deleting it
  1560. putBackTime = 12;
  1561. self MoveTo( self.origin - ( 0, 0, floatHeight ), putBackTime, ( putBackTime * 0.5 ) );
  1562. wait( putBackTime );
  1563.  
  1564. if(isdefined(self))
  1565. {
  1566. self Delete();
  1567. }
  1568. }
  1569.  
  1570. treasure_chest_glowfx()
  1571. {
  1572. fxObj = spawn( "script_model", self.origin +( 0, 0, 0 ) );
  1573. fxobj setmodel( "tag_origin" );
  1574. fxobj.angles = self.angles +( 90, 0, 0 );
  1575.  
  1576. playfxontag( level._effect["chest_light"], fxObj, "tag_origin" );
  1577.  
  1578. self waittill_any( "weapon_grabbed", "box_moving" );
  1579.  
  1580. fxobj delete();
  1581. }
  1582.  
  1583. // self is the player string comes from the randomization function
  1584. treasure_chest_give_weapon( weapon_string )
  1585. {
  1586. primaryWeapons = self GetWeaponsListPrimaries();
  1587. current_weapon = undefined;
  1588.  
  1589. if( self HasWeapon( weapon_string ) )
  1590. {
  1591. self GiveMaxAmmo( weapon_string );
  1592. self SwitchToWeapon( weapon_string );
  1593. return;
  1594. }
  1595.  
  1596. // This should never be true for the first time.
  1597. if( primaryWeapons.size >= 2 ) // he has two weapons
  1598. {
  1599. current_weapon = self getCurrentWeapon(); // get hiss current weapon
  1600.  
  1601. if ( current_weapon == "mine_bouncing_betty" )
  1602. {
  1603. current_weapon = undefined;
  1604. }
  1605.  
  1606. if( isdefined( current_weapon ) )
  1607. {
  1608. if( !( weapon_string == "fraggrenade" || weapon_string == "stielhandgranate" || weapon_string == "molotov" || weapon_string == "zombie_cymbal_monkey" ) )
  1609. {
  1610. // PI_CHANGE_BEGIN
  1611. // JMA - player dropped the tesla gun
  1612. if( isDefined(level.script) && (level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory") )
  1613. {
  1614. if( current_weapon == "tesla_gun" )
  1615. {
  1616. level.player_drops_tesla_gun = true;
  1617. }
  1618. }
  1619. // PI_CHANGE_END
  1620.  
  1621. self TakeWeapon( current_weapon );
  1622. }
  1623. }
  1624. }
  1625.  
  1626. if( IsDefined( primaryWeapons ) && !isDefined( current_weapon ) )
  1627. {
  1628. for( i = 0; i < primaryWeapons.size; i++ )
  1629. {
  1630. if( primaryWeapons[i] == "zombie_colt" )
  1631. {
  1632. continue;
  1633. }
  1634.  
  1635. if( weapon_string != "fraggrenade" && weapon_string != "stielhandgranate" && weapon_string != "molotov" && weapon_string != "zombie_cymbal_monkey" )
  1636. {
  1637. // PI_CHANGE_BEGIN
  1638. // JMA - player dropped the tesla gun
  1639. if( isDefined(level.script) && (level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory") )
  1640. {
  1641. if( primaryWeapons[i] == "tesla_gun" )
  1642. {
  1643. level.player_drops_tesla_gun = true;
  1644. }
  1645. }
  1646. // PI_CHANGE_END
  1647.  
  1648. self TakeWeapon( primaryWeapons[i] );
  1649. }
  1650. }
  1651. }
  1652.  
  1653. self play_sound_on_ent( "purchase" );
  1654.  
  1655. if( weapon_string == "molotov" || weapon_string == "molotov_zombie" )
  1656. {
  1657. // PI_CHANGE_BEGIN
  1658. // JMA 051409 sanity check to see if we have the weapon before we remove it
  1659. has_weapon = self HasWeapon( "zombie_cymbal_monkey" );
  1660. if( isDefined(has_weapon) && has_weapon )
  1661. {
  1662. self TakeWeapon( "zombie_cymbal_monkey" );
  1663. }
  1664. // PI_CHANGE_END
  1665. }
  1666. if( weapon_string == "zombie_cymbal_monkey" )
  1667. {
  1668. // PI_CHANGE_BEGIN
  1669. // JMA 051409 sanity check to see if we have the weapon before we remove it
  1670. has_weapon = self HasWeapon( "molotov" );
  1671. if( isDefined(has_weapon) && has_weapon )
  1672. {
  1673. self TakeWeapon( "molotov" );
  1674. }
  1675.  
  1676. if( isDefined(level.zombie_weapons) && isDefined(level.zombie_weapons["molotov_zombie"]) )
  1677. {
  1678. has_weapon = self HasWeapon( "molotov_zombie" );
  1679. if( isDefined(has_weapon) && has_weapon )
  1680. {
  1681. self TakeWeapon( "molotov_zombie" );
  1682. }
  1683. }
  1684. // PI_CHANGE_END
  1685.  
  1686. self maps\_zombiemode_cymbal_monkey::player_give_cymbal_monkey();
  1687. play_weapon_vo(weapon_string);
  1688. return;
  1689. }
  1690.  
  1691. self GiveWeapon( weapon_string, 0 );
  1692. self GiveMaxAmmo( weapon_string );
  1693. self SwitchToWeapon( weapon_string );
  1694.  
  1695. play_weapon_vo(weapon_string);
  1696.  
  1697. // self playsound (level.zombie_weapons[weapon_string].sound);
  1698. }
  1699.  
  1700. weapon_cabinet_think()
  1701. {
  1702. weapons = getentarray( "cabinet_weapon", "targetname" );
  1703.  
  1704. doors = getentarray( self.target, "targetname" );
  1705. for( i = 0; i < doors.size; i++ )
  1706. {
  1707. doors[i] NotSolid();
  1708. }
  1709.  
  1710. self.has_been_used_once = false;
  1711.  
  1712. self decide_hide_show_hint();
  1713.  
  1714. while( 1 )
  1715. {
  1716. self waittill( "trigger", player );
  1717.  
  1718. if( !player can_buy_weapon() )
  1719. {
  1720. wait( 0.1 );
  1721. continue;
  1722. }
  1723.  
  1724. cost = 1500;
  1725. if( self.has_been_used_once )
  1726. {
  1727. cost = get_weapon_cost( self.zombie_weapon_upgrade );
  1728. }
  1729. else
  1730. {
  1731. if( IsDefined( self.zombie_cost ) )
  1732. {
  1733. cost = self.zombie_cost;
  1734. }
  1735. }
  1736.  
  1737. ammo_cost = get_ammo_cost( self.zombie_weapon_upgrade );
  1738.  
  1739. if( !is_player_valid( player ) )
  1740. {
  1741. player thread ignore_triggers( 0.5 );
  1742. continue;
  1743. }
  1744.  
  1745. if( self.has_been_used_once )
  1746. {
  1747. player_has_weapon = player has_weapon_or_upgrade( self.zombie_weapon_upgrade );
  1748. /*
  1749. player_has_weapon = false;
  1750. weapons = player GetWeaponsList();
  1751. if( IsDefined( weapons ) )
  1752. {
  1753. for( i = 0; i < weapons.size; i++ )
  1754. {
  1755. if( weapons[i] == self.zombie_weapon_upgrade )
  1756. {
  1757. player_has_weapon = true;
  1758. }
  1759. }
  1760. }
  1761. */
  1762.  
  1763. if( !player_has_weapon )
  1764. {
  1765. if( player.score >= cost )
  1766. {
  1767. self play_sound_on_ent( "purchase" );
  1768. player maps\_zombiemode_score::minus_to_player_score( cost );
  1769. player weapon_give( self.zombie_weapon_upgrade );
  1770. }
  1771. else // not enough money
  1772. {
  1773. play_sound_on_ent( "no_purchase" );
  1774. player thread maps\_zombiemode_perks::play_no_money_perk_dialog();
  1775. }
  1776. }
  1777. else if ( player.score >= ammo_cost )
  1778. {
  1779. ammo_given = player ammo_give( self.zombie_weapon_upgrade );
  1780. if( ammo_given )
  1781. {
  1782. self play_sound_on_ent( "purchase" );
  1783. player maps\_zombiemode_score::minus_to_player_score( ammo_cost ); // this give him ammo to early
  1784. }
  1785. }
  1786. else // not enough money
  1787. {
  1788. play_sound_on_ent( "no_purchase" );
  1789. player thread maps\_zombiemode_perks::play_no_money_perk_dialog();
  1790. }
  1791. }
  1792. else if( player.score >= cost ) // First time the player opens the cabinet
  1793. {
  1794. self.has_been_used_once = true;
  1795.  
  1796. self play_sound_on_ent( "purchase" );
  1797.  
  1798. self SetHintString( &"ZOMBIE_WEAPONCOSTAMMO", cost, ammo_cost );
  1799. // self SetHintString( get_weapon_hint( self.zombie_weapon_upgrade ) );
  1800. self setCursorHint( "HINT_NOICON" );
  1801. player maps\_zombiemode_score::minus_to_player_score( self.zombie_cost );
  1802.  
  1803. doors = getentarray( self.target, "targetname" );
  1804.  
  1805. for( i = 0; i < doors.size; i++ )
  1806. {
  1807. if( doors[i].model == "dest_test_cabinet_ldoor_dmg0" )
  1808. {
  1809. doors[i] thread weapon_cabinet_door_open( "left" );
  1810. }
  1811. else if( doors[i].model == "dest_test_cabinet_rdoor_dmg0" )
  1812. {
  1813. doors[i] thread weapon_cabinet_door_open( "right" );
  1814. }
  1815. }
  1816.  
  1817. player_has_weapon = player has_weapon_or_upgrade( self.zombie_weapon_upgrade );
  1818. /*
  1819. player_has_weapon = false;
  1820. weapons = player GetWeaponsList();
  1821. if( IsDefined( weapons ) )
  1822. {
  1823. for( i = 0; i < weapons.size; i++ )
  1824. {
  1825. if( weapons[i] == self.zombie_weapon_upgrade )
  1826. {
  1827. player_has_weapon = true;
  1828. }
  1829. }
  1830. }
  1831. */
  1832.  
  1833. if( !player_has_weapon )
  1834. {
  1835. player weapon_give( self.zombie_weapon_upgrade );
  1836. }
  1837. else
  1838. {
  1839. if( player has_upgrade( self.zombie_weapon_upgrade ) )
  1840. {
  1841. player ammo_give( self.zombie_weapon_upgrade+"_upgraded" );
  1842. }
  1843. else
  1844. {
  1845. player ammo_give( self.zombie_weapon_upgrade );
  1846. }
  1847. }
  1848. }
  1849. else // not enough money
  1850. {
  1851. play_sound_on_ent( "no_purchase" );
  1852. player thread maps\_zombiemode_perks::play_no_money_perk_dialog();
  1853. }
  1854. }
  1855. }
  1856.  
  1857. pay_turret_think( cost )
  1858. {
  1859. if( !isDefined( self.target ) )
  1860. {
  1861. return;
  1862. }
  1863. turret = GetEnt( self.target, "targetname" );
  1864.  
  1865. if( !isDefined( turret ) )
  1866. {
  1867. return;
  1868. }
  1869.  
  1870. turret makeTurretUnusable();
  1871.  
  1872. while( true )
  1873. {
  1874. self waittill( "trigger", player );
  1875.  
  1876. if( !is_player_valid( player ) )
  1877. {
  1878. player thread ignore_triggers( 0.5 );
  1879. continue;
  1880. }
  1881.  
  1882. if( player in_revive_trigger() )
  1883. {
  1884. wait( 0.1 );
  1885. continue;
  1886. }
  1887.  
  1888. if(isdefined(player.is_drinking))
  1889. {
  1890. wait(0.1);
  1891. continue;
  1892. }
  1893.  
  1894. if( player.score >= cost )
  1895. {
  1896. player maps\_zombiemode_score::minus_to_player_score( cost );
  1897. turret makeTurretUsable();
  1898. turret UseBy( player );
  1899. self disable_trigger();
  1900.  
  1901. player.curr_pay_turret = turret;
  1902.  
  1903. turret thread watch_for_laststand( player );
  1904. turret thread watch_for_fake_death( player );
  1905. if( isDefined( level.turret_timer ) )
  1906. {
  1907. turret thread watch_for_timeout( player, level.turret_timer );
  1908. }
  1909.  
  1910. while( isDefined( turret getTurretOwner() ) && turret getTurretOwner() == player )
  1911. {
  1912. wait( 0.05 );
  1913. }
  1914.  
  1915. turret notify( "stop watching" );
  1916.  
  1917. player.curr_pay_turret = undefined;
  1918.  
  1919. turret makeTurretUnusable();
  1920. self enable_trigger();
  1921. }
  1922. else // not enough money
  1923. {
  1924. play_sound_on_ent( "no_purchase" );
  1925. player thread maps\_zombiemode_perks::play_no_money_perk_dialog();
  1926. }
  1927. }
  1928. }
  1929.  
  1930. watch_for_laststand( player )
  1931. {
  1932. self endon( "stop watching" );
  1933.  
  1934. while( !player maps\_laststand::player_is_in_laststand() )
  1935. {
  1936. if( isDefined( level.intermission ) && level.intermission )
  1937. {
  1938. intermission = true;
  1939. }
  1940. wait( 0.05 );
  1941. }
  1942.  
  1943. if( isDefined( self getTurretOwner() ) && self getTurretOwner() == player )
  1944. {
  1945. self UseBy( player );
  1946. }
  1947. }
  1948.  
  1949. watch_for_fake_death( player )
  1950. {
  1951. self endon( "stop watching" );
  1952.  
  1953. player waittill( "fake_death" );
  1954.  
  1955. if( isDefined( self getTurretOwner() ) && self getTurretOwner() == player )
  1956. {
  1957. self UseBy( player );
  1958. }
  1959. }
  1960.  
  1961. watch_for_timeout( player, time )
  1962. {
  1963. self endon( "stop watching" );
  1964.  
  1965. self thread cancel_timer_on_end( player );
  1966.  
  1967. player thread maps\_zombiemode_timer::start_timer( time, "stop watching" );
  1968.  
  1969. wait( time );
  1970.  
  1971. if( isDefined( self getTurretOwner() ) && self getTurretOwner() == player )
  1972. {
  1973. self UseBy( player );
  1974. }
  1975. }
  1976.  
  1977. cancel_timer_on_end( player )
  1978. {
  1979. self waittill( "stop watching" );
  1980. player notify( "stop watching" );
  1981. }
  1982.  
  1983. weapon_cabinet_door_open( left_or_right )
  1984. {
  1985. if( left_or_right == "left" )
  1986. {
  1987. self rotateyaw( 120, 0.3, 0.2, 0.1 );
  1988. }
  1989. else if( left_or_right == "right" )
  1990. {
  1991. self rotateyaw( -120, 0.3, 0.2, 0.1 );
  1992. }
  1993. }
  1994.  
  1995. weapon_spawn_think()
  1996. {
  1997. cost = get_weapon_cost( self.zombie_weapon_upgrade );
  1998. ammo_cost = get_ammo_cost( self.zombie_weapon_upgrade );
  1999. is_grenade = (WeaponType( self.zombie_weapon_upgrade ) == "grenade");
  2000. if(is_grenade)
  2001. {
  2002. ammo_cost = cost;
  2003. }
  2004.  
  2005. self thread decide_hide_show_hint();
  2006.  
  2007. self.first_time_triggered = false;
  2008. for( ;; )
  2009. {
  2010. self waittill( "trigger", player );
  2011. // if not first time and they have the weapon give ammo
  2012.  
  2013. if( !is_player_valid( player ) )
  2014. {
  2015. player thread ignore_triggers( 0.5 );
  2016. continue;
  2017. }
  2018.  
  2019. if( !player can_buy_weapon() )
  2020. {
  2021. wait( 0.1 );
  2022. continue;
  2023. }
  2024.  
  2025. // Allow people to get ammo off the wall for upgraded weapons
  2026. player_has_weapon = player has_weapon_or_upgrade( self.zombie_weapon_upgrade );
  2027. /*
  2028. player_has_weapon = false;
  2029. weapons = player GetWeaponsList();
  2030. if( IsDefined( weapons ) )
  2031. {
  2032. for( i = 0; i < weapons.size; i++ )
  2033. {
  2034. if( weapons[i] == self.zombie_weapon_upgrade )
  2035. {
  2036. player_has_weapon = true;
  2037. }
  2038. }
  2039. }
  2040. */
  2041.  
  2042. if( !player_has_weapon )
  2043. {
  2044. // else make the weapon show and give it
  2045. if( player.score >= cost )
  2046. {
  2047. if( self.first_time_triggered == false )
  2048. {
  2049. model = getent( self.target, "targetname" );
  2050. // model show();
  2051. model thread weapon_show( player );
  2052. self.first_time_triggered = true;
  2053.  
  2054. if(!is_grenade)
  2055. {
  2056. self SetHintString( &"ZOMBIE_WEAPONCOSTAMMO", cost, ammo_cost );
  2057. }
  2058. }
  2059.  
  2060. player maps\_zombiemode_score::minus_to_player_score( cost );
  2061.  
  2062. bbPrint( "zombie_uses: playername %s playerscore %d round %d cost %d name %s x %f y %f z %f type weapon",
  2063. player.playername, player.score, level.round_number, cost, self.zombie_weapon_upgrade, self.origin );
  2064.  
  2065. player weapon_give( self.zombie_weapon_upgrade );
  2066. }
  2067. else
  2068. {
  2069. play_sound_on_ent( "no_purchase" );
  2070. player thread maps\nazi_zombie_sumpf_blockers::play_no_money_purchase_dialog();
  2071.  
  2072. }
  2073. }
  2074. else
  2075. {
  2076. // MM - need to check and see if the player has an upgraded weapon. If so, the ammo cost is much higher
  2077. if ( player has_upgrade( self.zombie_weapon_upgrade ) )
  2078. {
  2079. ammo_cost = 4500;
  2080. }
  2081. else
  2082. {
  2083. ammo_cost = get_ammo_cost( self.zombie_weapon_upgrade );
  2084. }
  2085.  
  2086. // if the player does have this then give him ammo.
  2087. if( player.score >= ammo_cost )
  2088. {
  2089. if( self.first_time_triggered == false )
  2090. {
  2091. model = getent( self.target, "targetname" );
  2092. // model show();
  2093. model thread weapon_show( player );
  2094. self.first_time_triggered = true;
  2095. if(!is_grenade)
  2096. {
  2097. self SetHintString( &"ZOMBIE_WEAPONCOSTAMMO", cost, get_ammo_cost( self.zombie_weapon_upgrade ) );
  2098. }
  2099. }
  2100.  
  2101. if( player HasWeapon( self.zombie_weapon_upgrade ) && player has_upgrade( self.zombie_weapon_upgrade ) )
  2102. {
  2103. ammo_given = player ammo_give( self.zombie_weapon_upgrade, true );
  2104. }
  2105. else if( player has_upgrade( self.zombie_weapon_upgrade ) )
  2106. {
  2107. ammo_given = player ammo_give( self.zombie_weapon_upgrade+"_upgraded" );
  2108. }
  2109. else
  2110. {
  2111. ammo_given = player ammo_give( self.zombie_weapon_upgrade );
  2112. }
  2113.  
  2114. if( ammo_given )
  2115. {
  2116. player maps\_zombiemode_score::minus_to_player_score( ammo_cost ); // this give him ammo to early
  2117.  
  2118. bbPrint( "zombie_uses: playername %s playerscore %d round %d cost %d name %s x %f y %f z %f type ammo",
  2119. player.playername, player.score, level.round_number, ammo_cost, self.zombie_weapon_upgrade, self.origin );
  2120. }
  2121. }
  2122. else
  2123. {
  2124. play_sound_on_ent( "no_purchase" );
  2125. }
  2126. }
  2127. }
  2128. }
  2129.  
  2130. weapon_show( player )
  2131. {
  2132. player_angles = VectorToAngles( player.origin - self.origin );
  2133.  
  2134. player_yaw = player_angles[1];
  2135. weapon_yaw = self.angles[1];
  2136.  
  2137. yaw_diff = AngleClamp180( player_yaw - weapon_yaw );
  2138.  
  2139. if( yaw_diff > 0 )
  2140. {
  2141. yaw = weapon_yaw - 90;
  2142. }
  2143. else
  2144. {
  2145. yaw = weapon_yaw + 90;
  2146. }
  2147.  
  2148. self.og_origin = self.origin;
  2149. self.origin = self.origin +( AnglesToForward( ( 0, yaw, 0 ) ) * 8 );
  2150.  
  2151. wait( 0.05 );
  2152. self Show();
  2153.  
  2154. play_sound_at_pos( "weapon_show", self.origin, self );
  2155.  
  2156. time = 1;
  2157. self MoveTo( self.og_origin, time );
  2158. }
  2159.  
  2160. weapon_give( weapon, is_upgrade )
  2161. {
  2162. primaryWeapons = self GetWeaponsListPrimaries();
  2163. current_weapon = undefined;
  2164.  
  2165. //if is not an upgraded perk purchase
  2166. if( !IsDefined( is_upgrade ) )
  2167. {
  2168. is_upgrade = false;
  2169. }
  2170.  
  2171. // This should never be true for the first time.
  2172. if( primaryWeapons.size >= 2 ) // he has two weapons
  2173. {
  2174. current_weapon = self getCurrentWeapon(); // get his current weapon
  2175.  
  2176. if ( current_weapon == "mine_bouncing_betty" )
  2177. {
  2178. current_weapon = undefined;
  2179. }
  2180.  
  2181. if( isdefined( current_weapon ) )
  2182. {
  2183. if( !( weapon == "fraggrenade" || weapon == "stielhandgranate" || weapon == "molotov" || weapon == "zombie_cymbal_monkey" ) )
  2184. {
  2185. self TakeWeapon( current_weapon );
  2186. }
  2187. }
  2188. }
  2189.  
  2190. if( weapon == "zombie_cymbal_monkey" )
  2191. {
  2192. // PI_CHANGE_BEGIN
  2193. // JMA 051409 sanity check to see if we have the weapon before we remove it
  2194. has_weapon = self HasWeapon( "molotov" );
  2195. if( isDefined(has_weapon) && has_weapon )
  2196. {
  2197. self TakeWeapon( "molotov" );
  2198. }
  2199.  
  2200. if( isDefined(level.zombie_weapons) && isDefined(level.zombie_weapons["molotov_zombie"]) )
  2201. {
  2202. has_weapon = self HasWeapon( "molotov_zombie" );
  2203. if( isDefined(has_weapon) && has_weapon )
  2204. {
  2205. self TakeWeapon( "molotov_zombie" );
  2206. }
  2207. }
  2208. // PI_CHANGE_END
  2209.  
  2210. self maps\_zombiemode_cymbal_monkey::player_give_cymbal_monkey();
  2211. play_weapon_vo( weapon );
  2212. return;
  2213. }
  2214. if( (weapon == "molotov" || weapon == "molotov_zombie") )
  2215. {
  2216. self TakeWeapon( "zombie_cymbal_monkey" );
  2217. }
  2218.  
  2219. self play_sound_on_ent( "purchase" );
  2220. self GiveWeapon( weapon, 0 );
  2221. self GiveMaxAmmo( weapon );
  2222. self SwitchToWeapon( weapon );
  2223.  
  2224. play_weapon_vo(weapon);
  2225. }
  2226. play_weapon_vo(weapon)
  2227. {
  2228. index = get_player_index(self);
  2229. if(!IsDefined (level.zombie_weapons[weapon].sound))
  2230. {
  2231. return;
  2232. }
  2233.  
  2234. if( level.zombie_weapons[weapon].sound == "vox_monkey" )
  2235. {
  2236. plr = "plr_" + index + "_";
  2237. create_and_play_dialog( plr, "vox_monkey", .25, "resp_monk" );
  2238. return;
  2239. }
  2240. // iprintlnbold (index);
  2241. if( level.zombie_weapons[weapon].sound != "" )
  2242. {
  2243. weap = level.zombie_weapons[weapon].sound;
  2244. // iprintlnbold("Play_Weap_VO_" + weap);
  2245. switch(weap)
  2246. {
  2247. case "vox_crappy":
  2248. if (level.vox_crappy_available.size < 1 )
  2249. {
  2250. level.vox_crappy_available = level.vox_crappy;
  2251. }
  2252. sound_to_play = random(level.vox_crappy_available);
  2253. level.vox_crappy_available = array_remove(level.vox_crappy_available,sound_to_play);
  2254. break;
  2255.  
  2256. case "vox_mg":
  2257. if (level.vox_mg_available.size < 1 )
  2258. {
  2259. level.vox_mg_available = level.vox_mg;
  2260. }
  2261. sound_to_play = random(level.vox_mg_available);
  2262. level.vox_mg_available = array_remove(level.vox_mg_available,sound_to_play);
  2263. break;
  2264. case "vox_shotgun":
  2265. if (level.vox_shotgun_available.size < 1 )
  2266. {
  2267. level.vox_shotgun_available = level.vox_shotgun;
  2268. }
  2269. sound_to_play = random(level.vox_shotgun_available);
  2270. level.vox_shotgun_available = array_remove(level.vox_shotgun_available,sound_to_play);
  2271. break;
  2272. case "vox_357":
  2273. if (level.vox_357_available.size < 1 )
  2274. {
  2275. level.vox_357_available = level.vox_357;
  2276. }
  2277. sound_to_play = random(level.vox_357_available);
  2278. level.vox_357_available = array_remove(level.vox_357_available,sound_to_play);
  2279. break;
  2280. case "vox_bar":
  2281. if (level.vox_bar_available.size < 1 )
  2282. {
  2283. level.vox_bar_available = level.vox_bar;
  2284. }
  2285. sound_to_play = random(level.vox_bar_available);
  2286. level.vox_bar_available = array_remove(level.vox_bar_available,sound_to_play);
  2287. break;
  2288. case "vox_flame":
  2289. if (level.vox_flame_available.size < 1 )
  2290. {
  2291. level.vox_flame_available = level.vox_flame;
  2292. }
  2293. sound_to_play = random(level.vox_flame_available);
  2294. level.vox_flame_available = array_remove(level.vox_flame_available,sound_to_play);
  2295. break;
  2296. case "vox_raygun":
  2297. if (level.vox_raygun_available.size < 1 )
  2298. {
  2299. level.vox_raygun_available = level.vox_raygun;
  2300. }
  2301. sound_to_play = random(level.vox_raygun_available);
  2302. level.vox_raygun_available = array_remove(level.vox_raygun_available,sound_to_play);
  2303. break;
  2304. case "vox_tesla":
  2305. if (level.vox_tesla_available.size < 1 )
  2306. {
  2307. level.vox_tesla_available = level.vox_tesla;
  2308. }
  2309. sound_to_play = random(level.vox_tesla_available);
  2310. level.vox_tesla_available = array_remove(level.vox_tesla_available,sound_to_play);
  2311. break;
  2312. case "vox_sticky":
  2313. if (level.vox_sticky_available.size < 1 )
  2314. {
  2315. level.vox_sticky_available = level.vox_sticky;
  2316. }
  2317. sound_to_play = random(level.vox_sticky_available);
  2318. level.vox_sticky_available = array_remove(level.vox_sticky_available,sound_to_play);
  2319. break;
  2320. case "vox_ppsh":
  2321. if (level.vox_ppsh_available.size < 1 )
  2322. {
  2323. level.vox_ppsh_available = level.vox_ppsh;
  2324. }
  2325. sound_to_play = random(level.vox_ppsh_available);
  2326. level.vox_ppsh_available = array_remove(level.vox_ppsh_available,sound_to_play);
  2327. break;
  2328. case "vox_mp40":
  2329. if (level.vox_mp40_available.size < 1 )
  2330. {
  2331. level.vox_mp40_available = level.vox_mp40;
  2332. }
  2333. sound_to_play = random(level.vox_mp40_available);
  2334. level.vox_mp40_available = array_remove(level.vox_mp40_available,sound_to_play);
  2335. break;
  2336.  
  2337. default:
  2338. sound_var = randomintrange(0, level.zombie_weapons[weapon].variation_count);
  2339. sound_to_play = level.zombie_weapons[weapon].sound + "_" + sound_var;
  2340.  
  2341. }
  2342.  
  2343. plr = "plr_" + index + "_";
  2344. //self playsound ("plr_" + index + "_" + sound_to_play);
  2345. //iprintlnbold (sound_to_play);
  2346.  
  2347. //thread setup_response_line( self, index, "monk" );
  2348. self maps\_zombiemode_spawner::do_player_playdialog(plr, sound_to_play, 0.05);
  2349. }
  2350. }
  2351. do_player_weap_dialog(player_index, sound_to_play, waittime)
  2352. {
  2353. if(!IsDefined (level.player_is_speaking))
  2354. {
  2355. level.player_is_speaking = 0;
  2356. }
  2357. if(level.player_is_speaking != 1)
  2358. {
  2359. level.player_is_speaking = 1;
  2360. self playsound(player_index + sound_to_play, "sound_done" + sound_to_play);
  2361. self waittill("sound_done" + sound_to_play);
  2362. wait(waittime);
  2363. level.player_is_speaking = 0;
  2364. }
  2365.  
  2366. }
  2367. get_player_index(player)
  2368. {
  2369. assert( IsPlayer( player ) );
  2370. assert( IsDefined( player.entity_num ) );
  2371. /#
  2372. // used for testing to switch player's VO in-game from devgui
  2373. if( player.entity_num == 0 && GetDVar( "zombie_player_vo_overwrite" ) != "" )
  2374. {
  2375. new_vo_index = GetDVarInt( "zombie_player_vo_overwrite" );
  2376. return new_vo_index;
  2377. }
  2378. #/
  2379. return player.entity_num;
  2380. }
  2381.  
  2382.  
  2383. ammo_give( weapon, also_has_upgrade )
  2384. {
  2385. // We assume before calling this function we already checked to see if the player has this weapon...
  2386.  
  2387. if( !isDefined( also_has_upgrade ) )
  2388. {
  2389. also_has_upgrade = false;
  2390. }
  2391.  
  2392. // Should we give ammo to the player
  2393. give_ammo = false;
  2394.  
  2395. // Check to see if ammo belongs to a primary weapon
  2396. if( weapon != "fraggrenade" && weapon != "stielhandgranate" && weapon != "molotov" )
  2397. {
  2398. if( isdefined( weapon ) )
  2399. {
  2400. // get the max allowed ammo on the current weapon
  2401. stockMax = WeaponMaxAmmo( weapon );
  2402. if( also_has_upgrade )
  2403. {
  2404. stockMax += WeaponMaxAmmo( weapon+"_upgraded" );
  2405. }
  2406.  
  2407. // Get the current weapon clip count
  2408. clipCount = self GetWeaponAmmoClip( weapon );
  2409.  
  2410. currStock = self GetAmmoCount( weapon );
  2411.  
  2412. // compare it with the ammo player actually has, if more or equal just dont give the ammo, else do
  2413. if( ( currStock - clipcount ) >= stockMax )
  2414. {
  2415. give_ammo = false;
  2416. }
  2417. else
  2418. {
  2419. give_ammo = true; // give the ammo to the player
  2420. }
  2421. }
  2422. }
  2423. else
  2424. {
  2425. // Ammo belongs to secondary weapon
  2426. if( self has_weapon_or_upgrade( weapon ) )
  2427. {
  2428. // Check if the player has less than max stock, if no give ammo
  2429. if( self getammocount( weapon ) < WeaponMaxAmmo( weapon ) )
  2430. {
  2431. // give the ammo to the player
  2432. give_ammo = true;
  2433. }
  2434. }
  2435. }
  2436.  
  2437. weapon_test = self getcurrentweapon();
  2438. if ( give_ammo && WeaponInventoryType( weapon_test ) == "altmode" )
  2439. {
  2440. alt_ammo = check_if_is_defined( weapon_test );
  2441. if ( alt_ammo && self.alt_message_count < level.alt_message_count_max )
  2442. {
  2443. self.alt_message_count ++;
  2444. self iprintlnbold( level.hint_alt_buy_wall );
  2445. }
  2446. }
  2447.  
  2448. special_ammo = check_if_is_defined( weapon );
  2449.  
  2450.  
  2451. if( give_ammo && !special_ammo )
  2452. {
  2453. self playsound( "cha_ching" );
  2454. self GivemaxAmmo( weapon );
  2455. if( also_has_upgrade )
  2456. {
  2457. self GiveMaxAmmo( weapon+"_upgraded" );
  2458. }
  2459. return true;
  2460. }
  2461.  
  2462. if( give_ammo && special_ammo || give_ammo && special_ammo || !give_ammo && WeaponInventoryType( weapon_test ) == "altmode" )
  2463. {
  2464. if ( self.alt_message_count < level.alt_message_count_max)
  2465. {
  2466. self.alt_message_count ++;
  2467. self iprintlnbold( level.hint_primary_buy_wall );
  2468. }
  2469. return false;
  2470. }
  2471.  
  2472. if( !give_ammo )
  2473. {
  2474. return false;
  2475. }
  2476. }
  2477.  
  2478. check_if_is_defined( weapon )
  2479. {
  2480. if(isdefined(level.shock_ammo[weapon]))
  2481. {
  2482. return true;
  2483. }
  2484.  
  2485. else if(isdefined(level.flame_ammo[weapon]))
  2486. {
  2487. return true;
  2488. }
  2489.  
  2490. else if(isdefined(level.expl_ammo[weapon]))
  2491. {
  2492. return true;
  2493. }
  2494.  
  2495. else
  2496. {
  2497. return false;
  2498. }
  2499. }
  2500.  
  2501. /*
  2502.  
  2503. check_if_is_defined( weapon )
  2504. {
  2505. if(isdefined(level.shock_ammo[weapon]))
  2506. {
  2507. return true;
  2508. }
  2509.  
  2510. else if(isdefined(level.flame_ammo[weapon]))
  2511. {
  2512. return true;
  2513. }
  2514.  
  2515. else if(isdefined(level.expl_ammo[weapon]))
  2516. {
  2517. return true;
  2518. }
  2519.  
  2520. else
  2521. {
  2522. return false;
  2523. }
  2524. }
  2525.  
  2526. */
  2527.  
  2528. add_weapon_to_sound_array(vo,num)
  2529. {
  2530. if(!isDefined(vo))
  2531. {
  2532. return;
  2533. }
  2534. player = getplayers();
  2535. for(i=0;i<player.size;i++)
  2536. {
  2537. index = maps\_zombiemode_weapons::get_player_index(player);
  2538. player_index = "plr_" + index + "_";
  2539. num = maps\_zombiemode_spawner::get_number_variants(player_index + vo);
  2540. }
  2541. // iprintlnbold(vo);
  2542.  
  2543. switch(vo)
  2544. {
  2545. case "vox_crappy":
  2546. if(!isDefined(level.vox_crappy))
  2547. {
  2548. level.vox_crappy = [];
  2549. for(i=0;i<num;i++)
  2550. {
  2551. level.vox_crappy[level.vox_crappy.size] = "vox_crappy_" + i;
  2552. }
  2553. }
  2554. level.vox_crappy_available = level.vox_crappy;
  2555. break;
  2556.  
  2557. case "vox_mg":
  2558. if(!isDefined(level.vox_mg))
  2559. {
  2560. level.vox_mg = [];
  2561. for(i=0;i<num;i++)
  2562. {
  2563. level.vox_mg[level.vox_mg.size] = "vox_mg_" + i;
  2564. }
  2565. }
  2566. level.vox_mg_available = level.vox_mg;
  2567. break;
  2568. case "vox_shotgun":
  2569. if(!isDefined(level.vox_shotgun))
  2570. {
  2571. level.vox_shotgun = [];
  2572. for(i=0;i<num;i++)
  2573. {
  2574. level.vox_shotgun[level.vox_shotgun.size] = "vox_shotgun_" + i;
  2575. }
  2576. }
  2577. level.vox_shotgun_available = level.vox_shotgun;
  2578. break;
  2579. case "vox_357":
  2580. if(!isDefined(level.vox_357))
  2581. {
  2582. level.vox_357 = [];
  2583. for(i=0;i<num;i++)
  2584. {
  2585. level.vox_357[level.vox_357.size] = "vox_357_" + i;
  2586. }
  2587. }
  2588. level.vox_357_available = level.vox_357;
  2589. break;
  2590. case "vox_bar":
  2591. if(!isDefined(level.vox_bar))
  2592. {
  2593. level.vox_bar = [];
  2594. for(i=0;i<num;i++)
  2595. {
  2596. level.vox_bar[level.vox_bar.size] = "vox_bar_" + i;
  2597. }
  2598. }
  2599. level.vox_bar_available = level.vox_bar;
  2600. break;
  2601. case "vox_flame":
  2602. if(!isDefined(level.vox_flame))
  2603. {
  2604. level.vox_flame = [];
  2605. for(i=0;i<num;i++)
  2606. {
  2607. level.vox_flame[level.vox_flame.size] = "vox_flame_" + i;
  2608. }
  2609. }
  2610. level.vox_flame_available = level.vox_flame;
  2611. break;
  2612.  
  2613. case "vox_raygun":
  2614. if(!isDefined(level.vox_raygun))
  2615. {
  2616. level.vox_raygun = [];
  2617. for(i=0;i<num;i++)
  2618. {
  2619. level.vox_raygun[level.vox_raygun.size] = "vox_raygun_" + i;
  2620. }
  2621. }
  2622. level.vox_raygun_available = level.vox_raygun;
  2623. break;
  2624. case "vox_tesla":
  2625. if(!isDefined(level.vox_tesla))
  2626. {
  2627. level.vox_tesla = [];
  2628. for(i=0;i<num;i++)
  2629. {
  2630. level.vox_tesla[level.vox_tesla.size] = "vox_tesla_" + i;
  2631. }
  2632. }
  2633. level.vox_tesla_available = level.vox_tesla;
  2634. break;
  2635. case "vox_sticky":
  2636. if(!isDefined(level.vox_sticky))
  2637. {
  2638. level.vox_sticky = [];
  2639. for(i=0;i<num;i++)
  2640. {
  2641. level.vox_sticky[level.vox_sticky.size] = "vox_sticky_" + i;
  2642. }
  2643. }
  2644. level.vox_sticky_available = level.vox_sticky;
  2645. break;
  2646. case "vox_ppsh":
  2647. if(!isDefined(level.vox_ppsh))
  2648. {
  2649. level.vox_ppsh = [];
  2650. for(i=0;i<num;i++)
  2651. {
  2652. level.vox_ppsh[level.vox_ppsh.size] = "vox_ppsh_" + i;
  2653. }
  2654. }
  2655. level.vox_ppsh_available = level.vox_ppsh;
  2656. break;
  2657. case "vox_mp40":
  2658. if(!isDefined(level.vox_mp40))
  2659. {
  2660. level.vox_mp40 = [];
  2661. for(i=0;i<num;i++)
  2662. {
  2663. level.vox_mp40[level.vox_mp40.size] = "vox_mp40_" + i;
  2664. }
  2665. }
  2666. level.vox_mp40_available = level.vox_mp40;
  2667. break;
  2668. case "vox_monkey":
  2669. if(!isDefined(level.vox_monkey))
  2670. {
  2671. level.vox_monkey = [];
  2672. for(i=0;i<num;i++)
  2673. {
  2674. level.vox_monkey[level.vox_monkey.size] = "vox_monkey_" + i;
  2675. }
  2676. }
  2677. level.vox_monkey_available = level.vox_monkey;
  2678. break;
  2679. }
  2680.  
  2681. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement