Downloads containing ab25ctf15.j2as

Downloads
Name Author Game Mode Rating
JJ2+ Only: Anniversary Bash 25 CTF Jazz2Online Capture the flag N/A Download file

File preview

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

void onLevelLoad() {
	jjUseLayer8Speeds = true;
	
	generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[9]], array<uint> = {40, 48, 16, 64});
    turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 19.75f, false);
    turnIntoCustomSpring(jjObjectPresets[OBJECT::HORREDSPRING], 1, 17.75f, false);
    turnIntoCustomSpring(jjObjectPresets[OBJECT::HORGREENSPRING], 2, 26.55f, false);
    turnIntoCustomSpring(jjObjectPresets[OBJECT::HORBLUESPRING], 3, 28.8f, false);
	for (int i = 73; i < 74; i++) {
		if (jjObjectPresets[i].playerHandling == HANDLING::PICKUP) {
			jjObjectPresets[i].behavior = CannotBeShotDown(jjObjectPresets[i].behavior);
		}
	}
	
	jjObjectPresets[OBJECT::HORREDSPRING].causesRicochet = jjObjectPresets[OBJECT::HORBLUESPRING].causesRicochet = jjObjectPresets[OBJECT::HORGREENSPRING].causesRicochet = false;
	
	jjDelayGeneratedCrateOrigins = true;
	
	jjWeapons[WEAPON::GUN8].spread = SPREAD::NORMAL;
	jjObjectPresets[OBJECT::FIREBALLBULLETPU].var[6] = 8 + 16;
}

void onLevelBegin() {
	for (int i = 1; i < jjObjectCount; i++) {
		if (jjObjects[i].eventID == OBJECT::CTFBASE || jjObjects[i].behavior == BEHAVIOR::FLAG) jjObjects[i].yOrg += 3;
	}
}

void onMain (){
	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::RFAMMO3 && obj.state == STATE::FLOAT){
			if (obj.xOrg > 70*32 && obj.xOrg < 80*32 && obj.yOrg > 115*32 && obj.yOrg < 116*32) {
				obj.yPos = obj.yOrg + 8;
			}
			if (obj.xOrg > 58*32 && obj.xOrg < 59*32 && obj.yOrg > 53*32 && obj.yOrg < 54*32) {
				obj.yPos = obj.yOrg + 8;
			}
			if (obj.xOrg > 60*32 && obj.xOrg < 61*32 && obj.yOrg > 53*32 && obj.yOrg < 54*32) {
				obj.yPos = obj.yOrg + 15;
			}
			if (obj.xOrg > 62*32 && obj.xOrg < 63*32 && obj.yOrg > 53*32 && obj.yOrg < 54*32) {
				obj.yPos = obj.yOrg + 22;
			}
			if (obj.xOrg > 59*32 && obj.xOrg < 61*32 && obj.yOrg > 54*32 && obj.yOrg < 56*32) {
				obj.yPos = obj.yOrg + 8;
			}
			if (obj.xOrg > 61*32 && obj.xOrg < 63*32 && obj.yOrg > 54*32 && obj.yOrg < 56*32) {
				obj.yPos = obj.yOrg + 15;
			}
			if (obj.xOrg > 63*32 && obj.xOrg < 65*32 && obj.yOrg > 54*32 && obj.yOrg < 56*32) {
				obj.yPos = obj.yOrg + 22;
			}
			if (obj.xOrg > 12*32 && obj.xOrg < 13*32 && obj.yOrg > 63*32 && obj.yOrg < 64*32) {
				obj.yPos = obj.yOrg + 14;
			}
			if (obj.xOrg > 14*32 && obj.xOrg < 15*32 && obj.yOrg > 63*32 && obj.yOrg < 64*32) {
				obj.yPos = obj.yOrg + 7;
			}
			if (obj.xOrg > 10*32 && obj.xOrg < 12*32 && obj.yOrg > 64*32 && obj.yOrg < 66*32) {
				obj.yPos = obj.yOrg + 14;
			}
			if (obj.xOrg > 12*32 && obj.xOrg < 14*32 && obj.yOrg > 64*32 && obj.yOrg < 66*32) {
				obj.yPos = obj.yOrg + 7;
			}
			if (obj.xOrg > 72*32 && obj.xOrg < 74*32 && obj.yOrg > 75*32 && obj.yOrg < 77*32) {
				obj.xPos = obj.xOrg - 14;
			}
			if (obj.xOrg > 74*32 && obj.xOrg < 75*32 && obj.yOrg > 77*32 && obj.yOrg < 78*32) {
				obj.xPos = obj.xOrg - 14;
			}
			if (obj.xOrg > 72*32 && obj.xOrg < 74*32 && obj.yOrg > 77*32 && obj.yOrg < 79*32) {
				obj.xPos = obj.xOrg - 7;
			}
			if (obj.xOrg > 74*32 && obj.xOrg < 75*32 && obj.yOrg > 79*32 && obj.yOrg < 80*32) {
				obj.xPos = obj.xOrg - 7;
			}
			if (obj.xOrg > 126*32 && obj.xOrg < 131*32 && obj.yOrg > 78*32 && obj.yOrg < 80*32) {
				obj.yPos = obj.yOrg - 16;
			}
			if (obj.xOrg > 121*32 && obj.xOrg < 125*32 && obj.yOrg > 36*32 && obj.yOrg < 38*32) {
				obj.yPos = obj.yOrg - 16;
				obj.xPos = obj.xOrg - 16;
			}
			if (obj.xOrg > 129*32 && obj.xOrg < 134*32 && obj.yOrg > 34*32 && obj.yOrg < 36*32) {
				obj.yPos = obj.yOrg + 16;
				obj.xPos = obj.xOrg + 16;
			}
			
		}
		if (obj.eventID == OBJECT::TOASTERAMMO3 && obj.state == STATE::FLOAT) {
			if (obj.xOrg > 32*32 && obj.xOrg < 39*32 && obj.yOrg > 92*32 && obj.yOrg < 95*32) {
				obj.yPos = obj.yOrg - 16;
			}
			if (obj.xOrg > 109*32 && obj.xOrg < 111*32 && obj.yOrg > 85*32 && obj.yOrg < 87*32) {
				obj.xPos = obj.xOrg - 14;
			}
			if (obj.xOrg > 109*32 && obj.xOrg < 111*32 && obj.yOrg > 83*32 && obj.yOrg < 85*32) {
				obj.xPos = obj.xOrg - 7;
			}
			if (obj.xOrg > 111*32 && obj.xOrg < 112*32 && obj.yOrg > 84*32 && obj.yOrg < 85*32) {
				obj.xPos = obj.xOrg - 14;
			}
			if (obj.xOrg > 111*32 && obj.xOrg < 112*32 && obj.yOrg > 82*32 && obj.yOrg < 83*32) {
				obj.xPos = obj.xOrg - 7;
			}
			if (obj.xOrg > 167*32 && obj.xOrg < 169*32 && obj.yOrg > 40*32 && obj.yOrg < 42*32) {
				obj.yPos = obj.yOrg + 14;
			}
			if (obj.xOrg > 165*32 && obj.xOrg < 167*32 && obj.yOrg > 40*32 && obj.yOrg < 42*32) {
				obj.yPos = obj.yOrg + 7;
			}
			if (obj.xOrg > 166*32 && obj.xOrg < 167*32 && obj.yOrg > 39*32 && obj.yOrg < 40*32) {
				obj.yPos = obj.yOrg + 14;
			}
			if (obj.xOrg > 164*32 && obj.xOrg < 165*32 && obj.yOrg > 39*32 && obj.yOrg < 40*32) {
				obj.yPos = obj.yOrg + 7;
			}
			if (obj.xOrg > 107*32 && obj.xOrg < 109*32 && obj.yOrg > 52*32 && obj.yOrg < 54*32) {
				obj.xPos = obj.xOrg - 14;
			}
			if (obj.xOrg > 109*32 && obj.xOrg < 110*32 && obj.yOrg > 54*32 && obj.yOrg < 55*32) {
				obj.xPos = obj.xOrg - 14;
			}
			if (obj.xOrg > 107*32 && obj.xOrg < 109*32 && obj.yOrg > 54*32 && obj.yOrg < 56*32) {
				obj.xPos = obj.xOrg - 7;
			}
			if (obj.xOrg > 109*32 && obj.xOrg < 110*32 && obj.yOrg > 56*32 && obj.yOrg < 57*32) {
				obj.xPos = obj.xOrg - 7;
			}
			if (obj.xOrg > 64*32 && obj.xOrg < 67*32 && obj.yOrg > 65*32 && obj.yOrg < 67*32) {
				obj.yPos = obj.yOrg - 16;
			}
		}
		if (obj.eventID == OBJECT::SEEKERAMMO3 && obj.state == STATE::FLOAT){
			if (obj.xOrg > 42*32 && obj.xOrg < 43*32 && obj.yOrg > 75*32 && obj.yOrg < 76*32) {
			    obj.yPos = obj.yOrg + 14;
			}
		}
		if (obj.eventID == OBJECT::GUN9AMMO3 && obj.state == STATE::FLOAT){
			if (obj.xOrg > 50*32 && obj.xOrg < 51*32 && obj.yOrg > 105*32 && obj.yOrg < 106*32) {
			    obj.xPos = obj.xOrg + 16;
			}
			if (obj.xOrg > 48*32 && obj.xOrg < 49*32 && obj.yOrg > 105*32 && obj.yOrg < 106*32) {
			    obj.xPos = obj.xOrg - 16;
			}
			if (obj.xOrg > 54*32 && obj.xOrg < 55*32 && obj.yOrg > 106*32 && obj.yOrg < 107*32) {
			    obj.xPos = obj.xOrg + 16;
			}
			if (obj.xOrg > 52*32 && obj.xOrg < 53*32 && obj.yOrg > 106*32 && obj.yOrg < 107*32) {
			    obj.xPos = obj.xOrg - 16;
			}
			if (obj.xOrg > 58*32 && obj.xOrg < 59*32 && obj.yOrg > 107*32 && obj.yOrg < 108*32) {
			    obj.xPos = obj.xOrg + 16;
			}
			if (obj.xOrg > 56*32 && obj.xOrg < 57*32 && obj.yOrg > 107*32 && obj.yOrg < 108*32) {
			    obj.xPos = obj.xOrg - 16;
			}
			if (obj.xOrg > 108*32 && obj.xOrg < 112*32 && obj.yOrg > 21*32 && obj.yOrg < 23*32) {
			    obj.yPos = obj.yOrg - 16;
			}
			if (obj.xOrg > 89*32 && obj.xOrg < 98*32 && obj.yOrg > 77*32 && obj.yOrg < 80*32) {
			    obj.xPos = obj.xOrg - 16;
				obj.yPos = obj.yOrg + 10;
			}
		}
		if (obj.eventID == OBJECT::BOUNCERAMMO3 && obj.state == STATE::FLOAT) {

			if (obj.xOrg > 88*32 && obj.xOrg < 89*32 && obj.yOrg > 85*32 && obj.yOrg < 86*32) {
				obj.yPos = obj.yOrg + 14;
			}
			if (obj.xOrg > 90*32 && obj.xOrg < 91*32 && obj.yOrg > 85*32 && obj.yOrg < 86*32) {
				obj.yPos = obj.yOrg + 7;
			}
			if (obj.xOrg > 86*32 && obj.xOrg < 88*32 && obj.yOrg > 86*32 && obj.yOrg < 88*32) {
				obj.yPos = obj.yOrg + 14;
			}
			if (obj.xOrg > 88*32 && obj.xOrg < 90*32 && obj.yOrg > 86*32 && obj.yOrg < 88*32) {
				obj.yPos = obj.yOrg + 7;
			}
			if (obj.xOrg > 91*32 && obj.xOrg < 95*32 && obj.yOrg > 52*32 && obj.yOrg < 54*32) {
				obj.yPos = obj.yOrg - 16;
			}
			if (obj.xOrg > 142*32 && obj.xOrg < 145*32 && obj.yOrg > 52*32 && obj.yOrg < 55*32) {
				obj.xPos = obj.xOrg - 16;
			}
		}
		if (obj.eventID == OBJECT::GUN8AMMO3 && obj.state == STATE::FLOAT) {
			if (obj.xOrg > 84*32 && obj.xOrg < 86*32 && obj.yOrg > 43*32 && obj.yOrg < 45*32) {
				obj.xPos = obj.xOrg + 14;
			}
			if (obj.xOrg > 83*32 && obj.xOrg < 84*32 && obj.yOrg > 42*32 && obj.yOrg < 43*32) {
				obj.xPos = obj.xOrg + 14;
			}
			if (obj.xOrg > 84*32 && obj.xOrg < 86*32 && obj.yOrg > 41*32 && obj.yOrg < 43*32) {
				obj.xPos = obj.xOrg + 7;
			}
			if (obj.xOrg > 83*32 && obj.xOrg < 84*32 && obj.yOrg > 40*32 && obj.yOrg < 41*32) {
				obj.xPos = obj.xOrg + 7;
			}
			if (obj.xOrg > 38*32 && obj.xOrg < 39*32 && obj.yOrg > 69*32 && obj.yOrg < 70*32) {
                obj.xPos = obj.xOrg - 8;
			}
			if (obj.xOrg > 39*32 && obj.xOrg < 40*32 && obj.yOrg > 69*32 && obj.yOrg < 70*32) {
                obj.xPos = obj.xOrg + 8;
			}
			if (obj.xOrg > 112*32 && obj.xOrg < 113*32 && obj.yOrg > 72*32 && obj.yOrg < 73*32) {
                obj.yPos = obj.yOrg + 10;
			}
			if (obj.xOrg > 86*32 && obj.xOrg < 87*32 && obj.yOrg > 92*32 && obj.yOrg < 94*32) {
                obj.xPos = obj.xOrg - 16;
				obj.yPos = obj.yOrg + 16;
			}
			if (obj.xOrg > 81*32 && obj.xOrg < 82*32 && obj.yOrg > 92*32 && obj.yOrg < 94*32) {
                obj.xPos = obj.xOrg - 16;
				obj.yPos = obj.yOrg + 16;
			}
			if (obj.xOrg > 128*32 && obj.xOrg < 130*32 && obj.yOrg > 49*32 && obj.yOrg < 51*32) {
				obj.yPos = obj.yOrg + 14;
			}
			if (obj.xOrg > 126*32 && obj.xOrg < 128*32 && obj.yOrg > 49*32 && obj.yOrg < 51*32) {
				obj.yPos = obj.yOrg + 7;
			}
			if (obj.xOrg > 127*32 && obj.xOrg < 128*32 && obj.yOrg > 48*32 && obj.yOrg < 49*32) {
				obj.yPos = obj.yOrg + 14;
			}
			if (obj.xOrg > 125*32 && obj.xOrg < 126*32 && obj.yOrg > 48*32 && obj.yOrg < 49*32) {
				obj.yPos = obj.yOrg + 7;
			}
		}
		if (obj.eventID == OBJECT::TOASTERAMMO15){
			if (obj.xOrg > 118*32 && obj.xOrg < 120*32) {
				obj.xPos = obj.xOrg - 16;
			}
		}
		if (obj.eventID == OBJECT::GUNCRATE){
			if (obj.xOrg > 136*32 && obj.xOrg < 137*32 && obj.yOrg > 78*32 && obj.yOrg < 80*32) {
				obj.xPos = obj.xOrg + 24;
				obj.yPos = 79.4*32;
				obj.ySpeed = 0;
			}
		}
		if (obj.eventID == OBJECT::BOUNCERPOWERUP){
			if (obj.xOrg > 10*32 && obj.xOrg < 11*32) {
				obj.direction = -1;
			}
		}
		if (obj.eventID == OBJECT::GUN8POWERUP){
			if (obj.xOrg > 169*32 && obj.xOrg < 170*32) {
				obj.direction = 0;
			}
		}
		if (obj.eventID == OBJECT::RFPOWERUP){
			if (obj.xOrg > 57*32 && obj.xOrg < 58*32) {
			    obj.xPos = obj.xOrg - 20;
				obj.direction = -1;
				obj.yPos = 55.7*32;
				obj.ySpeed = 0;
			}
		}
		if (obj.eventID == OBJECT::TOASTERPOWERUP){
			if (obj.xOrg > 106*32 && obj.xOrg < 107*32) {
				obj.direction = 0;
			}
		}
		if (obj.eventID == OBJECT::FULLENERGY){
			if (obj.xOrg > 90*32 && obj.xOrg < 91*32) {
				obj.xPos = obj.xOrg - 16;
			}
		}
		if (obj.eventID == OBJECT::GREENSPRING){
			if (obj.xOrg > 110*32 && obj.xOrg < 111*32 && obj.yOrg > 37*32 && obj.yOrg < 38*32) {
				obj.xPos = obj.xOrg - 16;
			}
		}
	}
}

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) {
	play.lightType = LIGHT::NONE;
	
	handleFastCustomSpringSpeeds(play);
}

class CannotBeShotDown : jjBEHAVIORINTERFACE {
	jjBEHAVIOR originalBehavior;
	CannotBeShotDown(jjBEHAVIOR behavior) {
		originalBehavior = behavior;
	}
	void onBehave(jjOBJ@ obj) override {
		obj.behave(originalBehavior);
		if (obj.state == STATE::FLOATFALL)
			obj.state = STATE::FLOAT;
		if (obj.eventID == OBJECT::FULLENERGY)
			obj.xPos = obj.xOrg - 16;
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
		obj.behavior = originalBehavior;
		if (bullet is null)
			player.objectHit(obj, force, obj.playerHandling);
		else
			bullet.objectHit(obj, obj.playerHandling);
		obj.behavior = CannotBeShotDown(obj.behavior);
		return true;
	}
}