Downloads containing Fio2_f.j2as

Downloads
Name Author Game Mode Rating
JJ2+ Only: Find It Out (Single Player)Featured Download Superjazz Single player 9.1 Download file

File preview

const bool MLLESetupSuccessful = MLLE::Setup(); ///@MLLE-Generated
#include "MLLE-Include-1.6.asc" ///@MLLE-Generated
#pragma require "Fio2_f-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "Fio2_f.j2l" ///@MLLE-Generated
#include "Fio_common.asc"
#include "Fio_cutscene.asc"
#include "Fio_drawing.asc"
#include "Fio_entities.asc"
#include "Fio_globals.asc"

enum Cutscene { CUTSCENE_NONE, CUTSCENE_PORTAL };

const float DURATION_CAMERA_FREEZE = CUTSCENE_SECOND * 24;

const string NEXT_LEVEL_FILENAME = "Fio2_z.j2l";

const array<ArmoryItem@> ARMORY_ITEMS = {
	ArmoryItem(0, "||||Bouncer Power up@+ 20 ammo", 25, 52, ANIM::PICKUPS, 61, 0, @fio::sellArmoryItemBouncerPU),
	ArmoryItem(1, "||||Toaster Power up@+20 ammo", 20, 48, ANIM::PICKUPS, 65, 0, @fio::sellArmoryItemToasterPU),
	ArmoryItem(2, "||||+15 Seeker ammo", 30, 48, ANIM::AMMO, 37, 1, @fio::sellArmoryItemSeekerAmmo),
	ArmoryItem(3, "", 15, 44, ANIM::PICKUPS, 72, 5, @fio::sellArmoryItemInvincibility, @fio::canBuyInvincibility), // Text updated later when currentGameSession has been loaded
	ArmoryItem(4, "", 10, 56, ANIM::PICKUPS, 21, 0, @fio::sellArmoryItemPocketCarrot, @fio::canBuyPocketCarrot) // Text updated later when currentGameSession has been loaded
};

bool isMindStoneVisible = false;
bool wasCutsceneWatchedTillTheEndPortal = false;

uint8 activeCutscene = uint8(CUTSCENE_NONE);

ANIM::Set playerAnimSet;

CharacterWithMindStone@ character;

array<Checkpoint@> fio2fCheckpoints = {
	Checkpoint(0, TILE * 102, TILE * 106),
	Checkpoint(1, TILE * 80, TILE * 54)
};

array<string> cutsceneTextsPortal = {
	"|Are you there Nicholas? I've found some kind of a portal at the end of this path. Where does it take me to?",
	"|||Yes, I am listening to you whenever I have enough energy to do so.",
	"|||I believe this portal you mention should be actually bound to the holy land of Zyrus itself.",
	"|||That way, once you enter it, you won't be too far from your destination.",
	"|||However, I cannot promise that you will get exactly where you want to. You will have to find your way through. Understand?",
	"|Yes. I think there's only one way to find it out!"
};

array<string> questTexts = {
	fio::getQuestText(5, 7, 5000),
	fio::getQuestTextComplete(5000),
	fio::getQuestTextPerfect(2000)
};

array<string> texts = {
	"|Hmm, now how to reach that ledge?",
	"|Looks like a dangerous game built by the demons.",
	"|I sense yet another diabolic trap..."
};

void drawMindStoneAtPlayerPos(jjCANVAS@ canvas) {
	canvas.drawTile(int(play.xPos) + character.mindStoneX, int(play.yPos) + character.mindStoneY, 114);
	canvas.drawTile(int(play.xPos) + character.mindStoneX, int(play.yPos) + character.mindStoneY + TILE, 124);
}

void endCutscenePortal() {
	fioCut::endCutscene(play.xPos, play.yPos);
	fioUtils::releasePlayer();
	staticPlayerRenderState = STATE_STATIC_PLAYER_RENDER_OFF;
	activeCutscene = CUTSCENE_NONE;
}

void initializePortalAnimationChain() {
	// Duration, xOrigin, yOrigin, xDestination, yDestination, angle, scaleX, scaleY, animSet, animationId,
	// startingFrame, finalFrame, frameRate, repetitions (optional)
	// REMINDER: DON'T FORGET TO REMOVE THE TRAILING COMMA, SINCE OTHERWISE AS WILL INSERT A NULL HANDLE AFTER THE LAST ACTUAL OBJECT ELEMENT
	const array<fioCut::Animation@> animationsPortalRabbit = {
		fioCut::Animation(16,
				play.xPos, play.yPos,
				play.xPos, play.yPos,
				0, 1, 1, playerAnimSet, character.digAnimation, character.digFrameStart, character.digFrameEnd, 2, 1),
		fioCut::Animation(CUTSCENE_SECOND * 35 + 3,
				play.xPos, play.yPos,
				play.xPos, play.yPos,
				0, 1, 1, playerAnimSet, character.withMindStoneAnimation, character.withMindStoneFrame, character.withMindStoneFrame, 1),
		fioCut::Animation(16,
				play.xPos, play.yPos,
				play.xPos, play.yPos,
				0, 1, 1, playerAnimSet, character.digAnimation, character.digFrameEnd, character.digFrameStart, 2, 1, true)
	};
	fioCut::createAnimationChain(animationsPortalRabbit);
}

// Required for each level
bool onCheat(string &in cheat) {
	return fio::handleCheat(cheat, NEXT_LEVEL_FILENAME);
}

// Required for each level
bool onDrawHealth(jjPLAYER@ play, jjCANVAS@ canvas) {
	fioDraw::animateHud();
	fioDraw::drawHud(play, canvas, activeCutscene != CUTSCENE_NONE);
	
	if (activeCutscene != CUTSCENE_NONE) {
		fioCut::drawCutscene(canvas, centeredText);
	}
	
	if (isPlayerInArmory) {
		fioDraw::drawArmoryInterface(canvas);
	}
	
	return activeCutscene != CUTSCENE_NONE;
}

void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ canvas) {
	if (activeCutscene != CUTSCENE_NONE) {
		fioCut::renderAnimations(canvas);
		if (isMindStoneVisible) {
			drawMindStoneAtPlayerPos(canvas);
		}
	}
	
	fioDraw::drawArmoryAtPos(canvas, TILE * 86.5, TILE * 60.75); // Offset with +0.5 xTiles and +0.75 yTiles
	fio::renderCommon(play, canvas);
}

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

bool onDrawScore(jjPLAYER@ play, jjCANVAS@ canvas) {
	return activeCutscene != CUTSCENE_NONE;
}

void onFunction0() {
	fio::killPlayer();
}

void onFunction1() {
	if (!checkpoints[0].isReached()) {
		checkpoints[0].setReached();
	}
}

void onFunction2() {
	fioDraw::doShowText(0);
}

void onFunction3() {
	if (!checkpoints[1].isReached()) {
		checkpoints[1].setReached();
	}
}

void onFunction4() {
	fioDraw::doShowText(1);
}

void onFunction5(bool show) {
	if (show) {
		play.noFire = true;
		isPlayerInArmory = true;
	} else {
		play.noFire = false;
		isPlayerInArmory = false;
	}
}

void onFunction6() {
	fioDraw::doShowText(2);
}

void onFunction7() {
	if (!wasCutsceneWatchedTillTheEndPortal) {
		forceMoveRight = true;
		play.noFire = true;
		fio::killFollowingEnemies();
	}
}

void onFunction8() {
	forceMoveRight = false;
	
	if (!wasCutsceneWatchedTillTheEndPortal) {
		fioCut::initializeCutscene(@processCutscenePortal, cutsceneTextsPortal);
		fioCut::setTickEventsProcessed(true);
		isPlayerHiddenAndUnableToMove = true;
		initializePortalAnimationChain();
		activeCutscene = CUTSCENE_PORTAL;
	} else {
		endCutscenePortal();
	}
	
}

void onFunction9() {
	play.lighting = 255;
	fio::handleLevelCycle(NEXT_LEVEL_FILENAME, true);
}

void onFunction10() {
	fioDraw::doShowOptionalQuest(0);
}

void onLevelBegin() {
	@character = fio::getCharacterWithMindStoneForPlayer(play);
}

// Required for each level
void onLevelLoad() {
	initializeGlobals(fio2fCheckpoints, 5, 5000, 2000);
	fioDraw::initializeDrawing(texts, questTexts, true);
	playerAnimSet = fio::getAnimSetForPlayer(jjLocalPlayers[0]);
	
	// Re-assignment via static declaration
	armoryItems = ARMORY_ITEMS;
	
	// Global indice
	armoryItemIndexInvincibility = 3;
	armoryItemIndexPocketCarrot = 4;
	
	armoryItems[armoryItemIndexInvincibility].text = fio::getInvincibilityItemText();
	armoryItems[armoryItemIndexPocketCarrot].text = fio::getPocketCarrotItemText();
	
	mindstoneCommunicationTileIds = array<uint16>(5);
	mindstoneCommunicationTileIds[0] = 109;
	mindstoneCommunicationTileIds[1] = 118;
	mindstoneCommunicationTileIds[2] = 119;
	mindstoneCommunicationTileIds[3] = 128;
	mindstoneCommunicationTileIds[4] = 129;
	
	// Just to make sure that each one is a unique instance, although I'm not using class level properties anymore
	jjObjectPresets[OBJECT::DESTRUCTSCENERY].behavior = function(obj) { obj.behavior = DestructSceneryWithHealthBar(); };
}

// Required for each level
void onLevelReload() {
	MLLE::ReapplyPalette();
	reloadGlobals();
	fioDraw::initializeDrawing(texts, questTexts, true);
	fio::handleLevelReload();
	
	isPlayerHiddenAndUnableToMove = false;
	staticPlayerRenderState = STATE_STATIC_PLAYER_RENDER_OFF;
	forceMoveRight = false;
	
	jjEnabledASFunctions[7] = true;
	jjEnabledASFunctions[8] = true;
}

// Required for each level
void onMain() {
	fio::controlPressedKeys();
	fioDraw::controlHud();
}

// Required for each level
void onPlayer(jjPLAYER@ play) {
	fio::handlePlayer(play);
	fio::controlQuest();
	
	if (activeCutscene != CUTSCENE_NONE) {
		fioCut::run();
		if (!fioCut::isTickEventsProcessed()) {
			processCutscenePortal(play);
			fioCut::setTickEventsProcessed(true);
		}
	}
}

// Required at least for each level with an armory or cutscene(s)
void onPlayerInput(jjPLAYER@ play) {
	fio::controlArmoryInput(play);
	fio::controlPlayerInput(play, activeCutscene != CUTSCENE_NONE);
	
	if (activeCutscene != CUTSCENE_NONE) {
		fioCut::controlPlayerInput(play);
		if (fioCut::isCutsceneSkipInitiatedAfterDelay(play)) {
			endCutscenePortal();
		}
	}
}

// Required for each level
void onRoast(jjPLAYER@ victim, jjPLAYER@ killer) {
	fio::saveTriggerStates();
	asPlay.savePlayerProperties(play);
}

void processCutscenePortal(jjPLAYER@ play) {
	switch(uint(fioCut::getElapsedCutscene())) {
		case 16:
			fioCut::startTextSliding();
			isMindStoneVisible = true;
			fioCut::isMindstoneCommunicationRendered = true;
			break;
		case CUTSCENE_SECOND * 36 - 16:
			isMindStoneVisible = false;
			fioCut::isMindstoneCommunicationRendered = false;
			break;
		case CUTSCENE_SECOND * 36:
			fio::increaseCutscenesWatchedIfFastForwardWasNotUsed(fioCut::wasFastForwardUsed);
			wasCutsceneWatchedTillTheEndPortal = true;
			endCutscenePortal();
			break;
	}
}