Downloads containing HH17_level05.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Holiday Hare '17Featured Download ShadowGPW Single player 8.8 Download file

File preview

#pragma require "CandionV.j2t"
#pragma require "SExmas.j2a"
#pragma require "hh17enemies.asc"
#include "hh17enemies.asc"

/*** Copypasted and adapted by Slaz, tree background by Violet CLM, xmas sprites by Sir Ementaler  ***/
/*** Feel free to use/edit this script like I did :P ***/

class Imitation : jjBEHAVIORINTERFACE {
	private uint8 eventID;
	private jjBEHAVIOR behavior;
	Imitation(uint8 realEventID, uint8 fakeEventID) {
		jjOBJ@ obj = jjObjectPresets[realEventID];
		eventID = obj.eventID;
		behavior = obj.behavior;
		obj.eventID = fakeEventID;
		obj.behavior = this;
	}
	void onBehave(jjOBJ@ obj) override {
		if (obj.state == STATE::DEACTIVATE)
			obj.eventID = eventID;
		obj.behave(behavior);
	}
}

class GiftBox : jjBEHAVIORINTERFACE {
	void destroy(jjOBJ@ obj) {
		jjSample(obj.xPos, obj.yPos, SOUND::COMMON_WOOD1);
		{
			int id = jjAddObject(OBJECT::EXPLOSION, obj.xPos, obj.yPos);
			if (id != 0) {
				jjOBJ@ other = jjObjects[id];
				other.determineCurAnim(ANIM::PICKUPS, 4);
			}
		}
		for (int i = jjRandom() & 7 | 8; i-- != 0;) {
			int id = jjAddObject(OBJECT::SHARD, obj.xPos, obj.yPos);
			if (id != 0) {
				jjOBJ@ other = jjObjects[id];
				other.determineCurAnim(ANIM::PICKUPS, 93 + (jjRandom() & 1));
			}
		}
		obj.yPos -= 8.f;
		for (int i = obj.var[1]; i-- != 0;) {
			int id = jjAddObject(obj.var[0], obj.xPos, obj.yPos);
			if (id != 0) {
				jjOBJ@ other = jjObjects[id];
				if (other.playerHandling == HANDLING::PICKUP) {
					int angle = (jjRandom() & 255) + 128;
					other.xSpeed = jjCos(angle) * 5.f;
					other.ySpeed = jjSin(angle) * -3.f;
				} else if (other.playerHandling == HANDLING::SPECIAL) {
					other.deactivates = false;
				}
			}
		}
		obj.clearPlatform();
		obj.delete();
	}
	void onBehave(jjOBJ@ obj) override {
		switch (obj.state) {
			case STATE::START:
				{
					uint16 x = int(obj.xOrg) >>> 5;
					uint16 y = int(obj.yOrg) >>> 5;
					obj.var[0] = jjParameterGet(x, y, 0, 8);
					obj.var[1] = jjParameterGet(x, y, 8, 4);
					obj.curAnim += jjParameterGet(x, y, 12, 2);
					obj.determineCurFrame();
					obj.bulletHandling = HANDLING::DESTROYBULLET;
					obj.scriptedCollisions = true;
				}
				break;
			case STATE::FALL:
				obj.var[2] = 1;
				break;
			case STATE::FREEZE:
			case STATE::SLEEP:
				if (obj.var[2] != 0) {
					destroy(obj);
					return;
				}
		}
		obj.behave(BEHAVIOR::MONITOR);
	}
	bool onObjectHit(jjOBJ@, jjOBJ@, jjPLAYER@, int) {
		return true;
	}
	bool onIsSolid(jjOBJ@) {
		return true;
	}
}

const uint levelWidth = jjLayerWidth[4];
const uint levelHeight = jjLayerHeight[4];

void onLevelLoad() {
	HH17::setEnemy(OBJECT::BAT);
	HH17::setEnemy(OBJECT::FENCER);
	HH17::setEnemy(OBJECT::ROTATINGROCK);
	
	array<uint8> paletteColorMapping(256);
	for (int i = 22; i < 88; ++i)
		paletteColorMapping[i] = i + 0;
	for (int i = 96; i < 112; ++i)
		paletteColorMapping[i] = i + 54;
	
	const int oldTileCount = jjTileCount;
	jjTilesFromTileset("CandionV.j2t", 570, 250, paletteColorMapping);
	
	jjUseLayer8Speeds = true;
	jjTexturedBGTexture = TEXTURE::WISETYNESS;
	
	Imitation(OBJECT::TACO, OBJECT::MILK);
	uint src = jjAnimSets[ANIM::CUSTOM[255]].load(0, "SExmas.j2a");
	uint dest = jjAnimSets[ANIM::PICKUPS];
	for (int i = 0; i < 95; i++) {
		const jjANIMATION@ anim = jjAnimations[src + i];
		if (anim.frameCount != 0)
			jjAnimations[dest + i] = anim;
	}
	jjAnimSets[ANIM::BRIDGE].load(1, "SExmas.j2a");
	jjAnimSets[ANIM::CUSTOM[0]].load(2, "SExmas.j2a");
	jjObjectPresets[OBJECT::BOMBCRATE].behavior = GiftBox();
	jjObjectPresets[OBJECT::BOMBCRATE].determineCurAnim(ANIM::CUSTOM[0], 0);
	
	jjPAL standard;
	standard.load("CandionV.j2t");
	jjPalette.copyFrom(16, 40, 16, standard, 1);
	jjPalette.copyFrom(59, 37, 59, standard, 1);
	jjPalette.apply();
	
	array<jjLAYER@> layerOrder = {jjLayers[1], jjLayers[2], jjLayers[3], jjLayers[4], jjLayers[5], jjLayers[6]};
	
	{
		jjLAYER bigTrees(4, 8), smallTrees(4, 5);
		bigTrees.tileWidth = smallTrees.tileWidth = true;
		bigTrees.limitVisibleRegion = smallTrees.limitVisibleRegion = true;
		bigTrees.yOffset = -230; smallTrees.yOffset = -350;
		bigTrees.generateSettableTileArea();
		smallTrees.generateSettableTileArea();
		for (uint x = 0; x < 4; ++x) {
			for (int y = 0; y < bigTrees.height; ++y) {
				if (y < 3) { if (!(y == 0 && x > 1))
					bigTrees.tileSet(x, y, 728 + (x & 1) + (y - x/2) * 10);
				} else
					bigTrees.tileSet(x, y, 748 + (x & 1));
			}
			for (int y = 0; y < smallTrees.height; ++y) {
				if (y < 2)
					smallTrees.tileSet(x, y, 726 + (x & 1) + (y * 10));
				else
					smallTrees.tileSet(x, y, 736);
			}
		}
		for (uint i = 0; i < 8; ++i) {
			jjLAYER trees(i < 5 ? bigTrees : smallTrees);
			trees.ySpeed = 0.13 - i * 0.02;
			trees.xSpeed = 0.3 - i * 0.024;
			trees.xOffset = jjRandom();
			trees.yOffset += (i < 5) ? int(i*60) : (210 + int(i*30));
			layerOrder.insertLast(@trees);
		}
	}
	
	layerOrder.insertLast(jjLayers[7]);
	jjLAYER secondCastle(jjLayers[7]);
	secondCastle.yOffset = 48;
	secondCastle.ySpeed *= 0.85;;
	secondCastle.xSpeed *= 0.90;
	layerOrder.insertLast(@secondCastle);
	
	layerOrder.insertLast(jjLayers[8]);
	jjLayerOrderSet(layerOrder);
}

void onLevelReload() {
	HH17::processEnemyColors();
	jjPAL standard;
	standard.load("CandionV.j2t");
	jjPalette.copyFrom(16, 40, 16, standard, 1);
	jjPalette.copyFrom(59, 37, 59, standard, 1);
	jjPalette.apply();
}