Downloads containing ab20ctf07.j2as

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

File preview

#include "MLLE-Include-1.4.asc"
const bool MLLESetupSuccessful = MLLE::Setup();
#pragma require "ab20ctf07-MLLE-Data-2.j2l"
#pragma require "ab20ctf07-MLLE-Data-1.j2l"
#pragma require "IC - Technoir3.j2t"
#pragma require "DiamDayFix.j2t"
#pragma require "ab20ctf07.j2l"
#pragma require "Lightningrod.j2a"
#pragma require "ZAPFIZZ1.wav"
#pragma require "ZAPFIZZ2.wav"
#pragma require "Syringe.j2a"

void onPlayer(jjPLAYER@ player){
	player.lightType = LIGHT::NONE;
	
	float MaxHealth = jjMaxHealth + 1;
	float Health = player.health + 1;
	float healthratio = MaxHealth / Health;

	if (healthratio < 1.3) jjWeapons[WEAPON::ICE].spread = SPREAD::NORMAL;
	if (healthratio >= 1.3 && healthratio < 2) jjWeapons[WEAPON::ICE].spread = SPREAD::RFNORMAL;
	if (healthratio >= 2) jjWeapons[WEAPON::ICE].spread = SPREAD::RFPU;
}

void onLevelLoad() {
	jjUseLayer8Speeds = true;
	jjTexturedBGTexture = TEXTURE::DIAMONDUSBETA;
	
	jjPalette.gradient(122, 122, 122, 232, 232, 232, 176, 32); // 176-207
	jjPalette.gradient(9, 15, 34, 3, 5, 13, 124, 4);
	jjPalette.gradient(5, 5, 20, 1, 1, 5, 152, 8);

	
	jjSetWaterGradient(187, 187, 187, 0, 0, 0);
	jjWaterChangeSpeed = 1;
	jjSetWaterLevel(70*32, true);
	jjWaterLighting = (WATERLIGHT::GLOBAL);
	jjWaterLayer = 4;
	
	jjOBJ@ preset = jjObjectPresets[OBJECT::FROZENSPRING];
	preset.behavior = coloredSpring;
	preset.bulletHandling = HANDLING::IGNOREBULLET;
	preset.freeze = 0;
	preset.ySpeed = -26.5f;
	preset.xPos = preset.xOrg + 8;
	
		array<int> BarrelSprites = {3,6,7,8,9};
	for (uint i = 0; i < BarrelSprites.length(); i++) {
		jjANIMATION@ animBarrel = jjAnimations[jjAnimSets[ANIM::PICKUPS] + BarrelSprites[i]];
		for (uint j = 0; j < animBarrel.frameCount; j++) {
			jjANIMFRAME@ frame = jjAnimFrames[animBarrel + j];
			jjPIXELMAP sprite(frame);
			for (uint x = 0; x < sprite.width; ++x) {
				for (uint y = 0; y < sprite.height; ++y) {
					if (sprite[x,y] == 40) sprite[x,y] = 24;
					if (sprite[x,y] == 53) sprite[x,y] = 41;
					if (sprite[x,y] >= 56 && sprite[x,y] <= 62) sprite[x,y] -= 31;
					if (sprite[x,y] >= 80 && sprite[x,y] <= 87) sprite[x,y] -= 64;
				}
			}
			sprite.save(frame);
		}
	}
	
	// Lightning Rod as TNT
	// DO NOT COPY THIS!!
	jjAnimSets[ANIM::CUSTOM[7]].load(0, "Lightningrod.j2a");
	jjAnimations[jjAnimSets[ANIM::AMMO] + 59] = jjAnimations[jjAnimSets[ANIM::CUSTOM[7]] + 0];
	
	jjObjectPresets[OBJECT::TNT].behavior = Lightningrod();
	jjObjectPresets[OBJECT::TNT].determineCurAnim(ANIM::CUSTOM[7], 0);
	jjObjectPresets[OBJECT::TNT].playerHandling = HANDLING::PARTICLE;
	jjObjectPresets[OBJECT::TNT].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::TNT].counterEnd = 255;
	
	jjObjectPresets[OBJECT::TNTAMMO3].behavior = LightningrodPickup();
	jjObjectPresets[OBJECT::TNTAMMO3].scriptedCollisions = true;
	jjObjectPresets[OBJECT::TNTAMMO3].determineCurAnim(ANIM::CUSTOM[7], 0);
	jjWeapons[WEAPON::TNT].maximum = 50;
	
	jjSampleLoad(SOUND::COMMON_ELECTRICHIT, "ZAPFIZZ1.wav");
	jjSampleLoad(SOUND::COMMON_ELECTRIC2, "ZAPFIZZ2.wav");
	
	
	// Sanguinespear as Ice
	// DO NOT COPY THIS!!
	jjAnimSets[ANIM::HATTER].load();
	jjAnimSets[ANIM::MONKEY].load();
	jjAnimSets[ANIM::CUSTOM[28]].load(0, "Syringe.j2a");
	
	jjAnimations[jjAnimSets[ANIM::AMMO] + 29] = jjAnimations[jjAnimSets[ANIM::CUSTOM[28]] + 0];
	jjAnimations[jjAnimSets[ANIM::AMMO] + 28] = jjAnimations[jjAnimSets[ANIM::CUSTOM[28]] + 1];
	jjAnimations[jjAnimSets[ANIM::PICKUPS] + 55] = jjAnimations[jjAnimSets[ANIM::CUSTOM[28]] + 3]; //gun 8 crate

	jjObjectPresets[OBJECT::ICEBULLET].behavior = jjObjectPresets[OBJECT::ICEBULLETPU].behavior = BloodSpear();
	jjObjectPresets[OBJECT::ICEBULLET].ySpeed = -1.5;
	jjObjectPresets[OBJECT::ICEBULLET].xSpeed = 8;
	jjObjectPresets[OBJECT::ICEBULLET].counterEnd = 85;
	jjObjectPresets[OBJECT::ICEBULLET].var[6] = 0;
	jjObjectPresets[OBJECT::ICEBULLETPU].ySpeed = -2;
	jjObjectPresets[OBJECT::ICEBULLETPU].xSpeed = 8.5;
	jjObjectPresets[OBJECT::ICEBULLETPU].counterEnd = 95;
	jjObjectPresets[OBJECT::ICEBULLETPU].var[6] = 8;
	jjObjectPresets[OBJECT::ICEBULLET].freeze = jjObjectPresets[OBJECT::ICEBULLETPU].freeze = 0;
	jjObjectPresets[OBJECT::ICEBULLET].eventID = OBJECT::ICEBULLET;
	jjObjectPresets[OBJECT::ICEBULLETPU].eventID = OBJECT::ICEBULLETPU;
	jjObjectPresets[OBJECT::ICEAMMO15].determineCurAnim(ANIM::CUSTOM[28], 3);
	jjObjectPresets[OBJECT::ICEAMMO15].determineCurFrame();
	
	jjObjectPresets[OBJECT::ICEPOWERUP].determineCurAnim(ANIM::CUSTOM[28], 2, true);
	jjObjectPresets[OBJECT::ICEPOWERUP].determineCurFrame();

	jjWeapons[WEAPON::ICE].defaultSample = false;
	jjWeapons[WEAPON::ICE].replacedByBubbles = true;
}

class BloodSpear : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::BULLET, false);
		obj.var[0] = int(atan2(-obj.ySpeed, obj.xSpeed) * (512.f * 0.318309886142228f));
		
		if (obj.counter == 1 && obj.state == STATE::FLY && jjPlayers[obj.creatorID].isLocal) {
			jjSample(jjPlayers[obj.creatorID].xPos, jjPlayers[obj.creatorID].yPos, SOUND::HATTER_PTOEI, 0, obj.eventID == OBJECT::ICEBULLETPU? 19000:20000);
		}
		
		if (obj.state == STATE::FLY) {
			jjDrawRotatedSprite(obj.xPos, obj.yPos, ANIM::HATTER, 3, jjGameTicks >> 2, obj.var[0], 2, 1, SPRITE::SINGLEHUE, obj.eventID == OBJECT::ICEBULLETPU? 15:24);
			switch (obj.direction) {
				case 1: obj.xSpeed -= 0.1; obj.ySpeed += 0.1; break;
				case -1: obj.xSpeed += 0.1; obj.ySpeed += 0.1; break;
			}
			if (obj.xSpeed == 0) obj.ySpeed += 0.15;
			
			jjPARTICLE@ blood = jjAddParticle(PARTICLE::ICETRAIL);
			blood.xPos = obj.xPos;
			blood.yPos = obj.yPos;
			blood.icetrail.color = obj.eventID == OBJECT::ICEBULLETPU? 16:24;
			blood.icetrail.colorStop = obj.eventID == OBJECT::ICEBULLETPU? 24:32;
		}
		
		if (obj.state == STATE::EXPLODE) {
			jjDrawSprite(obj.xPos, obj.yPos, ANIM::MONKEY, 1, obj.curFrame, obj.direction, SPRITE::SINGLEHUE, obj.eventID == OBJECT::ICEBULLETPU? 15:24);
			if (obj.var[1] < 27) {
				if (obj.var[1] == 1) jjSample(obj.xPos, obj.yPos, SOUND::HATTER_SPLOUT, 0, 20000);
				obj.var[1] = obj.var[1] + 1;
			}
			if (obj.var[1] == 27) {
				obj.var[1] = 0;
				obj.delete();
			}
		}
		
	}
}

void onMain() {
	for (int i = 0; i < 1024; i++) {
		jjPARTICLE@ particle = jjParticles[i];
		if (particle.type == PARTICLE::FLOWER && particle.yPos > jjWaterLevel) {
			particle.type = PARTICLE::INACTIVE;
		}
	}
	
	for (int i = 1; i < jjObjectCount; i++) {
		if (jjObjects[i].eventID == OBJECT::SEEKERPOWERUP) {
		jjObjects[i].yPos = jjObjects[i].yOrg;
		}
	}
	
	jjWeapons[WEAPON::GUN8].comesFromGunCrates = true;
    jjWeapons[WEAPON::GUN9].comesFromGunCrates = true;
}

void coloredSpring(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::SPRING, false);
	jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, 216);
}

void offsetPosition(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::SPRING);
	if (obj.xPos > 88*32 && obj.xPos < 90*32) obj.xPos = obj.xOrg + 12;
}

class Lightningrod : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::BULLET, false);
		jjPLAYER@ creator = jjPlayers[obj.creatorID];
		
		if (jjGameMode == GAME::CTF) {
			switch (creator.team) {
				case TEAM::BLUE: obj.var[4] = 1; break;
				case TEAM::RED: obj.var[4] = 2; break;
				case TEAM::YELLOW: obj.var[4] = 3; break;
				case TEAM::GREEN: obj.var[4] = 4; break;
			}
		} else {
			obj.var[4] = 1;
		}
		
		jjDrawSprite(obj.xPos, obj.yPos, ANIM::CUSTOM[7], obj.var[0] == 1? obj.var[4] : 0, obj.var[0] == 1? jjGameTicks / 10 % 6 : 0, obj.direction, SPRITE::NORMAL);
		
		if (obj.counter == 2 && jjPlayers[obj.creatorID].isLocal) {
			jjSample(creator.xPos, creator.yPos, SOUND::COMMON_MONITOR, 0, 12500);
			obj.age = 0;
			obj.var[1] = 0;
		}
		
		if (obj.counter == 127) obj.counter = 2; 
		
		if (!jjMaskedHLine(int(obj.xPos - 16), 24, int(obj.yPos + 8))) {
			obj.yPos += 6;
			obj.var[0] = 0;
			obj.lightType = LIGHT::POINT;
		} else {
			obj.var[0] = 1;
		}
		
		if (obj.var[0] == 1) {
			obj.age++;
			if (obj.var[1] == 0) {
				jjSample(obj.xPos, obj.yPos, SOUND::COMMON_LANDCAN1, 0, 30000);
				obj.var[1] = 1;
			}
			obj.lightType = LIGHT::BRIGHT;
			obj.light = 10;
			if (obj.age % 20 == 0) {
				for (int i = -4; i <= 4; i += 4) {
					Electricity temp;
					int id = jjAddObject(OBJECT::LIGHTNINGSHIELDBULLET, obj.xPos, obj.yPos - 12, obj.creatorID, CREATOR::PLAYER, jjVOIDFUNCOBJ(temp.onBehave));
					if (id != 0) {
						jjOBJ@ zap = jjObjects[id];
						zap.lightType = LIGHT::NONE;
						zap.counterEnd = 6;
						zap.animSpeed = 2;
						zap.direction = obj.direction;
						zap.lightType = LIGHT::NONE;
						zap.playerHandling = HANDLING::PLAYERBULLET;
						zap.var[3] = 1;
						zap.var[6] = 8;
						zap.xSpeed = i;
						zap.xAcc = 0;
						if (i == 0) zap.ySpeed = -4;
					}
				}
			}
		}
		
		if (obj.age == 160) {
			obj.var[0] = obj.var[1] = 0;
			obj.particlePixelExplosion(0);
			obj.delete();
		}
	}
}

class Electricity : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::BULLET, false);
	}
}

class LightningrodPickup : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PICKUP);
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ play, int force) {
		if (play.ammo[WEAPON::TNT] < jjWeapons[WEAPON::TNT].maximum) {
			if (play.isLocal) {
				play.ammo[WEAPON::TNT] = play.ammo[WEAPON::TNT] + 3;
				if (jjAutoWeaponChange && play.ammo[WEAPON::TNT] < 1) play.currWeapon = WEAPON::TNT;
				jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PICKUPW1, 0, 0);
			}
			obj.behavior = BEHAVIOR::EXPLOSION2;
			obj.scriptedCollisions = false;
			obj.frameID = 0;
		}
		return true;
	}
}