Downloads containing mo4a_4-5.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, null, 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-5.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 "HH18savegems.asc"

int i,u=1,c=1;
bool onDrawHealth(jjPLAYER@ player, jjCANVAS@ canvas) {
    return false;
}

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

void onLevelLoad() {
	gem::restorePlayerGems();
	jjLevelName = ("");
	jjObjectPresets[OBJECT::TUFBOSS].behavior = MegaBilsy();
	jjObjectPresets[OBJECT::TUFBOSS].energy = 100;
	jjObjectPresets[OBJECT::TUFBOSS].playerHandling = HANDLING::ENEMY;
	jjObjectPresets[OBJECT::TUFBOSS].bulletHandling = HANDLING::HURTBYBULLET;
	jjObjectPresets[OBJECT::TUFBOSS].deactivates = false;
	jjObjectPresets[OBJECT::TUFBOSS].scriptedCollisions = false;

	jjObjectPresets[OBJECT::DEMON].behavior = DemonGhost();
	jjObjectPresets[OBJECT::DEMON].scriptedCollisions = true;

	jjObjectPresets[OBJECT::BEES].behavior = FallingIce();
	jjObjectPresets[OBJECT::BEES].playerHandling = HANDLING::SPECIAL;
	jjObjectPresets[OBJECT::BEES].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::BEES].scriptedCollisions = true;
	jjObjectPresets[OBJECT::BEES].determineCurFrame();	

	jjObjectPresets[OBJECT::FIREBALLBULLET].playerHandling = HANDLING::ENEMY;

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

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

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

	jjObjectPresets[OBJECT::BILSY].behavior = DevanTank();
	jjObjectPresets[OBJECT::BILSY].playerHandling = HANDLING::SPECIAL;
	jjObjectPresets[OBJECT::BILSY].bulletHandling = HANDLING::HURTBYBULLET;
	jjObjectPresets[OBJECT::BILSY].determineCurFrame();
	jjObjectPresets[OBJECT::BILSY].scriptedCollisions = false;
	jjObjectPresets[OBJECT::BILSY].energy = 100;

	jjANIMATION@ tankAnim = jjAnimations[jjObjectPresets[OBJECT::BILSY].curAnim];

	for (uint i = 0; i < tankAnim.frameCount; ++i)
		jjAnimFrames[tankAnim.firstFrame + i].coldSpotY = -95;


}

bool DevanDefeated = false;

void onFunction1(jjPLAYER@ p){

		p.boss= jjAddObject(OBJECT::BILSY, 20*32, 12*32);
		jjOBJ@ boss = jjObjects[p.boss];
		p.bossActivated = true;
		jjEnabledASFunctions[1] = false;
}

class DevanTank : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::BILSY].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP tank(0, 24*32, 3*32, 3*32, 5);
	tank.save(frame);
	frame.hotSpotY = -102;
	frame.hotSpotX = -32;

	jjPLAYER@ play = jjLocalPlayers[0];
	if (obj.energy <=0) 
	{	obj.state = STATE::KILL;
		obj.behave(BEHAVIOR::EXPLOSION);
		obj.delete(); 
		DevanDefeated = true;
		p.boss= jjAddObject(OBJECT::TUFBOSS, 12*32, 3*32);
		jjOBJ@ boss = jjObjects[p.boss];
		p.bossActivated = true;
	}
		switch (obj.state) {
	case STATE::START:
	u=(jjRandom() & 3);
		obj.frameID = obj.counter/5;		
		obj.putOnGround(true);	
		obj.yPos = jjSin(10)*10 + obj.yPos;
	if (++obj.counter == 55){
		jjPARTICLE@ particle = jjAddParticle(PARTICLE::STRING);
		if (particle !is null) {
		particle.xPos = obj.xPos-20;
		particle.yPos = obj.yPos;
		}
		
		particle.ySpeed = -0.4;
		
	}	
		if ((obj.findNearestPlayer(600*600) > -1) && ++obj.counter > 55)
		{obj.state = STATE::WALK; obj.counter = 0;}
		break;
 	case STATE::WALK:
        obj.behave(BEHAVIOR::WALKINGENEMY);

        {

jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::BILSY].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP tankopen(0, 24*32, 3*32, 3*32, 5);
	tankopen.save(frame);
	frame.hotSpotY = -102;

		if (obj.counter >= 180)
		{obj.counter = 0; }
                obj.counter++;
                if (u==0||u==1)
                {if (++obj.counter < 165){
                        obj.xSpeed= (1)*obj.direction;
                        if (obj.counter == 10){
                        jjSample(obj.xPos, obj.yPos, SOUND::DEVILDEVAN_WINGSOUT);}
                        if (obj.justHit == 0)
			 
                        {jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);}
                        
						}
  else
                        {obj.frameID = obj.counter = 0;
                        obj.state = STATE::IDLE;}
                        }
                        else if (u==2||u==3)
                        {if (++obj.counter < 180){
                        obj.xSpeed= (2)*obj.direction;
			jjSample(obj.xPos, obj.yPos, SOUND::DEVILDEVAN_WINGSOUT);
                        }
                        else
                        {
                        obj.state = STATE::IDLE;}

						if (obj.justHit == 0)
                        {jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);}
                        
                        }

       
                break;
        }
	
		case STATE::ACTION:


		c=((jjRandom() & 5)-2.5);

		if (++obj.counter < 10) {
jjSample(obj.xPos, obj.yPos, SOUND::COMMON_METALHIT);
jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::BILSY].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP tank(0, 30*32, 3*32, 3*32, 5);
	tank.save(frame);
	frame.hotSpotY = -102;
obj.putOnGround(true);
jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);


			obj.determineCurFrame();		

			obj.frameID = obj.counter/5;
			jjOBJ@ bullet = jjObjects[jjAddObject(OBJECT::BOMB, obj.xPos + 25 * obj.direction, obj.yPos - 90, obj.creatorID, obj.creatorType)];
				bullet.playerHandling = HANDLING::SPECIAL;
				bullet.bulletHandling = HANDLING::IGNOREBULLET;
				bullet.state = STATE::FLY;
				bullet.ySpeed = -10;
					int xspeedd = (jjRandom() & 9);
					bullet.xSpeed = 6.2*obj.direction;
					int yspeedd = (jjRandom() & 6);
					bullet.ySpeed = yspeedd - 3;
					bullet.counterEnd = 55;



			
		} else {
	 {obj.state = STATE::IDLE;}
				obj.counter=0;
		}
		
		break;

	case STATE::FREEZE:
			if (obj.freeze > 0) {
				obj.draw();
				obj.freeze -= 4;
			}
			if (obj.freeze < 4) {
				obj.unfreeze(0);
				obj.state = obj.oldState;
			}
			break;
	case STATE::DEACTIVATE:
		obj.deactivate();
		break;
	case STATE::DONE:


		
		obj.frameID = obj.counter/20;
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
	++obj.counter;
	if (++obj.counter>89) {
	obj.energy = 100;}
			if (++obj.counter>90) {
	obj.state = STATE::START;

		obj.counter==0;			
		}
		break;

	case STATE::IDLE:
		obj.frameID = obj.counter/5;

obj.putOnGround(true);
		
		if (obj.justHit == 0)
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
		else 
		 
			if (obj.var[0] == 0) { obj.var[0] = 1; }
			switch (jjRandom() & 3) {
			
				case 0:
				
					obj.state = STATE::ATTACK;
					obj.counter = 0;
					break;
				
				case 1:
					obj.state = STATE::ACTION;
					obj.counter = 0;
					break;

				case 2:
					obj.state = STATE::WALK;
					obj.counter = 0;
					break;
				
					
			}
		
		break;

	case STATE::ATTACK:

		if (++obj.counter <20) {
if (++obj.frameID >= 0)

jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
obj.putOnGround(true);
		if(++obj.counter ==10)
{			obj.frameID = obj.counter/5;
					jjOBJ@ bullet = jjObjects[obj.fireBullet(OBJECT::FIREBALLBULLET)];
				
				bullet.killAnim = bullet.determineCurAnim(ANIM::AMMO, 4, false);
				bullet.playerHandling = HANDLING::ENEMYBULLET;
				bullet.bulletHandling = HANDLING::IGNOREBULLET;
				bullet.state = STATE::FLY;
				bullet.ySpeed = (-(jjRandom() & 2));
				bullet.xPos = obj.xPos+80*obj.direction;
				bullet.yPos = obj.yPos-65; 	
				bullet.animSpeed = 1;
				jjSample(obj.xPos, obj.yPos, SOUND::AMMO_FIREGUN2A, 6000);}
			
		} else {
			obj.state = STATE::IDLE;
		}
		break;
	}

obj.draw();
	
}
}

bool Boss = false;



int earth = 0;
int fire = 0;
int water = 0;


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


class DemonGhost: jjBEHAVIORINTERFACE {	

	void onBehave(jjOBJ@ obj) {
		if(fire < jjGameTicks)
			{obj.behavior = BEHAVIOR::BURNING;
			obj.delete();}
		else
			obj.behave(BEHAVIOR::WALKINGENEMY, false);
			obj.bulletHandling = HANDLING::IGNOREBULLET;
			obj.playerHandling = HANDLING::SPECIAL;
			obj.determineCurAnim(ANIM::DEMON, 2);
			jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::TRANSLUCENTSINGLEHUE, 72);
			obj.xSpeed = 5*obj.direction;
			if (jjMaskedVLine(obj.xSpeed > 0 ? obj.xPos + 16 : obj.xPos - 16, obj.yPos, 1))
			{obj.direction = obj.xSpeed = -obj.xSpeed;}
	}

	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ p, int force) {		
		if(p !is null && force >= -1)
			p.hurt();
		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();	
		jjSwitchTrigger(25);
		obj.behavior = BEHAVIOR::EXPLOSION2;
		jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);

		return true;
	}
}

bool startrush = false;
bool readytorush = false;

void onPlayer(jjPLAYER@ p) {

	gem::trackPlayerGems(p);
	gem::upgradeHealth(p);

	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 (p.idle > 5 && p.xPos >180*32 && (p.keyLeft || p.keyRight || p.keyJump || p.keyFire))
		{spike = false;}

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

}

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;

		case STATE::FLY:
			obj.playerHandling = HANDLING::SPECIAL;
			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 Lava : jjBEHAVIORINTERFACE {
void onBehave(jjOBJ@ obj) {
jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::FRUITPLATFORM].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP lava(0, 15*32, 29*32, 9*32, 5);
	lava.save(frame);
	frame.hotSpotX = -60;
		
switch (obj.state) {
		case STATE::START:
			obj.ySpeed = 0;
			obj.state = STATE::FLY;
			obj.beSolid();
			obj.yPos = 15*32;
		case STATE::FLY:
		++obj.counter; 
jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
			if(p.yPos==obj.yPos-32){
				p.health = 0;
}
		obj.xPos = jjSin(obj.counter*4)*4 + obj.xOrg;
		if(earth > jjGameTicks && obj.yPos > 13*32)
		{obj.ySpeed = -0.3;
		obj.yPos = obj.yPos + obj.ySpeed;}
		if(earth > jjGameTicks && obj.yPos < 13*32)
		{obj.ySpeed = -0.2;
		obj.yPos = obj.yPos + obj.ySpeed;}
		if(earth < jjGameTicks && obj.yPos <15*32)
		{obj.ySpeed = 6.5;
		obj.yPos = obj.yPos + obj.ySpeed;}		
		if(earth < jjGameTicks && obj.yPos == 15*32)
		{obj.state = STATE::START;
		obj.ySpeed = 0;}
		
			obj.beSolid();
			obj.deactivates = false;
		

			break;

	}

}
bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ play, int force) { 
p.health = 0;
return true;
}
}

class FallingIce : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ enemy) {
	if(water <jjGameTicks || water == 0)
	{enemy.deactivates = true;}

	else if(water > jjGameTicks) 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.playerHandling = HANDLING::ENEMY;
			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.playerHandling = HANDLING::ENEMY;
			objj.bulletHandling = HANDLING::IGNOREBULLET;
			objj.killAnim = jjObjectPresets[OBJECT::ICEBULLET].killAnim;
			objj.ySpeed = 6;
			objj.counterEnd = 100; }

	}
	jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::BEES].curAnim];
	anim.frameCount = 1;
	jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
	jjPIXELMAP pump(0, 28*32, 4*32, 2*32, 5);
	pump.save(frame);
	frame.hotSpotX = -32;
	if (enemy.justHit == 0)

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

}	
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ p, int force) {
	if(p !is null && force >= -1) {
	p.hurt();
	}
	return true;
	}
}






class MegaBilsy: jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ boss) {
	if(DevanDefeated == false)
	{boss.state == STATE::FLY;}	
	jjPLAYER@ play = jjLocalPlayers[0];
	if (boss.energy <= 0) {
	jjAddObject(OBJECT::FREEZEENEMIES, boss.xPos, boss.yPos-32);
		boss.state = STATE::KILL;
		boss.delete();
		}
		
	if(DevanDefeated == true) switch (boss.state) {
	case STATE::START:
	earth = 0;
	water = 0;
	fire = 0;
	 if (++boss.counter >= 0&&++boss.counter <= 400)
	 	{boss.determineCurFrame();
			boss.frameID = boss.counter/22;}
	boss.determineCurAnim(ANIM::BILSBOSS, 1);
	boss.direction = (jjLocalPlayers[0].xPos < boss.xPos) ? -1 : 1;
	 if (++boss.counter > 400&&++boss.counter <= 1200)
	{boss.determineCurFrame();
	boss.frameID = boss.counter/40;
	boss.determineCurAnim(ANIM::BILSBOSS, 4);}	
		

		
		boss.determineCurFrame();
		boss.frameID = boss.counter/5;
		if (boss.justHit == 0)
		jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::SINGLEHUE, 72);
		else boss.draw();
		boss.putOnGround(true);	
		

		
		if (++boss.counter > 600) {
		boss.state = STATE::IDLE; 
		boss.counter == 0;}
		break;
		
	case STATE::DONE:
	
		
			if (++boss.counter>100) {
			
	jjAddObject(OBJECT::FREEZEENEMIES, boss.xPos, boss.yPos);
		}
	break;
			case STATE::KILL:
	case STATE::DEACTIVATE:
		boss.deactivate();
		break;

	case STATE::IDLE:
		boss.frameID = boss.counter/5;
		boss.determineCurFrame();
		switch (jjRandom() & 3) {
		case 0:
			boss.state = STATE::FIRE; //fire
			boss.direction = (jjLocalPlayers[0].xPos < boss.xPos) ? -1 : 1;
			boss.determineCurAnim(ANIM::BILSBOSS, 0);
			if (boss.justHit == 0)
			jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::PALSHIFT, 0);
			else boss.draw();	
			boss.counter = 0;
			break;
		case 1:
			boss.state = STATE::ATTACK; //earth
			boss.direction = (jjLocalPlayers[0].xPos < boss.xPos) ? -1 : 1;
			boss.determineCurAnim(ANIM::BILSBOSS, 0);
			boss.counter = 0;
			if (boss.justHit == 0)
			jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::PALSHIFT, -8);
			else boss.draw();	
			break;
		case 2:
			boss.state = STATE::ACTION; //water
			boss.direction = (jjLocalPlayers[0].xPos < boss.xPos) ? -1 : 1;
			boss.determineCurAnim(ANIM::BILSBOSS, 0);
			if (boss.justHit == 0)
			jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::PALSHIFT, -8);
			else boss.draw();	
			boss.counter = 0;
			break;
}
		break;
	case STATE::FADEOUT:
		 if (++boss.counter < 50) {
			boss.frameID = boss.counter / 5;
			boss.determineCurAnim(ANIM::BILSBOSS, 2);			
			jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::SINGLEHUE, 72);
			boss.playerHandling = HANDLING::PLAYERBULLET;
			boss.bulletHandling = HANDLING::IGNOREBULLET;				
			boss.determineCurFrame();
			}
			if (++boss.counter == 1200) {

			boss.state = STATE::FADEIN;
			boss.playerHandling = HANDLING::ENEMY;
			boss.bulletHandling = HANDLING::HURTBYBULLET;			
			boss.xPos = boss.xAcc;
			boss.yPos = boss.yAcc - 10;
			boss.direction = (jjLocalPlayers[0].xPos < boss.xPos) ? -1 : 1;
			boss.determineCurFrame();
			boss.putOnGround(true);
			return;
		}
		break;
	case STATE::FADEIN:
		for (int i = 1; i < jjObjectCount; i++) { 
		jjOBJ@ o = jjObjects[i];
		if (o.isActive && o.eventID == OBJECT::GRASSPLATFORM) 
			{o.delete();}
		}
		if (++boss.counter < 40) {
			boss.frameID = boss.counter / 5;
			boss.determineCurFrame();
			jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::SINGLEHUE, 72);
		} else {

			boss.frameID = 0;
			boss.counter = 0;
			boss.state = STATE::START;

		}
		break;
	case STATE::FIRE:

		if (++boss.counter < 90) {
		if(++boss.counter > 70)
		{fire = jjGameTicks + 590;}
			if(boss.counter == 50){
			jjOBJ@ obj = jjObjects[boss.fireBullet(OBJECT::BLASTERBULLET)];
			obj.behavior = BEHAVIOR::BILSYBULLET;
			obj.determineCurAnim(ANIM::BILSBOSS, 3);
			jjSample(boss.xPos, boss.yPos, SOUND::AMMO_BMP2);
			obj.playerHandling = HANDLING::ENEMYBULLET;
			obj.bulletHandling = HANDLING::IGNOREBULLET;
			obj.yPos = boss.yPos -40;
			obj.xPos = boss.xPos + 1*boss.direction;
			obj.energy = 1;
			obj.xSpeed = -8*boss.direction;
				if (p.xPos < boss.xPos) obj.direction = -1;
				else obj.direction = 1;
				obj.ySpeed = 2;
			obj.counterEnd = 100;
				jjOBJ@ o = jjObjects[boss.fireBullet(OBJECT::FIREBALLBULLET)];
					o.bulletHandling = HANDLING::IGNOREBULLET;
					o.determineCurAnim(ANIM::AMMO, 15);
					o.lightType = LIGHT::POINT;
					o.xPos = boss.xPos-62*p.direction;
					o.yPos = boss.yPos-12; 	
					o.xAcc = .12;
					int xspeed = (jjRandom() & 3);
					o.xSpeed = xspeed*p.direction;
					int yspeed = (jjRandom() & 6);
					o.ySpeed = yspeed + 8* p.direction;
					o.counterEnd = 155; 
				jjOBJ@ ob = jjObjects[boss.fireBullet(OBJECT::FIREBALLBULLET)];
					ob.bulletHandling = HANDLING::IGNOREBULLET;
					ob.determineCurAnim(ANIM::AMMO, 15);
					ob.lightType = LIGHT::POINT;
					ob.xPos = 40;
					ob.yPos = boss.yPos-12; 	
					ob.xAcc = .12;
					ob.xSpeed = 20;
					int yyspeed = (jjRandom() & 4);
					ob.ySpeed = yyspeed + 8* p.direction;
					ob.counterEnd = 755; 
				jjOBJ@ objj = jjObjects[boss.fireBullet(OBJECT::FIREBALLBULLET)];
					objj.bulletHandling = HANDLING::IGNOREBULLET;
					objj.determineCurAnim(ANIM::AMMO, 15);
					objj.lightType = LIGHT::POINT;
					objj.xPos = 23*32;
					objj.yPos = boss.yPos-12; 	
					objj.xAcc = .12;
					objj.xSpeed = -20;
					int yyyspeed = (jjRandom() & 1);
					objj.ySpeed = yyyspeed + 8* p.direction;
					objj.counterEnd = 755; 
			}
				if(++boss.counter > 88)
					{jjAddObject(OBJECT::DEMON, 13*32, 9*32);}
		boss.frameID = boss.counter / 5;
		boss.determineCurFrame();
		if (boss.justHit == 0)
		{jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::PALSHIFT, 0);}
		else {boss.draw();}
		break;	
		}	
		else {
			boss.state = STATE::FADEOUT;
			if (boss.justHit == 0)
			{jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::PALSHIFT, 0);}
			else {boss.draw();}
			boss.counter = 0;
			boss.xAcc = play.xPos;
			boss.yAcc = play.yPos;
		}		
		break;	
	case STATE::ATTACK:
		if (++boss.counter < 90) {
			
		if(++boss.counter > 70)
		{earth = jjGameTicks + 580;}
			if(boss.counter == 50){
			jjAddObject(OBJECT::GRASSPLATFORM, 11*32, 9*32);
			jjOBJ@ obj = jjObjects[boss.fireBullet(OBJECT::BLASTERBULLET)];

			obj.determineCurAnim(ANIM::DEVILDEVAN, 17);
			jjSample(boss.xPos, boss.yPos, SOUND::AMMO_BMP2);
			obj.playerHandling = HANDLING::ENEMYBULLET;
			obj.bulletHandling = HANDLING::IGNOREBULLET;
			obj.yPos = boss.yPos -40;
			obj.xPos = boss.xPos + 1*boss.direction;
			obj.energy = 1;
			obj.ySpeed = 65;
			obj.xSpeed = -15*boss.direction;
				if (p.xPos < boss.xPos) obj.direction = -1;
				else obj.direction = 1;
				obj.ySpeed = 2;
			obj.counterEnd = 100;
			}
		boss.frameID = boss.counter / 5;
		boss.determineCurFrame();
		if (boss.justHit == 0)
		{jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::PALSHIFT, -8);}
		else {boss.draw();}
		break;	
		}	
		else {
			boss.state = STATE::FADEOUT;
			if (boss.justHit == 0)
			{jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::PALSHIFT, -8);}
			else {boss.draw();}
			boss.counter = 0;
			boss.xAcc = play.xPos;
			boss.yAcc = play.yPos;
		}		
		break;	
	case STATE::ACTION:
		if (++boss.counter < 90) {
		if(++boss.counter < 70)
		{water = jjGameTicks + 590;}
			if(boss.counter == 50){			
			jjOBJ@ obj = jjObjects[boss.fireBullet(OBJECT::BLASTERBULLET)];
			obj.behavior = BEHAVIOR::BULLET;
			obj.determineCurAnim(ANIM::PINKPLAT, 1);
			jjSample(boss.xPos, boss.yPos, SOUND::AMMO_BMP2);
			obj.playerHandling = HANDLING::ENEMYBULLET;
			obj.bulletHandling = HANDLING::IGNOREBULLET;
			obj.energy = 1;
			obj.points = 5;
			obj.ySpeed = -16;
			obj.counterEnd = 100;
			}

		boss.frameID = boss.counter / 5;
		boss.determineCurFrame();
		if (boss.justHit == 0)
		{jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::PALSHIFT, 8);}
		else {boss.draw();}
		break;	
		}	
		else {

			boss.state = STATE::FADEOUT;
			if (boss.justHit == 0)
			{jjDrawSpriteFromCurFrame(boss.xPos, boss.yPos, boss.curFrame, boss.direction, SPRITE::PALSHIFT, 8);}
			else {boss.draw();}
			boss.counter = 0;
			boss.xAcc = play.xPos;
			boss.yAcc = play.yPos;
		}		
		break;	

}
}


}

void onLevelReload(){
	gem::restorePlayerGems();
	jjLocalPlayers[0].lives++;
	earth = 0;
	fire = 0;
	water = 0;
	DevanDefeated = false;
	Boss = false;
	jjEnabledASFunctions[1] = true;
}


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

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