Downloads containing fusioncannon.mut

Downloads
Name Author Game Mode Rating
JJ2+ Only: Arcane WeaponsFeatured Download PurpleJazz Mutator 10 Download file

File preview

#pragma name "Fusion Cannon"
#pragma require "FusionCannon.j2a"
#pragma require "f_fus1.wav"
#pragma require "f_fus3.wav"

bool gameIsActive() {
	return jjGameState == GAME::STARTED || jjGameState == GAME::OVERTIME;
}

void onLevelLoad() {
	jjAnimSets[ANIM::CUSTOM[29]].load(0, "FusionCannon.j2a");
	jjAnimations[jjAnimSets[ANIM::AMMO] + 68] = jjAnimations[jjAnimSets[ANIM::CUSTOM[29]] + 0];
	jjAnimations[jjAnimSets[ANIM::AMMO] + 67] = jjAnimations[jjAnimSets[ANIM::CUSTOM[29]] + 1];
	jjAnimations[jjAnimSets[ANIM::PLUS_COMMON] + 1] = jjAnimations[jjAnimSets[ANIM::CUSTOM[29]] + 3]; //gun 9 crate

	jjObjectPresets[OBJECT::ELECTROBULLET].behavior = jjObjectPresets[OBJECT::ELECTROBULLETPU].behavior = FusionCannon();
	jjObjectPresets[OBJECT::ELECTROBULLET].counterEnd = jjObjectPresets[OBJECT::ELECTROBULLETPU].counterEnd = 255;
	jjObjectPresets[OBJECT::ELECTROBULLET].eventID = jjObjectPresets[OBJECT::BLASTERBULLET].eventID;
	jjObjectPresets[OBJECT::ELECTROBULLET].eventID = jjObjectPresets[OBJECT::BLASTERBULLETPU].eventID;
	jjObjectPresets[OBJECT::ELECTROBULLET].killAnim = jjObjectPresets[OBJECT::ELECTROBULLETPU].killAnim = jjObjectPresets[OBJECT::ICEBULLET].killAnim;
	jjObjectPresets[OBJECT::ELECTROBULLET].var[6] = 2 + 16;
	jjObjectPresets[OBJECT::ELECTROBULLETPU].var[6] = 2 + 8 + 16;

	jjObjectPresets[OBJECT::GUN9AMMO3].behavior = FusionPickup();
	jjObjectPresets[OBJECT::GUN9AMMO3].determineCurFrame();
	jjObjectPresets[OBJECT::GUN9AMMO3].scriptedCollisions = true;
	
	jjObjectPresets[OBJECT::GUN9POWERUP].determineCurAnim(ANIM::CUSTOM[29], 2);
	jjObjectPresets[OBJECT::GUN9POWERUP].determineCurFrame();
	
	jjWeapons[WEAPON::GUN9].style = WEAPON::CAPPED;
	jjWeapons[WEAPON::GUN9].maximum = 25;
	
	jjSampleLoad(SOUND::AMMO_LASER2, "f_fus1.wav");
	jjSampleLoad(SOUND::AMMO_LASER3, "f_fus3.wav");
}

class FusionCannon : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::BULLET, obj.state == STATE::EXPLODE? true:false);
		jjPLAYER@ creator = jjPlayers[obj.creatorID];
		
		obj.var[5] = obj.eventID == OBJECT::ELECTROBULLETPU? 2:1;
		
		switch (obj.state) {
			case STATE::START:
				obj.state = STATE::FLY;
			break;
			
			case STATE::FLY:
				obj.var[11] = obj.xSpeed > 0? 5 : obj.xSpeed < 0? -5 : 0;
				obj.xSpeed = obj.var[11];
				obj.ySpeed = obj.var[11] == 0? -4:0;
				
				jjDrawSprite(obj.xPos, obj.yPos, ANIM::AMMO, 77, 6, 0, SPRITE::ALPHAMAP, obj.eventID == OBJECT::ELECTROBULLETPU? 35:40);
				jjDrawSprite(obj.xPos, obj.yPos, ANIM::AMMO, 77, 6, 0, SPRITE::ALPHAMAP, obj.eventID == OBJECT::ELECTROBULLETPU? 35:40);
				
				if (obj.counter % 5 == 0 && !jjLowDetail) {
					ColoredTrail temp;
					jjOBJ@ trail = jjObjects[jjAddObject(OBJECT::EXPLOSION, int(obj.xPos - jjCos(obj.var[0])), int(obj.yPos - jjSin(obj.var[0])), obj.creatorID, CREATOR::PLAYER, jjVOIDFUNCOBJ(temp.onBehave))];
					trail.determineCurAnim(ANIM::AMMO, 12);
					trail.lightType = LIGHT::POINT;
					trail.playerHandling = HANDLING::PARTICLE;
					trail.bulletHandling = HANDLING::IGNOREBULLET;
					trail.isBlastable = false;
					trail.var[0] = obj.eventID == OBJECT::ELECTROBULLETPU? 32:59;
				}
				
			break;
			
			case STATE::EXPLODE:
				if (obj.var[2] == 0) {
					Shockwave temp;
					jjOBJ@ blast = jjObjects[jjAddObject(OBJECT::BULLET, obj.xPos, obj.yPos, obj.creatorID, CREATOR::PLAYER, jjVOIDFUNCOBJ(temp.onBehave))];
					obj.var[2] = 1;
					blast.var[2] = 1;
					blast.var[5] = obj.var[5];
				}
			break;
		}
	}
}

class Shockwave : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		jjPLAYER@ creator = jjPlayers[obj.creatorID];
		
		obj.playerHandling = HANDLING::PARTICLE;
		obj.bulletHandling = HANDLING::IGNOREBULLET;
		obj.animSpeed = 1;
		
		if (obj.var[2] == 1) {
			obj.lightType = obj.var[2] == 1? LIGHT::RING2 : LIGHT::NONE;
			obj.var[0] = obj.var[0] + 1;
			obj.light += 3;
			obj.var[4] = obj.light * 4;
			
			for (int i = 1; i < jjObjectCount; i++) {
				jjOBJ@ target = jjObjects[i];
				float dx = target.xPos - obj.xPos, dy = target.yPos - obj.yPos;
				if ((target.eventID == OBJECT::TNT || target.behavior == BEHAVIOR::MONITOR || target.behavior == BEHAVIOR::AMMO15 || target.eventID == OBJECT::GUNCRATE || target.eventID == OBJECT::GEMCRATE || target.eventID == OBJECT::CARROTCRATE || target.playerHandling == HANDLING::ENEMY || target.eventID == OBJECT::DESTRUCTSCENERY) && target.var[4] == 0) {
					if (dx * dx + dy * dy < obj.var[4] * obj.var[4]) {
						if (target.eventID != OBJECT::TNT) {
							obj.objectHit(target, target.bulletHandling == HANDLING::HURTBYBULLET? HANDLING::ENEMY : HANDLING::SPECIAL);
							if (target.playerHandling != HANDLING::ENEMY) target.state = STATE::KILL;
						}
						else target.state = STATE::EXPLODE;
						if (target.playerHandling != HANDLING::ENEMY) target.var[4] = 1;
					}
					else target.var[4] = 0;
				}
				else if ((target.behavior == BEHAVIOR::PICKUP || target.eventID == OBJECT::TNTAMMO3 || target.eventID == OBJECT::GUN9AMMO3) && target.state == STATE::FLOAT) {
					if (dx * dx + dy * dy < obj.var[4] * obj.var[4])
						target.state = STATE::FLOATFALL;
				}
				else if (target.playerHandling == HANDLING::ENEMY && target.state != STATE::KILL) {
					if (dx * dx + dy * dy < obj.var[4] * obj.var[4]) {
						if (obj.var[8] & 1 << i == 0) {
							obj.energy -= 1;
							obj.var[8] = obj.var[8] | 1 << i;
						}
					}
				}
			}
			
			if (jjIsServer && gameIsActive()) {
				for (int i = 0; i < 32; i++) {
					jjPLAYER@ player = jjPlayers[i];
					if (
						player.isActive && player.isInGame && player.health > 0 && player !is creator && creator.blink == 0 &&
							(jjGameMode != GAME::CTF || jjFriendlyFire || player.team != creator.team)
					) {
						float dx = player.xPos - obj.xPos, dy = player.yPos - obj.yPos;
						if (dx * dx + dy * dy < obj.var[4] * obj.var[4]) {
							if (obj.var[8] & 1 << i == 0) {
								player.hurt(obj.var[5], false, creator);
								obj.var[8] = obj.var[8] | 1 << i;
							}
						}
					}
				}
			}
		}
		
		if (obj.var[0] == 20) {
			obj.var[0] = 0;
			obj.var[2] = 0;
			obj.var[4] = 0;
			obj.delete();
		}
	}
}

class ColoredTrail : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::EXPLOSION, false);
		if (obj.isActive) jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::TRANSLUCENTSINGLEHUE, obj.var[0]);
	}
}

class FusionPickup : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PICKUP);
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ play, int force) {
		if (play.ammo[WEAPON::GUN9] < jjWeapons[WEAPON::GUN9].maximum) {
			if (play.isLocal) {
				play.ammo[WEAPON::GUN9] = play.ammo[WEAPON::GUN9] + 2;
				if (jjAutoWeaponChange && play.ammo[WEAPON::GUN9] < 1) play.currWeapon = WEAPON::GUN9;
				jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PICKUPW1, 0, 0);
			}
			obj.behavior = BEHAVIOR::EXPLOSION2;
			obj.scriptedCollisions = false;
			obj.frameID = 0;
		}
		return true;
	}
}

void onPlayer(jjPLAYER@ play) {
	jjEnforceLighting = LIGHT::BASIC;
	if (play.ammo[WEAPON::GUN9] > 25) play.ammo[WEAPON::GUN9] = 25;
}