Downloads containing xlmsilcat.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: The Silenced Cathedral Loon Battle N/A Download file

File preview

const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, null, BubbleGun::Weapon(), null, null, null, null, WeaponVMega::Boomerang::Weapon(), null}); ///@MLLE-Generated
#include "MLLE-Include-1.6w.asc" ///@MLLE-Generated
#pragma require "xlmsilcat-MLLE-Data-4.j2l" ///@MLLE-Generated
#pragma require "xlmsilcat-MLLE-Data-3.j2l" ///@MLLE-Generated
#pragma require "xlmsilcat-MLLE-Data-2.j2l" ///@MLLE-Generated
#pragma require "xlmsilcat-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "xlmsilcat.j2l" ///@MLLE-Generated
#include "WeaponVMega1.asc" ///@MLLE-Generated
#pragma require "WeaponVMega1.asc" ///@MLLE-Generated
#include "BubbleGun.asc" ///@MLLE-Generated
#pragma require "BubbleGun.asc" ///@MLLE-Generated

int sampleBoomerang = 0;

bool sprited;
uint sprite;
int glowValue;

jjPAL LavaFall;
jjPAL LavaFloor;

void onLevelLoad() {
	jjUseLayer8Speeds = true;
	jjTexturedBGFadePositionY = 0.125;
	
	jjAnimSets[ANIM::SKELETON].load();
	jjAnimSets[ANIM::SNOW].load();
	
	jjObjectPresets[OBJECT::GUN8POWERUP].direction = 0;
	jjObjectPresets[OBJECT::TOASTERPOWERUP].direction = 0;
	
	jjObjectPresets[OBJECT::ELECTROBULLET].xSpeed = jjObjectPresets[OBJECT::ELECTROBULLET].xSpeed * 1.15;
	jjObjectPresets[OBJECT::ELECTROBULLETPU].xSpeed = jjObjectPresets[OBJECT::ELECTROBULLETPU].xSpeed * 1.45;
	
	jjObjectPresets[OBJECT::ELECTROBULLETPU].eventID = OBJECT::ELECTROBULLET;
	
	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);
	}
	
	jjANIMATION@ greenToaster = jjAnimations[jjAnimSets[ANIM::AMMO] + 0];
	for (uint j = 0; j < greenToaster.frameCount; j++) {
		jjANIMFRAME@ frame = jjAnimFrames[greenToaster + j];
		jjPIXELMAP sprite(frame);
		for (uint x = 0; x < sprite.width; ++x) {
			for (uint y = 0; y < sprite.height; ++y) {
				if (sprite[x,y] >= 32 && sprite[x,y] <= 39) sprite[x,y] -= 16;
			}
		}
		sprite.save(frame);
	}
	
	jjANIMATION@ greenToasterFlame = jjAnimations[jjAnimSets[ANIM::AMMO] + 58];
	for (uint j = 0; j < greenToasterFlame.frameCount; j++) {
		jjANIMFRAME@ frame = jjAnimFrames[greenToasterFlame + j];
		jjPIXELMAP sprite(frame);
		for (uint x = 0; x < sprite.width; ++x) {
			for (uint y = 0; y < sprite.height; ++y) {
				if (sprite[x,y] >= 32 && sprite[x,y] <= 39) sprite[x,y] -= 16;
			}
		}
		sprite.save(frame);
	}
	
	jjANIMATION@ greenToasterAmmo = jjAnimations[jjAnimSets[ANIM::AMMO] + 56];
	for (uint j = 0; j < greenToasterAmmo.frameCount; j++) {
		jjANIMFRAME@ frame = jjAnimFrames[greenToasterAmmo + j];
		jjPIXELMAP sprite(frame);
		for (uint x = 0; x < sprite.width; ++x) {
			for (uint y = 0; y < sprite.height; ++y) {
				if (sprite[x,y] >= 88 && sprite[x,y] <= 95) sprite[x,y] -= 72;
			}
		}
		sprite.save(frame);
	}
	
	jjANIMATION@ greenToasterPU = jjAnimations[jjAnimSets[ANIM::PICKUPS] + 65];
	for (uint j = 0; j < greenToasterPU.frameCount; j++) {
		jjANIMFRAME@ frame = jjAnimFrames[greenToasterPU + j];
		jjPIXELMAP sprite(frame);
		for (uint x = 0; x < sprite.width; ++x) {
			for (uint y = 0; y < sprite.height; ++y) {
				if (sprite[x,y] >= 88 && sprite[x,y] <= 95) sprite[x,y] -= 72;
			}
		}
		sprite.save(frame);
	}
	
	generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[9]], array<uint> = {40, 48, 16, 88});
    turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 19.75f, false);
    turnIntoCustomSpring(jjObjectPresets[OBJECT::HORREDSPRING], 1, 17.75f, false);
    turnIntoCustomSpring(jjObjectPresets[OBJECT::HORGREENSPRING], 2, 27.45f, false);
    turnIntoCustomSpring(jjObjectPresets[OBJECT::HORBLUESPRING], 3, 35.5f, false);
	
	jjObjectPresets[OBJECT::HORREDSPRING].causesRicochet = jjObjectPresets[OBJECT::HORBLUESPRING].causesRicochet = jjObjectPresets[OBJECT::HORGREENSPRING].causesRicochet = false;
	
	jjDelayGeneratedCrateOrigins = true;
	
	jjWeapons[WEAPON::TOASTER].multiplier = 24;
	
	jjObjectPresets[OBJECT::TOASTERBULLETPU].behavior = SuperToaster();
	jjObjectPresets[OBJECT::TOASTERBULLETPU].lightType = LIGHT::FLICKER;
	jjObjectPresets[OBJECT::TOASTERBULLETPU].light = 12;
	
	WeaponVMega::Boomerang::BoomerangEdit().Apply(WEAPON::GUN8, MLLE::WeaponHook);
}

class SuperToaster : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::TOASTERBULLET);
		
		if (obj.counter == 1) obj.xSpeed = 5 * obj.direction;
		if (obj.xSpeed != 0) obj.ySpeed += 0.085;
		
		jjPARTICLE@ cinders = jjAddParticle(PARTICLE::FIRE);
		if (cinders !is null && obj.counter > 10) {
			cinders.xPos = int(obj.xPos - 8) + jjRandom()%17;
			cinders.yPos = int(obj.yPos - 8) + jjRandom()%17;
			cinders.fire.color = 16;
			cinders.fire.colorStop = 24;
			cinders.fire.colorDelta = 2;
		}
	}
}


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

void onMain() {
	jjWeapons[WEAPON::TNT].comesFromGunCrates = true;	
	jjWeapons[WEAPON::GUN8].comesFromGunCrates = true;
    jjWeapons[WEAPON::GUN9].comesFromGunCrates = true;

	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ obj = jjObjects[i];
			if (obj.eventID == OBJECT::BOUNCERPOWERUP){
				obj.xPos = obj.xOrg + 16;
			}
			if (obj.eventID == OBJECT::RFPOWERUP){
				obj.xPos = obj.xOrg + 16;
			}
	}
	
	jjWeapons[WEAPON::GUN8].gradualAim = true;
	
	array<jjLAYER@> layers = jjLayerOrderGet();
	layers[1].xOffset += 1.3f;
	layers[2].xOffset += 1.3f;
	layers[3].xOffset += 0.9f;
	layers[17].xOffset += 0.65f;
	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[17].xOffset % (layers[17].widthReal*32) == 0) layers[17].xOffset = 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()%10 == 0) {
					if (jjRandom()%3 == 0) {
						jjPARTICLE@ ember = jjAddParticle(PARTICLE::FIRE);
						if (ember !is null) {
							ember.xPos = particle.xPos;
							ember.yPos = particle.yPos;
							ember.fire.color = 16;
							ember.fire.colorStop = 24;
							ember.fire.colorDelta = 2;
							}
						}
				}				
				
				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!!!!!
		}
	}
}

bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
	return MLLE::WeaponHook.drawAmmo(player, 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();
}
 
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;
                }
        }
}

void onPlayer(jjPLAYER@ player) {
	handleFastCustomSpringSpeeds(player);
}
void onLevelBegin() {
	LavaFall.gradient(255, 240, 170, 240, 87, 36, 112, 16, 1.0);
	LavaFloor.gradient(255, 240, 170, 240, 87, 36, 208, 22, .8);
	
	MLLE::SpawnOffgrids();
	
	for (int i = 1; i < 255; i++) {
		jjOBJ@ preset = jjObjectPresets[i];
		if (preset.playerHandling == HANDLING::PICKUP && i != 72) {
			preset.behavior = CannotBeShotDown(preset.behavior);
		}
	}
	
	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;
	}
	
	array<uint> BoomerangIDs = {4, 6, 7};
	for (uint i = 0; i < BoomerangIDs.length(); i++) {
		jjANIMATION@ anim2 = jjAnimations[jjAnimSets[ANIM::CUSTOM[0]] + BoomerangIDs[i]];
		for (uint j = 0; j < anim2.frameCount; j++) {
			jjANIMFRAME@ frame = jjAnimFrames[anim2 + j];
			jjPIXELMAP sprite(frame);
			for (uint x = (BoomerangIDs[i] == 7? 3 : 0); x < (BoomerangIDs[i] == 7? 16 : sprite.width); ++x) {
				for (uint y = (BoomerangIDs[i] == 7? 4 : 0); y < (BoomerangIDs[i] == 7? 20 : sprite.height); ++y) {
					if (sprite[x,y] >= 64 && sprite[x,y] <= 71) sprite[x,y] -= 32;
					if (sprite[x,y] >= 72 && sprite[x,y] <= 79) sprite[x,y] -= 56;
				}
			}
			sprite.save(frame);
		}
	}
}

void onLevelReload() {
	MLLE::ReapplyPalette();
	MLLE::SpawnOffgridsLocal();
}

namespace WeaponVMega {
	namespace Boomerang {
		class BoomerangEdit : Weapon {
			void onBehave(jjOBJ@ obj) override {
			if (obj.state == STATE::START) {
							obj.xAcc = (obj.xSpeed + obj.var[7] / 65536.f) * 48;
							obj.yAcc = obj.ySpeed * 48;
							obj.state = STATE::FLY;
							jjSample(obj.xPos, obj.yPos, SOUND::P2_FOEW4, 0, 0);
						}
						
						obj.counter += 4;
						
						if (obj.counter > 1) {
							sampleBoomerang = jjSampleLooped(obj.xPos, obj.yPos, SOUND::MONKEY_THROW, sampleBoomerang, 0, 0);
						}
						
						const auto lastX = obj.xPos, lastY = obj.yPos;
						obj.xPos = obj.xOrg + jjSin(obj.counter) * obj.xAcc;
						obj.yPos = obj.yOrg + jjSin(obj.counter) * obj.yAcc;
						obj.xSpeed = obj.xPos - lastX; //for GetAngle
						obj.ySpeed = obj.yPos - lastY; //
						
						obj.lightType = LIGHT::POINT2;
						obj.light = 24;
						
						obj.frameID = ((jjGameTicks + obj.objectID) / 3) & 7;
						if (obj.frameID >= 4)
							obj.frameID = 7 - obj.frameID;
						obj.curFrame = jjAnimations[obj.curAnim] + obj.frameID;
						
						if (obj.counter >= 512 || MLLEWeapons::HelpfulBulletFunctions::MaskedPixel(obj) || obj.state == STATE::EXPLODE) {
							obj.delete();
							if (obj.creatorType == CREATOR::PLAYER) {
								const jjPLAYER@ play = jjPlayers[obj.creator];
								if (abs(obj.xPos - play.xPos) <= 20 && abs(obj.yPos - play.yPos) <= 20) {
									return; //inside shooter; no explosion anim needed
								}
							}
							jjObjects[jjAddObject(OBJECT::EXPLOSION, obj.xPos, obj.yPos, obj.objectID, CREATOR::OBJECT)].curAnim = obj.killAnim;
							return;
						} else if (obj.counter == 256 && obj.creatorType == CREATOR::PLAYER) { //reverse
							obj.xAcc = obj.xPos - (obj.xOrg = jjPlayers[obj.creator].xPos);
							obj.yAcc = obj.yPos - (obj.yOrg = jjPlayers[obj.creator].yPos);
						}
						
						jjDrawRotatedSpriteFromCurFrame(
							obj.xPos, obj.yPos,
							obj.curFrame,
							MLLEWeapons::HelpfulBulletFunctions::GetAngle(obj), MLLEWeapons::HelpfulBulletFunctions::GetDirection(obj), 1,
							SPRITE::SINGLEHUE, !MLLEWeapons::HelpfulBulletFunctions::IsPowerup(obj) ? 33 : 17
				);
			}
		}
	}
}

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 onDrawLayer5(jjPLAYER@ play, jjCANVAS@ canvas) {
	// cage
	canvas.drawResizedSprite(((18*32) + 12), ((83*32) + 22), ANIM::SKELETON, 2, 12, 0.6, 0.6, SPRITE::SINGLEHUE, 128);
	
	// hanging facing right
	// canvas.drawRotatedSprite(((20*32) + 15), ((84*32) + 33), ANIM::SKELETON, 2, 6, -50, -0.72, 0.72, SPRITE::SINGLEHUE, 128);
	
	// hanging facing left
	canvas.drawRotatedSprite(((20*32) + 18), ((84*32) + 33), ANIM::SKELETON, 2, 6, -50, -0.72, 0.72, SPRITE::SINGLEHUE, 128);
}

void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ canvas) {
	// canvas.drawSprite(((35*32) + 8), ((85*32) + 47), ANIM::SKELETON, 2, 6, 0, SPRITE::SINGLEHUE, 128);
	// canvas.drawSprite(((54*32) + 22), ((89*32) + 47), ANIM::SKELETON, 2, 6, -1, SPRITE::SINGLEHUE, 128);
	
	// hanging facing right
	canvas.drawRotatedSprite(((35*32) + 15), ((85*32) + 47), ANIM::SKELETON, 2, 6, 50, 1.1, 1.1, SPRITE::SINGLEHUE, 128);
	canvas.drawRotatedSprite(((16*32) + 15), ((33*32) + 47), ANIM::SKELETON, 2, 6, 50, 1.1, 1.1, SPRITE::SINGLEHUE, 128);
	
	// hanging facing left
	canvas.drawRotatedSprite(((54*32) + 18), ((81*32) + 47), ANIM::SKELETON, 2, 6, -50, -1.1, 1.1, SPRITE::SINGLEHUE, 128);
	canvas.drawRotatedSprite(((30*32) + 18), ((35*32) + 47), ANIM::SKELETON, 2, 6, -50, -1.1, 1.1, SPRITE::SINGLEHUE, 128);

}

void onDrawLayer3(jjPLAYER@ play, jjCANVAS@ canvas) {
	canvas.drawSprite(28*32, ((95*32) - 6), ANIM::SKELETON, 2, 12, 0, SPRITE::SINGLEHUE, 128);
	
	canvas.drawSprite(((41*32) + 12), ((67*32) + 19), ANIM::SKELETON, 2, 12, 0, SPRITE::SINGLEHUE, 128);
}

/*
void drawSprite(int xPixel, int yPixel, int setID, uint8 animation, uint8 frame, int8 direction = 0, SPRITE::Mode mode = SPRITE::NORMAL, uint8 param = 0)

canvas.drawSprite(((106*32) + 4), ((34*32) - 11), ANIM::SKELETON, 2, 12, 1, SPRITE::SINGLEHUE, 72);

void drawResizedSprite(int xPixel, int yPixel, int setID, uint8 animation, uint8 frame, float xScale, float yScale, SPRITE::Mode mode = SPRITE::NORMAL, uint8 param = 0)

canvas.drawResizedSprite(((106*32) + 4), ((34*32) - 11), ANIM::SKELETON, 2, 12, 0.5, 0.5, SPRITE::SINGLEHUE, 72);

void drawRotatedSprite(int xPixel, int yPixel, int setID, uint8 animation, uint8 frame, int angle, float xScale = 1, float yScale = 1, SPRITE::Mode mode = SPRITE::NORMAL, uint8 param = 0)

canvas.drawRotatedSprite(((106*32) + 4), ((34*32) - 11), ANIM::SKELETON, 2, 12, 256, 0.5, 0.5, SPRITE::SINGLEHUE, 72);
*/