Downloads containing H-survival1.j2as

Downloads
Name Author Game Mode Rating
JJ2+ Only: Survival Mission 1 hafial Single player 6.8 Download file

File preview

//H-survival1 script by Hafial

jjPAL daytime;
bool alertDialog = false;
bool deactivatedDialog = false;
bool paused = false;
bool dialogStarter = true;
bool briefingDialog = false;
uint elapsed = 0;

void sendChat(string sender, string text) {
	jjAlert("" + sender + "  " + text);
}

void onLevelReload() {
	elapsed = 0;
	dialogStarter = true;
}

void onPlayerInput(jjPLAYER@ p) {
	if (paused) {
		p.keyUp = p.keyDown = p.keyRight = p.keyLeft = p.keyFire = p.keyJump = false;
		p.keyRun = true;
		}
		if (briefingDialog == true && elapsed > 1050 && elapsed < 1150) {
			p.keyRun = false;
			p.keyLeft = true;
		}
}

void onPlayer(jjPLAYER@ p) {
		p.jumpStrength = -15;
		p.fastfire = 5;
		p.food = 100;
		
	if (dialogStarter == true) {
		switch (elapsed) {
			case 1:
				paused = true;
				sendChat("||||||Radio:|||||||", "Now, your mission is shut down the power generator.");
				break;
			case 200:
				sendChat("||||||Radio:|||||||", "You must survive from this area because there isn't savepoint.");
				break;
			case 450:
				sendChat("||||||You:|||||||", "OK, i can do my best to do it!");
				break;
			case 451:
				dialogStarter = false;
				paused = false;
				break;
		}
		++elapsed;
	}
		
	if (jjTriggers[1] == true && alertDialog == true) {
		switch (elapsed) {
			case 1:
				sendChat("||||||SYSTEM:|||||||", "SECURITY GATE OPENED!");
				break;
			case 140:
				sendChat("||||||SYSTEM:|||", "INTRUDER ALERT!!! LAUNCH ALL ARMY UNITS!");
				break;
			case 280:
				sendChat("||||||You:|||||||", "Aww,sucks!");
				break;
			case 380:	
				alertDialog = false;
				break;
		}
		if (elapsed > 140 && elapsed < 370) {
		jjPalette = daytime;
		jjPalette.fill(255,0,0, jjSin((elapsed)*16) * .500 + .5);
		jjSetFadeColors();
		jjPalette.apply();
	}
		++elapsed;
	}

	if (jjTriggers[29] == true && deactivatedDialog == true) {
			switch (elapsed) {
				case 1:
					sendChat("||||||You:|||||||", "The Generator was deactivated! Now, I should go outta here.");
					paused = true;
					break;
				case 140:
					sendChat("||||||You:|||||||", "Huh!");
					p.lighting = 0;
					break;
				case 160:
					sendChat("||||||You:|||||||", "The light was turned off when I deactivated the generator.");
					break;
				case 320:
					sendChat("||||||You:|||||||", "I should find the way out from this place!");
					break;
				case 500:
					sendChat("||||||You:|||||||", "But first,I should turn on the light because it's too dark");
					break;
				case 680:
					sendChat("||||||You:|||||||", "to go out in my own way with this condition.");
					paused = false;
					deactivatedDialog = false;
					break;
			}
			++elapsed;
	}

	if (briefingDialog == true) {
		switch (elapsed) {
			case 1:
				paused = true;
				sendChat("||||||Radio:|||||||", "OK, your mission is complete now, well done!");
				break;
			case 200:
				sendChat("||||||You:|||||||", "Yes, thanks!");
				break;
			case 450:
				sendChat("||||||Radio:|||||||", "Now, go back to our base to take a rest for a while.");
				break;
			case 650:
				sendChat("||||||You:|||||||", "OK, I will go back.");
				break;
			case 850:
				sendChat("||||||Radio:|||||||", "I will send you an unit to take you back.");
				break;
			case 1050:
				sendChat("||||||You:|||||||", "Yeah!");
				break;
			case 1150:
				briefingDialog = false;
				paused = false;
				jjNxt("ending", false, false);
				break;
		}
		++elapsed;
	}
}

void onLevelLoad() { 
			daytime.load("Desolation7th.j2t");
			jjLocalPlayers[1].lives = 0;
			jjChat("/allowmouseaim on");
			jjChat("/smhealth 8");
			jjObjectPresets[OBJECT::NORMTURTLE].energy = 5;
			jjObjectPresets[OBJECT::TUFTURT].energy = 10;
			jjObjectPresets[OBJECT::FLOATSUCKER].energy = 5;
			jjObjectPresets[OBJECT::SUCKER].energy = 5;
			jjObjectPresets[OBJECT::HELMUT].energy = 5;
			jjObjectPresets[OBJECT::LABRAT].energy = 5;
			jjObjectPresets[OBJECT::DEMON].energy = 10;
			jjObjectPresets[OBJECT::DEMON].isFreezable = false;
			jjObjectPresets[OBJECT::DEMON].behavior = DemonBullet;
			jjObjectPresets[OBJECT::FLOATLIZARD].energy = 5;
			jjObjectPresets[OBJECT::LIZARD].energy = 5;
}

void DemonBullet(jjOBJ@ demon) {
	if (demon.state == STATE::START) {
		demon.direction = demon.xSpeed = 2;
		demon.counter = (jjRandom()&45) + 70;
		demon.state = STATE::WALK;
	}
	demon.behave(BEHAVIOR::WALKINGENEMY);
	if (demon.freeze == 0) {
		demon.counter--;
		if (demon.counter <= 0) {
			demon.counter = (jjRandom()&45) + 70;
			demon.light = 16;
			jjOBJ@ bullet = jjObjects[demon.fireBullet(OBJECT::FIREBALLBULLET)];
				bullet.killAnim = bullet.determineCurAnim(ANIM::AMMO, 7, false);
				bullet.playerHandling = HANDLING::ENEMYBULLET;
				bullet.state = STATE::FLY;
				bullet.yPos = bullet.yPos + 24;
				bullet.animSpeed = 1;
			jjSample(demon.xPos, demon.yPos, SOUND::COMMON_RINGGUN);
		}
		else demon.light = 0;
	}
	if (demon.state == STATE::KILL) {
		demon.lightType = LIGHT::NONE;
		demon.light = 0;
	}
}

void onFunction0() {
		dialogStarter = true;
}

void onFunction1() {
	jjTriggers[3] = true;
	jjTriggers[31] = true;
}

void onFunction2() {
	elapsed = 0;
	alertDialog = true;
	jjTriggers[1] = true;
	jjTriggers[2] = true;
	jjAddObject(118, 22*32, 96*32, 0, CREATOR::OBJECT, BEHAVIOR::DEFAULT);
	jjAddObject(102, 24*32, 96*32, 0, CREATOR::OBJECT, BEHAVIOR::DEFAULT);
	jjAddObject(118, 26*32, 96*32, 0, CREATOR::OBJECT, BEHAVIOR::DEFAULT);
	jjAddObject(102, 28*32, 96*32, 0, CREATOR::OBJECT, BEHAVIOR::DEFAULT);
	jjAddObject(118, 38*32, 82*32, 0, CREATOR::OBJECT, BEHAVIOR::DEFAULT);
	jjAddObject(102, 40*32, 82*32, 0, CREATOR::OBJECT, BEHAVIOR::DEFAULT);
	jjAddObject(118, 42*32, 82*32, 0, CREATOR::OBJECT, BEHAVIOR::DEFAULT);
	jjAddObject(102, 44*32, 82*32, 0, CREATOR::OBJECT, BEHAVIOR::DEFAULT);
}

void onFunction3() {
	jjTriggers[6] = true;
	sendChat("||||||SYSTEM:|||||||", "SECURITY ROOM DOOR 1 OPENED!");
}

void onFunction4() {
	jjTriggers[8] = true;
	jjTriggers[10] = true;
	sendChat("||||||SYSTEM:|||||||", "DOOR 1 AND CONTROLLER ROOM DOOR 2 OPENED!");
}

void onFunction5() {
	jjTriggers[7] = true;
	sendChat("||||||SYSTEM:|||||||", "SECURITY ROOM DOOR 2 OPENED!");
}

void onFunction6() {
	jjTriggers[9] = true;
	sendChat("||||||SYSTEM:|||||||", "DOOR 2 OPENED!");
}

void onFunction7() {
	jjTriggers[28] = true;
	sendChat("||||||SYSTEM:|||||||", "DOOR TO GENERATOR ROOM OPENED!");
}

void onFunction8() {
	elapsed = 0;
	jjTriggers[25] = true;
	jjTriggers[27] = true;
	jjTriggers[29] = true;
	deactivatedDialog = true;
}

void onFunction9() {
	jjTriggers[25] = false;
	p.lighting = 50;
	sendChat("||||||You:|||||||", "Nah! The light was turned on, I can go outta here now.");
}

void onFunction10() {
	elapsed = 0;
	briefingDialog = true;
}