Downloads containing AngelWings.asc

Downloads
Name Author Game Mode Rating
Mover Weapons Violet CLM Other 6.5 Download file

File preview

#pragma require "AngelWings.asc"
#include "MLLE-Weapons.asc"
#pragma require "AngelWings.j2a"

namespace AngelWings {
	class Weapon : MLLEWeapons::WeaponInterface {
		uint Halos = 0, HalosPU = 1;
		float HaloSpeed = 7.5;
		Weapon() {
			super(
				regularObjectTemplate: MLLEWeapons::ObjectTemplate(
					xSpeed: 1,
					curAnim: 2,
					killAnim: jjAnimSets[ANIM::AMMO] + 4,
					playerHandling: HANDLING::PARTICLE,
					state: STATE::FLY
				),
				animSetFilename: "AngelWings.j2a",
				pickupAnimation: 0,
				style: WEAPON::CAPPED,
				traits: se::weapon_default_traits | se::weapon_increases_mobility,
				onPlayer: DetermineLifetime,
				behavior: MLLEWeapons::behaviorFunction(StartWings),
				apply: MLLEWeapons::applyFunction(CheckHalo)
			);
		}
		bool CheckHalo(uint, se::WeaponHook@, jjSTREAM@ parameters) {
			if (parameters !is null && parameters.getSize() >= 12) {
				uint param;
				parameters.pop(param);
				Halos = param;
				parameters.pop(param);
				HalosPU = param;
				parameters.pop(param);
				HaloSpeed = param / 2.f;
			}
			return true;
		}
		void StartWings(jjOBJ@ obj, bool powerup) {
			jjSample(obj.xPos, obj.yPos, SOUND::COMMON_FLAP);
			
			uint feathers = 2 + (jjRandom() & (powerup ? 3 : 1));
			do {
				jjOBJ@ feather = jjObjects[jjAddObject(OBJECT::SHARD, obj.xOrg + (int(jjRandom()) & 63) - 32, obj.yOrg, obj.objectID,CREATOR::OBJECT, behavior: Feather)];
				feather.curAnim = powerup ? PoweredUpPickupAnimation : PickupAnimation;
				feather.ySpeed /= 4;
				feather.xSpeed /= 2;
				feather.behavior = Feather;
				feather.counterEnd = 255;
				feather.frameID = jjRandom() & 15;
			} while (--feathers != 0);
			
			uint halos = powerup ? HalosPU : Halos;
			if (halos != 0) {
				int angle = (int(halos) - 1) * -24;
				do {
					jjOBJ@ halo = jjObjects[jjAddObject(obj.eventID, obj.xPos, obj.yPos, obj.creatorID,obj.creatorType, Halo)];
					halo.xSpeed = jjSin(angle) * HaloSpeed;
					halo.ySpeed = jjCos(angle) * HaloSpeed;
					halo.var[7] = obj.var[7];
					if (obj.ySpeed < 0)
						halo.ySpeed = -halo.ySpeed;
					angle += 48;
				} while (--halos != 0);
			}
			
			if (obj.creatorType == CREATOR::PLAYER) {
				const jjPLAYER@ play = jjPlayers[obj.creatorID];
				obj.xPos = play.xPos;
				obj.yPos = play.yPos + 24;
				while (jjMaskedHLine(int(play.xPos) - 12, 24, int(obj.yPos - 36)))
					obj.yPos += 1;
				if (play.isLocal)
					obj.counterEnd = obj.doesHurt;
			}
			obj.doesHurt = 0;
			
			obj.behavior = Wings;
		}
	}
	void DetermineLifetime(jjPLAYER@ p, int number) {
		jjOBJ@ preset = jjObjectPresets[(p.powerup[number] ? se::getPoweredBulletOfWeapon : se::getBasicBulletOfWeapon)(number)];
		preset.doesHurt = preset.counterEnd = p.fastfire;
	}
	void Wings(jjOBJ@ obj) {
		if (obj.doesHurt > obj.counterEnd) {
			obj.clearPlatform();
			obj.delete();
		} else {
			const bool powerup = MLLEWeapons::HelpfulBulletFunctions::IsPowerup(obj);
			float x,y;
			if (obj.creatorType == CREATOR::PLAYER) {
				const jjPLAYER@ play = jjPlayers[obj.creatorID];
				x = play.xPos;
				y = play.yPos;
			} else {
				x = obj.xOrg;
				y = obj.yOrg;
			}
			const jjANIMATION@ anim = jjAnimations[obj.curAnim];
			const int frameID = obj.doesHurt++ * (anim.frameCount - 1) / (obj.counterEnd + 1) + 1;
			jjDrawSpriteFromCurFrame(
				x,y,
				sprite: anim + frameID,
				layerZ: frameID == 3 ? 3 : 4,
				mode: powerup ? SPRITE::PALSHIFT : SPRITE::NORMAL, param: 8
			);
			obj.bePlatform(obj.xPos, obj.yPos);
		}
	}
	void Feather(jjOBJ@ obj) {
		if (obj.state != STATE::START) {
			jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::BLEND_NORMAL, obj.counterEnd);
			if ((obj.counterEnd -= 4) == 3) {
				obj.delete();
				return;
			}
		}
		obj.behave(BEHAVIOR::BIRDFEATHER, false);
	}
	void Halo(jjOBJ@ obj) {
		obj.special = (obj.curAnim -= 1);
		obj.determineCurFrame();
		obj.playerHandling = (obj.creatorType == CREATOR::PLAYER) ? HANDLING::PLAYERBULLET : HANDLING::ENEMYBULLET;
		obj.counterEnd = 35;
		obj.lightType = LIGHT::POINT2;
		if (obj.eventID == OBJECT::ICEBULLET) obj.eventID = OBJECT::BLASTERBULLET;
		obj.behave(obj.behavior = BEHAVIOR::BULLET);
	}
}