Downloads containing weaponVMega1.asc

Downloads
Name Author Game Mode Rating
JJ2+ Only: Knapweed Bog Lark Battle N/A Download file
TSF with JJ2+ Only: Freeport Loon Battle N/A Download file
TSF with JJ2+ Only: Anniversary Bash 22 levels Jazz2Online Multiple N/A Download file
TSF with JJ2+ Only: Facilis descensus AvernoFeatured Download Loon Battle 8.5 Download file
Custom Weapons...Featured Download Violet CLM Other 10 Download file

File preview

#pragma require "weaponVMega1.asc"
#include "MLLE-Weapons.asc"
#pragma require "weaponVMega.j2a"

namespace WeaponVMega {
	namespace Boomerang {
		class Weapon : MLLEWeapons::WeaponInterface {
			Weapon() {
				super(
					regularObjectTemplate: MLLEWeapons::ObjectTemplate(
						xSpeed: 6,
						xAcc: 0.125,
						killAnim: jjAnimSets[ANIM::AMMO].firstAnim + 80,
						isBlastable: false,
						lightType: LIGHT::POINT2,
						counterEnd: 35
					),
					powerupObjectTemplate: MLLEWeapons::ObjectTemplate(
						xSpeed: 7,
						xAcc: 0.1875,
						killAnim: jjAnimSets[ANIM::AMMO].firstAnim + 80,
						isBlastable: false,
						lightType: LIGHT::POINT,
						counterEnd: 30,
						animSpeed: 2
					),
					animSetFilename: "weaponVMega.j2a",
					animSetID: 0,
					pickupAnimation: 1,
					behavior: function(obj, powerup) { obj.behavior = Behavior; }
				);
			}
		}
		void Behavior(jjOBJ@ obj) {
			if (obj.state == STATE::START) {
				obj.xAcc = (obj.xSpeed + obj.var[7] / 65536.f) * 32;
				obj.yAcc = obj.ySpeed * 32;
				obj.state = STATE::FLY;
				DefaultWeapons::DefaultSample(obj, WEAPON::BLASTER);
			}
			
			obj.counter += 8;
			
			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.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) ? 65 : 72
			);
		}
	}
}