Downloads containing ab23ctf06.j2as

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

File preview

const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, null, se::RollerMLLEWrapper(), null, null, null, null, se::EnergyBlastMLLEWrapper(), null}); ///@MLLE-Generated
#include "MLLE-Include-1.5w.asc" ///@MLLE-Generated
#pragma require "ab23ctf06-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "ab23ctf06.j2l" ///@MLLE-Generated
#include "SEenergyblast-mlle.asc" ///@MLLE-Generated
#pragma require "SEenergyblast-mlle.asc" ///@MLLE-Generated
#include "SEroller-mlle.asc" ///@MLLE-Generated
#pragma require "SEroller-mlle.asc" ///@MLLE-Generated

#pragma require "Castle2E.j2t"

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

#include "MLLE-Weapons.asc"
#pragma require "MLLE-Weapons.asc"

void onLevelLoad() {
		jjPAL eclipse;
		eclipse.load("Castle2E.j2t");
		jjPalette.copyFrom(24, 16, 24, eclipse, 0.75f);
		jjPalette.copyFrom(40, 1,  40, eclipse, 0.5f);
		jjPalette.copyFrom(41, 15, 41, eclipse, 0.75f);
		jjPalette.copyFrom(64, 8,  64, eclipse, 0.75f);
		jjPalette.copyFrom(72, 8,  72, eclipse, 1.f);
		jjPalette.copyFrom(80, 8,  80, eclipse, 0.5f);
		jjPalette.copyFrom(88, 8,  88, eclipse, 0.75f);
		jjPalette.apply();

		jjTexturedBGTexture = TEXTURE::MEDIVO;
		jjUseLayer8Speeds = true;
		
		jjObjectPresets[OBJECT::BOUNCERAMMO3].lightType =
		jjObjectPresets[OBJECT::ICEAMMO3].lightType =
		jjObjectPresets[OBJECT::SEEKERAMMO3].lightType =
		jjObjectPresets[OBJECT::RFAMMO3].lightType =
		jjObjectPresets[OBJECT::GUN8AMMO3].lightType =
		jjObjectPresets[OBJECT::GUN9AMMO3].lightType =
		jjObjectPresets[OBJECT::CTFBASE].lightType =
		jjObjectPresets[OBJECT::SHARD].lightType = 
		jjObjectPresets[OBJECT::BOUNCERPOWERUP].lightType =
		jjObjectPresets[OBJECT::ICEPOWERUP].lightType =
		jjObjectPresets[OBJECT::RFPOWERUP].lightType = LIGHT::POINT2;
		
		jjObjectPresets[OBJECT::FULLENERGY].lightType = LIGHT::BRIGHT;
		jjObjectPresets[OBJECT::FULLENERGY].light = 10;

		for (int i = 33; i < 40; i++) {
			jjObjectPresets[i].behavior = CannotBeShotDown(jjObjectPresets[i].behavior);
		}
		
		jjObjectPresets[OBJECT::STEADYLIGHT].behavior = ToggleableTorch;
		
		jjObjectPresets[OBJECT::APPLE].behavior = 
		jjObjectPresets[OBJECT::BANANA].behavior = 
		jjObjectPresets[OBJECT::BURGER].behavior = Wisp;
		
		jjObjectPresets[OBJECT::PRETZEL].behavior = WarpOrb();
		jjObjectPresets[OBJECT::PRETZEL].lightType = LIGHT::FLICKER;
		jjObjectPresets[OBJECT::PRETZEL].scriptedCollisions = true;
		
		jjObjectPresets[OBJECT::GRASSPLATFORM].bulletHandling = HANDLING::IGNOREBULLET;
		 	
	   	jjObjectPresets[OBJECT::BOUNCERPOWERUP].direction = SPRITE::FLIPH;
	   	
	   	//jjObjectPresets[OBJECT::TRIGGERCRATE].determineCurAnim(ANIM::CUSTOM[0], 2);
	   	//jjObjectPresets[OBJECT::TRIGGERCRATE].determineCurFrame();
	   	//jjObjectPresets[OBJECT::TRIGGERCRATE].behavior = ShittyBlastCrate;
	   	
	   	for (int i = 3240; i < 3280; i++) {
			jjTileType[i] = 5;
		}
		
		generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[99]], array<uint> = {40, 16});
		turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 29.f, false);
		turnIntoCustomSpring(jjObjectPresets[OBJECT::GREENSPRING],  1, 24.1f, false);
		
		jjANIMFRAME@ frame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::SPIKEBOLL].firstAnim].firstFrame];
		jjPIXELMAP(0, 0, 32, 32, 4).save(frame);
		frame.hotSpotX = -frame.width/2;
		frame.hotSpotY = -frame.height + 14;
		
		for (int x = 0; x < jjLayerWidth[1]; x++) {
			for (int y = 0; y < jjLayerHeight[1]; y++) {
				uint16 myTile = jjTileGet(1, x, y);
				if (myTile < 1350) {
					jjTileSet(1, x, y, myTile + 1350);
				}
			}
		}
		
		jjANIMFRAME@ CircularGlow = jjAnimFrames[jjObjectPresets[OBJECT::ORANGE].curFrame];
		jjPIXELMAP circle(32, 32);
		for (uint x = 0; x < circle.width; ++x)
			for (uint y = 0; y < circle.height; ++y)
				circle[x,y] = (sqrt(pow(16-int(x), 2) + pow(16-int(y), 2)) < 16) ? 234 : 0;
		circle.save(CircularGlow);
		CircularGlow.hotSpotX = -CircularGlow.width/2;
		CircularGlow.hotSpotY = -CircularGlow.height/2;
}

void onLevelBegin() {
		jjAddObject(OBJECT::APPLE, 736, 736);		//bouncer powerup
		jjAddObject(OBJECT::APPLE, 1824, 608);		//full energy
		jjAddObject(OBJECT::APPLE, 1920, 1600);		//roller powerup
		jjAddObject(OBJECT::APPLE, 2976, 992);		//RF powerup
}

void onMain() {	
		jjLAYER@ shadows = MLLE::GetLayer("Ceiling Shadow Layer");
		
		if (jjLowDetail || jjColorDepth == 8) {
			jjLayers[7].spriteParam = 0;
			jjLayers[7].hasTiles = false;
			shadows.hasTiles = false;
		}
		else {			
			jjLayers[7].spriteParam = 96 + int(jjCos(jjGameTicks << 2) * 32);
			jjLayers[7].hasTiles = true;
			shadows.hasTiles = true;
		}
		
		jjLAYER@ torches = MLLE::GetLayer("Torch Layer");
		jjLAYER@ vegs = MLLE::GetLayer("Vegitation Layer");
		jjLAYER@ owls = MLLE::GetLayer("Owl Layer");	
		
		jjLayers[5].hasTiles = jjLayers[6].hasTiles = torches.hasTiles = vegs.hasTiles = owls.hasTiles = !jjLowDetail;
}

class CannotBeShotDown : jjBEHAVIORINTERFACE {
	jjBEHAVIOR originalBehavior;
	CannotBeShotDown(jjBEHAVIOR behavior) {
		originalBehavior = behavior;
	}
	void onBehave(jjOBJ@ obj) override {
		obj.behave(originalBehavior);
		if (obj.state == STATE::FLOATFALL)
			obj.state = STATE::FLOAT;
		if (obj.eventID == OBJECT::FULLENERGY)
			obj.xPos = obj.xOrg - 16;
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
		obj.behavior = originalBehavior;
		if (bullet is null)
			player.objectHit(obj, force, obj.playerHandling);
		else
			bullet.objectHit(obj, obj.playerHandling);
		obj.behavior = CannotBeShotDown(obj.behavior);
		return true;
	}
}

//class OriginalBehavior : jjBEHAVIORINTERFACE {
    //private jjBEHAVIOR nativeBehavior;
    //OriginalBehavior(const jjBEHAVIOR &in nb) { nativeBehavior = nb; }

    //void onBehave(jjOBJ@ obj) {
        //obj.behave(nativeBehavior);
        //if (obj.state == STATE::FLOATFALL) obj.state = STATE::FLOAT;
    //}
    
	//bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
		//auto@ pickup = cast<se::AmmoPickup@>(cast<jjBEHAVIORINTERFACE@>(nativeBehavior));
		//if (pickup !is null)
			//return pickup.onObjectHit(obj, bullet, player, force);
		//else return false;
	//}
//}

void ToggleableTorch(jjOBJ@ obj) {
		if (!jjLowDetail)
			obj.lightType = LIGHT::POINT2;
		else
			obj.lightType = LIGHT::NONE;
			
		obj.behave(BEHAVIOR::STEADYLIGHT);
}

void Wisp(jjOBJ@ obj) {
		if (obj.state == STATE::START) {
			obj.bulletHandling = HANDLING::IGNOREBULLET;
			obj.playerHandling = HANDLING::PARTICLE;
			obj.deactivates = obj.triggersTNT = obj.isTarget = obj.isBlastable = obj.isFreezable = false;
		}
		
		switch (obj.eventID) {
			case OBJECT::APPLE:	
				obj.xPos = obj.xOrg + int(jjSin(jjGameTicks << 2) * 64);
				obj.yPos = obj.yOrg + int(jjSin(jjGameTicks << 1) * 32);
				break;
			case OBJECT::BANANA:	
				obj.xPos = obj.xOrg + int(jjSin(jjGameTicks * 5) * 48);
				obj.yPos = obj.yOrg - int(jjSin(jjGameTicks << 2) * 48) + 24;
				break;
			case OBJECT::BURGER:	
				obj.xPos = obj.xOrg - int(jjSin(jjGameTicks << 1) * 48);
				obj.yPos = obj.yOrg - int(jjSin(jjGameTicks << 2) * 32) + 80 + int(jjCos(jjGameTicks << 1) * 24);
				break;
		}
		
		obj.behave(BEHAVIOR::PICKUP, false);
		if (!jjLowDetail) {
			obj.lightType = LIGHT::POINT2;
			jjDrawTile(obj.xPos - 16, obj.yPos - 16, 176, TILE::ALLQUADRANTS, 3);
		}
		else obj.lightType = LIGHT::NONE;
}

int fdim(int n) {
	if (n > 0) return n;
	else return 0;	
}

int VeryCoolMathWizFunction(int n) {
	return int(255 * tanh(jjSin(n << 2)*2)/tanh(2));
}

class WarpOrb : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		if (obj.state == STATE::START) {
			obj.xPos = obj.xOrg += 16;
			obj.yPos = obj.yOrg += 8;	
		}
		obj.behave(BEHAVIOR::PICKUP, false);
		if (obj.state == STATE::FLOATFALL) obj.state = STATE::FLOAT;
	}
	void onDraw(jjOBJ@ obj) {			
		int frame = obj.objectID * 8 + jjGameTicks;
		frame = (frame + int(obj.xPos) + int(obj.yPos) * 256)*16;
		
		jjDrawTile(obj.xPos- 16, (obj.yPos + jjSin(frame)*4) - 18, 8 + TILE::ANIMATED);
		jjDrawSprite(obj.xPos, obj.yPos + jjSin(frame)*4, ANIM::SPIKEBOLL, 0, 0, 0, SPRITE::TRANSLUCENT, 255);
		jjDrawSprite(obj.xPos, obj.yPos + jjSin(frame)*4, ANIM::SPIKEBOLL, 0, 0, 0, SPRITE::BLEND_COLOR, 255);
		jjDrawSprite(obj.xPos, obj.yPos + jjSin(frame)*4, ANIM::SPIKEBOLL, 0, 0, 0, SPRITE::TRANSLUCENT, 255);
		
		jjDrawSpriteFromCurFrame(obj.xPos, (obj.yPos + jjSin(frame)*4) - 2,	jjObjectPresets[OBJECT::ORANGE].curFrame, 0, SPRITE::BLEND_COLOR, fdim(VeryCoolMathWizFunction(jjGameTicks)));
		
		//jjDrawString(obj.xPos + 48, obj.yPos, "" + VeryCoolMathWizFunction(jjGameTicks));
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
		player.warpToID(0);
		jjSample(player.xPos, player.yPos, SOUND::COMMON_PICKUP1, 63, 17500);
		obj.frameID = 0;
		obj.behavior = BEHAVIOR::EXPLOSION2;
		return true;
	}
}

//void ShittyBlastCrate(jjOBJ@ obj) {
	//if (obj.state == STATE::ACTION) {
		//for (int i = 0; i < 5; ++i) {
			//jjOBJ@ ExtraBlastAmmo = jjObjects[jjAddObject(OBJECT::ICEAMMO3, obj.xPos + jjRandom()%24, obj.yPos - 32 - jjRandom()%6, obj.objectID)];
			//ExtraBlastAmmo.xSpeed = ((jjRandom() & 30) - 7.5f) / 2.f;
			//ExtraBlastAmmo.ySpeed = -1.4f - ((jjRandom() & 5) / 2.f);
			//ExtraBlastAmmo.behavior = MLLEWeapons::AmmoPickupWithCrateAndCorpseSupport(
				//jjAnimations[jjAnimSets[ANIM::CUSTOM[0]].firstAnim],
				//jjAnimations[jjAnimSets[ANIM::CUSTOM[0]].firstAnim + 1],		//unused in the level
				//5
			//);
			//ExtraBlastAmmo.counter = 560;
		//}
	//}
	//obj.behave(BEHAVIOR::CRATE);
//}

void onPlayerInput(jjPLAYER@ play) {
	MLLE::WeaponHook.processPlayerInput(play);
}

bool onDrawAmmo(jjPLAYER@ play, jjCANVAS@ canvas) {
	return MLLE::WeaponHook.drawAmmo(play, canvas);
}

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