Downloads containing ab26ctf16.j2as

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

File preview

const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, null, se::FireworkMLLEWrapper(), null, null, null, null, null, null}); ///@MLLE-Generated
#include "MLLE-Include-1.6w.asc" ///@MLLE-Generated
#pragma require "ab26ctf16.j2l" ///@MLLE-Generated
#include "SEfirework-mlle.asc" ///@MLLE-Generated
#pragma require "SEfirework-mlle.asc" ///@MLLE-Generated
#pragma require "balloons.png"

const uint8 BalloonEventID = OBJECT::APPLE;

void onLevelLoad() {
	jjPIXELMAP image("balloons.png");
	jjAnimSets[ANIM::CUSTOM[0]].load(image, image.width / 4, image.height);
	jjOBJ@ balloon = jjObjectPresets[BalloonEventID];
	balloon.playerHandling = HANDLING::SPECIALDONE;
	balloon.bulletHandling = HANDLING::DETECTBULLET;
	balloon.scriptedCollisions = true;
	balloon.isFreezable = false;
	balloon.isBlastable = false;
	balloon.energy = 50;
	balloon.behavior = Balloon();
	balloon.determineCurAnim(ANIM::CUSTOM[0], 0);
	balloon.determineCurFrame();
	jjObjectPresets[OBJECT::BRIDGE].behavior = CustomBridgeLength;
}

void CustomBridgeLength(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::BRIDGE);
	obj.var[0] = 616;
	obj.var[1] = obj.var[0] / 5;
	obj.var[2] = obj.var[0] + 1;
}

array<jjOBJ@> Balloons(2, null);

class Balloon : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		switch (obj.state) {
			case STATE::START:
				obj.var[0] = (obj.xOrg < jjLayerWidth[4] * 16) ? 1 : 0;
				@Balloons[obj.var[0]] = obj;
				obj.state = STATE::SLEEP;
				break;
			case STATE::DEACTIVATE:
				obj.clearPlatform();
				obj.deactivate();
				break;
			case STATE::SLEEP: {
				const SPRITE::Mode mode = obj.justHit == 0 ? SPRITE::NORMAL : SPRITE::SINGLECOLOR;
				jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame + obj.var[0], mode: obj.playerHandling == HANDLING::SPECIAL ? mode : SPRITE::TRANSLUCENT, param: 15);
				jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame + 2, mode: mode, param: 15);
				jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame + 3, layerZ: 3, mode: mode, param: 15);
				if (obj.playerHandling == HANDLING::SPECIAL) {
					const int health = (obj.energy + 9) / 10;
					int healthX = int(obj.xPos) + 14 - (5 * 15);
					for (int i = 0; i < 5; ++i) {
						jjDrawResizedSprite(healthX, int(obj.yPos) - 200, ANIM::PICKUPS,41,0, 2,2, mode: i < health ? SPRITE::NORMAL : SPRITE::SINGLECOLOR);
						healthX += 30;
					}
				}
		
				const auto lastX = obj.xPos, lastY = obj.yPos;
				for (int localPlayerID = 0; localPlayerID < jjLocalPlayerCount; ++localPlayerID) {
					const jjPLAYER@ localPlayer = jjLocalPlayers[localPlayerID];
					if (localPlayer.platform == obj.objectID && localPlayer.team != obj.var[0] && localPlayer.keyFire && localPlayer.currWeapon == WEAPON::TOASTER) {
						const auto curAnim = localPlayer.curAnim - jjAnimSets[localPlayer.setID];
						obj.playerHandling = HANDLING::SPECIAL;
						if (curAnim == RABBIT::LOOKUP || curAnim == RABBIT::FIREUP || curAnim == RABBIT::FIREUPQUIT) {
							if (obj.ySpeed >= 0)
								obj.yPos -= 1;
							if (localPlayer.powerup[WEAPON::TOASTER]) {
								if (obj.ySpeed > -4.25)
									obj.ySpeed -= 0.2;
							} else {
								if (obj.ySpeed > -3)
									obj.ySpeed -= 0.14;
							}
						} else {
							if (obj.xSpeed == 0) {
								obj.xSpeed = (localPlayer.direction >= 0) ? 1.15 : -1.15;
							} else if (localPlayer.powerup[WEAPON::TOASTER]) {
								if (abs(obj.xSpeed) < 8)
									obj.xSpeed += (localPlayer.direction >= 0) ? 0.0775 : -0.0775;
							} else {
								if (abs(obj.xSpeed) < 6)
									obj.xSpeed += (localPlayer.direction >= 0) ? 0.0467 : -0.0467;
							}
						}
						obj.age = 0;
						if (jjGameTicks - obj.counter >= 4) {
							obj.counter = jjGameTicks;
							SendPacket(obj.var[0], BalloonPacket::Update);
						}
						break;
					}
				}
				if (obj.xSpeed > 1 && !jjMaskedVLine(int(obj.xPos) + 90, int(obj.yPos) - 278, 278))
					obj.xSpeed -= 0.0175;
				else if (obj.xSpeed < -1 && !jjMaskedVLine(int(obj.xPos) - 90, int(obj.yPos) - 278, 278))
					obj.xSpeed += 0.0175;
				else
					obj.xSpeed = 0;
				if (obj.ySpeed < 0.f && jjMaskedHLine(int(obj.xPos) - 88, 177, int(obj.yPos) - 278)) {
					obj.ySpeed = 0;
					obj.yPos += 1;
				} else if (!jjMaskedHLine(int(obj.xPos) - 27, 55, int(obj.yPos) + 15))
					obj.ySpeed += 0.0175;
				else
					obj.ySpeed = 0;
				obj.xPos += obj.xSpeed;
				obj.yPos += obj.ySpeed;
				obj.curFrame += 2; //basket
				obj.bePlatform(lastX, lastY);
				obj.curFrame -= 2;
				break; }
		}
		
		if (obj.playerHandling == HANDLING::SPECIAL) {
			++obj.age;
			if (obj.age > 400) {
				if (obj.age >= 400 + 70 * 5 && (jjIsServer || jjGameConnection == GAME::LOCAL)) {
					SendPacket(obj.var[0], BalloonPacket::Destroy);
					obj.particlePixelExplosion(2);
					obj.clearPlatform();
					obj.delete();
				} else {
					int frameID = 22 - ((obj.age - 331) / 70);
					if (frameID < 16) frameID = 16; //'0'
					jjDrawResizedSprite(obj.xPos - 40, obj.yPos - 235, ANIM::FONT,2,frameID, 2,2);
				}
			}
		}
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
		if (bullet !is null && player.team == obj.var[0]) {
			bullet.state = STATE::EXPLODE;
			obj.justHit = 5;
			if (jjIsServer || jjGameConnection == GAME::LOCAL) {
				obj.energy -= force;
				if (obj.energy <= 0) {
					SendPacket(obj.var[0], BalloonPacket::Destroy);
					obj.particlePixelExplosion(0);
					obj.clearPlatform();
					obj.delete();
				}
			}
		}
		return true;
	}
}

namespace BalloonPacket { enum BalloonPacket { Update, Destroy } }

void SendPacket(int balloonID, BalloonPacket::BalloonPacket packetType) {
	jjSTREAM packet;
	packet.push(uint8(packetType));
	packet.push(uint8(balloonID));
	if (packetType == BalloonPacket::Update) {
		const jjOBJ@ balloon = Balloons[balloonID];
		packet.push(int16(balloon.xPos));
		packet.push(int16(balloon.yPos));
		packet.push(float(balloon.xSpeed));
		packet.push(float(balloon.ySpeed));
	}
	jjSendPacket(packet);
}
void onReceive(jjSTREAM &in packet, int clientID) {
	if (jjIsServer)
		jjSendPacket(packet, -clientID);
	uint8 packetType, balloonID;
	packet.pop(packetType);
	packet.pop(balloonID);
	jjOBJ@ balloon = Balloons[balloonID];
	if (packetType == BalloonPacket::Update) {
		balloon.playerHandling = HANDLING::SPECIAL;
		balloon.age = 0;
		int16 xPos, yPos;
		float xSpeed, ySpeed;
		packet.pop(xPos); balloon.xPos = xPos;
		packet.pop(yPos); balloon.yPos = yPos;
		packet.pop(xSpeed); balloon.xSpeed = xSpeed;
		packet.pop(ySpeed); balloon.ySpeed = ySpeed;
	} else {
		balloon.particlePixelExplosion(0);
		balloon.clearPlatform();
		balloon.delete();
	}
}

void onPlayer(jjPLAYER@ player) {
	const jjOBJ@ platform = jjObjects[player.platform];
	if (platform.eventID == BalloonEventID && platform.var[0] != player.team) {
		if (player.keyFire && player.currWeapon == WEAPON::TOASTER) {
			if (player.keyLeft) {
				player.direction = -1;
				player.keyLeft = false;
			}
			if (player.keyRight) {
				player.direction = 1;
				player.keyRight = false;
			}
		}
	}
}
bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
	return MLLE::WeaponHook.drawAmmo(player, canvas);
}

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

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