Downloads containing ab19ctf04.j2as

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

File preview

/*******************************
A 2017 Mystic Legends Release!
http://www.mysticlegends.org
/******************************/

#pragma require "Jungle1_1.00gx.j2t"
#pragma require "ab19ctf04ex.j2l"
//#pragma offer "mlprice-extra.j2as"			//Restore this once 5.5 is out

void onLevelLoad() {
	importTilesIntoLayers();
	jjTilesFromTileset("Lomat.j2t", 0, 0); 		//BlurredD's hack to restore current tileset's CRC32 (to be removed when 5.5 is out)
	
	jjLayers[2].spriteMode = SPRITE::BLEND_NORMAL;
	jjLayers[2].spriteParam = 255;
	
	jjLayers[5].generateSettableTileArea();
	for (int x = 0; x < jjLayerWidth[5]; x++)
		for (int y = 0; y < jjLayerHeight[5]; y++)
      			jjTileSet(5, x, y, jjTileGet(5, x, y) ^ TILE::VFLIPPED);
	
	jjPalette.gradient(99,143,68, 4,10,1, 104, 8);
	jjPalette.gradient(24,48,32, 0,1,0, 224, 12);
	jjPalette.fill(0,0,1, 176, 32);	
	
	jjSetWaterGradient(99,143,68, 24,48,32);
	jjWaterLighting = WATERLIGHT::GLOBAL;
	jjSetWaterLevel(54.5f*32, true);
	
	jjObjectPresets[OBJECT::ICEAMMO15].direction = SPRITE::FLIPV;	
	jjObjectPresets[OBJECT::MORPH].direction = SPRITE::FLIPV;
	
	jjObjectPresets[OBJECT::FULLENERGY].lightType = LIGHT::BRIGHT;
	jjObjectPresets[OBJECT::FULLENERGY].light = 14;
	
	jjObjectPresets[OBJECT::GOLDCOIN].behavior = OffsetCoin();
	//jjObjectPresets[OBJECT::WARP].behavior = TeamCoinWarp();
	
	jjSetDarknessColor(jjPALCOLOR(0,0,0));		//This unfucks 8-bit
}


class OffsetCoin : jjBEHAVIORINTERFACE {		//This didn't need to be a class implementing jjBEHAVIORINTERFACE (could have been a regular global function),
	void onBehave(jjOBJ@ obj) {			//but I wanted to use it anyways. Not that there is any noticeable performance loss (...that I know of)
		if (obj.state == STATE::START) {
			obj.xPos = obj.xOrg + 16;
		}
		obj.lightType = LIGHT::POINT2;
		obj.direction = SPRITE::FLIPV;
		obj.behave(BEHAVIOR::PICKUP);
	}
}

class TeamCoinWarp : jjBEHAVIORINTERFACE {		//This didn't work as anticipated, feel free to uncomment and see for yourself (and maybe try to fix it???)
	void onBehave(jjOBJ@ obj) {		
		jjDrawSprite(obj.xPos, obj.yPos, ANIM::PLUS_WARP, 0, obj.curFrame, obj.direction, SPRITE::SINGLEHUE, (obj.xPos > 67*32) ? 24 : 32);
		jjDrawSprite(obj.xPos, obj.yPos, ANIM::PLUS_WARP, 1, obj.curFrame);
		obj.behave(BEHAVIOR::WARP, false);
	}
}

void importTilesIntoLayers() {
	const int oldTileCount = jjTileCount;
	if (!jjTilesFromTileset("Jungle1_1.00gx.j2t", 840, 109)) {
		jjAlert("|ERROR: Jungle1_1.00gx.j2t not found!", false, STRING::MEDIUM);
		return;
	}
	array<jjLAYER@> jungLayers = jjLayersFromLevel("ab19ctf04ex.j2l", array<uint> = {5,5,7}, oldTileCount - 840);
		
	jjLayers[6].spriteMode = SPRITE::BRIGHTNESS;
	jjLayers[6].spriteParam = 64;	//50% light
	jjLayers[6].yOffset = 16;
		
	jungLayers[0].spriteMode = SPRITE::SINGLEHUE;
	jungLayers[0].spriteParam = 224;
	jungLayers[0].xSpeed = 0.35f;
		
	jungLayers[1].ySpeed = 0.025f;
		
	/*
	jungLayers[2].spriteMode = SPRITE::SINGLECOLOR;
	jungLayers[2].spriteParam = 176;
	*/		
									//This operation saves about 25 FPS in comparison to doing the above.
	for (int i = 1060; i < 1109; i++) {				//For every tile from 1060 to 1109 (that exist because we imported them from the 1.00g Jungle set)
		jjPIXELMAP blacktree(i);				//copy the contents of that tile onto a jjPIXELMAP
		for (uint x = 0; x < blacktree.width; ++x)		//and
			for (uint y = 0; y < blacktree.height; ++y)	//paint
				if (blacktree[x,y] > 0) {		//every non-transparent pixel
					blacktree[x,y] = 176;		//with color 176 (which will be changed to black when line 6 is executed)
				}					//and
		blacktree.save(i);					//permanently save the modified pixel map onto the original tile.
	}
	
	//Black tile for jjLayer[7]
	jjPIXELMAP blackness(0);
	for (uint x = 0; x < blackness.width; ++x)
		for (uint y = 0; y < blackness.height; ++y)
			blackness[x,y] = 176;
	blackness.save(909);
	
	//Green tile for low detail jjLayer[1]
	jjPIXELMAP greenness(0);
	for (uint x = 0; x < greenness.width; ++x)
		for (uint y = 0; y < greenness.height; ++y)
			greenness[x,y] = 108;
	greenness.save(910);
		
	jjLayerOrderSet(array<jjLAYER@> = {
		jjLayers[1],
		jjLayers[2],
		jjLayers[3],
		jjLayers[4],
		jjLayers[5],
		jjLayers[6],
		jungLayers[0],
		jjLayers[7],
		jungLayers[1],
		jungLayers[2],
		jjLayers[8]
		}
	);
}

void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ layer) {
	layer.drawTile(30*32  + (jjRandom()&6) - 3, 13*32 + (jjRandom()&6) - 3, 908);
	layer.drawTile(102*32 + (jjRandom()&6) - 3, 13*32 + (jjRandom()&6) - 3, 908);
}

void onDrawLayer6(jjPLAYER@ play, jjCANVAS@ layer) {
	layer.drawTile(48*32,      31*32, 8  + TILE::ANIMATED);
	layer.drawTile(50*32 + 16, 32*32, 9  + TILE::ANIMATED);
	layer.drawTile(55*32,      31*32, 10 + TILE::ANIMATED);
}

void onPlayer(jjPLAYER@ play) {
	int skill = jjParameterGet(uint16(play.xPos/32), uint16(play.yPos/32), -4, 2);	
	if (skill == 3) {
		if (jjLayers[2].spriteParam > 96) {
			jjLayers[2].spriteParam = jjLayers[2].spriteParam - 10;
		}
	}
	else if (jjLayers[2].spriteParam != 255) {
		jjLayers[2].spriteParam = jjLayers[2].spriteParam + 10;
	}
}

void onMain() {
	jjPLAYER @play = jjLocalPlayers[0];
	array<jjLAYER@> layers = jjLayerOrderGet();	
	if (jjLowDetail) {
		layers[layers.length - 2].xSpeed = layers[layers.length - 2].ySpeed = 1;
		layers[layers.length - 2].xOffset = play.cameraX * (0.1f - 1);
		layers[layers.length - 2].yOffset = -play.cameraY + 0.5f;
	}
	else {
		layers[layers.length - 2].xSpeed = 0.1f;
		layers[layers.length - 2].ySpeed = 0;
		layers[layers.length - 2].xOffset = layers[layers.length - 2].yOffset = 0;
	}
	
	//jjLayers[1].hasTiles = jjLowDetail ? true : false;
	jjLayers[1].yOffset = jjWaterLevel * -1;
	
	if (jjLowDetail || jjColorDepth == 8 || (jjLowDetail && jjColorDepth == 8)) {
		jjWaterLayer = 9;
	}
	else jjWaterLayer = 1;
	
	jjTriggers[1] = (jjGameCustom == GAME::FR) ? true : false;
}