Downloads containing saldr5.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Devan's Revenge (Intro)Featured Download sAlAmAnDeR Single player 9.6 Download file

File preview

#include "SaLLiB-v2.0.asc"
#include "saldr-common.asc"

void onLevelLoad() {
	jjObjectPresets[OBJECT::DEMON].determineCurAnim(ANIM::DEMON,0);
	jjObjectPresets[OBJECT::DEMON].determineCurFrame();
	jjObjectPresets[OBJECT::BILSY].determineCurAnim(ANIM::BILSBOSS,4);
	jjObjectPresets[OBJECT::BILSY].determineCurFrame();
	jjObjectPresets[OBJECT::DEVILDEVAN].determineCurAnim(ANIM::DEVILDEVAN,5);
	jjObjectPresets[OBJECT::DEVILDEVAN].determineCurFrame();
	jjObjectPresets[OBJECT::FISH].determineCurAnim(ANIM::BIRD3D,0);
	jjObjectPresets[OBJECT::FISH].determineCurFrame();
	jjObjectPresets[OBJECT::RAVEN].determineCurAnim(ANIM::RAVEN,0);
	jjObjectPresets[OBJECT::RAVEN].determineCurFrame();
}

void onLevelBegin() {
	jjSetFadeColors(255,192,0);
	jjPalette.gradient(255, 255, 128, 128, 32, 0, 176, 32);
	jjPalette.apply();

	for(uint i = 0; i < 20; i++) {
		DemonNPC@ demon = @DemonNPC(40*32-24*i,25*32);
		demon.direction = 1;
		demon.charge();
		demon.playerHandling = HANDLING::ENEMY;
		demons.insertLast(demon);
	}
	
	@lotrfan = @RabbitNPC(CHAR::SPAZ,55.4*32,20.7*32);
	lotrfan.becomeLotrfan();
	lotrfan.ledgeAnim();
	lotrfan.direction = -1;
	
	@dog = @RabbitNPC(CHAR::SPAZ,58*32,24.5*32);
	dog.becomeDog();
	dog.direction = -1;
	dog.poseAnim();
	
	@noob = @RabbitNPC(CHAR::SPAZ,59*32,19.8*32);
	noob.becomeNoob();
	noob.direction = -1;
	noob.hangVineAnim();
	
	p.cameraFreeze(42*32,12*32,false,true);
	p.ammo[2]=50;
	
	CUSTOM::UI.drawAmmo = false;
	CUSTOM::UI.drawLives = false;
	CUSTOM::UI.drawScore = false;
	CUSTOM::UI.drawHealth = false;
	CUSTOM::UI.drawPlayerTimer = false;
	
	//jjLocalPlayers[0].xPos = -32;
	//jjLocalPlayers[0].yPos = -32;
	//jjLocalPlayers[0].xSpeed = -1;
	//jjLocalPlayers[0].ySpeed = -1;
}

RabbitNPC@ lotrfan;
RabbitNPC@ dog;
RabbitNPC@ noob;
array<DemonNPC@> demons();
BirdNPC@ bird;

enum State {
	DIALOGUE,
	BIRDINIT,
	BIRDENTERFRONT,
	BIRDFIGHT,
	BIRDEXPLOSION,
	PAUSE,
	INIT,
	APPROACH,
	LOL,
	DEVANARRIVE,
	FIREBREATH,
	FIREBREATH2,
	DEMONSRUN,//When a good man goes to war
	DEVANREVERT,
	DEVANSHRINK,
	DEVANSTARTFALL,
	DEVANFALL,
	DEVANSTAND,
	DEVANLEAVE
}

class ExplosionCascade : CUSTOM::Object {
	private int size;
	bool exploded = false;
	
	ExplosionCascade(float xPos, float yPos, int size) {
		super(NIL,xPos,yPos);
		this.size = size;
		spriteScaleX = size+4;
		spriteScaleY = size+4;
		spriteLayerZ = 3;
		playAnimation(ANIM::AMMO,5,0,12,7,false);
	}
	
	void behavior() {
		CUSTOM::Object::behavior();
		if(!isPlayingAnimation()) {
			delete();
			return;
		}
		if(frame > 1 && !exploded && size >= 1) {
			exploded = true;
			int offset = 64;
			ExplosionCascade(xPos+offset,yPos+offset,size-1);
			ExplosionCascade(xPos-offset,yPos+offset,size-1);
			ExplosionCascade(xPos+offset,yPos-offset,size-1);
			ExplosionCascade(xPos-offset,yPos-offset,size-1);
		}
		
	}
}

State state = BIRDINIT;
//State state = INIT;
array<NPC@> birds();
COMMON::Timer timer();
array<GAME::Speech@> chat();
GAME::Dialogue@ dialogue;
DevilDevanNPC@ devan;

RavenNPC@ makeRaven(float xPos = 40*32,float yPos = 12*32) {
	float scale = random(0,1);
	float y = random(yPos,yPos+15*32);
	RavenNPC@ raven = RavenDOA(xPos,y);
	raven.direction = 1;
	raven.spriteScaleX = scale;
	raven.spriteScaleY = scale;
	if(scale < .4) raven.spriteLayerZ = 8;
	else if(scale < .7) raven.spriteLayerZ = 7;
	else raven.spriteLayerZ = 8;
	raven.moveLinear(xPos+25*32,y,int(750-(scale * 500)));
	return raven;
}

void onMain() {
	p.ballTime = 1;
	if(jjGameTicks % 20 == 0) {
			makeRaven(71*32,0*32);
			makeRaven();
		}
	if(state == BIRDINIT) {
		p.cameraFreeze(71*32,0*32,false,true);
		state = BIRDENTERFRONT;
		@bird = @BirdNPC(81*32,7*32);
		bird.fly3D();
		bird.spriteScaleX = 40;
		bird.spriteScaleY = 40;
		bird.scaleDeccelerate(40,0,500,1.1);
		
		BirdNPC@ bird2 = @BirdNPC(11*32,11*32);
		bird2.fly3D();
		bird2.spriteScaleX = 40;
		bird2.spriteScaleY = 40;
		bird2.scaleDeccelerate(40,0,500,1.1);
		bird2.moveDeccelerate(11*32,11*32,79*32,8*32,500,1.1);
		
		BirdNPC@ bird3 = @BirdNPC(161*32,11*32);
		bird3.fly3D();
		bird3.spriteScaleX = 40;
		bird3.spriteScaleY = 40;
		bird3.scaleDeccelerate(40,0,500,1.1);
		bird3.moveDeccelerate(161*32,11*32,83*32,8*32,500,1.1);
	} else if(state == BIRDENTERFRONT) {
		if(bird.spriteScaleX == 0) {
			state = BIRDFIGHT;
			@bird = @BirdNPC(92*32,7*32);
			bird.direction = -1;
			bird.moveLinear(71*32,7*32,210);
			birds.insertLast(bird);
			
			BirdNPC@ bird2 = @BirdNPC(94*32,5*32);
			bird2.direction = -1;
			bird2.moveLinear(73*32,5*32,210);
			birds.insertLast(bird2);
			
			BirdNPC@ bird3 = @BirdNPC(96*32,3*32);
			bird3.direction = -1;
			bird3.moveLinear(75*32,3*32,210);
			birds.insertLast(bird3);
			
			BirdNPC@ bird4 = @BirdNPC(94*32,9*32);
			bird4.direction = -1;
			bird4.moveLinear(73*32,9*32,210);
			birds.insertLast(bird4);
			
			BirdNPC@ bird5 = @BirdNPC(96*32,11*32);
			bird5.direction = -1;
			bird5.moveLinear(75*32,11*32,210);
			birds.insertLast(bird5);
			
			RavenNPC@ raven = @RavenNPC(71*32,7*32);
			raven.direction = 1;
			raven.moveLinear(91*32,7*32,210);
			birds.insertLast(raven);
			
			RavenNPC@ raven2 = @RavenNPC(69*32,5*32);
			raven2.moveLinear(89*32,5*32,210);
			birds.insertLast(raven2);
			
			RavenNPC@ raven3 = @RavenNPC(67*32,3*32);
			raven3.moveLinear(87*32,3*32,210);
			birds.insertLast(raven3);
			
			RavenNPC@ raven4 = @RavenNPC(69*32,9*32);
			raven4.moveLinear(89*32,9*32,210);
			birds.insertLast(raven4);
			
			RavenNPC@ raven5 = @RavenNPC(67*32,11*32);
			raven5.moveLinear(87*32,11*32,210);
			birds.insertLast(raven5);
			state = BIRDFIGHT;
		}
	} else if(state == BIRDFIGHT) {
		if(bird.xPos < 81*32) {
			state = BIRDEXPLOSION;
			ExplosionCascade(81*32,7*32,4);
		}
	} else if(state == BIRDEXPLOSION) {
		if(!bird.isMoving()) {
			for(uint i = 0; i < birds.length(); i++) {
				birds[i].delete();
			}
			state = PAUSE;
			timer.start(500);
		}
	} else if(state == PAUSE) {
		if(jjGameTicks % 20 == 0) {
			makeRaven(71*32,0*32);
			makeRaven();
		}
		if(timer.isFinished()) {
			state = INIT;
		}
	} else if(state == INIT) {
		p.cameraFreeze(42*32,12*32,false,true);
		state = APPROACH;
		for(uint i = 0; i < demons.length(); i++)
			demons[i].moveLinear(51*32-24*i,25*32-20,140);
	} else if(state == APPROACH) {
		if(jjGameTicks % 20 == 0) makeRaven();
		bool done = false;
		for(uint i = 0; i < demons.length; i++) {
			if(!demons[i].isMoving()) {
				demons[i].stand();
				state = DIALOGUE;
				done = true;
			}
		}
		if(done) {
			chat.insertLast(GAME::Speech(lotrfan,		"|||Stop foul creatures!",     6*32));
			chat.insertLast(GAME::Speech(lotrfan,		"|||YOU SHALL NOT PASS!",      6*32));
			@dialogue = @GAME::DialogueScaledDelay(chat);
		}
	} else if(state == DIALOGUE) {
		if(jjGameTicks % 20 == 0) makeRaven();
		if(!dialogue.isActive) {
			state = DEVANARRIVE;
			@devan = DevilDevanNPC(36*32,20*32);
			devan.spriteScaleX = 2;
			devan.spriteScaleY = 2;
			devan.direction = 1;
			devan.moveLinear(49*32,20*32,300);
		}
	} else if(state == DEVANARRIVE) {
		if(jjGameTicks % 20 == 0) makeRaven();
		if(!devan.isMoving()) {
			state = FIREBREATH;
			devan.startFireBreath();
		}
	} else if(state == FIREBREATH) {
		if(jjGameTicks % 20 == 0) makeRaven();
		if(!devan.isPlayingAnimation()) {
			devan.fireBreathPause();
			state = FIREBREATH2;
			timer.start(300);
		}
	} else if(state == FIREBREATH2) {
		if(jjGameTicks % 20 == 0) makeRaven();
		if(timer.elapsedTime()%2 == 0) {
			Firebreath@ fire = @Firebreath(devan.xPos+96,devan.yPos-16,int(random(0,256)));
			fire.spriteScaleX = 3;
			fire.spriteScaleY = 3;
			fire.direction = 1;
		}
		if(timer.isFinished()) {
			devan.fly();
			state = DEMONSRUN;
			noob.particlePixelExplosion(1);
			noob.delete();
			lotrfan.particlePixelExplosion(1);
			lotrfan.delete();
			dog.particlePixelExplosion(1);
			dog.delete();
			jjAddParticleTileExplosion(55,24,26,false);
			jjAddParticleTileExplosion(55,23,26,false);
			jjAddParticleTileExplosion(55,22,26,false);
			jjAddParticleTileExplosion(55,21,26,false);
			jjAddParticleTileExplosion(55,20,17,false);
			
			jjAddParticleTileExplosion(51,24,66,false);
			jjAddParticleTileExplosion(52,24,66,false);
			jjAddParticleTileExplosion(53,24,66,false);
			jjTriggers[1] = true;
			
			for(uint i = 0; i < demons.length(); i++) {
				demons[i].charge();
				demons[i].moveLinear(demons[i].xPos+27*32,demons[i].yPos,300);
			}
		}
	} else if(state == DEMONSRUN) {
		if(jjGameTicks % 20 == 0) makeRaven();
		if(!demons[0].isMoving()) {
			state = DEVANREVERT;
			devan.revertUntilFall();
		}
	} else if(state == DEVANREVERT) {
		if(jjGameTicks % 20 == 0) makeRaven();
		if(!devan.isPlayingAnimation()) {
			devan.scaleLinear(2,1,70);
			devan.aboutToFall();
			state = DEVANSHRINK;
		}
	} else if(state == DEVANSHRINK) {
		if(jjGameTicks % 20 == 0) makeRaven();
		if(!devan.isScaling()) {
			devan.startFall();
			state = DEVANSTARTFALL;
		}
	} else if(state == DEVANSTARTFALL) {
		if(jjGameTicks % 20 == 0) makeRaven();
		if(!devan.isPlayingAnimation()) {
			devan.fall();
			devan.moveLinear(devan.xPos,24*32,70);
			state = DEVANFALL;
		}
	} else if(state == DEVANFALL) {
		if(jjGameTicks % 20 == 0) makeRaven();
		if(!devan.isMoving()) {
			devan.stand();
			timer.start(140);
			jjSamplePriority(SOUND::DEVILDEVAN_LAUGH);
			state = DEVANSTAND;
		}
	} else if(state == DEVANSTAND) {
		if(jjGameTicks % 20 == 0) makeRaven();
		if(timer.isFinished()) {
			devan.moveLinear(devan.xPos+15*32,devan.yPos,170);
			devan.run();
			state = DEVANLEAVE;
		}
	} else if(state == DEVANLEAVE) {
		if(jjGameTicks % 20 == 0) makeRaven();
		if(!devan.isMoving()) 
			jjNxt("saldr6.j2l",false,true);
	}
}