Downloads containing ab20btl08.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Anniversary Bash 20 Levels Jazz2Online Multiple N/A Download file

File preview

#pragma require "ab20btl08-1stLayer.j2l"
#pragma require "ab20btl08-2ndLayer.j2l"
#pragma require "ab20btl08-3rdLayer.j2l"

#pragma require "BubbleGun.j2a"
#pragma require "A_CarrFIXday.j2t"

const array<uint16> tilesToVFlip = {
	40, 41, 42, 43, 44,
	55, 56, 57, 58, 59
};

const array<uint16> tilesToGiveBlackBGs = {
	33, 45, 49, 69
};

const array<uint16> tilesToReplace1 = {
	340, 341, 342, 343, 344, 345, 346, 347, 348, 349
};

const array<uint16> tilesToReplace2 = {
	360, 361, 362, 363, 364, 365, 366, 367, 368, 369
};

const array<uint16> tilesToReplace3 = {
	380, 381, 382, 383, 384, 385, 386, 387, 388, 389
};

const array<uint16> tilesToReplace4 = {
	390, 391, 392, 393
};

void onLevelLoad() {

	
	jjPalette.gradient(110,160,246,56,83,190,240,6);
	jjPalette.gradient(47,73,150,24,39,124,11,4);
	jjPalette.gradient(22,37,105,17,32,80,57,2);
	jjPalette.gradient(15,29,73,13,26,69,120,2); // Always stop at 69

	jjTexturedBGFadePositionY = 0.30;
	
	/* jjWaterLayer = 8;

	jjWaterInteraction = WATERINTERACTION::SWIM;
	jjSetWaterGradient(10, 10, 11, 10, 12, 2); */

	array<jjLAYER@> extraLayers = jjLayersFromLevel("ab20btl08-1stLayer.j2l", array<uint> = {1,2,3,5,6,7,8}, 0);
	array<jjLAYER@> extraLayers2 = jjLayersFromLevel("ab20btl08-2ndLayer.j2l", array<uint> = {1,2,3,5,6,7,8}, 0);
	array<jjLAYER@> extraLayers3 = jjLayersFromLevel("ab20btl08-3rdLayer.j2l", array<uint> = {1,2,3,8}, 0);
	jjLayerOrderSet(array<jjLAYER@> = {jjLayers[1], jjLayers[2], jjLayers[3], jjLayers[4], jjLayers[5], jjLayers[6], jjLayers[7], extraLayers[0], extraLayers[1], extraLayers[2], extraLayers[3], extraLayers[4], extraLayers[5], extraLayers2[0], extraLayers2[1], extraLayers2[2], extraLayers2[3], extraLayers2[4], extraLayers2[5], extraLayers3[0], extraLayers3[1], extraLayers3[2], extraLayers2[6], extraLayers3[3], extraLayers[6], jjLayers[8]});

	extraLayers[0].spriteMode = 
	extraLayers[1].spriteMode = 
	extraLayers[2].spriteMode = SPRITE::BRIGHTNESS;
	
	extraLayers[0].spriteParam =
	extraLayers[1].spriteParam =
	extraLayers[2].spriteParam = 50;

	extraLayers[3].spriteMode =
	extraLayers[4].spriteMode =
	extraLayers[5].spriteMode = SPRITE::BRIGHTNESS;
	
	extraLayers[3].spriteParam =
	extraLayers[4].spriteParam = 
	extraLayers[5].spriteParam = 40;
	
	extraLayers2[0].spriteMode = 
	extraLayers2[1].spriteMode = 
	extraLayers2[2].spriteMode = SPRITE::BRIGHTNESS;
	
	extraLayers2[0].spriteParam =
	extraLayers2[1].spriteParam =
	extraLayers2[2].spriteParam = 30;
	
	extraLayers2[3].spriteMode =
	extraLayers2[4].spriteMode =
	extraLayers2[5].spriteMode = SPRITE::BRIGHTNESS;
	
	extraLayers2[3].spriteParam =
	extraLayers2[4].spriteParam = 
	extraLayers2[5].spriteParam = 20;
	
	extraLayers3[0].spriteMode = 
	extraLayers3[1].spriteMode = 
	extraLayers3[2].spriteMode = SPRITE::BRIGHTNESS;
	
	extraLayers3[0].spriteParam =
	extraLayers3[1].spriteParam =
	extraLayers3[2].spriteParam = 12;
	
	extraLayers3[3].spriteMode = SPRITE::BRIGHTNESS;
	
	extraLayers3[3].spriteParam = 60;
	
	
	
	jjTexturedBGTexture = TEXTURE::PSYCH;
	
	jjAnimSets[ANIM::CUSTOM[0]].load(0, "BubbleGun.j2a");
	jjAnimSets[ANIM::CUSTOM[1]].load(1, "BubbleGun.j2a");
	jjAnimSets[ANIM::CUSTOM[2]].load(2, "BubbleGun.j2a");
	jjAnimations[jjAnimSets[ANIM::AMMO] + 29] = jjAnimations[jjAnimSets[ANIM::AMMO] + 8];
	jjAnimations[jjAnimSets[ANIM::AMMO] + 28] = jjAnimations[jjAnimSets[ANIM::CUSTOM[0]] + 0];
	
	jjObjectPresets[OBJECT::ICEBULLET].special = jjObjectPresets[OBJECT::ICEBULLET].determineCurAnim(ANIM::AMMO, 8);
	jjObjectPresets[OBJECT::ICEBULLET].xSpeed = 2;
	jjObjectPresets[OBJECT::ICEBULLET].counterEnd = 105;
	jjObjectPresets[OBJECT::ICEBULLET].var[6] = 0;
	jjObjectPresets[OBJECT::ICEBULLET].freeze = 0;
	jjObjectPresets[OBJECT::ICEBULLET].lightType = jjObjectPresets[OBJECT::BLASTERBULLET].lightType;

	jjObjectPresets[OBJECT::ICEBULLETPU].special = jjObjectPresets[OBJECT::ICEBULLETPU].determineCurAnim(ANIM::CUSTOM[0], 0);
	jjObjectPresets[OBJECT::ICEBULLETPU].xSpeed = 3;
	jjObjectPresets[OBJECT::ICEBULLETPU].counterEnd = 105;
	jjObjectPresets[OBJECT::ICEBULLETPU].var[6] = 8;
	jjObjectPresets[OBJECT::ICEBULLETPU].freeze = 0;
	jjObjectPresets[OBJECT::ICEBULLETPU].lightType = jjObjectPresets[OBJECT::BLASTERBULLET].lightType;
	
	jjObjectPresets[OBJECT::ICEBULLET].behavior = jjObjectPresets[OBJECT::ICEBULLETPU].behavior = BubbleGun();
	
	jjObjectPresets[OBJECT::ICEPOWERUP].determineCurAnim(ANIM::CUSTOM[1], 0, true);
	
	jjObjectPresets[OBJECT::ICEAMMO15].behavior = BubbleCrate;
	
	//jjObjectPresets[OBJECT::CARROT].behave(BEHAVIOR::FLICKERGEM);
	
	jjObjectPresets[OBJECT::ICEAMMO15].behave(BEHAVIOR::FLICKERGEM);
	
	jjWeapons[WEAPON::ICE].spread = SPREAD::NORMAL;
	jjWeapons[WEAPON::ICE].defaultSample = false;
	
	for (int i = 0; i < 10; ++i) {
		jjPIXELMAP VFlippedCaves1(tilesToVFlip[i]);
		VFlippedCaves1.save(tilesToReplace1[i] | TILE::VFLIPPED, true);
		
		jjPIXELMAP VFlippedCaves2(tilesToVFlip[i]);
			for (uint x = 0; x < VFlippedCaves2.width; ++x)
				for (uint y = 0; y < VFlippedCaves2.height; ++y)
					if (VFlippedCaves2[x,y] == 0)
						VFlippedCaves2[x,y] = 95; //black background
		VFlippedCaves2.save(tilesToReplace2[i] | TILE::VFLIPPED, true);
		
		jjPIXELMAP cavesBlackBG(tilesToVFlip[i]);
			for (uint x = 0; x < cavesBlackBG.width; ++x)
				for (uint y = 0; y < cavesBlackBG.height; ++y)
					if (cavesBlackBG[x,y] == 0)
						cavesBlackBG[x,y] = 95;
		cavesBlackBG.save(tilesToReplace3[i], true);	
	}
	
	for (int i = 0; i < 4; ++i) {
		jjPIXELMAP cavesBlackBG(tilesToGiveBlackBGs[i]);
			for (uint x = 0; x < cavesBlackBG.width; ++x)
				for (uint y = 0; y < cavesBlackBG.height; ++y)
					if (cavesBlackBG[x,y] == 0)
						cavesBlackBG[x,y] = 95;
		cavesBlackBG.save(tilesToReplace4[i], true);		
	}

	jjPIXELMAP blackTile(759);
		for (uint x = 0; x < blackTile.width; ++x)
			for (uint y = 0; y < blackTile.height; ++y)
				if (blackTile[x,y] != 254)
					blackTile[x,y] = 95;
	blackTile.save(759, true);
	
	for (int i = 1; i < 255; i++) {
		if (jjObjectPresets[i].playerHandling == HANDLING::PICKUP) {
			jjObjectPresets[i].behavior = CannotBeBuried();
		}
	}
	
	generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {40});
	turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 19.f, false);
	

	jjUseLayer8Speeds = true;
	
	
	//cooba began here
	if (!jjTilesFromTileset("A_CarrFIXday.j2t", 660, 4)) {
		jjAlert("|ERROR: A_CarrFIXday.j2t not found!", false, STRING::MEDIUM);
		return;
	}
	
	jjMASKMAP stars(839);
	for (int i = 870; i < 874; i++) {
		jjPIXELMAP imported(i);
		imported.save(i - 494);
		stars.save(i - 494);
	}
	
	jjTilesFromTileset("Noka - Labrat 4.j2t", 0, 0);		//remove this in jj2+ 5.5
}

jjANIMSET@ customSpringSprite;
array<int> fastCustomSpringSpeeds(jjLocalPlayerCount);
bool generateCustomSpringSprites(jjANIMSET@ anim, const array<uint> &in colors) {
	int length = colors.length();
	bool success = (@customSpringSprite = anim).allocate(array<uint>(length * 3, 5)) !is null;
	if (success) {
		uint srcSet = jjAnimSets[ANIM::SPRING];
		for (int i = 0; i < length; i++) {
			uint color = colors[i];
			uint destAnimOffset = anim + i * 3;
			for (int j = 0; j < 3; j++) {
				uint srcAnim = jjAnimations[srcSet + j];
				uint destAnim = jjAnimations[destAnimOffset + j];
				for (int k = 0; k < 5; k++) {
					jjPIXELMAP image(jjAnimFrames[destAnim + k] = jjAnimFrames[srcAnim + k]);
					int width = image.width;
					int height = image.height;
					for (int l = 0; l < height; l++) {
						for (int m = 0; m < width; m++) {
							int pixel = image[m, l];
							if (pixel >= 32 && pixel < 40)
								image[m, l] = color + (pixel & 7);
						}
					}
					if (!image.save(jjAnimFrames[destAnim + k]))
						return false;
				}
			}
		}
	}
	return success;
}
void initializeCustomSpring(jjOBJ@ obj) {
	int anim = obj.curAnim;
	obj.behave(obj.behavior = BEHAVIOR::SPRING, false);
	if (obj.curAnim != anim) {
		obj.curAnim = anim + 2;
		obj.determineCurFrame();
	}
	obj.draw();
}

void turnIntoCustomSpring(jjOBJ@ obj, uint color, float power, bool horizontal) {
	if (horizontal) {
		obj.xSpeed = power;
		obj.ySpeed = 0.f;
	} else {
		obj.xSpeed = 0.f;
		obj.ySpeed = -power;
		if (obj.state == STATE::START && obj.creatorType == CREATOR::LEVEL) {
			int x = int(obj.xPos) >> 5;
			int y = int(obj.yPos) >> 5;
			if (jjParameterGet(x, y, 0, 1) != 0) {
				jjParameterSet(x, y, 0, 1, 0);
				obj.yPos -= 4.f;
				obj.ySpeed = power;
			}
		}
	}
	obj.behavior = initializeCustomSpring;
	obj.curAnim = customSpringSprite + color * 3 + (horizontal ? 1 : 0);
	obj.energy = obj.frameID = obj.freeze = obj.justHit = obj.light = obj.points = 0;
	obj.isBlastable = obj.isTarget = obj.scriptedCollisions = obj.triggersTNT = false;
	obj.deactivates = obj.isFreezable = true;
	obj.bulletHandling = HANDLING::IGNOREBULLET;
	obj.playerHandling = HANDLING::SPECIAL;
	obj.lightType = LIGHT::NORMAL;
	obj.determineCurFrame();
}

class CannotBeBuried : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		if (obj.eventID == OBJECT::CARROT) {
			obj.behave(obj.creatorType == CREATOR::PLAYER? BEHAVIOR::FLICKERGEM : BEHAVIOR::PICKUP);
		} else {
			obj.behave(BEHAVIOR::PICKUP);
		}
		if (jjMaskedPixel(int(obj.xPos), int(obj.yPos) + 8)) {
			obj.state = STATE::FLOAT;
		}
		if (obj.ySpeed < 0) obj.ySpeed = 0.25;
	}
}

void onDrawLayer8(jjPLAYER@ play, jjCANVAS@ screen) {
  jjSetWaterLevel(-32, true);
}
void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ screen) {
  jjSetWaterLevel(16000, true);
}

void onLevelBegin() {
	jjPalette.gradient(50,50,170, 2,2 ,2 , 176, 32);
	jjPalette.apply();
}

class BubbleGun : jjBEHAVIORINTERFACE {
    void onBehave(jjOBJ@ bubble) {
		if (bubble.state == STATE::START) {
			bubble.state = STATE::FLY;
			if (jjPlayers[bubble.creatorID].isLocal) jjSample(bubble.xPos, bubble.yPos, SOUND::COMMON_PLOP2, 0, 0);
		}
		
		if (jjMaskedPixel(int(bubble.xPos) + int(bubble.xSpeed), int(bubble.yPos)) || jjMaskedPixel(int(bubble.xPos) - int(bubble.xSpeed), int(bubble.yPos)) || jjMaskedPixel(int(bubble.xPos), int(bubble.yPos) + int(bubble.ySpeed)) || jjMaskedPixel(int(bubble.xPos), int(bubble.yPos) - int(bubble.ySpeed))) {
			jjSample(bubble.xPos, bubble.yPos, SOUND::P2_SPLOUT, 0, 0);
		}
		
		bubble.behave(BEHAVIOR::WATERSHIELDBULLET);
		
		if (bubble.state == STATE::FLY && bubble.counter > 0) {
			switch (bubble.direction) {
				case 1: bubble.xSpeed -= (bubble.eventID == OBJECT::ICEBULLETPU? 0.1:0.04); bubble.ySpeed -= (bubble.eventID == OBJECT::ICEBULLETPU? 0.1:0.04); break;
				case -1: bubble.xSpeed += (bubble.eventID == OBJECT::ICEBULLETPU? 0.1:0.04); bubble.ySpeed -= (bubble.eventID == OBJECT::ICEBULLETPU? 0.1:0.04); break;
			}
		}
		
		bubble.killAnim = jjObjectPresets[OBJECT::WATERSHIELDBULLET].killAnim;
	}
}

void BubbleCrate(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::AMMO15, false);
	jjDrawSprite(int(obj.xPos), int(obj.yPos), ANIM::CUSTOM[2], 0, 0, SPRITE::NORMAL);
}

void onFunction1(jjPLAYER@ play) {
	play.showText("@@@@@Space Dump@Created by Loon@Tileset conversion by NOKA@Created for Total Annihilation III:@Extraterrestrial Shelter");
}