ijontichy

<stdin>

Apr 13th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. script 476 (int begin, int button, int superThreshold)
  2. {
  3. begin = !!begin;
  4. superThreshold = condFalse(superThreshold, 26);
  5. button = condFalse(button, BT_ALTATTACK);
  6.  
  7. int pln = PlayerNumber();
  8. if (pln == -1) { terminate; }
  9. int curstate = MissileCheckStates[pln];
  10. if (curstate == begin) { terminate; }
  11.  
  12. MissileCheckStates[pln] = begin;
  13.  
  14. int chargelevel = 0;
  15. int couldsuper, cansuper = 0, givesuper = 0, canmissile = 0, isfiring = 0;
  16.  
  17. while (MissileCheckStates[pln])
  18. {
  19. // There's a dirty joke somewhere in here.
  20. if (CheckInventory("BorphMallAcquired") || CheckInventory("SpeedBoosterActive"))
  21. {
  22. MissileCheckStates[pln] = 0;
  23. break;
  24. }
  25.  
  26. cansuper = !!CheckInventory("SuperMissileAmmo");
  27. canmissile = !!CheckInventory("MissileAmmo");
  28. isfiring = keyDown(button);
  29.  
  30. // Clear out the trigger if we can hold for super missiles
  31. // - if we only have normal missiles, this could waste bandwidth
  32.  
  33. if (cansuper && CheckInventory("DakkaBeamCanMissile"))
  34. {
  35. TakeInventory("DakkaBeamCanMissile", 0x7FFFFFFF);
  36. }
  37.  
  38. // chargan
  39. if (isfiring && cansuper) { chargelevel++; }
  40. else
  41. {
  42. // Let go of the trigger before charged? fire a normal missile
  43. if (chargelevel > 0 && cansuper && !couldsuper)
  44. {
  45. GiveInventory("DakkaBeamCanMissile", 1);
  46. }
  47.  
  48. chargelevel = 0;
  49. }
  50.  
  51. givesuper = chargelevel >= superThreshold;
  52. givesuper &= cansuper;
  53.  
  54. // Handle no-super-missiles here
  55. if (!cansuper)
  56. {
  57. if (isfiring && canmissile && !CheckInventory("DakkaBeamCanMissile")) { GiveInventory("DakkaBeamCanMissile", 1); }
  58. else if (CheckInventory("DakkaBeamCanMissile")) { TakeInventory("DakkaBeamCanMissile", 0x7FFFFFFF); }
  59. }
  60.  
  61. // LOCKED AND LOADED
  62. if (givesuper && !couldsuper)
  63. {
  64. ActivatorSound("supermissile/ready", 127);
  65. }
  66.  
  67. // If we let go of the trigger, either send the super missile signal
  68. // (if charged), or clear the signal if there (if not)
  69. if (!givesuper)
  70. {
  71. if (couldsuper) { GiveInventory("DakkaBeamCanSuper", 1); }
  72. else if (CheckInventory("DakkaBeamCanSuper")) { TakeInventory("DakkaBeamCanSuper", 0x7FFFFFFF); }
  73. }
  74.  
  75. couldsuper = givesuper;
  76. Delay(1);
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment