Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
Miscellaneous stuff | Violet CLM | Multiple | N/A |
jjTEXTAPPEARANCE CenteredRingText(STRING::NORMAL);
void onLevelLoad() {
jjAnimations[jjObjectPresets[OBJECT::SILVERCOIN].curAnim] = jjAnimations[jjObjectPresets[OBJECT::DONUT].curAnim]; //center bottom HUD
jjObjectPresets[OBJECT::SILVERCOIN].curAnim = jjObjectPresets[OBJECT::DONUT].curAnim;
const array<jjOBJ@> presets = {jjObjectPresets[OBJECT::SILVERCOIN], jjObjectPresets[OBJECT::REDGEM], jjObjectPresets[OBJECT::FLICKERGEM], jjObjectPresets[OBJECT::GREENGEM], jjObjectPresets[OBJECT::BLUEGEM], jjObjectPresets[OBJECT::GOLDCOIN]};
for (int i = presets.length - 1; i >= 0; --i) {
jjOBJ@ preset = presets[i];
if (i >= 0) {
preset.curAnim = presets[0].curAnim;
preset.var[0] = presets[0].var[0]; //don't draw as gem
preset.eventID = presets[0].eventID;
}
preset.behavior = RingAnimation;
}
jjPIXELMAP ring(jjAnimFrames[jjAnimations[jjAnimSets[ANIM::FONT].firstAnim + STRING::MEDIUM].firstFrame + 16]); //middle O
jjANIMFRAME@ targetFrame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::PICKUPS].firstAnim + 25]]; //donut
for (uint x = 0; x < ring.width; ++x)
for (uint y = 0; y < ring.height; ++y)
if (ring[x,y] != 0)
ring[x,y] -= 3*8; //repaint gold
ring.save(targetFrame);
targetFrame.hotSpotX = -targetFrame.width / 2;
targetFrame.hotSpotY = -targetFrame.height / 2;
const array<jjOBJ@> otherPresets = {jjObjectPresets[OBJECT::SUPERGEM], jjObjectPresets[OBJECT::CARROT], jjObjectPresets[OBJECT::FULLENERGY]};
for (int i = otherPresets.length - 1; i >= 0; --i) {
jjOBJ@ preset = otherPresets[i];
preset.behavior = BEHAVIOR::BEES; //can't be drawn
preset.playerHandling = HANDLING::SPECIALDONE; //can't be touched
}
CenteredRingText.align = STRING::CENTER;
}
void onLevelBegin() {
if (jjIsServer) {
if (jjStartHealth != 1 || jjMaxHealth <= 2) {
jjChat("/starthealth 1");
jjChat("/maxhealth 5");
jjChat("/hfk off");
jjChat("/instagib off");
jjChat("/r");
}
} //else for (int i = 0; i < jjLocalPlayerCount; ++i)
//jjLocalPlayers[i].spriteMode = SPRITE::TRANSLUCENTPLAYER; //vulnerable
}
void RingAnimation(jjOBJ@ obj) {
obj.behave((obj.counter == 0) ? BEHAVIOR::PICKUP : BEHAVIOR::FLICKERGEM, false);
if (obj.isActive && (obj.counter == 0 || obj.counter > 210 || jjRenderFrame & 1 == 1))
jjDrawResizedSpriteFromCurFrame(obj.xPos, obj.yPos + ((obj.ySpeed == 0) ? (4 * jjSin(int((jjGameTicks + obj.objectID * 8 + obj.xOrg + obj.yPos * 256) * 16))) : 0), obj.curFrame, obj.direction * jjSin(jjGameTicks * 8 + obj.objectID * 16), 1);
}
bool onDrawHealth(jjPLAYER@ play, jjCANVAS@ screen) {
screen.drawSprite(jjSubscreenWidth - 60, 20, ANIM::FONT, STRING::LARGE, 16, 0, SPRITE::PALSHIFT, 256-3*8);
string health;
if (play.coins == 0) {
if (jjRenderFrame & 15 < 7)
return true;
health = "||000"; //red
} else
health = formatInt(play.coins, "0", 3);
screen.drawString(jjSubscreenWidth - 40, 58, health, STRING::MEDIUM, CenteredRingText, 0, SPRITE::SHADOW);
screen.drawString(jjSubscreenWidth - 43, 55, health, STRING::MEDIUM, CenteredRingText);
return true;
}
array<int> lastRingCount(32, 0);
array<int> totalRingsCollected(32, 0);
uint8 lostRingPlacementCounter = 0;
void onMain() {
if (jjIsServer || jjGameConnection == GAME::LOCAL) {
for (int i = 0; i < 32; ++i) {
jjPLAYER@ play = jjPlayers[i];
if (!play.isInGame)
continue;
if (play.health == 1 && play.coins > 0) {
play.health = jjMaxHealth; //imperviousish to harm
play.lightType = LIGHT::RING2; //as a sort of shield
} else if (play.health > 1 && play.health < jjMaxHealth) { //hurt!
play.health = 1;
play.lightType = LIGHT::PLAYER;
jjSTREAM coinLossInfo;
coinLossInfo.push(i);
coinLossInfo.push(play.xPos);
coinLossInfo.push(play.yPos);
coinLossInfo.push(lostRingPlacementCounter);
int coinsToLose = play.coins;
if (coinsToLose > 15)
coinsToLose = 15; //arbitrary
coinLossInfo.push(coinsToLose);
jjSendPacket(coinLossInfo, 0);
onReceive(coinLossInfo, 0);
} else if (play.coins > lastRingCount[i]) {
totalRingsCollected[i] += (play.coins - lastRingCount[i]);
if (totalRingsCollected[i] >= 100) {
totalRingsCollected[i] -= 100;
if (play.lrsLives > 0) {
jjChat("/setlives " + (i+1) + " " + (play.lrsLives + 1));
} else {
//do what?
}
}
}
lastRingCount[i] = play.coins;
}
}
}
void onReceive(jjSTREAM &in coinLossInfo, int clientID) {
int playerID; coinLossInfo.pop(playerID);
jjPlayers[playerID].coins = 0;
float x, y; coinLossInfo.pop(x); coinLossInfo.pop(y);
coinLossInfo.pop(lostRingPlacementCounter);
int coinsToLose; coinLossInfo.pop(coinsToLose);
for (int i = 0; i < coinsToLose; ++i) {
jjOBJ@ lostRing = jjObjects[jjAddObject(OBJECT::FLICKERGEM, lostRingPlacementCounter++ * 32, 0, 0, CREATOR::LEVEL)];
lostRing.xPos = x; lostRing.yPos = y;
lostRing.ySpeed = -(jjRandom() & 7);
lostRing.xSpeed = (jjRandom() & 15) - 7.5;
if (lostRing.xSpeed < 0) lostRing.direction = -1;
lostRing.playerHandling = HANDLING::DELAYEDPICKUP;
lostRing.var[2] = (jjPlayers[playerID].isLocal) ? 210 : 70; //time until it may be collected
}
}
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.