#pragma name "Platform Spear" #pragma require "platspear.j2a" /**Platform Spear**/ /**Author: szmol96**/ int delay = 0; uint customAnimID = 0; void findCustomAnimID() { //This function is copied from Bunny Must Die! guns while (jjAnimSets[ANIM::CUSTOM[customAnimID]].firstAnim != 0) ++customAnimID; jjAnimSets[ANIM::CUSTOM[customAnimID]].load(0, "platspear.j2a"); } void platSpear(jjOBJ@ spear) { if (spear.state == STATE::START) { // jjSample(p.xPos, p.yPos, SOUND::MONKEY_THROW, 63, 17500); spear.state = STATE::FLY; } jjPLAYER@ p = jjPlayers[spear.creatorID]; spear.xPos = spear.xPos + spear.xSpeed + (spear.xAcc * 2); spear.yPos = spear.yPos + spear.ySpeed + (spear.yAcc * 2); if (jjMaskedPixel(spear.xPos, spear.yPos) && spear.state != STATE::STILL) { spear.xSpeed = 0; spear.ySpeed = 0; spear.xAcc = 0; spear.yAcc = 0; spear.counter = 1; spear.state = STATE::STILL; } if (spear.state == STATE::STILL) { if (spear.direction == 1) { spear.bePlatform(spear.xPos, spear.yPos, 0, 0); } else { spear.bePlatform(spear.xPos + 113, spear.yPos, 0, 0); } } if (spear.counter >= spear.counterEnd) { spear.behavior = BEHAVIOR::BULLET; spear.clearPlatform(); } spear.counter++; spear.determineCurFrame(); spear.draw(); } void onLevelLoad() { findCustomAnimID(); jjWeapons[1].allowedPowerup = true; jjObjectPresets[OBJECT::BLASTERBULLETPU].determineCurAnim(ANIM::CUSTOM[customAnimID], 0); jjObjectPresets[OBJECT::BLASTERBULLETPU].behavior = platSpear; jjObjectPresets[OBJECT::BLASTERBULLETPU].counterEnd = 140; } void onLevelBegin() { jjAlert("[UP] + [LEFT/RIGHT] + [FIRE] to fire a spear"); } void onPlayerInput(jjPLAYER@ p) { if ((p.keyUp && p.keyLeft) || (p.keyUp && p.keyRight)) { p.powerup[1] = true; p.noFire = true; if (p.keyFire && delay == 0) { p.fireBullet(WEAPON::BLASTER, true, true, DIRECTION::CURRENT); delay = 70; } } else { p.powerup[1] = false; p.noFire = false; } } void onMain() { if (delay > 0) delay--; }