Downloads containing weaponMega3.mut

Downloads
Name Author Game Mode Rating
JJ2+ Only: Weapon MegaFeatured Download Violet CLM Mutator 8.7 Download file

File preview

#pragma name "Weapon Mega: Ice Cloud"
#pragma require "weaponMega3.mut"
#include "weaponMega.asc"

bool LoadWeaponMega3() {
	if (!SafeToReplaceWeapon(WEAPON::ICE))
		return false;
	
	jjWeapons[WEAPON::ICE].style = WEAPON::POPCORN;
	jjWeapons[WEAPON::ICE].spread = SPREAD::TOASTER;
	jjWeapons[WEAPON::ICE].multiplier = 4;
	jjWeapons[WEAPON::ICE].gradualAim = true;
	
	Preset1.behavior = ApplyIceCloud;
	Preset2.behavior = ApplyIceCloud;
	Preset1.special = Preset1.determineCurAnim(AnimSet, 0);
	Preset2.special = Preset2.determineCurAnim(AnimSet, 0);
	Preset1.determineCurFrame(); Preset2.determineCurFrame();
	Preset1.isBlastable = true; Preset2.isBlastable = true;
	//Preset1.var[6] = Preset1.var[6] | 16; //"fireball"
	//Preset2.var[6] = Preset2.var[6] | 16;
	Preset1.counterEnd = 120; //lifetime
	Preset2.counterEnd = 200;
	
	return true;
}
const bool WeaponMega3Loaded = LoadWeaponMega3();

void ApplyIceCloud(jjOBJ@ obj) { obj.behavior = IceCloud(obj); obj.behave(); }
class IceCloud : WeaponMega {
	IceCloud(jjOBJ@ objectOfAttachment) {
		@obj = @objectOfAttachment;
		obj.xSpeed += obj.var[7] / 65536.f;
		if (obj.creatorType == CREATOR::PLAYER)
			obj.ySpeed += int(jjPlayers[obj.creatorID].ySpeed) / 2;
		obj.state = STATE::FLY;
	}
	void onBehave(jjOBJ@) override {
		obj.xPos += obj.xSpeed *= 0.96;
		obj.yPos += obj.ySpeed *= 0.96;
		if (obj.frameID < 3 && ++obj.age & 15 == 15) {
			++obj.frameID; ++obj.curFrame;
		}
		if (--obj.counterEnd == 0 || obj.state == STATE::EXPLODE) {
			int playerID;
			if (isPowerup() && (playerID = getNearestEnemy(256)) >= 0) {
				obj.frameID = 0;
				obj.killAnim = (obj.curAnim += 1) + 1;
				obj.counterEnd = 100;
				obj.freeze = 0;
				const jjPLAYER@ target = jjPlayers[playerID];
				obj.xSpeed = (target.xPos - obj.xPos) / 25;
				obj.ySpeed = (target.yPos - obj.yPos) / 25;
				obj.xAcc = obj.yAcc = obj.var[7] = 0;
				obj.behavior = BEHAVIOR::BULLET;
			} else {
				obj.counter = 0;
				obj.frameID = 0;
				obj.curAnim += 2;
				obj.behavior = BEHAVIOR::EXPLOSION;
			}
			jjSample(obj.xPos, obj.yPos, SOUND::COMMON_ICECRUSH);
		} else if (jjGameTicks & 1 == 0) {
			jjPARTICLE@ part = jjAddParticle(PARTICLE::ICETRAIL);
			if (part !is null) {
				part.yPos = obj.yPos;
				part.xPos = obj.xPos + (jjRandom() & 31) - 15;
			}
		}
	}
	void onDraw(jjOBJ@) override {
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, 1, SPRITE::TRANSLUCENT);
		if (obj.frameID == 3 && isPowerup())
			jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, jjAnimations[obj.curAnim + 1], 0, SPRITE::TRANSLUCENTCOLOR, 15);
	}
}