Guest User

Untitled

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