Downloads containing mlpricejb.j2as

Downloads
Name Author Game Mode Rating
JJ2+ Only: The Price of AdmissionFeatured Download cooba Capture the flag 8.7 Download file

File preview

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

#pragma require "Jungle1_1.00gx.j2t"
#pragma require "spelunky_ignite.wav"
#pragma require "mlprice-extra.j2l"
#pragma offer "mlprice-extra.j2as"

void onLevelLoad() {
	/********************************************************************* COLOR MODIFICATIONS *************************************************************************/
	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);
	jjPalette.copyFrom(192, 8, 104, jjPalette, 0.35);	
	
	jjSetWaterGradient(99,143,68, 24,48,32);
	jjWaterLighting = WATERLIGHT::GLOBAL;
	jjSetWaterLevel(54.5f*32, true);
	
	jjSetDarknessColor(jjPALCOLOR(0,0,0));		//This unfucks 8-bit
						
	
	/********************************************************************* EXTRA TILES AND LAYERS **********************************************************************/
	importTilesIntoLayers();
	
	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);
      			
	jjLayers[6].spriteMode = SPRITE::BRIGHTNESS;
	jjLayers[6].spriteParam = 64;	//50% light
	jjLayers[6].yOffset = 16;

	jjTilesFromTileset("Carrot1.j2t", 264, 1);
	jjPIXELMAP carrotsign(1170);
	carrotsign.save(823);
	
	jjTilesFromTileset("Lomat.j2t", 0, 0);
	
		
	/*********************************************************** MODIFIED OBJECT PROPERTIES AND BEHAVIORS **************************************************************/
	jjSampleLoad(SOUND::P2_POEP, "spelunky_ignite.wav");	

	jjObjectPresets[OBJECT::ICEAMMO15].direction = SPRITE::FLIPV;
	jjObjectPresets[OBJECT::MORPH].direction = SPRITE::FLIPV;
	
	jjObjectPresets[OBJECT::FULLENERGY].behavior = BlockedCarrot;	
	jjObjectPresets[OBJECT::GOLDCOIN].behavior = OffsetCoin;
	
	jjObjectPresets[OBJECT::FROZENSPRING].behavior = RefreezingSpring;
	jjObjectPresets[OBJECT::FROZENSPRING].ySpeed = -32.5f;
}

void BlockedCarrot(jjOBJ@ obj) {
	if (obj.state == STATE::START) {
		obj.lightType = LIGHT::BRIGHT;
		obj.light = 14;
	}
	if (jjEventGet(uint16(obj.xPos/32), uint16(obj.yPos/32)) == AREA::HURT) {
		if (obj.xSpeed > 0) {
			obj.xSpeed = 0;
			
			array<jjLAYER@> layers = jjLayerOrderGet();
			if (layers[6].spriteParam != 180) layers[6].spriteParam = 180;				
		}
		else if (obj.xSpeed < 0) {
			obj.xSpeed = 0;
			
			array<jjLAYER@> layers = jjLayerOrderGet();
			if (layers[5].spriteParam != 180) layers[5].spriteParam = 180;
		}
	}
	obj.behave(BEHAVIOR::PICKUP);
}

void OffsetCoin(jjOBJ@ obj) {
	if (obj.state == STATE::START) {
		obj.xPos = obj.xOrg + 16;
		obj.lightType = LIGHT::POINT2;
		obj.direction = SPRITE::FLIPV;
	}
	obj.behave(BEHAVIOR::PICKUP);
}

//jb exclusive behaviors

const int FREEZETIME = 490;	//7 seconds
void RefreezingSpring(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::SPRING, false);
	if (obj.freeze == 0) {
		obj.age++;
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, 216);
	}
	else {
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::FROZEN);
	}
	switch (obj.age) {
		case 1:
			jjSample(obj.xPos, obj.yPos, SOUND::COMMON_BURN, 32);
			break;
		case (FREEZETIME - 28):
		case (FREEZETIME - 21):
		case (FREEZETIME - 14):
			jjAddObject(OBJECT::EXPLOSION, obj.xPos + (12 - jjRandom()&24), obj.yPos - (6 + jjRandom()&12), obj.objectID, CREATOR::OBJECT, FreezeSparkleParticle);
			break;
		case FREEZETIME:
			jjAddObject(OBJECT::FROZENSPRING, obj.xOrg, obj.yOrg);
			obj.delete();
			break;
	}
}

void FreezeSparkleParticle(jjOBJ@ obj) {
	if (obj.state == STATE::START) {
		obj.determineCurAnim(ANIM::PICKUPS, 86);
		obj.determineCurFrame();
	}
	obj.behave(BEHAVIOR::EXPLOSION, false);
	jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, 0, SPRITE::FROZEN);
}

//end jb exclusive behaviors

void importTilesIntoLayers() {
	const int oldTileCount = jjTileCount;
	
	//comment 1
	
	jjTilesFromTileset("Jungle1_1.00gx.j2t", 840, 60);
	jjTilesFromTileset("Jungle1_1.00gx.j2t", 840, 60);
	array<uint8> fullblack(256, 176);
	fullblack[0] = 0;
	jjTilesFromTileset("Jungle1_1.00gx.j2t", 900, 59, fullblack);
	
	//comment about recoloring
	
	for (int i = 1000; i <= 1059; i++) {
		jjPIXELMAP recoloredTree(i);
		for (uint x = 0; x < recoloredTree.width; ++x)
			for (uint y = 0; y < recoloredTree.height; ++y)			
				if (recoloredTree[x,y] >= 136 && recoloredTree[x,y] <= 143) {
					recoloredTree[x,y] += 56;
				}
				else if (recoloredTree[x,y] >= 149 && recoloredTree[x,y] <= 156) {
					recoloredTree[x,y] += 43;
				}
		recoloredTree.save(i);
	}
	
	array<jjLAYER@> extraForeLayer = jjLayersFromLevel("mlprice-extra.j2l", array<uint> = {1,2,2}, 0);
	array<jjLAYER@> jungLayerFront = jjLayersFromLevel("mlprice-extra.j2l", array<uint> = {6}, oldTileCount - 840);
	array<jjLAYER@> jungLayersBack = jjLayersFromLevel("mlprice-extra.j2l", array<uint> = {5,6,7}, oldTileCount - 780);
	
	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);
	
	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(929);
		
	jjLayerOrderSet(array<jjLAYER@> = {
		jjLayers[1],
		extraForeLayer[0],
		jjLayers[2],
		jjLayers[3],
		jjLayers[4],
		extraForeLayer[1],
		extraForeLayer[2],
		jjLayers[5],
		jjLayers[6],
		jungLayerFront[0],
		jungLayersBack[0],
		jungLayersBack[1],
		jungLayersBack[2],
		jjLayers[8]
		}
	);
	
	jjTileSet(8, 0, 0, 909);
	
	jungLayerFront[0].xSpeed = 0.35f;
	jungLayersBack[1].ySpeed = 0.025f;
	
	extraForeLayer[1].spriteMode = extraForeLayer[2].spriteMode = SPRITE::BLEND_NORMAL;
	extraForeLayer[1].spriteParam = extraForeLayer[2].spriteParam = 0;
	
	extraForeLayer[1].xOffset = -66*32;
	extraForeLayer[1].yOffset = -48*32;
	
	extraForeLayer[2].xOffset = -70*32;
	extraForeLayer[2].yOffset = -48*32;	
}

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);
}

const int MAXSHIELDTIME = 1050;
void onPlayer(jjPLAYER@ play) {
	if (play.yPos >= 0) {
		//Wherein "skill 3" means "MP Only"
		int skill = jjParameterGet(uint16(play.xPos/32), uint16(play.yPos/32), -4, 2);	
		if (skill == 3) {
			if (jjLayers[2].spriteParam > 96) {
				if (jjLayers[2].spriteParam == 255) jjSamplePriority(SOUND::P2_POEP);
				jjLayers[2].spriteParam = jjLayers[2].spriteParam - 10;
			}
		}
		else if (jjLayers[2].spriteParam != 255) {
			jjLayers[2].spriteParam = jjLayers[2].spriteParam + 10;
		}
	}
	//Warp ID 999 is reserved for the /ready command.
	if (play.warpID == 999 && play.coins < 5) play.coins = 5;
	
	//jb exclusive
	if (play.shieldTime > MAXSHIELDTIME) play.shieldTime = MAXSHIELDTIME;
}

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;
	}
	layers[0].hasTiles = !jjLowDetail;
	layers[1].yOffset = jjWaterLevel * -1;
	
	if (layers[5].spriteParam > 0) {
		layers[5].spriteParam = layers[5].spriteParam - 10;
	}
	if (layers[6].spriteParam > 0) {
		layers[6].spriteParam = layers[6].spriteParam - 10;
	}
		
	if (jjLowDetail || jjColorDepth == 8 || (jjLowDetail && jjColorDepth == 8)) {
		jjWaterLayer = 9;
	}
	else jjWaterLayer = 1;
	
	if (jjGameTicks == 1) jjTriggers[31] = true;
	//jjTriggers[1] = (jjGameCustom == GAME::FR) ? true : false;
}

//jb exclusive (ironically, Text events with Vanish=1 don't play well with the vanishing foreground trick)
bool alreadySawMessage = false;
void onFunction0(jjPLAYER@ play) {
	if (!alreadySawMessage) {
		play.showText(0, 0);
		alreadySawMessage = true;
	}
}