Downloads containing tornadogun.mut

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

File preview

#pragma name "Tornado Gun"
#pragma require "TornadoGun.j2a"

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

void onLevelLoad() {
	jjAnimSets[ANIM::CUSTOM[26]].load(0, "TornadoGun.j2a");
	jjAnimations[jjAnimSets[ANIM::AMMO] + 57] = jjAnimations[jjAnimSets[ANIM::CUSTOM[26]] + 3];
	jjAnimations[jjAnimSets[ANIM::AMMO] + 56] = jjAnimations[jjAnimSets[ANIM::CUSTOM[26]] + 2];
	
	jjObjectPresets[OBJECT::TOASTERBULLET].behavior = TornadoGun();
	jjObjectPresets[OBJECT::TOASTERBULLET].special = jjObjectPresets[OBJECT::TOASTERBULLET].determineCurAnim(ANIM::CUSTOM[26], 0);
	jjObjectPresets[OBJECT::TOASTERBULLET].xSpeed = 4;
	jjObjectPresets[OBJECT::TOASTERBULLET].counterEnd = 110;
	jjObjectPresets[OBJECT::TOASTERBULLET].var[6] = 0;
	jjObjectPresets[OBJECT::TOASTERBULLET].freeze = 0;
	jjObjectPresets[OBJECT::TOASTERBULLET].eventID = OBJECT::FIREBALLBULLET;
	jjObjectPresets[OBJECT::TOASTERBULLET].lightType = jjObjectPresets[OBJECT::FIREBALLBULLET].lightType;
	jjObjectPresets[OBJECT::TOASTERBULLET].killAnim = jjObjectPresets[OBJECT::ICEBULLET].killAnim;
	jjObjectPresets[OBJECT::TOASTERBULLET].lightType = LIGHT::POINT;
	
	jjObjectPresets[OBJECT::TOASTERBULLETPU].behavior = TornadoGunPU();
	jjObjectPresets[OBJECT::TOASTERBULLETPU].special = jjObjectPresets[OBJECT::TOASTERBULLETPU].determineCurAnim(ANIM::CUSTOM[26], 1);
	jjObjectPresets[OBJECT::TOASTERBULLETPU].xSpeed = 6;
	jjObjectPresets[OBJECT::TOASTERBULLETPU].counterEnd = 120;
	jjObjectPresets[OBJECT::TOASTERBULLETPU].var[6] = 8;
	jjObjectPresets[OBJECT::TOASTERBULLETPU].freeze = 0;
	jjObjectPresets[OBJECT::TOASTERBULLETPU].eventID = OBJECT::FIREBALLBULLET;
	jjObjectPresets[OBJECT::TOASTERBULLETPU].killAnim = jjObjectPresets[OBJECT::ICEBULLET].killAnim;
	jjObjectPresets[OBJECT::TOASTERBULLETPU].lightType = LIGHT::POINT2;
	
	jjObjectPresets[OBJECT::TOASTERPOWERUP].determineCurAnim(ANIM::CUSTOM[26], 4);
	jjObjectPresets[OBJECT::TOASTERPOWERUP].determineCurFrame();
	
	jjObjectPresets[OBJECT::TOASTERAMMO15].determineCurAnim(ANIM::CUSTOM[26], 5);
	jjObjectPresets[OBJECT::TOASTERAMMO15].determineCurFrame();

	jjWeapons[WEAPON::TOASTER].defaultSample = false;
	jjWeapons[WEAPON::TOASTER].replacedByBubbles = false;
	jjWeapons[WEAPON::TOASTER].spread = SPREAD::NORMAL;
	jjWeapons[WEAPON::TOASTER].style = WEAPON::NORMAL;
	jjWeapons[WEAPON::TOASTER].multiplier = 1;
}

class TornadoGun : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::BULLET);
		jjPLAYER@ creator = jjPlayers[obj.creatorID];
		if (obj.state == STATE::FLY) {
			if (obj.counter == 1 && creator.isLocal) {
				jjSample(creator.xPos, creator.yPos, SOUND::INTRO_BLOW, 48, 25000);
				jjSample(creator.xPos, creator.yPos, SOUND::COMMON_BIRDFLY, 48, 25000);
			}
			
			switch (obj.direction) {
				case 1: obj.xSpeed = obj.xSpeed - 0.05; obj.ySpeed = obj.ySpeed - 0.1; break;
				case -1: obj.xSpeed = obj.xSpeed + 0.05; obj.ySpeed = obj.ySpeed - 0.1; break;
			}
			
			float pdx = jjLocalPlayers[0].xPos - obj.xPos, pdy = jjLocalPlayers[0].yPos - obj.yPos;
			if ((pdx * pdx + pdy * pdy < 64 * 64) && !creator.isLocal && jjLocalPlayers[0].blink == 0 && (jjLocalPlayers[0].team != creator.team || jjFriendlyFire || jjGameMode != GAME::CTF) && gameIsActive()) {
				jjLocalPlayers[0].ySpeed -= 2.5;
				jjLocalPlayers[0].xSpeed += 2.5 * obj.direction;
			}
		}
		if (obj.state == STATE::EXPLODE) {
			if (obj.var[0] == 0) {
				jjSample(obj.xPos, obj.yPos, SOUND::COMMON_SWISH4, 36, 15000);
				obj.var[0] = 1;
			}
		}
	}
}

class TornadoGunPU : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::BULLET);
		jjPLAYER@ creator = jjPlayers[obj.creatorID];
		if (obj.state == STATE::FLY) {
			if (obj.counter == 1 && creator.isLocal) {
				jjSample(creator.xPos, creator.yPos, SOUND::INTRO_BLOW, 48, 30000);
				jjSample(creator.xPos, creator.yPos, SOUND::COMMON_BIRDFLY, 48, 30000);
			}

			switch (obj.direction) {
				case 1: obj.xSpeed = obj.xSpeed - 0.05; obj.ySpeed = obj.ySpeed - 0.1; break;
				case -1: obj.xSpeed = obj.xSpeed + 0.05; obj.ySpeed = obj.ySpeed - 0.1; break;
			}
			
			float pdx = jjLocalPlayers[0].xPos - obj.xPos, pdy = jjLocalPlayers[0].yPos - obj.yPos;
			if ((pdx * pdx + pdy * pdy < 96 * 96) && !creator.isLocal && jjLocalPlayers[0].blink == 0 && (jjLocalPlayers[0].team != creator.team || jjFriendlyFire || jjGameMode != GAME::CTF) && gameIsActive()) {
				jjLocalPlayers[0].ySpeed -= 5;
				jjLocalPlayers[0].xSpeed += 5 * obj.direction;
			}
		}
		if (obj.state == STATE::EXPLODE) {
			if (obj.var[0] == 0) {
				jjSample(obj.xPos, obj.yPos, SOUND::COMMON_SWISH4, 36, 15000);
				obj.var[0] = 1;
			}
		}
	}
}