Downloads containing weaponVMega7.asc

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Malice in WonderlandFeatured Download Loon Battle 9.9 Download file
TSF with JJ2+ Only: Anniversary Bash 23 levels Jazz2Online Multiple N/A Download file
Custom Weapons...Featured Download Violet CLM Other 10 Download file

File preview

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

namespace WeaponVMega {
	namespace GravityWell {
		class Weapon : MLLEWeapons::WeaponInterface {
			Weapon() {
				super(
					regularObjectTemplate: MLLEWeapons::ObjectTemplate(
						state: STATE::IDLE,
						counterEnd: 175,
						isBlastable: false,
						var: array<int> = {0,0,0,0,0,0,16}
					),
					powerupObjectTemplate: MLLEWeapons::ObjectTemplate(
						state: STATE::IDLE,
						counterEnd: 234,
						isBlastable: false,
						var: array<int> = {0,0,0,0,0,0,16}
					),
					animSetFilename: "weaponVMega.j2a",
					animSetID: 6,
					pickupAnimation: 1,
					poweredUpPickupAnimation: 2,
					style: WEAPON::MISSILE,
					traits: se::weapon_default_traits | se::weapon_causes_splash_damage | se::weapon_inflicts_status_condition,
					behavior: function(obj, powerup) { obj.eventID = OBJECT::BULLET; obj.behavior = Behavior; }
				);
			}
		}
		void Behavior(jjOBJ@ obj) {
			obj.frameID = ++obj.counter / 7;
			obj.age = jjSampleLooped(obj.xPos, obj.yPos, SOUND::COMMON_MONITOR, obj.age, 63, 5000);
			
			const bool regular = !MLLEWeapons::HelpfulBulletFunctions::IsPowerup(obj);
			
			if (--obj.counterEnd == 0) {
				jjSample(obj.xPos, obj.yPos, SOUND::COMMON_SHLDOF3);
				obj.particlePixelExplosion(regular ? 88 : 24);
				obj.delete();
			} else {
				float d, dx, dy;
				const float m = regular ? 290 : 320;
				for (uint i = jjObjectCount; --i != 0; ) {
					jjOBJ@ other = jjObjects[i];
					if (other.isActive && other.eventID <= OBJECT::BULLET && other.isBlastable && other.state != STATE::EXPLODE && (other.creatorType != CREATOR::PLAYER || MLLEWeapons::HelpfulBulletFunctions::PlayerIsEnemy(obj, jjPlayers[other.creator]))) {
						if (withinRange(obj, other.xPos, other.yPos, d, dx, dy, m)) {
							const float angle = atan2(dy, dx);
							other.xSpeed += 64 / d * cos(angle);
							other.ySpeed += 64 / d * sin(angle);
						}
					}
				}
				for (uint i = 0; i < 32; ++i) {
					jjPLAYER@ other = jjPlayers[i];
					if (other.isInGame && other.blink == 0 && (obj.creatorType != CREATOR::PLAYER || jjPlayers[obj.creatorID].isEnemy(other))) {
						if (withinRange(obj, other.xPos, other.yPos, d, dx, dy, m)) {
							const float angle = atan2(dy, dx);
							other.xSpeed += 24 / d * cos(angle);
							other.ySpeed += 14 / d * sin(angle);
						}
					}
				}
				if (obj.frameID <= 6) {
					obj.curFrame = jjAnimations[obj.curAnim] + obj.frameID;
					jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, 1, SPRITE::PALSHIFT, regular ? 0 : 192);
				} else {
					while (obj.frameID > 6) obj.frameID -= 3;
					obj.curFrame = jjAnimations[obj.curAnim] + obj.frameID;
					jjDrawRotatedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, (obj.counter - 7*7) * (obj.xSpeed >= 0 ? -32 : 32), 1,1, SPRITE::PALSHIFT, regular ? 0 : 192);
					obj.lightType = LIGHT::RING2;
					obj.light = (regular ? 15 : 22) - (obj.counter & 7) * 2;
				}
			}
		}
		bool withinRange(const jjOBJ@ obj, float x, float y, float &out d, float &out dx, float &out dy, float m) {
			dx = obj.xPos - x;
			dy = obj.yPos - y;
			return (d = sqrt(dx * dx + dy * dy)) < m;
		}
	}
}