Advertisement
Yomomdog8010

zombiemode_weapons

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