Downloads containing ab22btl20.j2as

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

File preview

const bool MLLESetupSuccessful = MLLE::Setup(); ///@MLLE-Generated
#include "MLLE-Include-1.5.asc" ///@MLLE-Generated
#pragma require "ab22btl20-MLLE-Data-2.j2l" ///@MLLE-Generated
#pragma require "ab22btl20-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "ab22btl20.j2l" ///@MLLE-Generated
#pragma require "SEroller.asc"
#include "SEroller.asc"

se::DefaultWeaponHook weaponHook;

jjPAL LavaFall;
jjPAL LavaFloor;

bool sprited;
uint sprite;
int glowValue;

void onLevelLoad() {
	se::roller.loadAnims(jjAnimSets[ANIM::CUSTOM[99]]);
	se::roller.loadSamples(array<SOUND::Sample> = {SOUND::P2_FART});
	se::roller.setAsWeapon(3, weaponHook);
	
	jjWeapons[WEAPON::ICE].allowed = jjWeapons[WEAPON::ICE].allowedPowerup = true;

	generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {40, 88, 48});
	turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 14.8f, false);
	turnIntoCustomSpring(jjObjectPresets[OBJECT::HORREDSPRING], 1, 28.f, false);
	turnIntoCustomSpring(jjObjectPresets[OBJECT::HORGREENSPRING], 2, 15.f, false);

	for (int i = 1; i < 255; i++) {
		if (jjObjectPresets[i].playerHandling == HANDLING::PICKUP && i != 72) {
			jjObjectPresets[i].behavior = CannotBeShotDown;
		}
	}

	//Fireball forced
	jjWeapons[WEAPON::GUN8].spread = SPREAD::NORMAL;
	jjObjectPresets[OBJECT::FIREBALLBULLETPU].var[6] = 8 + 16;
	//jjObjectPresets[OBJECT::ICEBULLETPU].counterEnd = 110;

 	if (jjEventGet(7, 91) == OBJECT::GUN9POWERUP) {
        	jjObjectPresets[OBJECT::GUN9POWERUP].direction = -1;
	}

	jjObjectPresets[OBJECT::FULLENERGY].behavior = CantBeBuried;
	jjObjectPresets[OBJECT::BOUNCERBULLET].behavior = bouncer;

	//particles
	jjAnimSets[ANIM::SNOW].load();

	jjANIMATION@ anim = jjAnimations[jjAnimSets[ANIM::SNOW] + 0];
	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] != 0) sprite[x,y] = 0;
			}
		}
		sprite.save(frame);
	}
}

void onLevelBegin() {
	jjTexturedBGFadePositionY = 0.55;
	LavaFall.gradient(255, 240, 170, 240, 87, 36, 112, 16, 1.0);
	LavaFloor.gradient(255, 240, 170, 240, 87, 36, 208, 22, .8);

	//Turn trigger scenery into one way events
 	for (int x = 0; x < jjLayerWidth[4]; x++) {
        for (int y = 0; y < jjLayerHeight[4]; y++) {
            if (jjEventGet(x, y) == OBJECT::TRIGGERSCENERY && jjParameterGet(x, y, 0, 5) == 5) {
                jjEventSet(x, y, AREA::ONEWAY);
        		}
        	}
    	}
	
	/*for (int i = 2665; i <= 2668; i++) {
		jjPIXELMAP lavaGlow(i);
			for (uint x = 0; x < lavaGlow.width; ++x) {
				for (uint y = 0; y < lavaGlow.height; ++y) {
					lavaGlow[x,y] = int((y + ((i-2665)*32))*1.5);
				}
			}
		lavaGlow.save(i, true);
	}*/
	
	jjANIMSET@ anim;
	for (int i = 0; i < 256; i++) {
		jjANIMSET@ custom = jjAnimSets[ANIM::CUSTOM[i]];
		if (custom == 0) {
			@anim = @custom;
			break;
		}
	}
	if (sprited = anim !is null) {
		jjPIXELMAP image(4, 128);
		for (int i = 0; i < 128; i++) {
			int alpha = int(i*1.5);
			for (int j = 0; j < 4; j++) {
				image[j, i] = alpha;
			}
		}
		jjANIMFRAME@ frame = jjAnimFrames[sprite = jjAnimations[anim.allocate(array<uint>(1, 1))]];
		image.save(frame);
		frame.hotSpotX = -2;
		frame.hotSpotY = -128;
	}
	
	jjANIMATION@ animRoller = jjAnimations[jjAnimSets[ANIM::CUSTOM[99] + 0]];
	for (uint j = 0; j < animRoller.frameCount; j++) {
		jjANIMFRAME@ frame = jjAnimFrames[animRoller + 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] += 24;
			}
		}
		sprite.save(frame);
	}
}

void onDrawLayer6(jjPLAYER@ play, jjCANVAS@ canvas) {
	if (!jjLowDetail && jjColorDepth == 16) {
		int end = int(play.cameraX) + jjSubscreenWidth + 2;
		int bottom = 106*32;
		for (int i = int(play.cameraX) & ~3 | 2; i < end; i += 4) {
			if (sprited)
				canvas.drawSpriteFromCurFrame(i, bottom, sprite, 0, SPRITE::ALPHAMAP, glowValue);
			else
				canvas.drawRectangle(i - 2, bottom, 4, -128, glowValue, SPRITE::BLEND_NORMAL, 64);
		}
	}
}

void onMain() {
	weaponHook.processMain();
	array<jjLAYER@> layers = jjLayerOrderGet();
	layers[0].xOffset += 1.6f;
	layers[1].xOffset += 1.6f;
	layers[2].xOffset += 1.1f;
	layers[11].xOffset += 0.6f;
	if (layers[0].xOffset % (layers[0].widthReal*32) == 0) layers[0].xOffset = 0;
	if (layers[1].xOffset % (layers[1].widthReal*32) == 0) layers[1].xOffset = 0;
	if (layers[2].xOffset % (layers[2].widthReal*32) == 0) layers[2].xOffset = 0;
	if (layers[11].xOffset % (layers[11].widthReal*32) == 0) layers[11].xOffset = 0;

    for (int i = 1; i < jjObjectCount; i++) {
        jjOBJ@ obj = jjObjects[i];
        if (obj.eventID == OBJECT::GUN9POWERUP) {
	        obj.direction = obj.xPos < (jjLayerWidth[4]*32)/2? -1:0;
        }
    }

	jjIsSnowingOutdoorsOnly = true;
	jjIsSnowing = true;
	jjSnowingType = SNOWING::SNOW;
	
	for (int i = 0; i < 1024; i++) {
		jjPARTICLE@ particle = jjParticles[i];		
		if (particle !is null && i > 0 && particle.type == PARTICLE::SNOW) {
				if (jjRandom()%90 == 0) {
					if (jjRandom()%15 == 0) {
						jjPARTICLE@ ember = jjAddParticle(PARTICLE::FIRE);
						if (ember !is null) {
							ember.xPos = particle.xPos;
							ember.yPos = particle.yPos;
							}
						}
				}				
				
				particle.xPos = 0;
				particle.yPos = 0;
				particle.xSpeed = 0;
				particle.ySpeed = 0;
				particle.type = PARTICLE::INACTIVE;
				particle.isActive = false;
				//jjAlert("destroyed particle " + i);  //do not uncomment this!!!!!
		}
	}
}


void onPlayer(jjPLAYER@ play) {
	weaponHook.processPlayer(play);
	p.powerup[WEAPON::ICE] = true;
	if (play.shieldTime > 30*70) {
		play.shieldTime = 30*70;
	}

	//can walk on lava with shield
   if (jjEventGet(int(play.xPos/32), int((play.yPos+16)/32)) == AREA::PATH) {
        if (play.shieldType != SHIELD::FIRE) play.hurt(1, false);
    }

	for (int i = 1; i < jjObjectCount; i++) {
		if (jjObjects[i].isActive && jjObjects[i].eventID == OBJECT::COPTER && jjObjects[i].state == STATE::FLY) {
			//Only set the counter if it's available to take
			jjObjects[i].counter = 0;
			if (jjObjects[i].var[4] == 0)
				jjObjects[i].state = STATE::DONE;
		}
	}
	if ((jjGameTicks % 3) > 0) return;
			glowValue = 226 + int(jjSin((jjGameTicks*5)) * 4); 
			jjPalette = MLLE::Palette;
			jjPalette.copyFrom(112, 16, 112, LavaFall, jjSin((jjGameTicks)*5) * .5 + .5);
			jjPalette.copyFrom(208, 22, 208, LavaFloor, jjSin((jjGameTicks)*2) * .13 + .52);

			jjPalette.fill(203, 55, 0, 1, 94, play.yPos / (jjLayerHeight[4] * 32) / 4);
			jjPalette.fill(203, 55, 0, 96, 7, play.yPos / (jjLayerHeight[4] * 32) / 6);
			jjPalette.fill(203, 55, 0, 104, 7, play.yPos / (jjLayerHeight[4] * 32) / 6);
			jjPalette.fill(203, 55, 0, 112, 14, play.yPos / (jjLayerHeight[4] * 32) / 6);
			jjPalette.fill(203, 55, 0, 128, 14, play.yPos / (jjLayerHeight[4] * 32) / 6);
			jjPalette.fill(203, 55, 0, 144, 14, play.yPos / (jjLayerHeight[4] * 32) / 6);
			jjPalette.fill(203, 55, 0, 160, 14, play.yPos / (jjLayerHeight[4] * 32) / 6);
			jjPalette.fill(203, 55, 0, 208, 45, play.yPos / (jjLayerHeight[4] * 32) / 6);

			jjPalette.fill(int(203 + jjSin((jjGameTicks)*20) * 30 + jjSin((jjGameTicks)*10) * 20 + jjSin((jjGameTicks)*5) * 10),
					int(55 + jjSin((jjGameTicks)*20) * 6 + jjSin((jjGameTicks)*10) * 5 + jjSin((jjGameTicks)*5) * 2),
					0, 96, 7, 0.1);

			jjPalette.fill(int(203 + jjSin((jjGameTicks)*20) * 30 + jjSin((jjGameTicks)*10) * 20 + jjSin((jjGameTicks)*5) * 10),
					int(55 + jjSin((jjGameTicks)*20) * 6 + jjSin((jjGameTicks)*10) * 5 + jjSin((jjGameTicks)*5) * 2),
					0, 104, 7, 0.1);

			jjPalette.fill(int(203 + jjSin((jjGameTicks)*20) * 30 + jjSin((jjGameTicks)*10) * 20 + jjSin((jjGameTicks)*5) * 10),
					int(55 + jjSin((jjGameTicks)*20) * 6 + jjSin((jjGameTicks)*10) * 5 + jjSin((jjGameTicks)*5) * 2),
					0, 144, 10, 0.2);

			jjPalette.fill(int(203 + jjSin((jjGameTicks)*20) * 30 + jjSin((jjGameTicks)*10) * 20 + jjSin((jjGameTicks)*5) * 10),
					int(55 + jjSin((jjGameTicks)*20) * 6 + jjSin((jjGameTicks)*10) * 5 + jjSin((jjGameTicks)*5) * 2),
					0, 160, 12, 0.2);

			jjPalette.fill(int(205 + jjSin((jjGameTicks)*20) * 30 + jjSin((jjGameTicks)*10) * 20 + jjSin((jjGameTicks)*5) * 10),
					int(120 + jjSin((jjGameTicks)*20) * 20 + jjSin((jjGameTicks)*10) * 10 + jjSin((jjGameTicks)*5) * 5),
					int(40 + jjSin((jjGameTicks)*20) * 10 + jjSin((jjGameTicks)*10) * 5 + jjSin((jjGameTicks)*5) * 3),
					189, 7, 0.2);

			jjPalette.fill(int(170 + jjSin((jjGameTicks)*20) * 30 + jjSin((jjGameTicks)*10) * 20 + jjSin((jjGameTicks)*5) * 10),
					int(40 + jjSin((jjGameTicks)*20) * 6 + jjSin((jjGameTicks)*10) * 4 + jjSin((jjGameTicks)*5) * 2),
					int(15 + jjSin((jjGameTicks)*20) * 4 + jjSin((jjGameTicks)*10) * 2 + jjSin((jjGameTicks)*5) * 1),
					197, 3, 0.1);

			jjPalette.apply();

	jjSetFadeColors(
		int(110 + jjSin((jjGameTicks)*1) * 15),
		int(26 + jjSin((jjGameTicks)*1) * 4),
		0);
	jjTexturedBGFadePositionY = 0.6 + jjSin((jjGameTicks) / 5) * .05;
}

void onPlayerInput(jjPLAYER@ play) {
	weaponHook.processPlayerInput(play);
}

void onReceive(jjSTREAM &in packet, int clientID) {
	weaponHook.processPacket(packet, clientID);
}

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

void onFunction0(jjPLAYER@ play) {
	jjObjects[play.fly - 1].counter = 0;
}

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

void CannotBeShotDown(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::PICKUP);
	if (obj.state == STATE::FLOATFALL) obj.state = STATE::FLOAT;
}

void CantBeBuried(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::PICKUP);
	if (jjMaskedPixel(int(obj.xPos), int(obj.yPos) + 8) && obj.xPos > 50*32 && obj.xPos < 57*32) {
		obj.state = STATE::FLOAT;
	}
}

void bouncer(jjOBJ@ obj) {
    float xSpeed = obj.xSpeed;
    float ySpeed = obj.ySpeed;
    obj.behave(BEHAVIOR::BOUNCERBULLET);
    if (xSpeed * obj.xSpeed < 0.f && ySpeed * obj.ySpeed < 0.f) {
        if (!jjMaskedPixel(int(obj.xPos + obj.xSpeed), int(obj.yPos + ySpeed))) {
            obj.var[0] = obj.var[0] - 1;
            obj.ySpeed = ySpeed;
            if (ySpeed > 0.f)
                obj.yPos += ySpeed;
        }
    }
}