Downloads containing ezsalt.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Saline Shores PurpleJazz Capture the flag N/A Download file

File preview

const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, null, NapsWeapons::AntiGravityBouncer(), null, null, WeaponVMega::Voranj::Weapon(), null, WeaponVMega::Boomerang::Weapon(), null}); ///@MLLE-Generated
#include "MLLE-Include-1.6w.asc" ///@MLLE-Generated
#pragma require "ezsalt-MLLE-Data-2.j2l" ///@MLLE-Generated
#pragma require "ezsalt-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "ezsalt.j2l" ///@MLLE-Generated
#include "WeaponVMega1.asc" ///@MLLE-Generated
#pragma require "WeaponVMega1.asc" ///@MLLE-Generated
#include "WeaponVMega8.asc" ///@MLLE-Generated
#pragma require "WeaponVMega8.asc" ///@MLLE-Generated
#include "AntiGravBouncers.asc" ///@MLLE-Generated
#pragma require "AntiGravBouncers.asc" ///@MLLE-Generated
///@SaveAndRunArgs -server -capture ///@MLLE-Generated

#pragma require "ezsalt_wind.ogg"

int sampleBoomerang, sampleWind = 0;

void onLevelLoad() {
	jjUseLayer8Speeds = true;
	jjWeapons[WEAPON::GUN8].comesFromGunCrates = true;
	
	generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {40});
	turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 19.f, false);
	
	WeaponVMega::Boomerang::BoomerangEdit().Apply(WEAPON::GUN8, MLLE::WeaponHook);
}

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


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 onPlayer(jjPLAYER@ play) {
	if (jjEventGet(int(play.xPos/32), int(play.yPos/32)) == AREA::PATH) {
		int direction = jjParameterGet(int(play.xPos/32), int(play.yPos/32), 6, 3);
		play.buttstomp = 100;
		if (direction > 1) {
			if (play.xSpeed > 1) play.xSpeed = -2;
		} else if (direction == 0) {
			if (play.xSpeed < 1) play.xSpeed = 2;
		}
	}
}

void onMain() {
	jjWeapons[WEAPON::GUN8].gradualAim = true;

	array<jjLAYER@> layers = jjLayerOrderGet();
	
	jjTexturedBGFadePositionY = !jjLowDetail? 0.45:0.5;
	
	if (!jjLowDetail) {
		sampleWind = jjSampleLooped(jjLocalPlayers[0].xPos, jjLocalPlayers[0].yPos, SOUND::WIND_WIND2A, sampleWind, 30, 0);
		
		layers[layers.length - 10].hasTiles = jjColorDepth == 16? true:false;
		layers[layers.length - 9].spriteMode = jjColorDepth == 16? SPRITE::BLEND_NORMAL : SPRITE::NORMAL;
	}
	
	jjIsSnowing = !jjLowDetail;
	
	for (int i = 0; i < 1024; i++) {
		jjPARTICLE@ particle = jjParticles[i];
		if (particle.type == PARTICLE::FLOWER) {
			particle.type = PARTICLE::PIXEL;
			particle.pixel.size = jjRandom()%2;
			for (uint j = 0; j <= 9; j++) {
				particle.pixel.color[j] = 112 + jjRandom()%8;
			}
		}
		if (particle.type == PARTICLE::PIXEL) {
			particle.xSpeed = ((particle.pixel.color[0] - 112)*-0.5) - 3;
			particle.ySpeed = ((particle.pixel.color[0] - 112)*0.075) + 0.5;
			if (jjMaskedPixel(int(particle.xPos + particle.xSpeed), int(particle.yPos + particle.ySpeed))) {
				particle.type = PARTICLE::INACTIVE;
			}
			if (jjTileGet(1, int(particle.xPos/32), int(particle.yPos/32)) == 9) {
				particle.type = PARTICLE::INACTIVE;
			}
		}
	}
}
bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
	return MLLE::WeaponHook.drawAmmo(player, canvas);
}


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);
		}
	}
	
	array<uint> BoomerangIDs = {4, 6, 7};
	for (uint i = 0; i < BoomerangIDs.length(); i++) {
		jjANIMATION@ anim = jjAnimations[jjAnimSets[ANIM::CUSTOM[0]] + BoomerangIDs[i]];
		for (uint j = 0; j < anim.frameCount; j++) {
			jjANIMFRAME@ frame = jjAnimFrames[anim + 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);
		}
	}
	
	jjSampleLoad(SOUND::WIND_WIND2A, "ezsalt_wind.ogg");
}

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