Downloads containing lightningrod.mut

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

File preview

#pragma name "Lightning Rod"
#pragma require "Lightningrod.j2a"
#pragma require "ZAPFIZZ1.wav"
#pragma require "ZAPFIZZ2.wav"

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

void onLevelLoad() {
	jjAnimSets[ANIM::CUSTOM[27]].load(0, "Lightningrod.j2a");
	jjAnimations[jjAnimSets[ANIM::AMMO] + 59] = jjAnimations[jjAnimSets[ANIM::CUSTOM[27]] + 0];
	
	jjObjectPresets[OBJECT::TNT].behavior = Lightningrod();
	jjObjectPresets[OBJECT::TNT].determineCurAnim(ANIM::CUSTOM[27], 0);
	jjObjectPresets[OBJECT::TNT].playerHandling = HANDLING::PARTICLE;
	jjObjectPresets[OBJECT::TNT].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::TNT].counterEnd = 255;
	
	jjObjectPresets[OBJECT::TNTAMMO3].behavior = LightningrodPickup();
	jjObjectPresets[OBJECT::TNTAMMO3].scriptedCollisions = true;
	jjObjectPresets[OBJECT::TNTAMMO3].determineCurAnim(ANIM::CUSTOM[27], 0);
	jjWeapons[WEAPON::TNT].maximum = 10;
	
	jjSampleLoad(SOUND::COMMON_ELECTRICHIT, "ZAPFIZZ1.wav");
	jjSampleLoad(SOUND::COMMON_ELECTRIC2, "ZAPFIZZ2.wav");
}

class Lightningrod : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::BULLET, false);
		jjPLAYER@ creator = jjPlayers[obj.creatorID];
		
		if (jjGameMode == GAME::CTF) {
			switch (creator.team) {
				case TEAM::BLUE: obj.var[4] = 1; break;
				case TEAM::RED: obj.var[4] = 2; break;
				case TEAM::YELLOW: obj.var[4] = 3; break;
				case TEAM::GREEN: obj.var[4] = 4; break;
			}
		} else {
			obj.var[4] = 1;
		}
		
		jjDrawSprite(obj.xPos, obj.yPos, ANIM::CUSTOM[27], obj.var[0] == 1? obj.var[4] : 0, obj.var[0] == 1? jjGameTicks / 10 % 6 : 0, obj.direction, SPRITE::NORMAL);
		
		if (obj.counter == 2 && jjPlayers[obj.creatorID].isLocal) {
			jjSample(creator.xPos, creator.yPos, SOUND::COMMON_MONITOR, 0, 12500);
			obj.age = 0;
			obj.var[1] = 0;
		}
		
		if (obj.counter == 127) obj.counter = 2; 
		
		if (!jjMaskedHLine(int(obj.xPos - 16), 24, int(obj.yPos + 8))) {
			obj.yPos += 6;
			obj.var[0] = 0;
			obj.lightType = LIGHT::POINT;
		} else {
			obj.var[0] = 1;
		}
		
		if (obj.var[0] == 1) {
			obj.age++;
			if (obj.var[1] == 0) {
				jjSample(obj.xPos, obj.yPos, SOUND::COMMON_LANDCAN1, 0, 30000);
				obj.var[1] = 1;
			}
			obj.lightType = LIGHT::BRIGHT;
			obj.light = 10;
			if (obj.age % 20 == 0) {
				for (int i = -4; i <= 4; i += 4) {
					Electricity temp;
					int id = jjAddObject(OBJECT::LIGHTNINGSHIELDBULLET, obj.xPos, obj.yPos - 12, obj.creatorID, CREATOR::PLAYER, jjVOIDFUNCOBJ(temp.onBehave));
					if (id != 0) {
						jjOBJ@ zap = jjObjects[id];
						zap.lightType = LIGHT::NONE;
						zap.counterEnd = 6;
						zap.animSpeed = 2;
						zap.direction = obj.direction;
						zap.lightType = LIGHT::NONE;
						zap.playerHandling = HANDLING::PLAYERBULLET;
						zap.var[3] = 1;
						zap.var[6] = 8;
						zap.xSpeed = i;
						zap.xAcc = 0;
						if (i == 0) zap.ySpeed = -4;
					}
				}
			}
		}
		
		if (obj.age == 420) {
			obj.var[0] = obj.var[1] = 0;
			obj.particlePixelExplosion(0);
			obj.delete();
		}
	}
}

class Electricity : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::BULLET, false);
	}
}

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