Downloads containing mo4a_4-4.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, WeaponVMega::IceCloud::Weapon(), WeaponVMega::Voranj::Weapon(), WeaponVMega::Backfire::Weapon(), null, ArcaneWeapons::FusionCannon::Weapon(), SzmolWeaponPack::PetrolBomb::Weapon(), ArcaneWeapons::MortarLauncher::Weapon()}); ///@MLLE-Generated
#include "MLLE-Include-1.5w.asc" ///@MLLE-Generated
#pragma require "mo4a_4-4-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "mo4a_4-4.j2l" ///@MLLE-Generated
#include "ArcaneWeapon4.asc" ///@MLLE-Generated
#pragma require "ArcaneWeapon4.asc" ///@MLLE-Generated
#include "petrolBomb.asc" ///@MLLE-Generated
#pragma require "petrolBomb.asc" ///@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 "WeaponVMega3.asc" ///@MLLE-Generated
#pragma require "WeaponVMega3.asc" ///@MLLE-Generated
#pragma require "petrolBomb.j2a"
#include "Jazz1Enemies v05.asc"
#include "Resize v11.asc"
#include "TrueColor v13.asc"
#include "HH18savegems.asc"

int SpeedUpUntil = 0, ElevatorUp = 0, CountlessDoubleJumps = 0, exit = 0;
bool water = false, itsraining = false, copterfloat = false, control = true;

void onLevelLoad() {
	gem::restorePlayerGems();
	jjLevelName = ("@@@@@@@@@Temple of Buddha");
	jjWaterLighting = WATERLIGHT::GLOBAL;

	jjObjectPresets[OBJECT::SAVEPOST].behavior = CheckpointWrapper;
	jjObjectPresets[OBJECT::SAVEPOST].deactivates = false;

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

	jjObjectPresets[OBJECT::HAM].behavior = KeyEarth();
	jjObjectPresets[OBJECT::HAM].scriptedCollisions = true;

	jjObjectPresets[OBJECT::PRETZEL].behavior = KeyWater();
	jjObjectPresets[OBJECT::PRETZEL].scriptedCollisions = true;

	jjObjectPresets[OBJECT::SANDWICH].behavior = KeyAir();
	jjObjectPresets[OBJECT::SANDWICH].scriptedCollisions = true;

	jjObjectPresets[OBJECT::FREEZEENEMIES].behavior = TimeFreezer();
	jjObjectPresets[OBJECT::FREEZEENEMIES].scriptedCollisions = true;

	jjObjectPresets[OBJECT::AIRBOARD].scriptedCollisions = true;
	jjObjectPresets[OBJECT::AIRBOARD].behavior = Fastrun();

	jjObjectPresets[OBJECT::GRASSPLATFORM].scriptedCollisions = true;
	jjObjectPresets[OBJECT::GRASSPLATFORM].behavior = Air();

	jjObjectPresets[OBJECT::FRUITPLATFORM].scriptedCollisions = true;
	jjObjectPresets[OBJECT::FRUITPLATFORM].behavior = AirT();

	jjObjectPresets[OBJECT::BURGER].scriptedCollisions = true;
	jjObjectPresets[OBJECT::BURGER].behavior = Fire();
	jjObjectPresets[OBJECT::BURGER].playerHandling = HANDLING::SPECIAL;
	jjObjectPresets[OBJECT::CHICKENLEG].scriptedCollisions = true;
	jjObjectPresets[OBJECT::CHICKENLEG].behavior = Fire2();
	jjObjectPresets[OBJECT::CHICKENLEG].playerHandling = HANDLING::SPECIAL;

	jjObjectPresets[OBJECT::TURTLESHELL].xSpeed = 5;
	jjObjectPresets[OBJECT::TURTLESHELL].scriptedCollisions = true;
	jjObjectPresets[OBJECT::TURTLESHELL].behavior = MovingSpring();
	jjObjectPresets[OBJECT::TURTLESHELL].determineCurAnim(ANIM::SPRING,7);

	jjObjectPresets[OBJECT::BEES].energy = 20;
	jjObjectPresets[OBJECT::BEES].behavior = FallingIce;
	jjObjectPresets[OBJECT::BEES].playerHandling = HANDLING::ENEMY;
	jjObjectPresets[OBJECT::BEES].bulletHandling = HANDLING::HURTBYBULLET;
	jjObjectPresets[OBJECT::BEES].isBlastable = true;
	jjObjectPresets[OBJECT::BEES].determineCurFrame();	
	jjObjectPresets[OBJECT::BEES].deactivates = false;

	jjObjectPresets[OBJECT::SONICPLATFORM].scriptedCollisions = true;
	jjObjectPresets[OBJECT::SONICPLATFORM].behavior = Elevator;
	jjObjectPresets[OBJECT::SONICPLATFORM].deactivates = false;

	jjObjectPresets[OBJECT::PINKPLATFORM].scriptedCollisions = true;
	jjObjectPresets[OBJECT::PINKPLATFORM].behavior = AirTimer();
	
	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::BEES].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP pump(0, 58*32, 2*32, 2*32, 5);
	pump.save(frame);
	frame.hotSpotX = -32;

	jjObjectPresets[OBJECT::BOLLPLATFORM].scriptedCollisions = true;
	jjObjectPresets[OBJECT::BOLLPLATFORM].behavior = Lava;
	jjObjectPresets[OBJECT::BOLLPLATFORM].playerHandling = HANDLING::SPECIAL;
	jjObjectPresets[OBJECT::BOLLPLATFORM].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::BOLLPLATFORM].deactivates = false;

	jjObjectPresets[OBJECT::FASTFEET].behavior = CountlessJumps();
	jjObjectPresets[OBJECT::FASTFEET].scriptedCollisions = true;

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

	Jazz1::MakeEnemy(OBJECT::RAVEN, Jazz1::Enemies::Holidaius_Devil).SetUsesJJ2StyleDeathAnimation(true).SetDeathSound(SOUND::BILSBOSS_THUNDER);
	Jazz1::MakeEnemy(OBJECT::SKELETON, Jazz1::Enemies::Megairbase_Doofusguard).SetUsesJJ2StyleDeathAnimation(true).SetBulletFireSound(SOUND::INTRO_SHOTGRN).SetBulletExplosionSound(SOUND::COMMON_GUNSM1);
	Jazz1::MakeEnemy(OBJECT::SPARK, Jazz1::Enemies::Scraparap_GunnerDrone).SetUsesJJ2StyleDeathAnimation(true).SetBulletFireSound(SOUND::ROBOT_SHOOT).SetBulletExplosionSound(SOUND::COMMON_GUNSM1);
}

class MovingSpring : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::WALKINGENEMY, false);
		obj.putOnGround();
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, 16);
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int) {
		if(bullet is null) {
		player.direction = player.ySpeed = -62;
		obj.scriptedCollisions = true;
		jjSample(obj.xPos, obj.yPos, SOUND::COMMON_SPRING1);}
		if(player !is null && bullet !is null)
		{obj.bulletHandling = HANDLING::DETECTBULLET;
		obj.causesRicochet = true;}
		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; 
	}
}

class CountlessJumps : 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, 16);

}

	bool onObjectHit(jjOBJ@ obj, jjOBJ@, jjPLAYER@ play, int force) {
		play.timerStart(3000);
		jjTriggers[26] = true;
		p.morphTo(CHAR::SPAZ);
		CountlessDoubleJumps = jjGameTicks + 55 * 61;
		obj.behavior = BEHAVIOR::EXPLOSION2;
		obj.frameID = 0;
		jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PICKUP1, 6000);

		return true;
	}

}

class AirTimer: jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {

obj.determineCurAnim(ANIM::PINKPLAT, 0);
++obj.counter; 


		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::INVISIBLE);

}

	bool onObjectHit(jjOBJ@ obj, jjOBJ@, jjPLAYER@ play, int force) {
	if(p.keyUp){
		play.timerStart(1200);
		p.cameraFreeze(198*32, 36*32, true, false);
		jjTriggers[7] = true;
		jjTriggers[8] = false;
		Switch7 = jjGameTicks + 21*61;
		obj.delete();
		//jjAddObject(OBJECT::FRUITPLATFORM, 5396, 1170);
		//jjAddObject(OBJECT::FRUITPLATFORM, 6346, 1170);
		jjSample(play.xPos, play.yPos, SOUND::INTRO_MONSTER2);}
		return true;
	}

}

bool lavarise = false;

void Lava (jjOBJ@ obj) {
	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::BOLLPLATFORM].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP lava(0, 0*32, 43*32, 19*32, 8);
	lava.save(frame);
	frame.hotSpotX = -60;
	if(lavarise == true) {
	jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
	if(p.yPos>obj.yPos-22 && itsraining == false )
		{p.health = 0;}
	if(itsraining == true) 
		{obj.state = STATE::FREEZE;
		obj.beSolid();
		obj.deactivates = false;
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::SINGLEHUE, 59);}
	if(p.xPos<60*32 && p.yPos < 5*32) 
		{obj.state = STATE::KILL;
		obj.delete();}

		switch (obj.state) {
		case STATE::START:
			obj.ySpeed = 0;

			obj.state = STATE::FLY;
			obj.beSolid();
		case STATE::FLY:
		++obj.counter; 
		obj.xPos = jjSin(obj.counter*4)*4 + obj.xOrg;
		if(p.xPos >74*32)
			{obj.direction = obj.ySpeed = -0.2;
			obj.yPos = obj.yPos + obj.ySpeed;}
			obj.beSolid();


			break;
		}
	}

}

void Elevator (jjOBJ@ obj) {
	switch (obj.state) {
		case STATE::START:
			obj.direction = obj.ySpeed = 2;
			obj.determineCurAnim(ANIM::SONICPLAT, 0);   
			obj.determineCurFrame();
			obj.playerHandling = HANDLING::SPECIAL;
			obj.state = STATE::FLY;
			obj.beSolid();
		case STATE::FLY:
			obj.beSolid();
			if(p.keyUp && ElevatorUp > jjGameTicks && p.xPos>obj.xPos-32 && p.xPos<obj.xPos+32) {
			obj.yPos = obj.yPos + obj.ySpeed;
			obj.direction = obj.ySpeed = -2; 
			 }
			if(p.keyDown && ElevatorUp > jjGameTicks && p.xPos>obj.xPos-32 && p.xPos<obj.xPos+32) {
			obj.yPos = obj.yPos + obj.ySpeed;
			p.ySpeed=3;
			obj.direction = obj.ySpeed = 2; 
			if (jjMaskedVLine(obj.xSpeed > 0 ? obj.yPos + 36 : obj.xPos - 16, obj.yPos, 1)) {
				obj.ySpeed = 0;
			} 
			}
			obj.draw();
			break;

	}
}
class Fire2 : jjBEHAVIORINTERFACE{
	void onBehave(jjOBJ@ enemy) {

	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::FIREBALLBULLET].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP flame(0, 63*32, 1*32, 1*32, 5);
	flame.save(frame);

	switch (enemy.state) {
		case STATE::START:
				enemy.determineCurAnim(ANIM::AMMO, 55);
				enemy.determineCurFrame();
			enemy.state = STATE::IDLE;
			break;
		
		case STATE::IDLE:

				enemy.direction = -1;
			if ((jjRandom() & 91) == 0) {
				enemy.state = STATE::ATTACK;
				enemy.determineCurAnim(ANIM::AMMO, 55);
				enemy.counter = 0;
				enemy.frameID = 0;
				jjSample(enemy.xPos, enemy.yPos, SOUND::COMMON_SWISH8);
			} else {
				if (++enemy.counter > 4) {
					enemy.counter = 0;
					if (++enemy.frameID >= 91)
						enemy.frameID = 0;

				}
			}
			break;
		case STATE::ATTACK:

			if (++enemy.counter > 6) {
				enemy.counter = 0;
				if (++enemy.frameID >= 91) {
					enemy.state = STATE::IDLE;
					enemy.frameID = 0;
				} else if (enemy.frameID ==1) {
					jjOBJ@ obj = jjObjects[enemy.fireBullet(OBJECT::FIREBALLBULLET)];
						
					frame.hotSpotX = -32;
					obj.playerHandling = HANDLING::PLAYERBULLET;
					obj.bulletHandling = HANDLING::IGNOREBULLET;
					obj.lightType = LIGHT::POINT;
					obj.xPos = enemy.xPos-62;
					obj.yPos = enemy.yPos-12; 	
					obj.xAcc = .12;
					int xspeed = (jjRandom() & 3);
					obj.xSpeed = -19 - xspeed;
					int yspeed = (jjRandom() & 6);
					obj.ySpeed = yspeed + 8* p.direction;
					obj.counterEnd = 155;
				}
				enemy.determineCurFrame();
			}
			break;
		case STATE::FREEZE:
		enemy.playerHandling = HANDLING::PLAYERBULLET;
		enemy.behavior = BEHAVIOR::BURNING;
		enemy.delete();
		break;
		case STATE::DEACTIVATE:
		case STATE::KILL:
			enemy.delete();
			break;
	}

		jjDrawRotatedSpriteFromCurFrame(enemy.xPos-5, enemy.yPos, enemy.curFrame, 270, 1, -1, SPRITE::NORMAL);

	}
	
	bool onObjectHit(jjOBJ@ enemy, jjOBJ@ bullet, jjPLAYER@ p, int force) {
		if (force == 0 || force == -1)
		{p.hurt();}
		else if (bullet.var[3] == WEAPON::ICE)
		{enemy.behavior = BEHAVIOR::EXPLOSION;
		enemy.state = STATE::FREEZE;
		enemy.delete();
		bullet.delete();}
	return true;
	}
}


class Fire : jjBEHAVIORINTERFACE{
	void onBehave(jjOBJ@ enemy) {

	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::FIREBALLBULLET].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP flame(0, 63*32, 1*32, 1*32, 5);
	flame.save(frame);

	switch (enemy.state) {
		case STATE::START:
				enemy.determineCurAnim(ANIM::AMMO, 55);
				enemy.determineCurFrame();
			enemy.state = STATE::IDLE;
			break;
		
		case STATE::IDLE:

				enemy.direction = 1;
			if ((jjRandom() & 91) == 0) {
				enemy.state = STATE::ATTACK;
				enemy.determineCurAnim(ANIM::AMMO, 55);
				enemy.counter = 0;
				enemy.frameID = 0;
				jjSample(enemy.xPos, enemy.yPos, SOUND::COMMON_SWISH8);
			} else {
				if (++enemy.counter > 4) {
					enemy.counter = 0;
					if (++enemy.frameID >= 91)
						enemy.frameID = 0;

				}
			}
			break;
		case STATE::ATTACK:

			if (++enemy.counter > 6) {
				enemy.counter = 0;
				if (++enemy.frameID >= 91) {
					enemy.state = STATE::IDLE;
					enemy.frameID = 0;
				} else if (enemy.frameID ==1) {
					jjOBJ@ obj = jjObjects[enemy.fireBullet(OBJECT::FIREBALLBULLET)];
						
					frame.hotSpotX = -32;
					obj.playerHandling = HANDLING::PLAYERBULLET;
					obj.bulletHandling = HANDLING::IGNOREBULLET;
					obj.lightType = LIGHT::POINT;
					obj.xPos = enemy.xPos+62;
					obj.yPos = enemy.yPos-12; 	
					obj.xAcc = .12;
					int xspeed = (jjRandom() & 3);
					obj.xSpeed = 19 + xspeed;
					int yspeed = (jjRandom() & 6);
					obj.ySpeed = yspeed -8* p.direction;
					obj.counterEnd = 155;
				}
				enemy.determineCurFrame();
			}
			break;
		case STATE::FREEZE:
		enemy.playerHandling = HANDLING::PLAYERBULLET;
		enemy.behavior = BEHAVIOR::BURNING;
		enemy.delete();
		break;
		case STATE::DEACTIVATE:
		case STATE::KILL:
			enemy.delete();
			break;
	}

		jjDrawRotatedSpriteFromCurFrame(enemy.xPos-5, enemy.yPos, enemy.curFrame, 270, 1, -1, SPRITE::NORMAL);

	}
	
	bool onObjectHit(jjOBJ@ enemy, jjOBJ@ bullet, jjPLAYER@ p, int force) {
		if (force == 0 || force == -1)
		{p.hurt();}
		else if (bullet.var[3] == WEAPON::ICE)
		{enemy.behavior = BEHAVIOR::EXPLOSION;
		enemy.state = STATE::FREEZE;
		enemy.delete();
		bullet.delete();}
	return true;
	}
}



class Air : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::BURNING, false);
		obj.determineCurAnim(ANIM::AMMO,3);
		obj.determineCurFrame();
		++obj.counter; 
		obj.yPos = jjSin(obj.counter*3 + 5)*2 + obj.yOrg;
		jjDrawSpriteFromCurFrame(obj.xPos+14, obj.yPos, obj.curFrame, obj.direction, SPRITE::TRANSLUCENTSINGLEHUE, 64);
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) { 
		if(bullet is null)
			{copterfloat = true;}
		return true;
	}
}

class AirT : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
	if(jjTriggers[7]==true) {
		obj.behave(BEHAVIOR::BURNING, false);
		obj.determineCurAnim(ANIM::AMMO,3);
		obj.determineCurFrame();
		++obj.counter; 
		obj.yPos = jjSin(obj.counter*3 + 5)*2 + obj.yOrg;
		jjDrawSpriteFromCurFrame(obj.xPos+14, obj.yPos+32, obj.curFrame, obj.direction, SPRITE::TRANSLUCENTSINGLEHUE, 64);
		} 
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
	if(jjTriggers[7]==true) {
		copterfloat = true;
	}
		return true;
	}
}


void FallingIce (jjOBJ@ enemy) {

	if (enemy.state == STATE::KILL || enemy.state == STATE::DEACTIVATE) {
		enemy.delete();

	} else  	switch (enemy.state) {
		case STATE::START:
	enemy.frameID = enemy.counter/8;


	enemy.determineCurFrame();	

		++enemy.counter;

		if (jjRandom() & 63 == 0) {
			jjOBJ@ obj = jjObjects[enemy.fireBullet(OBJECT::BULLET)];

			obj.behavior = BEHAVIOR::BULLET;
			obj.determineCurAnim(ANIM::AMMO, 30);
			obj.lightType = LIGHT::POINT;
			jjSample(enemy.xPos, enemy.yPos, SOUND::COMMON_PLOP2);
			obj.bulletHandling = HANDLING::IGNOREBULLET;
			obj.killAnim = jjObjectPresets[OBJECT::ICEBULLET].killAnim;
			obj.ySpeed = 6;
			obj.counterEnd = 100;

		}
		else if (jjRandom() & 63 == 0) {
			jjOBJ@ objj = jjObjects[enemy.fireBullet(OBJECT::BULLET)];
			objj.xPos = enemy.xPos + 2;
			objj.behavior = BEHAVIOR::BULLET;
			objj.determineCurAnim(ANIM::AMMO, 30);
			objj.lightType = LIGHT::POINT;
			jjSample(enemy.xPos, enemy.yPos, SOUND::COMMON_PLOP2);
			objj.bulletHandling = HANDLING::IGNOREBULLET;
			objj.killAnim = jjObjectPresets[OBJECT::ICEBULLET].killAnim;
			objj.ySpeed = 6;
			objj.counterEnd = 100; }

	}
	if (enemy.justHit == 0)

		jjDrawSpriteFromCurFrame(enemy.xPos, enemy.yPos, enemy.curFrame, enemy.direction, SPRITE::TRANSLUCENT);
	else
		enemy.draw();

}	



class KeyFire : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		if(jjTriggers[5] == true)
		{obj.delete();}
		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::NORMAL);
}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) { 
		jjTriggers[5] = true;
		jjAddObject(OBJECT::CHICKENLEG, 26*32, 33*32);
		jjAddObject(OBJECT::BURGER, 30*32, 33*32);
		obj.behavior = BEHAVIOR::EXPLOSION2;
		jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);

		return true;
	}
}


class Fastrun : 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, -32);

}

	bool onObjectHit(jjOBJ@ obj, jjOBJ@, jjPLAYER@ play, int force) {
	play.timerStart(700);
		SpeedUpUntil = jjGameTicks + 11 * 61;
		obj.behavior = BEHAVIOR::EXPLOSION2;
		obj.frameID = 0;
		jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PICKUP1, 6000);

		return true;
	}

}

class KeyEarth : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		if(jjTriggers[6] == true)
		{obj.delete();}
		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::NORMAL);
}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) { 
		jjTriggers[6] = true;
		jjTriggerRock(4);
		obj.behavior = BEHAVIOR::EXPLOSION2;
		jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);

		return true;
	}
}

class KeyWater : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		if(jjTriggers[9] == true)
		{obj.delete();}
		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::NORMAL);
}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) { 
		jjTriggers[9] = true;
		obj.behavior = BEHAVIOR::EXPLOSION2;
		jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);

		return true;
	}
}

class KeyAir : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		if(jjTriggers[11] == true)
		{obj.delete();}
		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::NORMAL);
}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) { 
		jjTriggers[11] = true;
		obj.behavior = BEHAVIOR::EXPLOSION2;
		jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);

		return true;
	}
}

class TimeFreezer : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PICKUP, false);
	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::FREEZEENEMIES].curAnim];
	anim.frameCount = 1; 
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP pump(0, 16*32, 1*32, 1*32, 5);
	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) { 
		jjTriggers[12] = true;
		obj.behavior = BEHAVIOR::EXPLOSION2;
		jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);

		return true;
	}
}

int Switch1 = 0; int Switch2 = 0; int Switch3 = 0; int Switch4 = 0; int Switch7 = 0; int Switch18 = 0; int Switch19 = 0;


void onFunction0(jjPLAYER@ p) {
	if(jjTriggers[5] == true && jjTriggers[6] == true && jjTriggers[9] == true && jjTriggers[11] == true) 
	{jjTriggers[22] = true;}
	else p.showText("@@Must collect all 4 element badges first.");
}

void onFunction1(jjPLAYER@ p) {
	jjNxt("mo4a_4-5_save", false, true);
	gem::saveGemData();	
}

void onFunction2(jjPLAYER@ p) {
	lavarise = true;
	jjEnabledASFunctions[2] = false;
	jjEnabledASFunctions[3] = true;
}

void onFunction3(jjPLAYER@ p) {
	lavarise = false;
	jjEnabledASFunctions[3] = false;
	jjEnabledASFunctions[2] = true;

}

void onFunction5(jjPLAYER@ p){
ElevatorUp = jjGameTicks + 21*61;}

void onFunction6(jjPLAYER@ p){
if(p.keyDown==true)
ElevatorUp = jjGameTicks + 100 *61;
else ElevatorUp = 0;}

void onFunction7(jjPLAYER@ p) {
Switch7 = jjGameTicks + 21* 61;
}

void onFunction4(jjPLAYER@ p) {
	p.timerStop();}


void onFunction9(jjPLAYER@ p)
{copterfloat = true;}

void onFunction10(jjPLAYER@ p)
{copterfloat = false;}


void onFunction26(jjPLAYER@ p) {
p.hurt();}

void onFunction20(jjPLAYER@ p) {
jjSetWaterLevel(1344, false);
jjTriggers[20] = true;
jjTriggers[21] = false;
jjTriggers[23] = false;
jjTriggers[24] = false;
jjSample(p.xPos, p.yPos, SOUND::ROBOT_HYDROPUF);
}

void onFunction21(jjPLAYER@ p) {
jjSetWaterLevel(1856, false);
jjTriggers[21] = true;
jjTriggers[20] = false;
jjTriggers[23] = false;
jjTriggers[24] = false;
jjSample(p.xPos, p.yPos, SOUND::ROBOT_HYDROPUF);
}

void onFunction23(jjPLAYER@ p) {
jjSetWaterLevel(2080, false);
jjTriggers[23] = true;
jjTriggers[20] = false;
jjTriggers[21] = false;
jjTriggers[24] = false;
jjSample(p.xPos, p.yPos, SOUND::ROBOT_HYDROPUF);
}

void onFunction24(jjPLAYER@ p) {
jjSetWaterLevel(1568, false);
jjTriggers[24] = true;
jjTriggers[20] = false;
jjTriggers[21] = false;
jjTriggers[23] = false;
jjSample(p.xPos, p.yPos, SOUND::ROBOT_HYDROPUF);
}

void onLevelReload() {
	gem::restorePlayerGems();
	jjLocalPlayers[0].lives++;
	jjWaterLighting = WATERLIGHT::GLOBAL;
  	for (uint i = 0; i < 32; ++i)
	  	jjTriggers[i] = SavedTriggers[i];
}

bool doorunblocked = false, startrush = false, readytorush = false;

void onPlayer(jjPLAYER@ p) {

	if(p.xPos < 115*32 && p.yPos > 20*32) {
	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::WEENIE].curAnim];
	anim.frameCount = 1; 
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP fire(0, 54*32, 1*32, 1*32, 5);
	fire.save(frame);
	}

	if(p.xPos < 115*32 && p.yPos < 20*32) {
	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::HAM].curAnim];
	anim.frameCount = 1; 
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP earth(0, 55*32, 1*32, 1*32, 5);
	earth.save(frame);
	}

	if(p.xPos > 115*32) {
	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::PRETZEL].curAnim];
	anim.frameCount = 1; 
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP water(0, 56*32, 1*32, 1*32, 5);
	water.save(frame);
	}

	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::SANDWICH].curAnim];
	anim.frameCount = 1; 
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP air(0, 57*32, 1*32, 1*32, 5);
	air.save(frame);

	gem::trackPlayerGems(p);
	gem::upgradeHealth(p);
	
	exit = 0;
	if(jjTriggers[5] == true)
		{exit += 1;}
	if(jjTriggers[6] == true)
		{exit += 1;}
	if(jjTriggers[9] == true)
		{exit += 1;}
	if(jjTriggers[11] == true)
		{exit += 1;}

		if(control==false)
		{p.keyLeft = false;
		p.keyRight = false;
		p.keyDown = false;}

		if(p.idle > 100 && p.xPos < 223*32)
		{p.cameraUnfreeze(true);
		control=true;}
		else if (p.idle > 5 && (p.keyLeft || p.keyRight || p.keyJump || p.keyFire))
		{p.cameraUnfreeze(true);
		control=true;}

	if(p.keyUp && p.xPos > 101*32 && p.xPos < 104*32 && p.yPos > 2*32 && p.yPos < 6*32 && water == false) {
		water = true;
		jjTriggers[10] = true;
		jjSample(p.xPos, p.yPos, SOUND::ROBOT_HYDROPUF);
	}

	if(p.food == 100 && jjKey[0x52] == false && startrush == false)
		{p.showText("@@@@@@@@@@@@@@@@Press 'R' when you need to use Sugar Rush!", STRING::MEDIUM);
		p.startSugarRush(0);
		startrush = true;
		readytorush = true;}

	if(readytorush == true)
		{p.food = 100;}

	if(p.food == 100 && jjKey[0x52])
		{p.startSugarRush(1400);
		p.food = 0;
		readytorush = false;
		startrush = false;
	}


	if(doorunblocked == false && jjTriggers[5] == true && jjTriggers[6] == true && jjTriggers[9] == true && jjTriggers[11] == true) 
	{	p.showText("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Badges collected.");
		p.cameraFreeze(115*32, 36*32, true, false);
		doorunblocked = true;	}

	if(water == true) {
	jjIsSnowing = true;
	jjSnowingType = SNOWING::RAIN;
	itsraining = true;
	}
if(copterfloat == true)
{jjCharacters[CHAR::JAZZ].helicopterYSpeed= -2;
jjCharacters[CHAR::LORI].helicopterYSpeed= -2;}
if(copterfloat == false)
{jjCharacters[CHAR::JAZZ].helicopterYSpeed= 1;
jjCharacters[CHAR::LORI].helicopterYSpeed= 1;}

p.lightType = LIGHT::NONE;
if (itsraining==true) {
jjTriggers[29] = true;
}
if (CountlessDoubleJumps > jjGameTicks && p.keyJump) {
	p.doubleJumpCount = 0;}
if (p.health == 0){
	CountlessDoubleJumps  = 0;
}

	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ o = jjObjects[i];
		if (o.isActive && o.eventID == OBJECT::SEEKERAMMO3 && p.ammo[WEAPON::SEEKER] < 1) {
			o.state = STATE::KILL;}
	}
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ o = jjObjects[i];
		if (o.isActive && o.eventID == OBJECT::RFAMMO3 && p.ammo[WEAPON::RF] < 1) {
			o.state = STATE::KILL;}
	}
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ o = jjObjects[i];
		if (o.isActive && o.eventID == OBJECT::TNTAMMO3 && p.ammo[WEAPON::TNT] < 1) {
			o.state = STATE::KILL;}
	}
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ o = jjObjects[i];
		if (o.isActive && o.eventID == OBJECT::GUN9AMMO3 && p.ammo[WEAPON::GUN9] < 1) {
			o.state = STATE::KILL;}
	}
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ o = jjObjects[i];
		if (o.isActive && o.eventID == OBJECT::SEEKERPOWERUP && p.ammo[WEAPON::SEEKER] < 1) {
			o.state = STATE::KILL;}
	}
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ o = jjObjects[i];
		if (o.isActive && o.eventID == OBJECT::RFPOWERUP && p.ammo[WEAPON::RF] < 1) {
			o.state = STATE::KILL;}
	}
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ o = jjObjects[i];
		if (o.isActive && o.eventID == OBJECT::TNTPOWERUP && p.ammo[WEAPON::TNT] < 1) {
			o.state = STATE::KILL;}
	}
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ o = jjObjects[i];
		if (o.isActive && o.eventID == OBJECT::GUN9POWERUP && p.ammo[WEAPON::GUN9] < 1) {
			o.state = STATE::KILL;}
	}

	if(p.keyUp && p.xPos > 117*32 && p.xPos < 118*32 && p.yPos < 48*32 && p.yPos >45*32) {
		p.timerStart(660);
		Switch2 = 0; 
		Switch19 = jjGameTicks + 11*61;
		p.cameraFreeze(164*32, 36*32, true, false);
		jjTriggers[19] = true;
		jjTriggers[1] = false;
		jjTriggers[2] = false;
		jjTriggers[18] = false;
		jjSample(p.xPos, p.yPos, SOUND::INTRO_MONSTER2);
	}
	if(Switch19 <jjGameTicks) 
		{jjTriggers[19] = false;}


	if(Switch7 < jjGameTicks) {
		jjTriggers[7] = false;
		for (int i = 1; i < jjObjectCount; i++) { 
			jjOBJ@ o = jjObjects[i];
			if (o.isActive && o.eventID == OBJECT::FRUITPLATFORM) 
				{o.delete();}
		}				
	}
	
	if(p.keyUp && p.xPos > 112*32 && p.xPos < 113*32 && p.yPos < 48*32 && p.yPos >45*32) {
		p.timerStart(660);
		Switch1 = 0;
		Switch18 = jjGameTicks + 11*61;
		p.cameraFreeze(74*32, 38*32, true, false);
		jjTriggers[18] = true;
		jjTriggers[1] = false;
		jjTriggers[2] = false;
		jjTriggers[19] = false;
		jjSample(p.xPos, p.yPos, SOUND::INTRO_MONSTER2);
		}
	if(Switch18 <jjGameTicks) {
		jjTriggers[18] = false;
		}
	if(p.keyUp && p.xPos>16*32 && p.xPos<17*32 && p.yPos<31*32 && p.yPos >28*32) {
		p.timerStart(300);
		Switch4 = jjGameTicks + 5*61;
		p.cameraFreeze(18*32, 48*32, true, false);
		jjTriggers[4] = true;
		jjSample(p.xPos, p.yPos, SOUND::INTRO_MONSTER2);
		}	
	if(Switch4 <jjGameTicks) {
		jjTriggers[4] = false;
		}
	if(p.keyUp && p.xPos > 71*32 && p.xPos < 73*32 && p.yPos < 50*32 && p.yPos >45*32) {
		p.timerStart(660);
		Switch3 = jjGameTicks + 11*61;
		jjTriggers[3] = true;
		jjSample(p.xPos, p.yPos, SOUND::INTRO_MONSTER2);
		}
	if(Switch3 <jjGameTicks) {
		jjTriggers[3] = false;
		}
	if(p.keyUp && p.xPos > 119*32 && p.xPos < 120*32 && p.yPos < 48*32 && p.yPos >45*32) {
		p.timerStart(300);
		Switch19 = 0; 
		Switch2 = jjGameTicks + 5*61;
		p.cameraFreeze(161*32, 52*32, true, false);
		jjTriggers[2] = true;
		jjTriggers[1] = false;
		jjTriggers[19] = false;
		jjTriggers[18] = false;
		jjSample(p.xPos, p.yPos, SOUND::INTRO_MONSTER2);
		}
	if(Switch2 <jjGameTicks) {
		jjTriggers[2] = false;
		}
	if(p.keyUp && p.xPos > 110*32 && p.xPos < 111*32 && p.yPos < 48*32 && p.yPos >45*32) {
		p.timerStart(300);
		Switch18 = 0; 
		p.cameraFreeze(74*32, 54*32, true, false);
		Switch1 = jjGameTicks + 5*61;
		jjTriggers[1] = true;
		jjTriggers[18] = false;
		jjTriggers[2] = false;
		jjTriggers[19] = false;
		jjSample(p.xPos, p.yPos, SOUND::INTRO_MONSTER2);

		}		
	if(Switch1 <jjGameTicks) {
		jjTriggers[1] = false;	
		}

}


bool onDrawHealth(jjPLAYER@ player, jjCANVAS@ canvas) {
    canvas.drawSprite(20, 580, ANIM::PICKUPS, 80, jjGameTicks>>2, -1, SPRITE::NORMAL);
    canvas.drawString(30, 585, formatInt(exit%5, "1") + "/4", STRING::SMALL, STRING::NORMAL);
    return false;
}

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


void onMain() {
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); 
}
}

bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
	return MLLE::WeaponHook.drawAmmo(player, canvas);
}

void onReceive(jjSTREAM&in packet, int fromClientID) {
	MLLE::WeaponHook.processPacket(packet, fromClientID);
}

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;
        }
      }
    }
  }
}