Downloads containing weaponVMega2.asc

Downloads
Name Author Game Mode Rating
JJ2+ Only: Anniversary Bash 25 CTF Jazz2Online Capture the flag N/A Download file
TSF with JJ2+ Only: Star of the year V2Featured Download TreyLina Capture the flag 8.5 Download file
TSF with JJ2+ Only: Anniversary Bash 24 CTF Jazz2Online Capture the flag N/A Download file
Custom Weapons...Featured Download Violet CLM Other 10 Download file

File preview

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

namespace WeaponVMega {
	namespace Burrower {
		class Weapon : MLLEWeapons::WeaponInterface {
			Weapon() {
				super(
					regularObjectTemplate: MLLEWeapons::ObjectTemplate(
						xSpeed: 3.5,
						ySpeed: 1,
						xAcc: 0.25f,
						yAcc: 0.125f,
						lightType: LIGHT::POINT2,
						counterEnd: (70*3)/2
					),
					powerupObjectTemplate: MLLEWeapons::ObjectTemplate(
						xSpeed: 5,
						ySpeed: 1,
						xAcc: 0.25f,
						yAcc: 0.125f,
						lightType: LIGHT::POINT2,
						counterEnd: (70*3)/2,
						curAnim: 1,
						animSpeed: 2
					),
					animSetFilename: "weaponVMega.j2a",
					animSetID: 1,
					pickupAnimation: 6,
					poweredUpPickupAnimation: 7,
					style: WEAPON::MISSILE,
					traits: se::weapon_default_traits | se::weapon_causes_splash_damage | se::weapon_goes_through_walls,
					behavior: function(obj, powerup) { obj.behavior = Behavior; }
				);
			}
		}
			
		void Behavior(jjOBJ@ obj) {
			obj.frameID = jjGameTicks >> 2;
			obj.determineCurFrame();
			
			if (obj.state == STATE::START) {
				obj.yAcc = abs(obj.yAcc);
				obj.state = STATE::FLY;
				obj.age = obj.objectID;
				jjSample(obj.xPos, obj.yPos, SOUND::COMMON_LAND);
			} else if (obj.state == STATE::EXPLODE)
				die(obj);
			else if (obj.state == STATE::FLY) {
				obj.xPos += obj.xSpeed + obj.var[7] / 65536.f;
				obj.yPos += (obj.ySpeed += obj.yAcc);
				if (obj.var[7] > 0x100000)
					obj.var[7] = obj.var[7] - 0x80000;
				else if (obj.var[7] < -0x100000)
					obj.var[7] = obj.var[7] + 0x80000;
				if (obj.xPos < 0 || obj.xPos >= MLLEWeapons::LevelRight || obj.yPos >= MLLEWeapons::LevelBottom)
					obj.delete();
				else if (inGround(obj)) {
					obj.state = STATE::SLEEP;
					if (int(obj.xSpeed) == 0)
						die(obj);
					else if (!MLLEWeapons::HelpfulBulletFunctions::IsPowerup(obj))
						obj.xSpeed *= 0.6667;
				}
				MLLEWeapons::HelpfulBulletFunctions::DrawAngled(obj);
			} else {
				//obj.ySpeed = 0;
				obj.xPos += obj.xSpeed;
				if (obj.xPos < 0 || obj.xPos >= MLLEWeapons::LevelRight || !inGround(obj) || MLLEWeapons::HelpfulBulletFunctions::GetNearestEnemyPosition(obj, 40) !is null)
					die(obj);
				else {
					obj.age = jjSampleLooped(obj.xPos, obj.yPos, SOUND::BUBBA_TORNADOATTACK2, obj.age, 63, 200000);
					if (jjGameTicks & 3 == 0) {
						jjOBJ@ rock = jjObjects[jjAddObject(OBJECT::SHARD, obj.xPos, obj.yPos - 14, obj.objectID, CREATOR::OBJECT, BEHAVIOR::INACTIVE)];
						rock.curAnim = obj.curAnim + (MLLEWeapons::HelpfulBulletFunctions::IsPowerup(obj) ? 1 : 2) + (jjRandom() & 3);
						rock.lightType = LIGHT::POINT;
						rock.light = 1;
						rock.behavior = BEHAVIOR::SHARD;
					}
				}
				jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, MLLEWeapons::HelpfulBulletFunctions::GetDirection(obj), SPRITE::NORMAL, 0, 5); //behind walls
			}
		}
		
		bool inGround(const jjOBJ@ obj) {
			return jjMaskedPixel(int(obj.xPos), int(obj.yPos) - 8);
		}
		void die(jjOBJ@ obj) {
			obj.direction = MLLEWeapons::HelpfulBulletFunctions::GetDirection(obj);
			obj.particlePixelExplosion(2);
			jjSample(obj.xPos, obj.yPos -= 16, SOUND::AMMO_BOEM1);
			jjObjects[jjAddObject(OBJECT::EXPLOSION, obj.xPos, obj.yPos)].determineCurAnim(ANIM::AMMO, 3);
			jjAddObject(obj.eventID, obj.xPos, obj.yPos, obj.creatorID, obj.creatorType, function(splash) {
				if (splash.state == STATE::START) {
					splash.curFrame = jjAnimations[jjAnimSets[ANIM::AMMO] + 5] + 6;
					splash.state = STATE::FLY;
					splash.animSpeed = 1;
					splash.var[6] = 16;
					splash.playerHandling = (splash.creatorType == CREATOR::PLAYER) ? HANDLING::PLAYERBULLET : HANDLING::ENEMYBULLET;
				} else {
					splash.delete();
				}
			});
			obj.delete();
		}
	}
}