Advertisement
Guest User

_zombiemode_weapons.gsc

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