Downloads containing mo4a_2-1_revisited2.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Mystery of the Four... chandie Single player 6.6 Download file

File preview

const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, null, ArcaneWeapons::MortarLauncher::Weapon(), WeaponVMega::Voranj::Weapon(), WeaponVMega::Backfire::Weapon(), null, ArcaneWeapons::FusionCannon::Weapon(), null, ArcaneWeapons::MortarLauncher::Weapon()}); ///@MLLE-Generated
#include "MLLE-Include-1.5w.asc" ///@MLLE-Generated
#pragma require "mo4a_2-1_revisited2.j2l" ///@MLLE-Generated
#include "ArcaneWeapon9.asc" ///@MLLE-Generated
#pragma require "ArcaneWeapon9.asc" ///@MLLE-Generated
#include "WeaponVMega5.asc" ///@MLLE-Generated
#pragma require "WeaponVMega5.asc" ///@MLLE-Generated
#include "WeaponVMega8.asc" ///@MLLE-Generated
#pragma require "WeaponVMega8.asc" ///@MLLE-Generated
#include "ArcaneWeapon4.asc" ///@MLLE-Generated
#pragma require "ArcaneWeapon4.asc" ///@MLLE-Generated
#include "TrueColor v13.asc"
#include "Jazz1Enemies v05.asc"
#include "Resize v11.asc"
#include "HH18savegems.asc"

void onLevelLoad()  {
	jjSetWaterLevel(2030, true);
	jjWaterLighting = WATERLIGHT::GLOBAL;
	gem::restorePlayerGems();
	p.buttstomp = 121;
	jjLevelName = ("@@@@@@@@@Central Area");
	jjObjectPresets[OBJECT::SAVEPOST].behavior = CheckpointWrapper;
	jjObjectPresets[OBJECT::SAVEPOST].deactivates = false;

	jjObjectPresets[OBJECT::WEENIE].behavior = Key();
	jjObjectPresets[OBJECT::WEENIE].scriptedCollisions = true;

	jjObjectPresets[OBJECT::CHICKENLEG].behavior = AntiCarrot();
	jjObjectPresets[OBJECT::CHICKENLEG].scriptedCollisions = true;
	jjObjectPresets[OBJECT::CHICKENLEG].determineCurAnim(ANIM::PICKUPS,82);

	jjObjectPresets[OBJECT::ICEAMMO15].behavior = Mortallaunchergun();
	jjObjectPresets[OBJECT::ICEAMMO15].scriptedCollisions = true;
	jjObjectPresets[OBJECT::ICEAMMO15].playerHandling = HANDLING::SPECIAL;

	jjObjectPresets[OBJECT::GUN9AMMO3].deactivates = false;
	
	jjObjectPresets[OBJECT::AIRBOARD].behavior = SuperCopter();
	jjObjectPresets[OBJECT::AIRBOARD].scriptedCollisions = true;

	jjObjectPresets[OBJECT::MOTH].behavior = Magic;

	Jazz1::MakeEnemy(OBJECT::DRAGONFLY, Jazz1::Enemies::Jungrock_RedBuzzer).SetUsesJJ2StyleDeathAnimation(true);
	Jazz1::MakeEnemy(OBJECT::LIZARD, Jazz1::Enemies::Pezrox_GreenSnake).SetUsesJJ2StyleDeathAnimation(true);
	Jazz1::MakeEnemy(OBJECT::RAVEN, Jazz1::Enemies::Sluggion_Dragoon).SetUsesJJ2StyleDeathAnimation(true);

	jjObjectPresets[OBJECT::EVA].behavior = TimeMachine;
	jjObjectPresets[OBJECT::EVA].determineCurAnim(ANIM::FLAG, 1);
	jjObjectPresets[OBJECT::EVA].putOnGround(false);
	jjObjectPresets[OBJECT::EVA].scriptedCollisions = true;
	jjANIMATION@ tmAnim = jjAnimations[jjObjectPresets[OBJECT::EVA].curAnim];
	for (uint i = 0; i < tmAnim.frameCount; ++i)
		jjAnimFrames[tmAnim.firstFrame + i].coldSpotY = -44;
	for (uint i = 0; i < tmAnim.frameCount; ++i)
		jjAnimFrames[tmAnim.firstFrame + i].hotSpotY = -64;
	for (uint i = 0; i < tmAnim.frameCount; ++i)
		jjAnimFrames[tmAnim.firstFrame + i].hotSpotX = -54;

	jjObjectPresets[OBJECT::FLYCARROT].determineCurAnim(ANIM::PLUS_WARP, 0);
	jjObjectPresets[OBJECT::FLYCARROT].behavior = Bonus;
	jjObjectPresets[OBJECT::FLYCARROT].scriptedCollisions = true;
	jjANIMATION@ BAnim = jjAnimations[jjObjectPresets[OBJECT::FLYCARROT].curAnim];
	for (uint i = 0; i < BAnim.frameCount; ++i)
		jjAnimFrames[BAnim.firstFrame + i].hotSpotY = -85;
	for (uint i = 0; i < BAnim.frameCount; ++i)
		jjAnimFrames[BAnim.firstFrame + i].hotSpotX = 20;

	jjObjectPresets[OBJECT::INVINCIBILITY].determineCurAnim(ANIM::PLUS_WARP, 1);
	jjObjectPresets[OBJECT::INVINCIBILITY].behavior = Bonuseye;
	jjObjectPresets[OBJECT::INVINCIBILITY].scriptedCollisions = true;
	jjObjectPresets[OBJECT::INVINCIBILITY].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::INVINCIBILITY].playerHandling = HANDLING::PLAYERBULLET;
	jjANIMATION@ BeAnim = jjAnimations[jjObjectPresets[OBJECT::INVINCIBILITY].curAnim];

	for (uint i = 0; i < BeAnim.frameCount; ++i)
		jjAnimFrames[BeAnim.firstFrame + i].hotSpotY = 12;
	for (uint i = 0; i < BeAnim.frameCount; ++i)
		jjAnimFrames[BeAnim.firstFrame + i].hotSpotX = 26;

}

void Bonuseye(jjOBJ@ obj){
	obj.direction = -1;
	obj.behave(BEHAVIOR::PICKUP, false);
	obj.draw();
}
void Bonus(jjOBJ@ obj){
	obj.putOnGround();
	obj.direction = -1;
	obj.behave(BEHAVIOR::PICKUP, false);
	obj.draw();
}

void Magic(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::MOTH,false);
	if(jjTriggers[8] == true && p.xPos<12*32){
		jjPARTICLE@ particle = jjAddParticle(PARTICLE::FLOWER);
		particle.xPos = obj.xPos;
		particle.yPos = obj.yPos;
	}
}

void onFunction0(jjPLAYER@ p) {
	jjTriggers[3] = true;
	jjEnabledASFunctions[0] = false;}

void onFunction1(jjPLAYER@ p) {
	p.showText("@@@@@@@@@@@@@@@@@@@@@@@@@Castle Road", STRING::MEDIUM);
	jjEnabledASFunctions[1] = false;}
void onFunction2(jjPLAYER@ p) {
	p.showText("@@@@@@@@@@@@@@@@@@@@@@@@@Sahara Desert", STRING::MEDIUM);
	jjEnabledASFunctions[2] = false;}

void onFunction3(jjPLAYER@ p) {
	jjNxt("mo4a_save6", false, true);
	gem::saveGemData();}


void TimeMachine(jjOBJ@ obj){
	obj.behave(BEHAVIOR::EVA, false);
		jjDrawResizedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, 1, 1, SPRITE::PALSHIFT, 8);

}

class Mortallaunchergun : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		if(p.ammo[WEAPON::GUN9] > 1)
		{obj.delete();}
		obj.behave(BEHAVIOR::MONITOR);	
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ play, int force) { 
		if(bullet !is null && play !is null)
			{obj.behave(BEHAVIOR::EXPLOSION2);
			jjAddObject(OBJECT::GUN9AMMO3, 78*32, 30*32);
			jjAddObject(OBJECT::GUN9AMMO3, 79*32, 30*32);
			jjAddObject(OBJECT::GUN9AMMO3, 70*32, 40*32);
			jjAddObject(OBJECT::GUN9AMMO3, 76*32, 40*32);			
			jjAddObject(OBJECT::GUN9AMMO3, 82*32, 40*32);
			jjAddObject(OBJECT::GUN9AMMO3, 88*32, 40*32);
			jjSample(p.xPos, p.yPos, SOUND::COMMON_HARP1, 1000);}
		return true;
	}
	
}

class AntiCarrot: jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		obj.determineCurFrame();
		obj.behave(BEHAVIOR::PICKUP, false);
		++obj.counter; 
		obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, -24);
	}

	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ p, int force) { 
		p.health = 1;
		p.blink = 245;	
		jjSample(obj.xPos, obj.yPos, SOUND::COMMON_EAT1, 1000);
		obj.frameID = 0;
		obj.behavior = BEHAVIOR::EXPLOSION2;

		return true; 
	}
}


bool buyammo = false;

void onPlayer(jjPLAYER@ p) {
	gem::trackPlayerGems(p);
	gem::upgradeHealth(p);
	
	if(p.ammo[WEAPON::GUN9] < 1 && p.xPos>65*32 && p.xPos<67*32 && p.yPos<43*32 && p.yPos>39*32 && jjKey[0x50] && p.gems[GEM::RED]<50 && buyammo == false)
		{p.testForGems(50, GEM::RED);}
	if(p.ammo[WEAPON::GUN9] < 1 && p.xPos>65*32 && p.xPos<67*32 && p.yPos<43*32 && p.yPos>39*32 && jjKey[0x50] && p.gems[GEM::RED]>=50 && buyammo == false)
		{p.testForGems(50, GEM::RED);
	jjTriggers[2]=true;
	buyammo = true;}
	if(p.ammo[WEAPON::GUN9] >= 1 && p.xPos>65*32 && p.xPos<67*32 && p.yPos<43*32 && p.yPos>39*32 && jjKey[0x50] && buyammo == false)
		{p.showText("@@You already have the weapon.");}
	p.lightType = LIGHT::NONE;

	if(SuperCopterOn > jjGameTicks)
		{jjCharacters[CHAR::JAZZ].helicopterYSpeed= 0;}
	if(SuperCopterOn < jjGameTicks)
		{jjCharacters[CHAR::JAZZ].helicopterYSpeed= 1;}
}

int SuperCopterOn = 0;

class SuperCopter : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PICKUP, false);
		obj.determineCurAnim(ANIM::PICKUPS, 33);
		++obj.counter; 
		obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, -8);

}

	bool onObjectHit(jjOBJ@ obj, jjOBJ@, jjPLAYER@ play, int force) {
		play.timerStart(360);
		p.morphTo(CHAR::JAZZ);
		SuperCopterOn= jjGameTicks + 6 * 61;
		obj.behavior = BEHAVIOR::EXPLOSION2;
		obj.frameID = 0;
		jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PICKUP1, 6000);

		return true;
	}

}

void onMain() {
p.ammo[WEAPON::ICE] = 0;
gem::deleteCollectedGems();
if(jjKey[9] && jjKey[0x51]) {
p.morphTo(CHAR::JAZZ, false); 
}
if(jjKey[9] && jjKey[0x57]) {
p.morphTo(CHAR::SPAZ, false); 
}
if(jjKey[9] && jjKey[0x45]) {
p.morphTo(CHAR::LORI, false); 
}
}

class Key : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PICKUP, false);
		jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::WEENIE].curAnim];
		anim.frameCount = 1; //The Bee enemy's animation has several frames, but the tileset only has material for one. Editing jjANIMATION::frameCount to 1 will ensure that the animation never extends beyond the one frame we're providing.	
		jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
		jjPIXELMAP pump(0, 0*32, 1*32, 1*32, 4);
		pump.save(frame);
		++obj.counter; 
		obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) { //"bullet" will always be null, because this is a PICKUP; "force" doesn't usually matter, because in normal JJ2 you can collect pickups regardless of whether you're using a special attack at the time.
		jjTriggers[1]=true;
		obj.behavior = BEHAVIOR::EXPLOSION2;
		jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);

		return true; //See plus-angelscript.html for an explanation of jjBEHAVIORINTERFACE::onObjectHit's return value, or else return true all the time and don't worry about it.
	}
}




bool onDrawLives(jjPLAYER@ player, jjCANVAS@ canvas) {return true;}

void onLevelReload()  {
	MLLE::Palette.apply();
	jjSetWaterLevel(2030, true);
	jjWaterLighting = WATERLIGHT::GLOBAL;
	gem::restorePlayerGems();
	jjLocalPlayers[0].lives++;
	buyammo == false;
	jjTriggers[2] = false;
  	for (uint i = 0; i < 32; ++i)
	  	jjTriggers[i] = SavedTriggers[i];
}

array<bool> SavedTriggers(32, false);
//Extendable Checkpoints by VioletCLM
void CheckpointWrapper(jjOBJ@ obj) {
  if (obj.state == STATE::STOP) { //don't do anything anymore
    jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, 8);
  } else if (obj.state == STATE::DEACTIVATE) { //due to death
    obj.deactivate();
  } else {
    obj.behave(BEHAVIOR::CHECKPOINT);
	jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, 8);
    if (obj.state == STATE::DONE) { //triggered by the player hitting it
      obj.state = STATE::STOP;
      //save the current state of some properties
      for (uint i = 0; i < 32; ++i)
        SavedTriggers[i] = jjTriggers[i];

      //OPTIONAL: this loop makes checkpoints reusable, so only the most recent checkpoint you touched is ever active
      for (int i = jjObjectCount; --i > 0;) {
        jjOBJ@ obj2 = jjObjects[i];
        if (obj2.eventID == OBJECT::CHECKPOINT && i != obj.objectID && obj2.isActive) {
          obj2.state = STATE::SLEEP;
          obj2.var[0] = 0;
        }
      }
    }
  }
}

jjTEXTAPPEARANCE SignTextAppearance = STRING::NORMAL;
class Sign {
	private int xPos, yPos; //These pixel-based positions will be generated from tile-based positions in the constructor by multiplying by 32
	private string text;
	private uint widthOfText;
	Sign(){} //AngelScript requires any class that appears in any array to have an explicit default constructor, even if it's never called
	Sign(int xTile, int yTile, const string &in t) {
		xPos = xTile * 32; //Since this is a constant operation, it could strictly be performed in the draw method instead of the constructor, but this way involves fewer multiplication instructions
		yPos = yTile * 32; //
		text = t;
		SignTextAppearance.newline = STRING::SPECIALSIGN; //Causes the drawString method to interpret instances of the \n character as signals to drop down to a new line, similar to the special effect of the @ character in the STRING::SPIN appearance.
		SignTextAppearance.spacing = -2; //int jjTEXTAPPEARANCE::spacing is new in 5.2, and this particular value is equivalent to prefixing the string with "ยง2". Make sure to check out bool jjTEXTAPPEARANCE::monospace too, though it didn't end up getting used in this level.
		widthOfText = jjGetStringWidth(text, STRING::SMALL, SignTextAppearance); //Used for determining how large of a dark rectangle should be drawn behind the text. A matching heightOfText value could of course be generated by counting the number of newline characters--for example, "heightOfText = text.split("\n").length * 20;"--but here the rectangles are constant height instead to limit the temptation to ramble on and on.
	}
	void draw(jjCANVAS@ layer, uint8 textIntensity) const { //Because this method will be called from an onDraw method, it's important to have a jjCANVAS@ passed among the arguments.
		layer.drawRectangle(xPos, yPos - 16, widthOfText + 8, 55, 0, SPRITE::TRANSLUCENT);
		layer.drawString(xPos, yPos, text, STRING::SMALL, SignTextAppearance, 0, SPRITE::BLEND_HARDLIGHT, textIntensity);
	}
}
const array<Sign> Signs = { 
	Sign(102, 59, "Find the second Time Freezer\nand come back."),
	Sign(57, 61, "A piece of advice:\nDon't eat everything you see around here."),	
	Sign(20, 50, "A magical cave, full of goodies\nlies beneath the West side of the desert."),
	Sign(150, 38, "Have you seen my husband?\nHis name is Ali Babba."),
	Sign(181, 21, "You brought back my lamp!\nTake this as a reward."),
	Sign(146, 54, "40 Thieves are destroyed\nby a brave rabbit, so they say."),
	Sign(169, 61, "We have the water supply\nthrough the canals."),
	Sign(209, 57, "Hey, how did you\nget back?!"),
	Sign(70, 41, "Press P if you'd like to\nbuy Mortal Launcher for 50 Gems."),
};

void onDrawLayer3(jjPLAYER@, jjCANVAS@ layer) { 
	if(jjKey[0x54]){
	const uint8 textIntensity = 200 + int(jjSin(jjGameTicks * 16) * 50); 
	for (uint signID = 0; signID < Signs.length; ++signID) 
		Signs[signID].draw(layer, textIntensity);
}
}

void onDrawLayer2(jjPLAYER@, jjCANVAS@ layer) { 
	if(p.yPos <21*32 && p.xPos >181*32 && p.yPos >14*32){
	const uint8 textIntensity = 200 + int(jjSin(jjGameTicks * 16) * 50); 
	for (uint signID = 0; signID < Signs.length; ++signID) 
		Signs[signID].draw(layer, textIntensity);
}
}
bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
	return MLLE::WeaponHook.drawAmmo(player, canvas);
}