Downloads containing xlmgongga.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Mt. Gongga Loon Battle N/A Download file

File preview

const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, null, BubbleGun::Weapon(), null, null, null, WeaponVMega::Voranj::Weapon(), null, null}); ///@MLLE-Generated
#include "MLLE-Include-1.6w.asc" ///@MLLE-Generated
#pragma require "xlmgongga-MLLE-Data-2.j2l" ///@MLLE-Generated
#pragma require "xlmgongga-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "xlmgongga.j2l" ///@MLLE-Generated
#include "WeaponVMega8.asc" ///@MLLE-Generated
#pragma require "WeaponVMega8.asc" ///@MLLE-Generated
#include "BubbleGun.asc" ///@MLLE-Generated
#pragma require "BubbleGun.asc" ///@MLLE-Generated
#pragma require "SS6_Tree1A.png"
#pragma require "SS6_Tree1B.png"
#pragma require "SS6_Tree2A.png"
#pragma require "SS6_Tree2B.png"
#pragma require "SS6_Bush2A.png"
#pragma require "SS6_Bush2B.png"

void onLevelLoad() {
	jjAnimSets[ANIM::CUSTOM[10]].load(
		jjPIXELMAP("SS6_Tree1A.png"),
		frameWidth: 256,
		frameHeight: 288
	);
	
	jjAnimSets[ANIM::CUSTOM[11]].load(
		jjPIXELMAP("SS6_Tree1B.png"),
		frameWidth: 256,
		frameHeight: 288
	);
	
	jjAnimSets[ANIM::CUSTOM[12]].load(
		jjPIXELMAP("SS6_Tree2A.png"),
		frameWidth: 160,
		frameHeight: 256
	);
	
	jjAnimSets[ANIM::CUSTOM[13]].load(
		jjPIXELMAP("SS6_Tree2B.png"),
		frameWidth: 160,
		frameHeight: 256
	);
	
	jjAnimSets[ANIM::CUSTOM[14]].load(
		jjPIXELMAP("SS6_Bush2A.png"),
		frameWidth: 128,
		frameHeight: 96
	);
	
	jjAnimSets[ANIM::CUSTOM[15]].load(
		jjPIXELMAP("SS6_Bush2B.png"),
		frameWidth: 128,
		frameHeight: 96
	);
	
	jjObjectPresets[OBJECT::APPLE].behavior =
	jjObjectPresets[OBJECT::ORANGE].behavior = BigTree();
	jjObjectPresets[OBJECT::CHERRY].behavior =
	jjObjectPresets[OBJECT::STRAWBERRY].behavior = SmallTree();
	jjObjectPresets[OBJECT::LIME].behavior = 
	jjObjectPresets[OBJECT::PEAR].behavior = Bush();
	
	jjObjectPresets[OBJECT::APPLE].playerHandling =
	jjObjectPresets[OBJECT::ORANGE].playerHandling =
	jjObjectPresets[OBJECT::CHERRY].playerHandling =
	jjObjectPresets[OBJECT::STRAWBERRY].playerHandling =
	jjObjectPresets[OBJECT::LIME].playerHandling = 
	jjObjectPresets[OBJECT::PEAR].playerHandling = HANDLING::PARTICLE;
	
	jjObjectPresets[OBJECT::APPLE].bulletHandling =
	jjObjectPresets[OBJECT::ORANGE].bulletHandling =
	jjObjectPresets[OBJECT::CHERRY].bulletHandling =
	jjObjectPresets[OBJECT::STRAWBERRY].bulletHandling =
	jjObjectPresets[OBJECT::LIME].bulletHandling = 
	jjObjectPresets[OBJECT::PEAR].bulletHandling = HANDLING::IGNOREBULLET;
	
	jjObjectPresets[OBJECT::APPLE].isBlastable =
	jjObjectPresets[OBJECT::ORANGE].isBlastable =
	jjObjectPresets[OBJECT::CHERRY].isBlastable =
	jjObjectPresets[OBJECT::STRAWBERRY].isBlastable =
	jjObjectPresets[OBJECT::LIME].isBlastable = 
	jjObjectPresets[OBJECT::PEAR].isBlastable = false;
	
	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, 33.0f, false);
	
	jjObjectPresets[OBJECT::HORREDSPRING].causesRicochet = jjObjectPresets[OBJECT::HORBLUESPRING].causesRicochet = jjObjectPresets[OBJECT::HORGREENSPRING].causesRicochet = false;
	
	jjWeapons[WEAPON::GUN8].spread = SPREAD::NORMAL;
	jjObjectPresets[OBJECT::FIREBALLBULLETPU].var[6] = 8 + 16;
}

class BigTree : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		if (inView(obj) && !jjLowDetail) {
			jjDrawSprite(obj.xPos, obj.yPos, obj.eventID == OBJECT::APPLE? ANIM::CUSTOM[10] : ANIM::CUSTOM[11], 0, (jjGameTicks/4) % 12, 0, SPRITE::NORMAL, 0, 6, 6);
		}
	}
}

class SmallTree : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		if (inView(obj) && !jjLowDetail) {
			jjDrawSprite(obj.xPos, obj.yPos, obj.eventID == OBJECT::CHERRY? ANIM::CUSTOM[12] : ANIM::CUSTOM[13], 0, (jjGameTicks/4) % 12, 0, SPRITE::NORMAL, 0, 7, 7);
		}
	}
}

class Bush : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		if (inView(obj) && !jjLowDetail) {
			jjDrawSprite(obj.xPos, obj.yPos, obj.eventID == OBJECT::LIME? ANIM::CUSTOM[14] : ANIM::CUSTOM[15], 0, (jjGameTicks/4) % 12, 0, SPRITE::NORMAL, 0, 3, 3);
		}
	}
}

bool inView(const jjOBJ@ obj) {
	for (int i = 0; i < jjLocalPlayerCount; i++) {
		const jjPLAYER@ play = jjLocalPlayers[i];
		if (obj.xPos > play.cameraX - 144 && obj.yPos > play.cameraY - 144 && obj.xPos < play.cameraX + jjSubscreenWidth + 144 && obj.yPos < play.cameraY + jjSubscreenHeight + 144)
			return true;
	}
	return false;
}

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::GUN8POWERUP){
			obj.xPos = obj.xOrg + 16;
			obj.direction = -1;
		}
		if (obj.eventID == OBJECT::TOASTERPOWERUP){
			obj.xPos = obj.xOrg + 8;
			obj.direction = -1;
		}
		if (obj.eventID == OBJECT::RFPOWERUP){
			obj.xPos = obj.xOrg - 8;
			obj.direction = 0;
		}
		if (obj.eventID == OBJECT::BOUNCERPOWERUP){
			obj.xPos = obj.xOrg - 16;
			obj.direction = 0;
		}
	}
	array<jjLAYER@> layers = jjLayerOrderGet();
	layers[15].xOffset += .28f;
	layers[16].xOffset += .21f;
	layers[18].xOffset += .15f;
}

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@ play) {
	handleFastCustomSpringSpeeds(play);
}

void onLevelBegin() {
	MLLE::SpawnOffgrids();
	for (int i = 1; i < 255; i++) {
		jjOBJ@ preset = jjObjectPresets[i];
		if (preset.playerHandling == HANDLING::PICKUP) {
			preset.behavior = CannotBeShotDown(preset.behavior);
		}
	}
}

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

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

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