Downloads containing ab16ctf07.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Anniversary Bash 16 Levels Jazz2Online Multiple N/A Download file

File preview

// Electric Express
// Created by PurpleJazz of XLM (2014)

/*******************************************************************/

uint elapsed = 0;
array<bool> electrocution(4, false);

void onLevelLoad() {
	jjTexturedBGTexture = TEXTURE::MEDIVO;
	
	jjObjectPresets[OBJECT::ICEBULLET].behavior = Messenger; //acts as a carrier to send a global JJ2 alert on death by electrocution
	jjObjectPresets[OBJECT::ICEBULLET].playerHandling = HANDLING::PARTICLE;

	jjObjectPresets[OBJECT::PLASMASHIELDBULLET].counterEnd = 0; //only the particle effect required
	jjObjectPresets[OBJECT::PLASMASHIELDBULLET].playerHandling = HANDLING::PARTICLE;

	jjWeapons[WEAPON::SEEKER].maximum = 25;
	jjWeapons[WEAPON::TNT].maximum = 25;

	jjWeapons[WEAPON::SEEKER].comesFromGunCrates = false;

	jjWeapons[WEAPON::GUN8].comesFromGunCrates = jjWeapons[WEAPON::GUN9].comesFromGunCrates = true;
}

const array<string> DeathMessages = {
	" got electrocuted",
	" completed the circuit",
	" was fried",
	" received 10,000 volts",
	" met the thunder god", 
	" came to a shocking conclusion",
	" became welded to the overhead wire"
};

void Messenger(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::BULLET, false);	
	if (obj.state == STATE::FLY) {
		jjPLAYER@ victim = jjPlayers[obj.creatorID];
		victim.yPos > 14*32?
			jjAlert("" + victim.name + " fell off the train") :
			jjAlert("" + victim.name + DeathMessages[jjRandom()%7]);
		obj.delete();
	}
}

void onLevelBegin() {
	if (jjIsServer) { 
		jjChat("/fireball on");
	}
}

void onPlayer(jjPLAYER@ play) {
	if (jjEventGet(play.xPos/32, (play.yPos/32)+0.5) == AREA::REVERTMORPH && play.health > 0) {
		electrocution[play.localPlayerID] = true;
	}
	if (electrocution[play.localPlayerID]) {
		elapsed++;

		play.xSpeed = -8; // the train is moving afterall
		play.ySpeed = 0;

		if (play.yPos > 14*32) { // hold still, damn it
			play.yPos = (51*32)-24;
		} else {
			play.yPos = (13*32)-24;
		}
	
		if (elapsed % 7 == 0) {
			play.hurt(0, true);
			jjAddObject(OBJECT::PLASMASHIELDBULLET, play.xPos, play.yPos, 0, CREATOR::OBJECT, BEHAVIOR::DEFAULT); //shocking!
			if (jjSoundEnabled) {
				jjSample(play.xPos, play.yPos, SOUND::COMMON_SHIELD_ELEC);
			}
		}

		if (elapsed >= 140) {
			elapsed = 0;
			electrocution[play.localPlayerID] = false;
			play.fireBullet(WEAPON::ICE, false, false, 3.14);
			play.kill(); // Die;
		}
	}

	for (int i = 1; i < jjObjectCount; i++) {
		if ((jjObjects[i].eventID == OBJECT::GOLDCOIN || jjObjects[i].eventID == OBJECT::SILVERCOIN) && jjObjects[i].state == STATE::FLOATFALL) {
			jjObjects[i].state = STATE::FLOAT; // can’t shoot the coins down
		}
		if (jjObjects[i].eventID == OBJECT::BOUNCERPOWERUP) {
			jjObjects[i].yPos = 49.8*32;
			jjObjects[i].ySpeed = 0;
		}
	}

	jjTriggers[1] = play.yPos > 49*32? true : false;
}