Advertisement
Guest User

_zombiemode_weapons.gsc

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