Guest User

Untitled

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