Downloads containing platspear.mut

Downloads
Name Author Game Mode Rating
JJ2+ Only: Platform Spear szmol96 Mutator N/A Download file

File preview

  1. #pragma name "Platform Spear"
  2. #pragma require "platspear.j2a"
  3.  
  4. /**Platform Spear**/
  5. /**Author: szmol96**/
  6.  
  7. int delay = 0;
  8. uint customAnimID = 0;
  9.  
  10. void findCustomAnimID() { //This function is copied from Bunny Must Die! guns
  11.         while (jjAnimSets[ANIM::CUSTOM[customAnimID]].firstAnim != 0) ++customAnimID;
  12.        
  13.         jjAnimSets[ANIM::CUSTOM[customAnimID]].load(0, "platspear.j2a");
  14. }
  15.  
  16. void platSpear(jjOBJ@ spear) {
  17.         if (spear.state == STATE::START) {
  18. //              jjSample(p.xPos, p.yPos, SOUND::MONKEY_THROW, 63, 17500);
  19.                 spear.state = STATE::FLY;
  20.         }
  21.         jjPLAYER@ p = jjPlayers[spear.creatorID];
  22.        
  23.         spear.xPos = spear.xPos + spear.xSpeed + (spear.xAcc * 2);
  24.         spear.yPos = spear.yPos + spear.ySpeed + (spear.yAcc * 2);
  25.  
  26.         if (jjMaskedPixel(spear.xPos, spear.yPos) && spear.state != STATE::STILL) {
  27.                 spear.xSpeed = 0;
  28.                 spear.ySpeed = 0;
  29.                 spear.xAcc = 0;
  30.                 spear.yAcc = 0;
  31.                 spear.counter = 1;
  32.                 spear.state = STATE::STILL;
  33.         }
  34.         if (spear.state == STATE::STILL) {
  35.                 if (spear.direction == 1) {
  36.                         spear.bePlatform(spear.xPos, spear.yPos, 0, 0);
  37.                 } else {
  38.                         spear.bePlatform(spear.xPos + 113, spear.yPos, 0, 0);
  39.                 }
  40.         }
  41.        
  42.         if (spear.counter >= spear.counterEnd) {
  43.                 spear.behavior = BEHAVIOR::BULLET;
  44.                 spear.clearPlatform();
  45.         }
  46.        
  47.         spear.counter++;
  48.        
  49.         spear.determineCurFrame();
  50.         spear.draw();
  51. }
  52.  
  53. void onLevelLoad() {
  54.         findCustomAnimID();
  55.         jjWeapons[1].allowedPowerup = true;
  56.         jjObjectPresets[OBJECT::BLASTERBULLETPU].determineCurAnim(ANIM::CUSTOM[customAnimID], 0);
  57.         jjObjectPresets[OBJECT::BLASTERBULLETPU].behavior = platSpear;
  58.         jjObjectPresets[OBJECT::BLASTERBULLETPU].counterEnd = 140;
  59. }
  60.  
  61. void onLevelBegin() {
  62.         jjAlert("[UP] + [LEFT/RIGHT] + [FIRE] to fire a spear");
  63. }
  64.  
  65. void onPlayerInput(jjPLAYER@ p) {
  66.         if ((p.keyUp && p.keyLeft) || (p.keyUp && p.keyRight)) {
  67.                 p.powerup[1] = true;
  68.                 p.noFire = true;
  69.                 if (p.keyFire && delay == 0) {
  70.                         p.fireBullet(WEAPON::BLASTER, true, true, DIRECTION::CURRENT);
  71.                         delay = 70;
  72.                 }
  73.         } else {
  74.                 p.powerup[1] = false;
  75.                 p.noFire = false;
  76.         }
  77. }
  78.  
  79. void onMain() {
  80.         if (delay > 0) delay--;
  81. }