Downloads containing xlmtapiibtl01.j2as

Downloads
Name Author Game Mode Rating
JJ2+ Only: Total Annihilation II:...Featured Download Loon Multiple 9.3 Download file

File preview

#pragma require "FlashBang.j2a"

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

array<bool> blinded(4, false);
int elapsed = 0;
jjPAL backup;

void onLevelLoad() {
	jjUseLayer8Speeds = true;
	jjTexturedBGTexture = TEXTURE::PSYCH;

	jjAnimSets[ANIM::CUSTOM[0]].load(0, "FlashBang.j2a");
	jjAnimations[jjAnimSets[ANIM::AMMO] + 27] = 
	jjAnimations[jjAnimSets[ANIM::AMMO] + 29] = 
	jjAnimations[jjAnimSets[ANIM::AMMO] + 31] = 
	jjAnimations[jjAnimSets[ANIM::CUSTOM[0]] + 0];
	
	jjAnimations[jjAnimSets[ANIM::AMMO] + 28] = 
	jjAnimations[jjAnimSets[ANIM::AMMO] + 30] = 
	jjAnimations[jjAnimSets[ANIM::AMMO] + 32] = 
	jjAnimations[jjAnimSets[ANIM::CUSTOM[0]] + 2];
	jjAnimations[jjAnimSets[ANIM::AMMO] + 82] = jjAnimations[jjAnimSets[ANIM::CUSTOM[0]] + 1];

	jjObjectPresets[OBJECT::ICEBULLET].behavior = jjObjectPresets[OBJECT::ICEBULLETPU].behavior = FlashBang();
	jjObjectPresets[OBJECT::ICEBULLET].freeze = jjObjectPresets[OBJECT::ICEBULLETPU].freeze = 0;
	jjObjectPresets[OBJECT::ICEBULLET].eventID = jjObjectPresets[OBJECT::ICEBULLETPU].eventID = OBJECT::FIREBALLBULLET;
	jjObjectPresets[OBJECT::ICEBULLET].counterEnd = jjObjectPresets[OBJECT::ICEBULLETPU].counterEnd = 90;
	
	jjObjectPresets[OBJECT::ICEBULLET].xSpeed = 6;
	jjObjectPresets[OBJECT::ICEBULLETPU].xSpeed = 8;
	jjObjectPresets[OBJECT::ICEBULLET].ySpeed = jjObjectPresets[OBJECT::ICEBULLETPU].ySpeed = -4;

	jjObjectPresets[OBJECT::ICEPOWERUP].determineCurAnim(ANIM::CUSTOM[0], 3);
	
	jjWeapons[WEAPON::ICE].defaultSample = false;
	jjWeapons[WEAPON::ICE].spread = SPREAD::NORMAL;
	
	for (int i = 0; i < 12; i++) {
		jjLayers[i].rotationRadiusMultiplier = 0;
	}
	
	backup.load("IC - Sluggion1.j2t");
}

class FlashBang : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::BULLET);
		jjPLAYER@ creator = jjPlayers[obj.creatorID];
		obj.var[0] = int(atan2(-obj.ySpeed, obj.xSpeed) * (512.f * 0.318309886142228f));
		obj.var[5] = obj.eventID == OBJECT::ICEBULLETPU? 2:1;
		obj.playerHandling = HANDLING::PARTICLE;
		
		switch (obj.state) {
			case STATE::START:
				obj.state = STATE::FLY;
				obj.lightType = LIGHT::POINT;
				obj.var[2] = 0;
			break;
			
			case STATE::FLY:
				if (obj.counter == 1 && creator.isLocal) {
					jjSample(creator.xPos, creator.yPos, SOUND::LABRAT_EYE3, 42, 0);
					jjSample(creator.xPos, creator.yPos, SOUND::COMMON_ITEMTRE, 42, 0);
				}
				if (obj.ySpeed < 8 && obj.xSpeed != 0) obj.ySpeed += 0.25;
			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[1] = obj.var[1] + 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.playerHandling == HANDLING::ENEMY? 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;
				}
			}
			if (gameIsActive()) {
				for (int i = 0; i < 32; i++) {
					jjPLAYER@ player = jjPlayers[i];
					if (
						player.isActive && player.isInGame && player.health > 0 && player !is creator && player.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);
								player.stoned = 90 * obj.var[5];
								if (player.isLocal) blinded[player.localPlayerID] = true;
								obj.var[8] = obj.var[8] | 1 << i;
							}
						}
					}
				}
			}
		}
		
		if (obj.var[1] == 14) {
			obj.var[1] = 0;
			obj.var[2] = 0;
			obj.var[4] = 0;
			obj.delete();
		}
	}
}

void onPlayer(jjPLAYER@ play) {
	if (blinded[play.localPlayerID]) {
		jjPalette.fill(250,250,250, 8, 246, 0.15);
		jjPalette.apply();
		jjTexturedBGUsed = false;
		elapsed++;
		if (elapsed == 20) {
			blinded[play.localPlayerID] = false;
			elapsed = 0;
			backup.apply();
			jjTexturedBGUsed = true;
		}
	}
}