Downloads containing weaponVMega6.asc

Downloads
Name Author Game Mode Rating
Custom Weapons...Featured Download Violet CLM Other 10 Download file

File preview

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

namespace WeaponVMega {
	namespace Crackerjack {
		class Weapon : MLLEWeapons::WeaponInterface {
			Weapon() {
				super(
					regularObjectTemplate: MLLEWeapons::ObjectTemplate(
						xSpeed: 1.25
					),
					powerupObjectTemplate: MLLEWeapons::ObjectTemplate(
						xSpeed: 1.25,
						animSpeed: 2,
						curAnim: 1
					),
					animSetFilename: "weaponVMega.j2a",
					animSetID: 5,
					pickupAnimation: 3,
					poweredUpPickupAnimation: 4,
					pickupFrameIDToUseForAmmoCrate: 1,
					gradualAim: true,
					traits: se::weapon_default_traits | se::weapon_increases_mobility | se::weapon_fails_in_interiors,
					behavior: function(obj, powerup) { obj.behavior = Behavior; }
				);
			}
		}
		void Behavior(jjOBJ@ obj) {
			if (obj.state == STATE::START) {
				obj.state = STATE::FLY;
				obj.xSpeed += obj.var[7] / 65536.f;
				obj.xPos += obj.xSpeed * 2; obj.yPos += obj.ySpeed * 2;
			} else if (obj.state == STATE::EXPLODE || MLLEWeapons::HelpfulBulletFunctions::MaskedPixel(obj))
				MLLEWeapons::HelpfulBulletFunctions::Blast(obj, jjAnimSets[ANIM::AMMO] + 5);
			else {
				const float parentX = (obj.creatorType == CREATOR::PLAYER) ? jjPlayers[obj.creatorID].xPos : obj.xOrg;
				const float parentY = (obj.creatorType == CREATOR::PLAYER) ? jjPlayers[obj.creatorID].yPos : obj.yOrg;
				if (abs(obj.xPos - parentX) >= 160 || abs(obj.yPos - parentY) >= 128)
					obj.state = STATE::EXPLODE;
				else {
					obj.xPos += obj.xSpeed;
					obj.yPos += obj.ySpeed;
					
					//obj.var[10] = obj.var[10] + 1; //ricochet
					
					if (jjGameTicks % 3 == 0)
						for (uint i = jjObjectCount; --i != 0; ) {
							jjOBJ@ other = jjObjects[i];
							if (other.isActive && (other.playerHandling == HANDLING::PLAYERBULLET || other.playerHandling == HANDLING::ENEMYBULLET) && other.state != STATE::EXPLODE && (other.var[6] & 16) == 0 && obj.creator != other.creator && obj.doesCollide(other, true))
								MLLEWeapons::HelpfulBulletFunctions::Blast(other, obj.curAnim + (MLLEWeapons::HelpfulBulletFunctions::IsPowerup(obj) ? 1 : 2));
						}
					int frameID = (jjGameTicks >> 2) & 3;
					if (frameID == 0) frameID = 2;
					jjDrawRotatedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame + frameID, MLLEWeapons::HelpfulBulletFunctions::GetAngle(obj), MLLEWeapons::HelpfulBulletFunctions::GetDirection(obj));
				}
			} 
		}
	}
}