Guest User

hoishaboi my weapons enkoleipieowhyrureadingthisempieono

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