Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
Treasure Jail | XxMoNsTeRXM | Treasure hunt | 7 |
//Level made by XxMoNsTeR
//Blaster Reloading script from plusComet by PurpleJazz from XLM
//Added new features to the Blaster Reloading script
//Credits go to the creators of the music and tileset
//Requested max score for this Treasure Hunt is [200 GEMS].
bool access = true;
class savedGems {
savedGems() {
red = green = blue = 0;
}
int red;
int green;
int blue;
};
array<int> playerArray(4);
array<savedGems> gemsArray(4);
bool load = false;
void onLevelBegin() {
jjLocalPlayers[0].showText("@@@@@@#Treasure Jail", STRING::LARGE);
}
array<int>fakeHealth(4, 0);
array<bool>forced(4, false);
void onPlayer(jjPLAYER@ p) {
reloadBlaster(p);
if ((p.health == 0 && forced[p.localPlayerID]) || (p.health == 5 && !forced[p.localPlayerID])) {
fakeHealth[p.localPlayerID] = p.health;
}
switch(fakeHealth[p.localPlayerID]) {
case 0:
if (access) {
gemsArray[p.localPlayerID].red = p.gems[GEM::RED];
gemsArray[p.localPlayerID].green = p.gems[GEM::GREEN];
gemsArray[p.localPlayerID].blue = p.gems[GEM::BLUE];
jjAlert("Red gems current: " + p.gems[GEM::RED]);
jjAlert("|Red gems saved: " + gemsArray[p.localPlayerID].red);
jjAlert("Green gems current: " + p.gems[GEM::GREEN]);
jjAlert("|Green gems saved: " + gemsArray[p.localPlayerID].green);
jjAlert("Blue gems current: " + p.gems[GEM::BLUE]);
jjAlert("|Blue gems saved: " + gemsArray[p.localPlayerID].blue);
forced[p.localPlayerID] = false;
access = false;
}
break;
case 5:
p.gems[GEM::RED] = gemsArray[p.localPlayerID].red;
jjAlert("||Red gems loaded: " + p.gems[GEM::RED]);
p.gems[GEM::GREEN] = gemsArray[p.localPlayerID].green;
jjAlert("||Green gems loaded: " + p.gems[GEM::GREEN]);
p.gems[GEM::BLUE] = gemsArray[p.localPlayerID].blue;
jjAlert("||Blue gems loaded: " + p.gems[GEM::BLUE]);
if (!access) access = true;
forced[p.localPlayerID] = true;
fakeHealth[p.localPlayerID] = 4;
break;
}
}
void onLevelLoad() {
jjWeapons[WEAPON::BLASTER].infinite = false;
jjWeapons[WEAPON::BLASTER].maximum = 25;
jjWeapons[WEAPON::TNT].maximum = 8;
jjWeapons[WEAPON::GUN9].maximum = 50;
jjWeapons[WEAPON::SEEKER].maximum = 20;
jjWeapons[WEAPON::RF].maximum = 30;
jjWeapons[WEAPON::GUN8].maximum = 25;
}
array<bool> isBlasterReloading(4, false);
array<bool> canBlasterFire(4, true);
array<bool> keepBlasterPoweredUp(4, false);
array<int> fakeBlasterAmmo(4, 0);
bool pressedOnce;
void reloadBlaster(jjPLAYER@ p) {
if (p.ammo[WEAPON::BLASTER] == 0) {
canBlasterFire[p.localPlayerID] = false;
}
else canBlasterFire[p.localPlayerID] = true;
if (isBlasterReloading[p.localPlayerID] && jjGameTicks % 12 == 0) {
jjSample(p.xPos, p.yPos, SOUND::COMMON_PICKUPW1, 30);
fakeBlasterAmmo[p.localPlayerID]++;
if (fakeBlasterAmmo[p.localPlayerID] == jjWeapons[WEAPON::BLASTER].maximum) {
p.ammo[WEAPON::BLASTER] = fakeBlasterAmmo[p.localPlayerID];
fakeBlasterAmmo[p.localPlayerID] = 0;
isBlasterReloading[p.localPlayerID] = false;
canBlasterFire[p.localPlayerID] = true;
if (p.currWeapon == WEAPON::BLASTER) jjAlert("Finished Reloading!");
else jjAlert("Finished Reloading Blaster!");
}
}
if (p.powerup[WEAPON::BLASTER] == true && p.ammo[WEAPON::BLASTER] > 0) keepBlasterPoweredUp[p.localPlayerID] = true;
if (keepBlasterPoweredUp[p.localPlayerID] == true) p.powerup[WEAPON::BLASTER] = true;
if (p.health == 0) keepBlasterPoweredUp[p.localPlayerID] = false;
}
void onPlayerInput(jjPLAYER@ p) {
if (jjKey[0x52] && !canBlasterFire[p.localPlayerID] && !isBlasterReloading[p.localPlayerID]) {
isBlasterReloading[p.localPlayerID] = true;
if (p.currWeapon == WEAPON::BLASTER) jjAlert("||Reloading...");
else jjAlert("||Reloading Blaster...");
}
if ((p.keyLeft || p.keyRight || p.keyJump) && isBlasterReloading[p.localPlayerID]) {
isBlasterReloading[p.localPlayerID] = false;
canBlasterFire[p.localPlayerID] = true;
p.ammo[WEAPON::BLASTER] = fakeBlasterAmmo[p.localPlayerID];
fakeBlasterAmmo[p.localPlayerID] = 0;
if (p.currWeapon == WEAPON::BLASTER) jjAlert("|Failed Reloading!");
else jjAlert("|Failed Reloading Blaster!");
}
if (p.keyFire && !canBlasterFire[p.localPlayerID] && !pressedOnce) {
pressedOnce = true;
jjSample(p.xPos, p.yPos, SOUND::PINBALL_FLIP4, 50, 20500);
}
pressedOnce = p.keyFire;
}
bool onDrawAmmo(jjPLAYER@ p, jjCANVAS@ canvas) {
if (p.currWeapon == WEAPON::BLASTER && !canBlasterFire[p.localPlayerID]) {
canvas.drawSprite(
jjSubscreenWidth - 88,
jjSubscreenHeight - 14,
ANIM::PICKUPS,
p.charCurr == CHAR::SPAZ?
30 :
29,
0,
0,
SPRITE::PALSHIFT,
p.charCurr == CHAR::SPAZ?
48 :
32
);
canvas.drawString(
jjSubscreenWidth - 80,
jjSubscreenHeight - 14,
"x" + fakeBlasterAmmo[p.localPlayerID],
STRING::MEDIUM,
STRING::DARK
);
canvas.drawString(
jjSubscreenWidth,
jjSubscreenHeight - 468,
"Press R to reload your Blaster",
STRING::MEDIUM,
STRING::RIGHTALIGN
);
return true;
}
else return false;
}
Jazz2Online © 1999-INFINITY (Site Credits). We have a Privacy Policy. Jazz Jackrabbit, Jazz Jackrabbit 2, Jazz Jackrabbit Advance and all related trademarks and media are ™ and © Epic Games. Lori Jackrabbit is © Dean Dodrill. J2O development powered by Loops of Fury and Chemical Beats.
Eat your lima beans, Johnny.