Downloads containing ab23ctf20.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::EnergyBlastMLLEWrapper(), null, null, null, null, null, null}); ///@MLLE-Generated
#include "MLLE-Include-1.5w.asc" ///@MLLE-Generated
#pragma require "ab23ctf20-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "ab23ctf20.j2l" ///@MLLE-Generated
#include "SEenergyblast-mlle.asc" ///@MLLE-Generated
#pragma require "SEenergyblast-mlle.asc" ///@MLLE-Generated
#include "Resize v11.asc"

const uint8 EXTRAAMMOPIECES = 3;
const int VANISHTIME = 560; //8 seconds
jjOBJ@ extrapiece;

void onLevelLoad() {
	jjUseLayer8Speeds = true;
	jjTexturedBGTexture = TEXTURE::MEDIVO;
	
	jjAnimSets[ANIM::CUSTOM[1]].allocate(array<uint>(99, 99));
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 0] = jjAnimations[jjAnimSets[ANIM::FLAG] + 1]; //ctf base
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 1] = jjAnimations[jjAnimSets[ANIM::FLAG] + 2]; //ctf light
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 2] = jjAnimations[jjAnimSets[ANIM::FLAG] + 3]; //blue flag
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 3] = jjAnimations[jjAnimSets[ANIM::FLAG] + 7]; //red flag
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 4] = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 21]; //carrot
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 5] = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 54]; //bouncer crate
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 6] = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 56]; //seek crate
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 7] = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 57]; //rf crate
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 8] = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 58]; //toaster crate
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 9] = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 61]; //bouncer pu
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 10] = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 63]; //seek pu
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 11] = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 64]; //rf pu
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 12] = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 65]; //toaster pu
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 13] = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 66]; //gun8 pu
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 14] = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 82]; //full nrg
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 15] = jjAnimations[jjAnimSets[ANIM::LIZARD] + 3]; //copter
	jjAnimations[jjAnimSets[ANIM::CUSTOM[1]] + 16] = jjAnimations[jjAnimSets[ANIM::AMMO] + 78]; //ammo crate shard
	
	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] = 144 + (sprite[x,y]&7)*2;
			}
		}
		sprite.save(frame);
	}
	
	jjANIMATION@ animRain = jjAnimations[jjAnimSets[ANIM::COMMON] + 2];
	for (uint j = 0; j < animRain.frameCount; j++) {
		jjANIMFRAME@ frameRain = jjAnimFrames[animRain + j];
		jjPIXELMAP sprite(frameRain);
		for (uint x = 0; x < sprite.width; ++x) {
			for (uint y = 0; y < sprite.height; ++y) {
				sprite[x,y] = 0;
			}
		}
		sprite.save(frameRain);
	}
	
	Resize::Resize(
		jjAnimSets[ANIM::BRIDGE],
		6,
		2,
		Resize::Method::Scale2x
	);
	
	Resize::Resize(
		jjAnimSets[ANIM::MOTH],
		4,
		2,
		Resize::Method::Scale2x
	);
	
	Resize::Resize(
		jjAnimSets[ANIM::PLUS_SCENERY],
		1,
		2,
		Resize::Method::Scale2x
	);
	
	
	Resize::Resize(
		jjAnimSets[ANIM::SPRING],
		9,
		2,
		Resize::Method::Scale2x
	);
	
	Resize::Resize(
		jjAnimSets[ANIM::CUSTOM[1]],
		17,
		2,
		Resize::Method::Scale2x
	);
	
	generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[2]], array<uint> = {40});
	turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 26.5f, false);
	
	jjObjectPresets[OBJECT::REDSPRING].ySpeed = jjObjectPresets[OBJECT::REDSPRING].ySpeed * 1.5;
	jjObjectPresets[OBJECT::GREENSPRING].ySpeed = jjObjectPresets[OBJECT::GREENSPRING].ySpeed * 1.5;
	jjObjectPresets[OBJECT::BLUESPRING].ySpeed = jjObjectPresets[OBJECT::BLUESPRING].ySpeed * 1.5;
	
	jjObjectPresets[OBJECT::FROZENSPRING].causesRicochet = false;
	
	jjObjectPresets[OBJECT::STEADYLIGHT].behavior = PlayerLight();
	
	jjObjectPresets[OBJECT::BOUNCERAMMO15].behavior = 
	jjObjectPresets[OBJECT::SEEKERAMMO15].behavior = 
	jjObjectPresets[OBJECT::RFAMMO15].behavior = 
	jjObjectPresets[OBJECT::TOASTERAMMO15].behavior = ExtraAmmoFrom15Crate;
	
}

void onLevelBegin() {
	jjANIMATION@ animCTFLight = jjAnimations[jjAnimSets[ANIM::CUSTOM[1]].firstAnim + 1];
	for (uint frameID = 0; frameID < animCTFLight.frameCount; ++frameID) {
		jjAnimFrames[animCTFLight.firstFrame + frameID].hotSpotX = 18;
		jjAnimFrames[animCTFLight.firstFrame + frameID].hotSpotY = -53;
	}
	
	for (int i = 9; i <= 13; i++) {
		jjANIMATION@ animPowerup = jjAnimations[jjAnimSets[ANIM::CUSTOM[1]].firstAnim + i];
		for (uint frameID = 0; frameID < animPowerup.frameCount; ++frameID) {
			jjAnimFrames[animPowerup.firstFrame + frameID].hotSpotY = -64;
		}
	}
	
	jjANIMATION@ animCopter = jjAnimations[jjAnimSets[ANIM::CUSTOM[1]].firstAnim + 15];
	for (uint frameID = 0; frameID < animCopter.frameCount; ++frameID) {
		jjAnimFrames[animCopter.firstFrame + frameID].hotSpotY = -82;
	}
}

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.causesRicochet = 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();
}
void handleFastCustomSpringSpeeds(jjPLAYER@ play) {
	if (play.ySpeed < -32.f) {
		fastCustomSpringSpeeds[play.localPlayerID] = int(ceil((play.ySpeed + 32.f) / -0.125f));
	} else if (fastCustomSpringSpeeds[play.localPlayerID] != 0) {
		if (play.ySpeed < -31.f) {
			fastCustomSpringSpeeds[play.localPlayerID]--;
			play.ySpeed = -32.f;
		} else {
			fastCustomSpringSpeeds[play.localPlayerID] = 0;
		}
	}
}

class PlayerLight : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::STEADYLIGHT);
		
		obj.xPos = jjLocalPlayers[0].cameraX + 400;
		obj.yPos = jjLocalPlayers[0].cameraY + 300;
		obj.light = jjLowDetail || jjLocalPlayerCount > 1? 0:127;
	}
}

void onPlayer(jjPLAYER@ play) {
	play.lightType = LIGHT::NONE;
	handleFastCustomSpringSpeeds(play);
	
	if (play.fly != FLIGHT::NONE && play.fly != FLIGHT::FLYCARROT && play.fly != FLIGHT::AIRBOARD) {
		if (play.keyUp) {
			play.ySpeed = -5;
			play.keyUp = false;
		}
	}
	
	jjSnowingType = jjGameTicks % 35 == 0? SNOWING::LEAF : SNOWING::RAIN;
	jjSnowingIntensity = 0;
	jjIsSnowingOutdoorsOnly = true;
	jjIsSnowing = !jjLowDetail;
	
	for (int i = 0; i < 1024; i++) {
		jjPARTICLE@ particle = jjParticles[i];
		if (particle.type == PARTICLE::LEAF) {
			particle.xSpeed = -0.5;
			particle.ySpeed = 0.25;
		}
		if (particle.type == PARTICLE::RAIN) {
			particle.type = PARTICLE::INACTIVE;
		}
	}
}

void onMain() {
	jjLayers[3].spriteMode = jjColorDepth == 16? SPRITE::BLEND_DARKEN : SPRITE::BLEND_NORMAL;
	jjLayers[3].spriteParam = jjColorDepth == 16? 196 : 96;
	
	array<jjLAYER@> layers = jjLayerOrderGet();
	layers[0].hasTiles = jjLayers[1].hasTiles;
	
	jjTexturedBGFadePositionY = jjLowDetail? 0.5:0.25;
	
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ obj = jjObjects[i];
		if (obj.behavior == BEHAVIOR::SPRING || obj.behavior == BEHAVIOR::MONITOR) {
			obj.xPos = obj.xOrg + 16;
		}
		if (obj.isActive && obj.eventID == OBJECT::COPTER && obj.state == STATE::FLY) {
			obj.counter = 40;
			obj.xPos = obj.xOrg + 16;
			if (obj.var[4] == 0)
				obj.state = STATE::DONE;
		}
	}
}

void ExtraAmmoFrom15Crate(jjOBJ@ obj) {
	if (obj.state == STATE::START) {
		obj.doesHurt = EXTRAAMMOPIECES;
		obj.var[10] = obj.var[2];
	}	
	if (obj.state == STATE::ACTION) {
		while (obj.doesHurt > 0) {
			@extrapiece = jjObjects[jjAddObject(obj.var[10], obj.xPos + jjRandom()%24, obj.yPos)];
			extrapiece.behavior = BEHAVIOR::FLICKERGEM;
			extrapiece.counter = VANISHTIME;
			extrapiece.state = STATE::FLOATFALL;
			
			obj.doesHurt--;
		}
	}
	obj.behave(BEHAVIOR::AMMO15);
}

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

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