Downloads containing ab25btl22.j2as

Downloads
Name Author Game Mode Rating
JJ2+ Only: Anniversary Bash 25 Battle Jazz2Online Battle N/A Download file

File preview

const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, null, null, se::FireworkMLLEWrapper(), null, null, null, WeaponVMega::Voranj::Weapon(), null}); ///@MLLE-Generated
#include "MLLE-Include-1.6w.asc" ///@MLLE-Generated
#pragma require "ab25btl22-MLLE-Data-4.j2l" ///@MLLE-Generated
#pragma require "ab25btl22-MLLE-Data-3.j2l" ///@MLLE-Generated
#pragma require "ab25btl22-MLLE-Data-2.j2l" ///@MLLE-Generated
#pragma require "ab25btl22-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "ab25btl22.j2l" ///@MLLE-Generated
#include "WeaponVMega8.asc" ///@MLLE-Generated
#pragma require "WeaponVMega8.asc" ///@MLLE-Generated
#include "SEfirework-mlle.asc" ///@MLLE-Generated
#pragma require "SEfirework-mlle.asc" ///@MLLE-Generated
#pragma require "rain9.wav"
#pragma require "lightning2.wav"
#pragma require "floorslide.wav"
#pragma require "floorslideclose.wav"

int sample, time = 0;
int lightningDelay = 90;
float lightningOffset = 0;
bool lightning, playOnceL, playOnceR = false;
array<bool> stopwatch(4, false);

void onLevelLoad() {
	jjUseLayer8Speeds = true;
	
	jjSetWaterLevel(89*32, true);
	jjSetWaterGradient(40, 45, 35, 200, 240, 180);
	jjWaterLighting = WATERLIGHT::GLOBAL;
	
	jjAnimSets[ANIM::UTERUS].load();
	jjAnimations[jjAnimSets[ANIM::AMMO] + 59] = jjAnimations[jjAnimSets[ANIM::UTERUS] + 6];
	
	jjANIMATION@ anim = jjAnimations[jjAnimSets[ANIM::UTERUS] + 6];
	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] >= 80 && sprite[x,y] <= 87)) sprite[x,y] = 40 + (sprite[x,y]&7);
			}
		}
		sprite.save(frame);
	}
	
	jjObjectPresets[OBJECT::ICEBULLET].xSpeed = jjObjectPresets[OBJECT::ICEBULLETPU].xSpeed = 11;
	jjObjectPresets[OBJECT::ICEBULLET].var[6] = jjObjectPresets[OBJECT::ICEBULLETPU].var[6] = 16;
	jjWeapons[WEAPON::ICE].gradualAim = true;
	
	jjObjectPresets[OBJECT::TOASTERPOWERUP].direction = 0;
	
	jjObjectPresets[OBJECT::TNT].killAnim = jjObjectPresets[OBJECT::BLASTERBULLET].killAnim;
	jjObjectPresets[OBJECT::TNT].determineCurFrame();
	jjObjectPresets[OBJECT::TNT].lightType = LIGHT::NONE;
	jjObjectPresets[OBJECT::TNT].behavior = SpikeBomb();
	
	jjObjectPresets[OBJECT::COPTER].triggersTNT = false;
	jjObjectPresets[OBJECT::COPTER].lightType = LIGHT::NONE;
	
	jjObjectPresets[OBJECT::STOPWATCH].behavior = SuperStopwatch();
	jjObjectPresets[OBJECT::STOPWATCH].scriptedCollisions = true;
	
	for (int i = 0; i < 255; i++) {
		if (jjObjectPresets[i].behavior == BEHAVIOR::MONITOR) jjObjectPresets[i].triggersTNT = true;
	}
	
	generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {40, 88});
	turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 21.f, false);
	turnIntoCustomSpring(jjObjectPresets[OBJECT::HORREDSPRING], 1, 28.5f, false);
	
	jjObjectPresets[OBJECT::HORREDSPRING].causesRicochet = false;
	jjObjectPresets[OBJECT::HORREDSPRING].lightType = LIGHT::NONE;
	jjObjectPresets[OBJECT::FROZENSPRING].lightType = LIGHT::NONE;
	
	jjPIXELMAP rain(32,32);
	for (uint x = 0; x < rain.width; ++x) {
		for (uint y = 0; y < rain.height; ++y) {
			if (x == 16) {
				if (y <= 16) rain[x,y] = 76;
				else if (y > 16 && y <= 24) rain[x,y] = 75;
				else rain[x,y] = 0;
			} else {
				rain[x,y] = 0;
			}
		}
	}
		
	jjANIMATION@ animRain = jjAnimations[jjAnimSets[ANIM::COMMON].firstAnim + 2];
	for (uint frameID = 0; frameID < animRain.frameCount; ++frameID) {
		jjANIMFRAME@ frame = jjAnimFrames[animRain.firstFrame + frameID];
		rain.save(frame);
		frame.hotSpotX = -frame.width/2;
		frame.hotSpotY = -frame.height;
	}
}

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

class SpikeBomb : jjBEHAVIORINTERFACE {
	int timer = 0;
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::TNT);
		
		if (obj.counter == 1 && jjPlayers[obj.creatorID].isLocal && obj.state != STATE::EXPLODE) jjSample(obj.xPos, obj.yPos, SOUND::COMMON_FOEW2, 0, 0);
		
		if (!jjMaskedHLine(int(obj.xPos - 12) , 24, int(obj.yPos + 8))) {
			obj.yPos += 5;
		}
		
		if (obj.state == STATE::EXPLODE) {
			if (obj.counter == 24) {
				jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PISTOL1, 0, 0);
				for (int i = -8; i <= 8; i += 8) {
					for (int j = -8; j <= 8; j += 8) {
						if (i != 0 || j != 0) {
							int id = jjAddObject(OBJECT::BULLET, obj.xPos, obj.yPos, obj.creatorID, CREATOR::PLAYER, BEHAVIOR::PEPPERBULLET);
							if (id != 0) {
								jjOBJ@ burst = jjObjects[id];
								burst.animSpeed = 1;
								burst.direction = obj.direction;
								burst.determineCurAnim(ANIM::AMMO, 16);
								burst.determineCurFrame();
								burst.behavior = Spike();
								burst.playerHandling = HANDLING::PLAYERBULLET;
								burst.var[3] = 8;
								burst.xSpeed = j;
								burst.ySpeed = i;
								burst.lightType = jjObjectPresets[OBJECT::BLASTERBULLET].lightType;
								burst.light = jjObjectPresets[OBJECT::BLASTERBULLET].light;
								burst.isBlastable = false;
							}
						}
					}
				}
			}
		}
	}
}

class Spike : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PEPPERBULLET, obj.state == STATE::EXPLODE? true:false);
		obj.var[0] = int(atan2(-obj.ySpeed, obj.xSpeed) * (512.f * 0.318309886142228f));
	}
	void onDraw(jjOBJ@ obj) {
		if (obj.state != STATE::EXPLODE) jjDrawRotatedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.var[0], 0.75, 0.75, SPRITE::NORMAL);
	}
}

class SuperStopwatch : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PICKUP);
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bull, jjPLAYER@ play, int force) {
		if (play !is null) {
			if (play.isLocal) {
				stopwatch[play.localPlayerID] = true;
				time = 60*70;
				if (play.shieldTime > 0 && play.shieldType != SHIELD::NONE) play.shieldTime += 15*70; 
				jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PICKUP1);
				jjAlert("|||||You picked up the ||||||Super Stopwatch!  |||||(slows shield drain)");
			}
			obj.behavior = BEHAVIOR::EXPLOSION2;
			obj.scriptedCollisions = false;
			obj.frameID = 0;
		}
		return true;
	}
}

void onLevelReload() {
	MLLE::Palette.apply();
}

void onLevelBegin() {
	for (int i = 1; i < 255; i++) {
		jjOBJ@ preset = jjObjectPresets[i];
		if (preset.playerHandling == HANDLING::PICKUP) {
			preset.behavior = CannotBeShotDown(preset.behavior);
		}
	}
	
	jjSampleLoad(SOUND::WIND_WIND2A, "rain9.wav");
	jjSampleLoad(SOUND::BILSBOSS_THUNDER, "lightning2.wav");
	jjSampleLoad(SOUND::SCIENCE_PLOPKAOS, "floorslide.wav");
	jjSampleLoad(SOUND::BONUS_BONUS1, "floorslideclose.wav");
}

class CannotBeShotDown : jjBEHAVIORINTERFACE {
	CannotBeShotDown(const jjBEHAVIOR &in behavior) {
		originalBehavior = behavior;
	}
	void onBehave(jjOBJ@ obj) {
		obj.behave(originalBehavior);
		if (obj.state == STATE::FLOATFALL)
			obj.state = STATE::FLOAT;
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
		if (bullet is null) {
			obj.behavior = originalBehavior;
			if (player.objectHit(obj, force, obj.playerHandling))
				return true;
			obj.behavior = this;
		}
		return false;
	}
	private jjBEHAVIOR originalBehavior;
}

void onPlayer(jjPLAYER@ play) {
	array<jjLAYER@> layers = jjLayerOrderGet();
	const int lightningLayer = layers.length - 4;
	layers[lightningLayer].xOffset = lightningOffset;
	if (jjGameTicks == 1) layers[lightningLayer].hasTiles = false;
	if (!jjLowDetail) {
		if (lightning && lightningDelay > 0) lightningDelay--;
		
		if (jjGameTicks % 1000 >= 940 && jjGameTicks % 1000 <= 979) {
			if (jjGameTicks % 5 == 0) {
				layers[lightningLayer].hasTiles = true;
				play.lighting = 145;
			}
			else {
				layers[lightningLayer].hasTiles = false;
				play.lighting = 125;
			}
		
			if (jjGameTicks % 18 == 0) lightningOffset = jjRandom()%800;
		} 
		
		if (jjGameTicks % 1000 >= 980) {
			lightning = true;
			lightningDelay = 90;
		}
		
		if (lightningDelay < 90) {
			play.lighting = 100;
		}
			
		if (lightning && lightningDelay == 0) {
			for (int i = 0; i < 2; i++) {
				jjSample(play.xPos, play.yPos, SOUND::BILSBOSS_THUNDER, 41 + jjRandom()%22, 0);
			}
			lightning = false;
			lightningDelay = 90;
		}
	} else {
		play.lighting = 100;
		layers[lightningLayer].hasTiles = false;
	}
	jjEnforceLighting = jjLowDetail? LIGHT::OPTIONAL : LIGHT::COMPLETE;
	play.lightType = LIGHT::NONE;
	
	if (stopwatch[play.localPlayerID] && play.timerState == TIMER::STOPPED) play.timerStart(time);
	if (!stopwatch[play.localPlayerID]) play.timerStop();
	if (play.timerState == TIMER::STARTED && play.timerTime <= 3*70 && play.timerTime > 0 && play.timerTime % 70 == 0) jjSamplePriority(SOUND::COMMON_NOCOIN);
	if (play.timerTime == 1) {
		stopwatch[play.localPlayerID] = false;
	}
	if (play.timerState == TIMER::STARTED && jjGameState == GAME::STOPPED) play.timerPause();
	if (play.timerState == TIMER::PAUSED && jjGameState != GAME::STOPPED) play.timerResume();
	
	if (play.shieldTime > 15*70) play.shieldTime = 15*70;
	if (stopwatch[play.localPlayerID] && jjGameTicks % 4 > 0 && jjGameState != GAME::STOPPED) play.shieldTime++;
	
	const int bounds = 24;
	
	if (play.xPos > ((jjLayerWidth[4]*32) - bounds) || play.xPos < bounds) {
		play.xPos = play.xPos < (bounds+1)? bounds : (jjLayerWidth[4]*32) - bounds;
		play.xSpeed = 0;
		play.specialMove = 0;
	}
	
	if (play.health == 0) {
		time = play.timerTime;
	}
}

void onMain() {
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ obj = jjObjects[i];
		if (obj.isActive && obj.eventID == OBJECT::COPTER && obj.state == STATE::FLY) {
			obj.counter = 0;
			if (obj.var[4] == 0)
				obj.state = STATE::DONE;
		}
		if (obj.behavior == BEHAVIOR::SPRING && obj.eventID != OBJECT::HORBLUESPRING) {
			obj.xPos = obj.xOrg + 16;
		}
		if (obj.eventID == OBJECT::WATERSHIELD) {
			obj.xPos = obj.xOrg - 16;
			obj.direction = 0;
		}
		if (obj.eventID == OBJECT::HORBLUESPRING) {
			obj.xPos = obj.xOrg - 8;
		}
	}
	
	if (!jjLowDetail) {
		sample = jjSampleLooped(jjLocalPlayers[0].xPos, jjLocalPlayers[0].yPos, SOUND::WIND_WIND2A, sample, 24, 0);
	}
	
	jjIsSnowing = !jjLowDetail;
	for (int i = 0; i < 1024; i++) {
		jjPARTICLE@ particle = jjParticles[i];
		if (particle.type == PARTICLE::RAIN) {
			particle.xSpeed = 0;
			particle.ySpeed = jjLocalPlayers[0].ySpeed < 0? 10 : int(10 + jjLocalPlayers[0].ySpeed);
			
			if (jjTileGet(6, int(particle.xPos/32), int(particle.yPos/32)) != 0) {
				particle.type = PARTICLE::INACTIVE;
			}
		}
	}
	
	if (jjMaskedPixel(67*32, 50*32)) {
		if (!playOnceL) {
			jjSample(67*32, 50*32, SOUND::SCIENCE_PLOPKAOS, 60, 0);
			playOnceL = true;
		}
	} else {
		if (playOnceL) {
			jjSample(67*32, 50*32, SOUND::BONUS_BONUS1, 50, 0);
			playOnceL = false;
		}
	}
	
	if (jjMaskedPixel(74*32, 46*32)) {
		if (!playOnceR) {
			jjSample(74*32, 46*32, SOUND::SCIENCE_PLOPKAOS, 60, 0);
			playOnceR = true;
		}
	} else {
		if (playOnceR) {
			jjSample(74*32, 46*32, SOUND::BONUS_BONUS1, 50, 0);
			playOnceR = false;
		}
	}
	
	jjWaterLayer = jjLowDetail? 36:0;
}



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

bool onDrawPlayerTimer(jjPLAYER@ play, jjCANVAS@ canvas) {
	if (stopwatch[play.localPlayerID]) {
      	canvas.drawString(
			jjSubscreenWidth - 73,
	      	jjSubscreenHeight - 284,
	      	"" + (play.timerTime + 70) / 70,
	      	STRING::LARGE,
	      	STRING::PALSHIFT,
	      	play.timerTime > 3*70?
	      		0 :
	      		jjGameTicks % 28 > 14?
	      			-40 :
	      			-24
		);
		
		canvas.drawSprite(
			jjSubscreenWidth - 90,
			jjSubscreenHeight - 270,
			ANIM::PICKUPS,
			87, 
			(jjGameTicks >> 2)/4
		);
	}
	return true;
}