Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
![]() |
Holiday Hare 24![]() |
PurpleJazz | Single player | 10 | ![]() |
#pragma require "HH24.asc"
namespace HH24 {
class Player {
array<int> startingAmmo(10, 0);
array<bool> startingPUs(10, false);
int startingScore = 0;
int startingLives = 0;
int startingFood = 0;
int startingFastfire = 0;
array<int> gemTotals(4);
int gemsCollected, nextHealth, currAmount;
bool restoreGems;
int maxHealth() {
return ((jjMaxHealth+1) - (jjDifficulty < 3? 5:3));
}
int totalCoins = 0;
int lastCoins = 0;
bool restoreCoins;
array<int> capValues = {35,27,21,18,15,13,12,11,10,9,8};
int index = 0;
int lastFastfire = 35;
}
array<Player> localPlayers(jjLocalPlayerCount);
void levelLoad() {
for (int i = 0; i < jjLocalPlayerCount; i++) {
Player@ P = localPlayers[i];
if (jjLocalPlayers[i].lives > 0) {
gem::restorePlayerGems();
coin::restorePlayerCoins();
} else {
jjLocalPlayers[i].lives++;
}
if (jjLocalPlayers[i].currWeapon == WEAPON::GUN9) {
jjLocalPlayers[i].currWeapon = WEAPON::BLASTER;
}
jjLocalPlayers[i].ammo[9] = 0;
jjLocalPlayers[i].powerup[9] = false;
for (int j = 1; j <= 9; j++) {
P.startingAmmo[j] = jjLocalPlayers[i].ammo[j];
P.startingPUs[j] = jjLocalPlayers[i].powerup[j];
}
P.startingScore = jjLocalPlayers[i].score;
P.startingLives = jjLocalPlayers[i].lives;
P.startingFood = jjLocalPlayers[i].food;
P.startingFastfire = jjLocalPlayers[i].fastfire;
}
}
void levelReload() {
for (int i = 0; i < jjLocalPlayerCount; i++) {
gem::restorePlayerGems();
coin::restorePlayerCoins();
jjLocalPlayers[i].lives++;
}
}
void player(jjPLAYER@ play) {
gem::trackPlayerGems(play);
coin::trackPlayerCoins(play);
gem::upgradeHealth(play);
fastfire::setFastfireCap(play);
}
void main() {
gem::deleteCollectedGems();
coin::deleteCollectedCoins();
}
void score(jjPLAYER@ play, jjCANVAS@ canvas, bool coins) {
gem::gemScore(play, canvas);
if (coins) coin::drawCoins(play, canvas);
}
bool cycleOnce = false;
void endLevel() {
if (!cycleOnce) {
gem::saveGemData();
jjNxt(true, false);
cycleOnce = true;
}
}
namespace gem {
// Yes this is for gems but now it's for settings too >:)
int SETTINGS_VERSION = 1;
void loadSettings() {
jjSTREAM settings("HH24settings.asdat");
if (settings.isEmpty())
// settings do not exist
return;
int poppedSettingsVersion;
settings.pop(poppedSettingsVersion);
if (poppedSettingsVersion != SETTINGS_VERSION) {
jjConsole("Failed to load settings! (different versions)");
return;
}
settings.pop(healthUpgradesEnabled);
}
bool draw = true;
bool healthUpgradesEnabled = true;
void upgradeHealth(jjPLAYER@ play) { //onPlayer
if (!healthUpgradesEnabled)
return;
for (int i = 0; i < jjLocalPlayerCount; i++) {
Player@ P = localPlayers[i];
switch (P.maxHealth()) {
case 1: P.currAmount = 250; break;
case 2: P.currAmount = 600; break;
case 3: P.currAmount = 1000; break;
}
if (P.gemsCollected >= P.currAmount && P.nextHealth != P.maxHealth() && P.maxHealth() < 4) {
// the max allowed health in online games is 7 (jj2+ limitation)
if (jjGameConnection != GAME::LOCAL && jjMaxHealth == 7)
return;
jjChat("/smhealth " + (jjMaxHealth + 1));
for (int j = 0; j < 8; ++j) {
jjAlert("");
}
P.nextHealth = jjMaxHealth;
if (jjGameTicks > 7) {
jjSample(play.xPos, play.yPos, SOUND::COMMON_HARP1, 0, 0);
jjAlert("||||By the power of gems, your maximum health is increased!", false, STRING::MEDIUM);
if (P.maxHealth() == 4) jjAlert("|||Congratulations, your health is maximised!", false, STRING::MEDIUM);
}
}
}
}
void trackPlayerGems(jjPLAYER@ play) { //onPlayer
if (!healthUpgradesEnabled)
return;
Player@ P = localPlayers[play.localPlayerID];
if (!P.restoreGems) {
P.gemTotals[0] = play.gems[GEM::RED];
P.gemTotals[1] = play.gems[GEM::GREEN] * 5;
P.gemTotals[2] = play.gems[GEM::BLUE] * 10;
P.gemTotals[3] = play.gems[GEM::PURPLE] * 20;
P.gemsCollected = P.gemTotals[0] + P.gemTotals[1] + P.gemTotals[2] + P.gemTotals[3];
} else {
play.gems[GEM::RED] = jjGameTicks > 1? P.gemTotals[0] : play.lives;
play.gems[GEM::GREEN] = P.gemTotals[1] / 5;
play.gems[GEM::BLUE] = P.gemTotals[2] / 10;
play.gems[GEM::PURPLE] = P.gemTotals[3] / 20;
P.restoreGems = false;
}
}
void restorePlayerGems() { //onLevelLoad and onLevelReload
loadSettings();
if (!healthUpgradesEnabled)
return;
for (int i = 0; i < jjLocalPlayerCount; i++) {
Player@ P = localPlayers[i];
P.restoreGems = true;
}
}
void saveGemData() { //this needs to go in an AS function that also acts as the level exit
if (!healthUpgradesEnabled)
return;
for (int i = 0; i < jjLocalPlayerCount; i++) {
Player@ P = localPlayers[i];
jjLocalPlayers[i].lives = P.gemsCollected;
}
}
void deleteCollectedGems() { //onMain
for (int i = 1; i < jjObjectCount; i++) {
jjOBJ@ obj = jjObjects[i];
int playerID = obj.findNearestPlayer(200000);
jjPLAYER@ play = jjPlayers[playerID];
if (playerID > -1 &&
(obj.eventID == OBJECT::REDGEM ||
obj.eventID == OBJECT::GREENGEM ||
obj.eventID == OBJECT::BLUEGEM ||
obj.eventID == OBJECT::PURPLEGEM ||
obj.eventID == OBJECT::RECTREDGEM ||
obj.eventID == OBJECT::RECTGREENGEM ||
obj.eventID == OBJECT::RECTBLUEGEM)) {
if (obj.creatorType == CREATOR::LEVEL) {
if (
obj.playerHandling == HANDLING::EXPLOSION || // if gem has been collected
(obj.eventID == OBJECT::GEMCRATE && obj.special == 0) // if crate has been opened
) {
jjEventSet(uint(obj.xOrg) >> 5, uint(obj.yOrg) >> 5, 0);
}
} else {
if (obj.creatorID == 0 && obj.state != STATE::FLOATFALL) {
obj.playerHandling = HANDLING::PARTICLE;
obj.delete();
}
}
}
if (obj.eventID == OBJECT::GEMBARREL || obj.eventID == OBJECT::GEMCRATE) {
if (obj.state == STATE::EXPLODE || obj.state == STATE::KILL) jjEventSet(uint(obj.xOrg) >> 5, uint(obj.yOrg) >> 5, 0);
}
if (obj.eventID == OBJECT::GEMRING) {
if (obj.state == STATE::HIT) jjEventSet(uint(obj.xOrg) >> 5, uint(obj.yOrg) >> 5, 0);
}
if (obj.eventID == OBJECT::SUPERGEM) {
if (obj.state == STATE::ACTION) jjEventSet(uint(obj.xOrg) >> 5, uint(obj.yOrg) >> 5, 0);
}
if (obj.eventID == OBJECT::BOMBCRATE || obj.eventID == OBJECT::ONEUPCRATE) {
if (obj.state == STATE::FALL && (obj.var[0] == OBJECT::REDGEM ||
obj.var[0] == OBJECT::GREENGEM ||
obj.var[0] == OBJECT::BLUEGEM ||
obj.var[0] == OBJECT::PURPLEGEM ||
obj.var[0] == OBJECT::RECTREDGEM ||
obj.var[0] == OBJECT::RECTGREENGEM ||
obj.var[0] == OBJECT::RECTBLUEGEM)) {
jjEventSet(uint(obj.xOrg) >> 5, uint(obj.yOrg) >> 5, 0);
}
}
}
}
void gemScore(jjPLAYER@ play, jjCANVAS@ canvas) { //onDrawScore
if (gem::draw && gem::healthUpgradesEnabled) {
canvas.drawSprite(20, jjSubscreenHeight - 40, ANIM::PICKUPS, 22, jjGameTicks>>2, 0, SPRITE::GEM, 0);
canvas.drawString(36, jjSubscreenHeight - 40, "x " + localPlayers[play.localPlayerID].gemsCollected, STRING::MEDIUM, STRING::NORMAL);
if (localPlayers[play.localPlayerID].maxHealth() < 4) {
canvas.drawString(8, jjSubscreenHeight - 12, "|" + localPlayers[play.localPlayerID].currAmount + " |||||for upgrade", STRING::SMALL, STRING::NORMAL);
} else {
canvas.drawString(8, jjSubscreenHeight - 12, "||||Max!", STRING::SMALL, STRING::NORMAL);
}
}
}
}
namespace coin {
bool draw = true;
void trackPlayerCoins(jjPLAYER@ play) { //onPlayer
Player@ P = localPlayers[play.localPlayerID];
if (!P.restoreCoins) {
P.totalCoins = play.coins;
} else {
play.coins = P.totalCoins;
P.restoreCoins = false;
}
if (play.coins > P.lastCoins) {
P.lastCoins = play.coins;
} else if (play.coins < P.lastCoins) {
play.coins = P.lastCoins;
}
}
void restorePlayerCoins() { //onLevelLoad and onLevelReload
for (int i = 0; i < jjLocalPlayerCount; i++) {
Player@ P = localPlayers[i];
P.restoreCoins = true;
}
}
void deleteCollectedCoins() { //onMain
for (int i = 1; i < jjObjectCount; i++) {
jjOBJ@ obj = jjObjects[i];
int playerID = obj.findNearestPlayer(200000);
jjPLAYER@ play = jjPlayers[playerID];
if (playerID > -1 &&
(obj.eventID == OBJECT::SILVERCOIN ||
obj.eventID == OBJECT::GOLDCOIN)) {
if (obj.creatorType == CREATOR::LEVEL) {
if (
obj.playerHandling == HANDLING::EXPLOSION || // if coin has been collected
(obj.eventID == OBJECT::GEMCRATE && obj.special == 0) // if crate has been opened
) {
jjEventSet(uint(obj.xOrg) >> 5, uint(obj.yOrg) >> 5, 0);
}
} else {
if (obj.creatorID == 0 && obj.state != STATE::FLOATFALL && obj.state != STATE::FALL && obj.state != STATE::FLOAT) {
obj.playerHandling = HANDLING::PARTICLE;
obj.delete();
}
}
}
if (obj.eventID == OBJECT::BOMBCRATE || obj.eventID == OBJECT::ONEUPCRATE) {
if (obj.state == STATE::FALL && (obj.var[0] == OBJECT::SILVERCOIN ||
obj.var[0] == OBJECT::GOLDCOIN)) {
jjEventSet(uint(obj.xOrg) >> 5, uint(obj.yOrg) >> 5, 0);
}
}
}
}
void drawCoins(jjPLAYER@ play, jjCANVAS@ canvas) { //onDrawScore
if (coin::draw) {
canvas.drawSprite(20, jjSubscreenHeight-(gem::healthUpgradesEnabled? 68:16), ANIM::PICKUPS, 84, jjGameTicks>>2, 0, SPRITE::NORMAL);
canvas.drawString(36, jjSubscreenHeight-(gem::healthUpgradesEnabled? 68:16), "x " + localPlayers[play.localPlayerID].totalCoins, STRING::MEDIUM, STRING::NORMAL);
}
}
}
namespace fastfire {
void setFastfireCap(jjPLAYER@ play) {
Player@ P = localPlayers[play.localPlayerID];
if (jjGameTicks == 1) {
P.lastFastfire = play.fastfire;
for (uint i = 0; i < P.capValues.length(); i++) {
if (play.fastfire < P.capValues[i]) {
continue;
} else {
P.index = i;
P.lastFastfire = P.capValues[P.index];
break;
}
}
} else {
if (play.fastfire != P.lastFastfire) {
P.lastFastfire = play.fastfire;
if (P.index < 10) P.index++;
}
if (play.fastfire != P.capValues[P.index]) {
play.fastfire = P.capValues[P.index];
P.lastFastfire = play.fastfire;
}
}
}
}
void resetLevel() {
for (int i = 0; i < jjLocalPlayerCount; i++) {
Player@ P = localPlayers[i];
for (int j = 1; j <= 9; j++) {
jjLocalPlayers[j].ammo[j] = P.startingAmmo[j];
jjLocalPlayers[j].powerup[j] = P.startingPUs[j];
}
jjLocalPlayers[i].score = P.startingScore;
jjLocalPlayers[i].lives = P.startingLives;
jjLocalPlayers[i].food = P.startingFood;
jjLocalPlayers[i].fastfire = P.startingFastfire;
}
jjNxt(jjLevelFileName, true, true);
}
}
bool onCheat(string &in cheat) {
if (cheat == "jjnxt" || cheat == "jjnext") {
HH24::gem::saveGemData();
jjNxt(true, true);
} else if (cheat == "jjgems") {
jjLocalPlayers[0].gems[GEM::RED] = jjLocalPlayers[0].gems[GEM::RED] + 100;
} else if (cheat == "jjeasy") {
jjChat("/difficulty easy");
HH24::resetLevel();
} else if (cheat == "jjmedium" || cheat == "jjnormal") {
jjChat("/difficulty medium");
HH24::resetLevel();
} else if (cheat == "jjhard") {
jjChat("/difficulty hard");
HH24::resetLevel();
} else if (cheat == "jjnightmare") {
jjChat("/difficulty turbo");
HH24::resetLevel();
} else if (cheat == "jjrestart") {
HH24::resetLevel();
} else
return false;
jjAlert(cheat, false, STRING::MEDIUM);
return true;
}
bool onDrawLives(jjPLAYER@ play, jjCANVAS@ canvas) { return true; }
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.