Downloads containing mo4a_1-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, DefaultWeapons::Blaster(), DefaultWeapons::Blaster(), WeaponVMega::Backfire::Weapon(), null, DefaultWeapons::Blaster(), SzmolWeaponPack::PetrolBomb::Weapon(), DefaultWeapons::Blaster()}); ///@MLLE-Generated
#include "MLLE-Include-1.5w.asc" ///@MLLE-Generated
#pragma require "mo4a_1-4.j2l" ///@MLLE-Generated
#include "petrolBomb.asc" ///@MLLE-Generated
#pragma require "petrolBomb.asc" ///@MLLE-Generated
#include "WeaponVMega5.asc" ///@MLLE-Generated
#pragma require "WeaponVMega5.asc" ///@MLLE-Generated
#include "MLLE-DefaultWeapons.asc" ///@MLLE-Generated
#pragma require "MLLE-DefaultWeapons.asc" ///@MLLE-Generated
#include "HH18savegems.asc"
#include "Jazz1Enemies v05.asc"
#include "Resize v11.asc"
#include "TrueColor v13.asc"
int frozen = 0;
int CountlessDoubleJumps = 0; 
bool Boss=false, control = true;  
jjOBJ@ stolenbullets;


void onLevelLoad()  {	
	jjWaterLighting = WATERLIGHT::GLOBAL;
	gem::restorePlayerGems();
	jjLevelName = ("@@@@@@@@@Temple of Sun");
	jjObjectPresets[OBJECT::SAVEPOST].behavior = CheckpointWrapper;
	jjObjectPresets[OBJECT::SAVEPOST].deactivates = false;

	jjObjectPresets[OBJECT::GRASSPLATFORM].scriptedCollisions = true;
	jjObjectPresets[OBJECT::GRASSPLATFORM].behavior = SpikeBump();
	jjObjectPresets[OBJECT::GRASSPLATFORM].deactivates = false;

	jjObjectPresets[OBJECT::BOLLPLATFORM].energy = 8;
	jjObjectPresets[OBJECT::BOLLPLATFORM].behavior = Boulder();

	jjObjectPresets[OBJECT::ROTATINGROCK].behavior = FallingBoulder;
	jjObjectPresets[OBJECT::ROTATINGROCK].scriptedCollisions = true;

	jjObjectPresets[OBJECT::SPARK].behavior = Flame;
	jjObjectPresets[OBJECT::SPARK].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::SPARK].playerHandling = HANDLING::ENEMYBULLET;
	jjObjectPresets[OBJECT::SPARK].animSpeed = 1;
	jjObjectPresets[OBJECT::SPARK].state = STATE::FLOAT;
	jjObjectPresets[OBJECT::SPARK].lightType = LIGHT::POINT;
	jjObjectPresets[OBJECT::SPARK].points =0;
	jjObjectPresets[OBJECT::SPARK].light =55;
	jjObjectPresets[OBJECT::SPARK].isTarget=false;
	jjObjectPresets[OBJECT::SPARK].scriptedCollisions=true;
	
	jjObjectPresets[OBJECT::BILSY].energy = 100;
	jjObjectPresets[OBJECT::BILSY].behavior = FlamingTotem();
	jjObjectPresets[OBJECT::BILSY].bulletHandling = HANDLING::HURTBYBULLET;
	jjObjectPresets[OBJECT::BILSY].state = STATE::FLOAT;
	jjObjectPresets[OBJECT::BILSY].deactivates = false;
	jjObjectPresets[OBJECT::BILSY].playerHandling = HANDLING::ENEMY;
	jjObjectPresets[OBJECT::BILSY].scriptedCollisions = true;

	jjObjectPresets[OBJECT::TUFTURT].behavior = Tuf;
	jjObjectPresets[OBJECT::TUFTURT].determineCurAnim(ANIM::TUFBOSS, 5);
	jjObjectPresets[OBJECT::TUFTURT].playerHandling = HANDLING::ENEMY;
	jjObjectPresets[OBJECT::TUFTURT].bulletHandling = HANDLING::HURTBYBULLET;
	jjObjectPresets[OBJECT::TUFTURT].energy = 30;
	jjObjectPresets[OBJECT::TUFTURT].deactivates = false;

	jjObjectPresets[OBJECT::TACO].behavior = Ammo();
	jjObjectPresets[OBJECT::TACO].scriptedCollisions = true;

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

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

	jjObjectPresets[OBJECT::TURTLESHELL].behavior = Key4();
	jjObjectPresets[OBJECT::TURTLESHELL].scriptedCollisions = true;

	Jazz1::MakeEnemy(OBJECT::FLOATSUCKER, Jazz1::Enemies::Jungrock_RedBuzzer).SetUsesJJ2StyleDeathAnimation(true);
	Jazz1::MakeEnemy(OBJECT::LIZARD, Jazz1::Enemies::Holidaius_SnowMonkey).SetUsesJJ2StyleDeathAnimation(true);
	Jazz1::MakeEnemy(OBJECT::SUCKER, Jazz1::Enemies::Turtemple_ScorpWeenie).SetUsesJJ2StyleDeathAnimation(true);
	Jazz1::MakeEnemy(OBJECT::HATTER, Jazz1::Enemies::Crysilis_LooGuard).SetUsesJJ2StyleDeathAnimation(true).SetBulletFireSound(SOUND::BUBBA_FROG2).SetBulletExplosionSound(SOUND::COMMON_GUNSM1);

	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::FASTFEET].behavior = CountlessJumps();
	jjObjectPresets[OBJECT::FASTFEET].scriptedCollisions = true;

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

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

}
bool fall = false; 
void FallingBoulder(jjOBJ@ obj) {
	if(fall == true){
		obj.behave(BEHAVIOR::ROTATINGROCK, false);
		obj.beSolid();
		}
	if(obj.ySpeed >0 && jjTriggers[3]==false)
	{p.cameraFreeze(64*32, 50*32,true,false);
	control = false;}
	if(obj.yPos>49*32)
		{if(jjTriggers[3]==false)
			{jjAddObject(OBJECT::ELECTROBULLET, 62*32, 51*32);}
		jjTriggers[3] = true;
		control = true;
		p.cameraUnfreeze();
		obj.delete();
		jjSample(obj.xPos, obj.yPos, SOUND::ROCK_ROCK1, 1000);}
	if(obj.xPos<52*32 && obj.yPos >46*32)
		{jjAddObject(OBJECT::BOLLPLATFORM, 1750, 849);
		obj.delete();
		jjTriggers[4] = false;}
	
	if(obj.yPos > 53*32)
		{obj.delete();
		obj.behave(BEHAVIOR::EXPLOSION2);}
		obj.determineCurAnim(ANIM::BOLLPLAT, 0);
		obj.determineCurFrame();

		jjDrawResizedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, 2, 2, SPRITE::PALSHIFT, 16);
		
		
}

int spring = 0;
bool spike = false;
class SpikeBump : jjBEHAVIORINTERFACE {

void onBehave(jjOBJ@ obj) {

	switch (obj.state) {
		case STATE::START:
			obj.determineCurFrame();
			obj.state = STATE::FLY;
			obj.direction = obj.xSpeed = 2;

		case STATE::FLY:
			obj.playerHandling = HANDLING::SPECIAL;
			obj.xPos = obj.xPos + obj.xSpeed;
			obj.deactivates = false;
			if (jjMaskedVLine(obj.xSpeed > 0 ? obj.xPos + 16 : obj.xPos - 16, obj.yPos, 1)) {
				obj.direction = obj.xSpeed = -obj.xSpeed;
			}
			
			if(obj.xPos > p.xPos + 64 || obj.xPos < p.xPos - 64 || obj.yPos > p.yPos + 64 || obj.yPos < p.yPos - 64)
			{obj.determineCurAnim(ANIM::BOLLPLAT, 0); 
			jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, -8);
			obj.determineCurFrame();}
			else {jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, -24);}
			break;

		
	}
}

	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ play, int force) { 
		if(bullet is null && play !is null && (force == -1 || force == 1))
			{spring = jjGameTicks + 1*61;
			obj.determineCurAnim(ANIM::BOLLPLAT, 0); 
			jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, -24);
			obj.determineCurFrame();
			p.buttstomp = 121;
			jjSample(obj.xPos, obj.yPos, SOUND::PINBALL_BELL, 1000);}
		if(force == 0 && spring < jjGameTicks)
			{play.hurt();
			obj.determineCurAnim(ANIM::SPIKEBOLL, 0);   
			obj.determineCurFrame();
			if(spike == false)
			{jjSample(obj.xPos, obj.yPos, SOUND::COMMON_METALHIT, 1000);}
			spike = true;}
		return true;
		}

}


class Boulder : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		if(jjTriggers[3]==true)
			{obj.delete();}
		obj.determineCurAnim(ANIM::BOLLPLAT, 0);
		obj.bulletHandling = HANDLING::HURTBYBULLET;
		obj.beSolid();
		obj.determineCurFrame();
		obj.behave(BEHAVIOR::PLATFORM, false);
		if(obj.justHit == 0)
		{jjDrawResizedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, 2, 2, SPRITE::PALSHIFT, 16);}
		else {jjDrawResizedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, 2, 2, SPRITE::BRIGHTNESS, 200);}
		if(obj.energy == 0) 
		{jjAddObject(OBJECT::ROTATINGROCK, obj.xPos, obj.yPos);
		jjTriggers[4] = true;
		p.showText("@@It's free.@Now it's needs one last push.");
		jjSample(obj.xPos, obj.yPos, SOUND::ROCK_ROCK1, 1000);
		fall = true;
		obj.behave(BEHAVIOR::EXPLOSION2);}


	}
}


class Ammo : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PICKUP, false);
		obj.lightType = LIGHT::LASER;
		obj.light = 100;
	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::WEENIE].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP pump(0, 3*32, 1*32, 1*32, 5);
	pump.save(frame);
		++obj.counter; 
		obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
		obj.determineCurAnim(ANIM::AMMO, 22);
		obj.determineCurFrame();
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) { 
		p.noFire = false;
		jjTriggers[6] = true;
		obj.behave(BEHAVIOR::EXPLOSION2);
		obj.delete();
		jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PICKUPW1, 1000);

		return true;
	}
}

class TimeFreezer : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PICKUP);
		obj.lightType = LIGHT::LASER;
		obj.light = 100;

}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ p, int force) {		
		jjNxt();
		gem::saveGemData();
		jjTriggers[25] = true;
		obj.behavior = BEHAVIOR::EXPLOSION2;
		jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);

		return true;
	}
}

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, 80*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, 80*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 CountlessJumps : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.deactivates = true;
		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);
		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 Key : jjBEHAVIORINTERFACE {

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

		return true;
	}
}


class Key2 : jjBEHAVIORINTERFACE {

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

		return true;
	}
}

class Key4 : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PICKUP, false);

jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::TURTLESHELL].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP pump(0, 3*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[30] = true;
		obj.behavior = BEHAVIOR::EXPLOSION2;
		jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);

		return true; 
	}
}


void onFunction0(jjPLAYER@ p) {
	if(jjTriggers[4]==false)
	p.showText("@@Doesn't move.@It has chained.");
}

void onFunction1(jjPLAYER@ p) {
		jjMusicLoad("mo4a_ The Lava Stream (Reprise 2).ogg");
		p.bossActivated = false;
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ o = jjObjects[i]; jjOBJ@ ob = jjObjects[i];
		if (o.isActive && o.eventID == OBJECT::DEMON){
			o.state = STATE::KILL;	o.delete();}
		if (ob.isActive && ob.eventID == OBJECT::FENCER){
			ob.state = STATE::KILL; ob.delete();}
	}
}

bool heavytext = false;

void onFunction2(jjPLAYER@ p) {
	if(jjTriggers[3]==false && heavytext == false)
		{p.showText("@@No switches around...@Maybe I can break the trapdoor@with a heavy object.");
		heavytext = true;}
}

void onFunction3(jjPLAYER@ p) {
		p.timerStop();
		CountlessDoubleJumps = 0;
		jjTriggers[1] = true;
}


void onFunction6(jjPLAYER@ p) {
		jjMusicLoad("mo4a_Doc's Cave.ogg");
		p.activateBoss();
		jjTriggers[13] = true;
		p.cameraFreeze(119*32, 88*32, true, false);
		jjEnabledASFunctions[6] = false;
}

void onFunction5(jjPLAYER@ p) {
		
		jjMusicLoad("mo4a_Doc's Cave.ogg");}

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 startrush = false, readytorush = false;

void onPlayer(jjPLAYER@ p) {

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

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

	gem::trackPlayerGems(p);
	gem::upgradeHealth(p);
	if(p.coins == 0)
		{p.coins += 3;}
	if(spring > jjGameTicks)
		{p.ySpeed = -10;}

	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(frozen > jjGameTicks)
{p.direction =-1;
p.keyUp = p.keyDown = p.keyLeft = p.keyRight = p.keyRun = false;}




p.lightType = LIGHT::NONE;
if (CountlessDoubleJumps > jjGameTicks && p.keyJump) {
	p.doubleJumpCount = 0;}
if (p.health == 0){
	CountlessDoubleJumps  = 0;
}


if (p.yPos > jjWaterLevel) {
p.health = 0;}
 

	if(p.keyUp && p.xPos > 33*32 && p.xPos < 35*32 && p.yPos <38*32 && p.yPos >35*32) {
		if(jjTriggers[18]==false)
		{jjSample(p.xPos, p.yPos, SOUND::INTRO_MONSTER2);
		jjTriggers[18] = true;
		p.cameraFreeze(64*32, 105*32, true, false);
		control = false;}
		}

	if(p.keyUp && p.xPos > 78*32 && p.xPos < 82*32 && p.yPos <28*32 && jjTriggers[5]==false) {
		jjTriggers[5] = true;
		jjSample(p.xPos, p.yPos, SOUND::INTRO_MONSTER2);
		}

		

}
int i, c=0,u=0;


void Tuf(jjOBJ@ enemy) {
	if (enemy.energy <= 0) {
		enemy.state = STATE::KILL;
		p.showText("@@Wait! What?");
		jjTriggers[17] = true;
		enemy.delete();
		{p.boss=jjAddObject(OBJECT::BILSY, 119*32, 88*32);}
		jjOBJ@ boss = jjObjects[p.boss];
		}
	else	{enemy.behave(BEHAVIOR::TUFBOSS);}
}

class FlamingTotem : jjBEHAVIORINTERFACE {

	void onBehave(jjOBJ@ boss) { 
	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::BILSY].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP totem(0, 6*32, 1*32, 2*32, 5);
	totem.save(frame);
	boss.lightType = LIGHT::FLICKER;

	if (boss.energy <=0) 
		{boss.state = STATE::KILL;
		boss.delete(); 
		jjTriggers[20] = true;
	}
			boss.xPos = jjSin(boss.counter*2)*170 + boss.xOrg;
			boss.yPos = jjSin(boss.counter*4)*40 + boss.yOrg;		

	if (boss.energy > 0) switch (boss.state) {
		case STATE::FLOAT:
			++boss.counter;


			boss.determineCurFrame();	
			//if (boss.findNearestPlayer(4096*3040) > -1) 
			if (++boss.counter > 900) 
				{boss.state = STATE::ATTACK;}
			break;

	 case STATE::ATTACK:

	 ++boss.counter;
	 if (boss.counter == 1)
	 {jjSample(boss.xPos, boss.yPos, SOUND::INTRO_GREN1);}
	 
	 boss.direction = (p.xPos < boss.xPos) ? -1 : 1;

	 	if (jjRandom() & 1 == 0 && jjDifficulty<3) {

	jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::NORMAL);
		frame.hotSpotX = -1;
			jjOBJ@ obj = jjObjects[boss.fireBullet(OBJECT::SPARK)];
			obj.determineCurAnim(ANIM::AMMO,55);
			 jjSample(obj.xPos, obj.yPos, SOUND::SONCSHIP_SHIPLOOP);
			obj.determineCurFrame();	
			obj.yPos = boss.yPos+50;
			obj.xPos = boss.xPos;
		}


		boss.determineCurFrame();
		boss.frameID = boss.counter/50;
		boss.counter += 5; 
		
		boss.xPos = jjSin(boss.counter/3*c)*3*c + boss.xPos; 
		boss.yPos = jjCos(boss.counter/2*c)*c + boss.yPos;

	
	if (++boss.counter > 3000) 
	{
	boss.xAcc= boss.yAcc =0;
	boss.state = STATE::ACTION;
	boss.counter =0; }	
		
		
	break;	
	
	case STATE::ACTION:
		if (++boss.counter < 100) {

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

	jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::TRANSLUCENTPALSHIFT, -8);
	{jjSample(boss.xPos, boss.yPos, SOUND::COMMON_LOADJAZZ);}

		boss.frameID = boss.counter / 20;
		boss.determineCurFrame();		
		boss.yPos = jjSin(boss.counter*9)*60 + boss.yOrg;} 
	else {
		{boss.state = STATE::FLOAT;}
		boss.counter=0;
		}
		
		break;

	}
	boss.draw();
	}

}
	
	void Flame(jjOBJ@ enemy) {
	if (enemy.state== STATE::FLOAT) {
		enemy.behave(BEHAVIOR::SPARK);
		++enemy.counter;
		if (enemy.counter >200)
				enemy.delete();
	} else
		enemy.delete();
	
	}





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

bool onDrawHealth(jjPLAYER@ player, jjCANVAS@ canvas) {

    return false;
}

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

void onLevelReload() {
	gem::restorePlayerGems();
	jjLocalPlayers[0].lives++;
	jjEnabledASFunctions[20] = true; 
	jjWaterLighting = WATERLIGHT::GLOBAL;
	jjEnabledASFunctions[6] = true;
	for (uint i = 0; i < 32; ++i)
	jjTriggers[i] = SavedTriggers[i]; //although this example uses jjTriggers, other things should work as well

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

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