Advertisement
Guest User

Gobble Gum Machine Initial Script

a guest
Feb 3rd, 2016
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.04 KB | None | 0 0
  1. //Add this script into your mapname.gsc file
  2. //Add this: thread gobble_gum_machine(); after
  3.  
  4. /*--------------------
  5. FUNCTION CALLS - PRE _Load
  6. ----------------------*/
  7. //level thread DLC3_threadCalls();
  8. //thread gobble_gum_machine(); HERE
  9.  
  10.  
  11. gobble_gum_machine()
  12. {
  13. //image of gobble gum
  14. PrecacheShader( "specialty_gobble_gum_zombies");
  15. PrecacheShader( "specialty_nuke");
  16. //cost of gobble gum buy
  17. cost = 500;
  18.  
  19. //activate the following script code when player buys perk
  20. trigger = getEnt("gobble_gum_trigger", "targetname");
  21.  
  22.  
  23. bought_round_number = undefined;
  24. //level.round_number = 0;
  25. last_round = 0;
  26.  
  27. trigger setHintString ("Hold &&1 to dispense Gobble Gum [500]");
  28.  
  29. //hold code till trigger is activated
  30. trigger waittill("trigger", player);
  31.  
  32. using_player = player;
  33.  
  34. //random gumball script here
  35. //--------------------------------------
  36. gobble_gums_index = 0;
  37.  
  38. gobble_gums = [];
  39.  
  40. add_to_array("gobble_gums","insta_kill");
  41. add_to_array("gobble_gums","double_points");
  42. add_to_array("gobble_gums","nuke");
  43. add_to_array("gobble_gums","plain_sight");
  44. add_to_array("gobble_gums","pack_a_punch");
  45.  
  46. //gobble_gum = gobble_gums[RandomInt(gobble_gums.size)];
  47.  
  48. //gobble_gum = array_randomize(gobble_gums);
  49.  
  50. //if( gobble_gums_index >= gobble_gums.size )
  51. //{
  52. // gobble_gums_index = 0;
  53. // randomize_gobble_gums(gobble_gums);
  54. //}
  55.  
  56. //gobble_gums_index++;
  57.  
  58. //--------------------------------------
  59. //final gumball selected from script
  60. //this pack a punch gobble gum packs my current gun for 30 seconds and then returns the old one after the time has ran out!
  61. gumball = "pack_a_punch";
  62. //this gumball code will give me the gumball without picking a random one
  63. //--------------------------------------
  64.  
  65.  
  66. if ( player.score < cost )
  67. {
  68. //player iprintln( "Not enough points to buy Perk: " + perk );
  69. self playsound("deny");
  70. player thread play_no_money_perk_dialog();
  71. //continue;
  72. }
  73. else
  74. {
  75. //blur players view for effect
  76. player setblur( 4, 0.1 );
  77. wait(0.6);
  78. player setblur(0, 0.1);
  79.  
  80. //add the image of the shader to the hud
  81. player thread gumball_hud_create(gumball);
  82.  
  83. //subtract players points for the cost of the gobble gum machine
  84. player maps\_zombiemode_score::minus_to_player_score(cost);
  85.  
  86. player thread gobble_gum_activate(using_player, gumball);
  87.  
  88. //bought_round_number = level.round_number;
  89. }
  90.  
  91. //rerun the gobble gum machine script so it keeps running
  92. thread gobble_gum_machine();
  93.  
  94. }
  95.  
  96. gobble_gum_activate(using_player, gumball)
  97. {
  98. perk_bottle = "specialty_quickrevive";
  99. while(1)
  100. {
  101. if(using_player useButtonPressed())
  102. {
  103. if(gumball == "none")
  104. {
  105. //iprintln("You have no gobble gums!");
  106. }
  107. else
  108. {
  109. //get players gun
  110. gun = self GetCurrentWeapon();
  111.  
  112. //eat gobble gum when pressed button
  113. thread perk_give_bottle_begin(perk_bottle);
  114.  
  115. //play blowing bubble sound effect
  116. //using_player playsound("blowing_gobble_gum");
  117. //notify player the gumball is being chewed (the player has the gumball)
  118. iprintln("Chewing Gobble Gum!");
  119. wait 3;
  120. thread perk_give_bottle_end(gun, perk_bottle);
  121.  
  122. //remove gobble gum from hud because it was used
  123. using_player thread gumball_hud_destroy(gumball);
  124.  
  125. //player eat gumball and recieve effects
  126. thread player_eat(gumball, using_player, gun);
  127. using_player setElectrified(true);
  128. gumball = "none";
  129. }
  130. wait 1;
  131. }
  132. wait 0.01;
  133.  
  134. }
  135. }
  136.  
  137. player_eat(gumball, using_player, gun)
  138. {
  139. if(gumball == "insta_kill")
  140. {
  141. maps\_zombiemode_powerups::insta_kill_powerup();
  142. }
  143. if(gumball == "nuke")
  144. {
  145. maps\_zombiemode_powerups::nuke_powerup();
  146. }
  147. if(gumball == "max_ammo")
  148. {
  149. maps\_zombiemode_powerups::full_ammo_powerup();
  150. }
  151. if(gumball == "carpenter")
  152. {
  153.  
  154. }
  155. if(gumball == "double_points")
  156. {
  157. maps\_zombiemode_powerups::double_points_powerup();
  158. }
  159. if(gumball == "pack_a_punch")
  160. {
  161. //time how long the player gets to use their pack-a-punched gun (seconds)
  162. level.packapunch_timeout = 30;
  163.  
  164. packa_timer = spawn("script_origin", self.origin);
  165.  
  166. using_player TakeWeapon(gun);
  167. using_player GiveWeapon(gun+"_upgraded");
  168. //using_player GiveMaxAmmo(gun+"_upgraded");
  169. using_player switchToWeapon(gun+"_upgraded");
  170.  
  171. self thread wait_for_timeout(packa_timer);
  172. self waittill("pap_timeout");
  173.  
  174. using_player TakeWeapon(self GetCurrentWeapon());
  175. wait 0.01;
  176. using_player GiveWeapon(gun);
  177. using_player switchToWeapon(gun);
  178. }
  179. //perkacholic is still beta
  180. if(gumball == "perkacholic")
  181. {
  182. using_player perk_hud_create("specialty_armorvest");
  183. using_player perk_hud_create("specialty_quickrevive");
  184. using_player perk_hud_create("specialty_fastreload");
  185. using_player perk_hud_create("specialty_rof");
  186. using_player.health = 300;
  187. }
  188. if(gumball == "plain_sight")
  189. {
  190. zombies = getaiarray("axis");
  191. zombies flagEnemyUnattackable();
  192. }
  193. if(gumball == "anywhere_but_here")
  194. {
  195. doggie = getent("start_zone_spawners_dog", "targetname");
  196. using_player setOrigin(doggie.origin);
  197. //using_player setElectrified(true);
  198. }
  199. }
  200.  
  201. wait_for_timeout(packa_timer)
  202. {
  203. wait( level.packapunch_timeout );
  204.  
  205. self notify( "pap_timeout" );
  206. //packa_timer stoploopsound(.05);
  207. //packa_timer playsound( "packa_deny" );
  208. }
  209.  
  210. gumball_hud_create(gumball)
  211. {
  212. if ( !IsDefined( self.gumball_hud ) )
  213. {
  214. self.gumball_hud = [];
  215. }
  216.  
  217. /#
  218. if ( GetDVarInt( "zombie_cheat" ) >= 5 )
  219. {
  220. if ( IsDefined( self.gumball_hud[gumball] ) )
  221. {
  222. return;
  223. }
  224. }
  225. #/
  226. shader = "";
  227. overlay = "";
  228.  
  229. switch(gumball)
  230. {
  231. case "pack_a_punch":
  232. shader = "specialty_gobble_gum_zombies";
  233. break;
  234.  
  235. case "insta_kill":
  236. shader = "specialty_gobble_gum_zombies";
  237. break;
  238.  
  239. case "nuke":
  240. shader = "specialty_nuke";
  241. break;
  242.  
  243. case "max_ammo":
  244. shader = "specialty_gobble_gum_zombies";
  245. break;
  246.  
  247. case "double_points":
  248. shader = "specialty_gobble_gum_zombies";
  249. break;
  250.  
  251. case "carpenter":
  252. shader = "specialty_gobble_gum_zombies";
  253. break;
  254.  
  255. case "perkacholic":
  256. shader = "specialty_gobble_gum_perkacholic";
  257. break;
  258.  
  259. case "plain_sight":
  260. shader = "specialty_gobble_gum_zombies";
  261. break;
  262.  
  263. default:
  264. shader = "specialty_gobble_gum_zombies";
  265. break;
  266. }
  267.  
  268. hud = create_simple_hud( self );
  269. hud.foreground = true;
  270. hud.sort = 1;
  271. hud.hidewheninmenu = false;
  272. hud.alignX = "right";
  273. hud.alignY = "bottom";
  274. hud.horzAlign = "right";
  275. hud.vertAlign = "bottom";
  276. hud.x = self.gumball_hud.size - 35;
  277. hud.y = hud.y - 100;
  278. hud.alpha = 1;
  279. hud SetShader( shader, 48, 48 );
  280.  
  281. self.gumball_hud2[ gumball ] = hud;
  282.  
  283. }
  284.  
  285. perk_hud_create( perk )
  286. {
  287. if ( !IsDefined( self.perk_hud ) )
  288. {
  289. self.perk_hud = [];
  290. }
  291.  
  292. /#
  293. if ( GetDVarInt( "zombie_cheat" ) >= 5 )
  294. {
  295. if ( IsDefined( self.perk_hud[ perk ] ) )
  296. {
  297. return;
  298. }
  299. }
  300. #/
  301.  
  302.  
  303. shader = "";
  304.  
  305. switch( perk )
  306. {
  307. case "specialty_armorvest":
  308. shader = "specialty_juggernaut_zombies";
  309. break;
  310.  
  311. case "specialty_quickrevive":
  312. shader = "specialty_quickrevive_zombies";
  313. break;
  314.  
  315. case "specialty_fastreload":
  316. shader = "specialty_fastreload_zombies";
  317. break;
  318.  
  319. case "specialty_rof":
  320. shader = "specialty_doubletap_zombies";
  321. break;
  322.  
  323. default:
  324. shader = "";
  325. break;
  326. }
  327.  
  328. hud = create_simple_hud( self );
  329. hud.foreground = true;
  330. hud.sort = 1;
  331. hud.hidewheninmenu = false;
  332. hud.alignX = "left";
  333. hud.alignY = "bottom";
  334. hud.horzAlign = "left";
  335. hud.vertAlign = "bottom";
  336. hud.x = self.perk_hud.size * 30;
  337. hud.y = hud.y - 70;
  338. hud.alpha = 1;
  339. hud SetShader( shader, 24, 24 );
  340.  
  341. self.perk_hud[ perk ] = hud;
  342.  
  343. }
  344.  
  345. gumball_hud_destroy(gumball)
  346. {
  347. self.gumball_hud[gumball] destroy_hud();
  348. self.gumball_hud[gumball] = undefined;
  349. }
  350.  
  351. perk_hud_destroy(perk)
  352. {
  353. self.perk_hud[perk] destroy_hud();
  354. self.perk_hud[perk] = undefined;
  355. }
  356.  
  357. perk_give_bottle_begin(perk_bottle)
  358. {
  359. self DisableOffhandWeapons();
  360. self DisableWeaponCycling();
  361.  
  362. self AllowLean( false );
  363. self AllowAds( false );
  364. self AllowSprint( false );
  365. self AllowProne( false );
  366. self AllowMelee( false );
  367.  
  368. wait( 0.05 );
  369.  
  370. if ( self GetStance() == "prone" )
  371. {
  372. self SetStance( "crouch" );
  373. }
  374.  
  375. gun = self GetCurrentWeapon();
  376. weapon = "";
  377.  
  378. switch( perk_bottle )
  379. {
  380. case "specialty_armorvest":
  381. weapon = "zombie_perk_bottle_jugg";
  382. break;
  383.  
  384. case "specialty_quickrevive":
  385. weapon = "zombie_perk_bottle_revive";
  386. break;
  387.  
  388. case "specialty_fastreload":
  389. weapon = "zombie_perk_bottle_sleight";
  390. break;
  391.  
  392. case "specialty_rof":
  393. weapon = "zombie_perk_bottle_doubletap";
  394. break;
  395. }
  396.  
  397. self GiveWeapon( weapon );
  398. self SwitchToWeapon( weapon );
  399.  
  400. return gun;
  401. }
  402.  
  403.  
  404. perk_give_bottle_end(gun, perk_bottle)
  405. {
  406. assert( gun != "zombie_perk_bottle_doubletap" );
  407. assert( gun != "zombie_perk_bottle_revive" );
  408. assert( gun != "zombie_perk_bottle_jugg" );
  409. assert( gun != "zombie_perk_bottle_sleight" );
  410. assert( gun != "syrette" );
  411.  
  412. self EnableOffhandWeapons();
  413. self EnableWeaponCycling();
  414.  
  415. self AllowLean( true );
  416. self AllowAds( true );
  417. self AllowSprint( true );
  418. self AllowProne( true );
  419. self AllowMelee( true );
  420. weapon = "";
  421. switch( perk_bottle )
  422. {
  423. case "specialty_armorvest":
  424. weapon = "zombie_perk_bottle_jugg";
  425. break;
  426.  
  427. case "specialty_quickrevive":
  428. weapon = "zombie_perk_bottle_revive";
  429. break;
  430.  
  431. case "specialty_fastreload":
  432. weapon = "zombie_perk_bottle_sleight";
  433. break;
  434.  
  435. case "specialty_rof":
  436. weapon = "zombie_perk_bottle_doubletap";
  437. break;
  438. }
  439.  
  440. // TODO: race condition?
  441. if ( self maps\_laststand::player_is_in_laststand() )
  442. {
  443. self TakeWeapon(weapon);
  444. return;
  445. }
  446.  
  447. if ( gun != "none" && gun != "mine_bouncing_betty" )
  448. {
  449. self SwitchToWeapon( gun );
  450. }
  451. else
  452. {
  453. // try to switch to first primary weapon
  454. primaryWeapons = self GetWeaponsListPrimaries();
  455. if( IsDefined( primaryWeapons ) && primaryWeapons.size > 0 )
  456. {
  457. self SwitchToWeapon( primaryWeapons[0] );
  458. }
  459. }
  460.  
  461. self GiveWeapon(gun);
  462. self SwitchToWeapon(gun);
  463. }
  464.  
  465. play_no_money_perk_dialog()
  466. {
  467.  
  468. index = maps\_zombiemode_weapons::get_player_index(self);
  469.  
  470. player_index = "plr_" + index + "_";
  471. if(!IsDefined (self.vox_nomoney_perk))
  472. {
  473. num_variants = maps\_zombiemode_spawner::get_number_variants(player_index + "vox_nomoney_perk");
  474. self.vox_nomoney_perk = [];
  475. for(i=0;i<num_variants;i++)
  476. {
  477. self.vox_nomoney_perk[self.vox_nomoney_perk.size] = "vox_nomoney_perk_" + i;
  478. }
  479. self.vox_nomoney_perk_available = self.vox_nomoney_perk;
  480. }
  481. sound_to_play = random(self.vox_nomoney_perk_available);
  482.  
  483. self.vox_nomoney_perk_available = array_remove(self.vox_nomoney_perk_available,sound_to_play);
  484.  
  485. if (self.vox_nomoney_perk_available.size < 1 )
  486. {
  487. self.vox_nomoney_perk_available = self.vox_nomoney_perk;
  488. }
  489.  
  490. self maps\_zombiemode_spawner::do_player_playdialog(player_index, sound_to_play, 0.25);
  491.  
  492. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement