Downloads containing ab21ctf13.j2as

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

File preview

#include "MLLE-Include-1.4.asc"
const bool MLLESetupSuccessful = MLLE::Setup();
#pragma require "ab21ctf13-MLLE-Data-2.j2l"
#pragma require "ab21ctf13-MLLE-Data-1.j2l"
#pragma require "ab21ctf13.j2l"
#pragma require "SEenergyblast.asc"
#include "SEenergyblast.asc"
#include "limitedoxygen.asc"
 
se::DefaultWeaponHook weaponHook;
funcdef jjPALCOLOR ColorFunction(jjPALCOLOR); 

void onLevelLoad() {
	jjUseLayer8Speeds = true;
	
	jjSetWaterLevel(100*32, true);
	jjSetWaterGradient(0, 30, 30, 0, 250, 250);
	jjWaterLighting = WATERLIGHT::GLOBAL;

    se::energyBlast.loadAnims(jjAnimSets[ANIM::CUSTOM[0]]);
    se::energyBlast.loadSamples(array<SOUND::Sample> = {SOUND::INTRO_BLOW});
    se::energyBlast.setAsWeapon(3, weaponHook);
	
	jjWeapons[WEAPON::ICE].maximum = 50;
	
	jjObjectPresets[OBJECT::FULLENERGY].behavior = CannotBeShotDown();
	
	for (int i = 1120; i <= 1489; i++) {
		jjPIXELMAP monoliths(i);
			for (uint x = 0; x < monoliths.width; ++x) {
				for (uint y = 0; y < monoliths.height; ++y) {
					if (monoliths[x,y] == 13 || monoliths[x,y] == 146) monoliths[x,y] = 220;
					if (monoliths[x,y] == 15 || monoliths[x,y] == 176) monoliths[x,y] = 228;
					if (monoliths[x,y] == 57 || monoliths[x,y] == 144 || monoliths[x,y] == 240) monoliths[x,y] = 225;
					if (monoliths[x,y] == 66 || monoliths[x,y] == 113) monoliths[x,y] = 224;
					if (monoliths[x,y] == 65 || monoliths[x,y] == 72 || monoliths[x,y] == 173 || monoliths[x,y] == 177) monoliths[x,y] = 227;
					if (monoliths[x,y] == 73) monoliths[x,y] = 226;
					if (monoliths[x,y] == 115) monoliths[x,y] = 222;
					if (monoliths[x,y] == 119) monoliths[x,y] = 216;
					if (monoliths[x,y] == 56 || monoliths[x,y] == 243 || monoliths[x,y] == 244) monoliths[x,y] = 223;
				}
			}
		monoliths.save(i, true);
	}
	
	jjANIMATION@ anim = jjAnimations[jjAnimSets[ANIM::BRIDGE] + 2];
	for (uint j = 0; j < anim.frameCount; j++) {
		jjANIMFRAME@ frame = jjAnimFrames[anim + j];
		jjPIXELMAP sprite(frame);
		for (uint x = 0; x < sprite.width; ++x) {
			for (uint y = 0; y < sprite.height; ++y) {
				if (sprite[x,y] >= 16 && sprite[x,y] <= 23) sprite[x,y] = 128 + (sprite[x,y]&7)*2;
			}
		}
		sprite.save(frame);
	}
	
	water::maxOxygen = 1500;
	
}

void onLevelBegin() {
	/*array<jjLAYER@> layers = jjLayerOrderGet();
	if (layers[15].hasTileMap) {
		darkenLayer(layers[15], array<uint8>(), function(color) {
			color.setHSL(color.getHue(), color.getSat() * 4 / 5, color.getLight() * 8 / 10);
			return color;
		});
	}
	if (layers[16].hasTileMap) {
		darkenLayer(layers[16], array<uint8>(), function(color) {
			color.setHSL(color.getHue(), color.getSat() * 3 / 5, color.getLight() * 7 / 10);
			return color;
		});
	}
	if (layers[17].hasTileMap) {
		darkenLayer(layers[17], array<uint8>(), function(color) {
			color.setHSL(color.getHue(), color.getSat() * 3 / 5, color.getLight() * 6 / 10);
			return color;
		});
	}*/
}

void darkenLayer(jjLAYER@ layer, array<uint8>& freePaletteIndices, ColorFunction@ func) {
	array<int> tileIDs, uniqueTileIDs;
	for (int i = 0; i < layer.height; i++) {
		for (int j = 0; j < layer.width; j++) {
			int tileID = layer.tileGet(j, i);
			if (tileID != 0)
				tileIDs.insertLast(tileID);
		}
	}
	int prev = 0;
	tileIDs.sortAsc();
	for (uint i = 0; i < tileIDs.length(); i++) {
		if (tileIDs[i] != prev)
			uniqueTileIDs.insertLast(prev = tileIDs[i]);
	}
	uint firstNewTile = jjTileCount;
	jjTilesFromTileset(jjTilesetFileName, 1, uniqueTileIDs.length());
	array<uint8> mapping(256);
	for (uint i = 0; i < uniqueTileIDs.length(); i++) {
		jjPIXELMAP tile(uniqueTileIDs[i]);
		for (int j = 0; j < 32; j++) {
			for (int k = 0; k < 32; k++) {
				uint8 pixel = tile[k, j];
				if (pixel != 0) {
					if (mapping[pixel] == 0) {
						jjPALCOLOR color = func(jjPalette.color[pixel]);
						uint8 bestMatch = jjPalette.findNearestColor(color);
						if (!freePaletteIndices.isEmpty()) {
							jjPALCOLOR other = jjPalette.color[bestMatch];
							int red = other.red - color.red;
							int green = other.green - color.green;
							int blue = other.blue - color.blue;
							int distance = red * red + green * green + blue * blue;
							if (distance > 16) {
								bestMatch = freePaletteIndices[freePaletteIndices.length() - 1];
								jjPalette.color[bestMatch] = color;
								freePaletteIndices.removeLast();
							}
						}
						mapping[pixel] = bestMatch;
					}
				tile[k, j] = mapping[pixel];
				}
			}
		}
		tile.save(firstNewTile + i);
	}
	layer.generateSettableTileArea();
	for (int i = 0; i < layer.height; i++) {
		for (int j = 0; j < layer.widthReal; j++) {
			int tileID = layer.tileGet(j, i);
			if (tileID != 0)
				layer.tileSet(j, i, firstNewTile + uniqueTileIDs.find(tileID));
		}
	}
}

class CannotBeShotDown : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PICKUP);
		if (obj.state == STATE::FLOATFALL) obj.state = STATE::FLOAT;
	}
}

void onPlayer(jjPLAYER@ play) {
    weaponHook.processPlayer(play);
	water::limitedOxygen(play);
	
	play.lightType = LIGHT::NONE;
}
void onPlayerInput(jjPLAYER@ play) {
	if (play.yPos > jjWaterLevel && play.currWeapon == WEAPON::ICE) play.keyFire = false;
    weaponHook.processPlayerInput(play);
}
 
void onMain() {
    weaponHook.processMain();
}
 
void onReceive(jjSTREAM &in packet, int clientID) {
    weaponHook.processPacket(packet, clientID);
}
 
bool onDrawAmmo(jjPLAYER@ play, jjCANVAS@ canvas) {
    return weaponHook.drawAmmo(play, canvas);
}

bool onDrawHealth(jjPLAYER@ play, jjCANVAS@ canvas) {
	water::drawOxygenTimer(play, canvas);
	return false;	
}