Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
Anniversary Bash 25 CTF | Jazz2Online | Capture the flag | N/A |
const bool MLLESetupSuccessful = MLLE::Setup(); ///@MLLE-Generated
#include "MLLE-Include-1.6.asc" ///@MLLE-Generated
#pragma require "ab25ctf24.j2l" ///@MLLE-Generated
#pragma require "FTURROCK.wav"
#pragma require "EXPSTD3.wav"
#pragma require "redeemer_flight.wav"
#pragma require "wind1.wav"
#pragma require "SHIPHUMS.wav"
#pragma require "xlmskywardeex.j2l"
#pragma require "xlmskywardeex2.j2l"
bool gameIsActive() {
return jjGameState == GAME::STARTED || jjGameState == GAME::OVERTIME;
}
bool CTFMode() {
return (jjGameMode == GAME::CTF && jjGameCustom == GAME::NOCUSTOM) || jjGameCustom == GAME::DCTF;
}
bool otherMode() {
return jjGameMode != GAME::CTF || jjGameCustom == GAME::TB || jjGameCustom == GAME::TLRS || jjGameCustom == GAME::DOM;
}
bool muteAmbientWind() {
return (jjLocalPlayers[0].xPos < 22*32 && jjLocalPlayers[0].yPos < 46*32) || (jjLocalPlayers[0].xPos > 258*32 && jjLocalPlayers[0].yPos < 46*32);
}
bool isWindSound(jjOBJ@ sound) {
return sound.xOrg >= 277*32;
}
bool isShipSound(jjOBJ@ sound) {
return sound.xOrg <= 2*32;
}
bool isDestructibleItem(jjOBJ@ target) {
return target.eventID == OBJECT::TNT || target.eventID == OBJECT::BOUNCERPOWERUP || target.eventID == OBJECT::RFPOWERUP || target.eventID == OBJECT::TOASTERPOWERUP || target.eventID == OBJECT::GUN8POWERUP || target.eventID == OBJECT::LIGHTNINGSHIELD;
}
const array<uint16> invisibleTiles = {
75,
102, 103,
112, 113, 116, 117, 118, 119,
122, 123, 126, 127, 128, 129,
132, 133,
142, 143,
152, 153
};
bool controllingRedeemer, warning = false;
int xPos = 0, yPos = 0, cameraX = 0, cameraY = 0, redeemerAngle = 0, CTFArrowTimer = 0;
uint delay = 0;
bool cameraFrozen = false;
float freezeCameraX = 0;
float freezeCameraY = 0;
bool freezeCameraCentered = false;
void pretendFreezeCamera(float x, float y, bool centered) {
cameraFrozen = true;
freezeCameraX = x;
freezeCameraY = y;
freezeCameraCentered = centered;
}
void pretendUnfreezeCamera() {
cameraFrozen = false;
}
void processFrozenCamera(jjPLAYER@ player) {
if (cameraFrozen)
player.cameraFreeze(freezeCameraX, freezeCameraY, freezeCameraCentered, true);
else
player.cameraUnfreeze();
}
int redeemerColor(jjPLAYER@ creator) {
switch(creator.team) {
case TEAM::BLUE: return 0;
case TEAM::RED: return 1;
case TEAM::GREEN: return 2;
case TEAM::YELLOW: return 3;
}
return 0;
}
uint8 getTeamColor(TEAM::Color team) {
switch (team) {
case TEAM::BLUE: return 32;
case TEAM::RED: return 24;
}
return 32;
}
const array<TEAM::Color> teams = {TEAM::BLUE, TEAM::RED, TEAM::GREEN, TEAM::YELLOW};
const float PI = 3.1415927f;
void onLevelLoad() {
jjSampleLoad(SOUND::P2_POEP, "FTURROCK.wav");
jjSampleLoad(SOUND::P2_PTOEI, "EXPSTD3.wav");
jjSampleLoad(SOUND::P2_SPLOUT, "redeemer_flight.wav");
jjSampleLoad(SOUND::WIND_WIND2A, "wind1.wav");
jjSampleLoad(SOUND::SCIENCE_PLOPKAOS, "SHIPHUMS.wav");
jjAnimSets[ANIM::SONCSHIP].load();
jjAnimSets[ANIM::VINE].load();
jjAnimations[jjAnimSets[ANIM::AMMO] + 59] = jjAnimations[jjAnimSets[ANIM::SONCSHIP] + 0];
jjTexturedBGFadePositionY = 0.01;
jjUseLayer8Speeds = true;
jjObjectPresets[OBJECT::LIGHTNINGSHIELD].behavior =
jjObjectPresets[OBJECT::RFPOWERUP].behavior = OscillatingMonitor();
jjObjectPresets[OBJECT::AMBIENTSOUND].behavior = AmbientSound();
jjObjectPresets[OBJECT::TNT].determineCurFrame();
jjObjectPresets[OBJECT::TNT].behavior = Redeemer();
jjObjectPresets[OBJECT::TNT].xSpeed = jjObjectPresets[OBJECT::BLASTERBULLET].xSpeed * 1.33;
jjObjectPresets[OBJECT::TNT].counterEnd = 255;
jjObjectPresets[OBJECT::TNT].killAnim = jjObjectPresets[OBJECT::SEEKERBULLET].killAnim;
jjObjectPresets[OBJECT::COPTER].determineCurAnim(ANIM::SONCSHIP, 0);
jjObjectPresets[OBJECT::COPTER].determineCurFrame();
jjObjectPresets[OBJECT::COPTER].behavior = RedeemerPickup();
jjObjectPresets[OBJECT::COPTER].scriptedCollisions = true;
jjWeapons[WEAPON::TNT].maximum = 1;
jjWeapons[WEAPON::GUN8].comesFromGunCrates = true;
jjLayerXOffset[6] = 128;
array<jjLAYER@> extraLayers = jjLayersFromLevel("xlmskywardeex.j2l", array<uint> = {1,2,3,5,6,7}, 0);
array<jjLAYER@> extraLayers2 = jjLayersFromLevel("xlmskywardeex2.j2l", array<uint> = {1,2,3,4,5,6,7}, 0);
jjLayerOrderSet(array<jjLAYER@> = {extraLayers[0], extraLayers[1], extraLayers2[4], extraLayers2[5], extraLayers2[6], jjLayers[3], jjLayers[1], jjLayers[4], extraLayers2[0], extraLayers2[1], extraLayers2[2], extraLayers2[3], jjLayers[2], jjLayers[5], extraLayers[2], jjLayers[6], jjLayers[7], extraLayers[3], extraLayers[4], extraLayers[5], jjLayers[8]});
extraLayers[1].spriteMode = SPRITE::TRANSLUCENTCOLOR;
extraLayers[1].spriteParam = 86;
extraLayers[2].xOffset = 100;
extraLayers[2].yOffset = 360;
extraLayers[3].xOffset = 80;
extraLayers[3].yOffset = 120;
extraLayers[4].xOffset = 160;
extraLayers[4].yOffset = 140;
extraLayers[5].xOffset = 320;
extraLayers[5].yOffset = 160;
extraLayers2[4].xOffset = 200;
extraLayers2[4].yOffset = -1700;
extraLayers2[5].xOffset = 300;
extraLayers2[5].yOffset = -1600;
extraLayers2[6].xOffset = 400;
extraLayers2[6].yOffset = -1500;
for (uint16 i = 0; i < invisibleTiles.length(); i++) {
jjTileType[invisibleTiles[i]] = 3; //invisible
}
jjTileType[1176] = 5;
generateColoredRedeemerSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {32, 24, 16, 40});
generateRedeemerPickupSprite(jjAnimSets[ANIM::CUSTOM[1]], array<uint> = {0});
}
void onLevelReload() {
MLLE::Palette.apply();
}
jjANIMSET@ coloredRedeemerSprite;
bool generateColoredRedeemerSprites(jjANIMSET@ anim, const array<uint> &in colors) {
int length = colors.length();
bool success = (@coloredRedeemerSprite = anim).allocate(array<uint>(length * 4, 8)) !is null;
if (success) {
uint srcSet = jjAnimSets[ANIM::SONCSHIP];
for (int i = 0; i < length; i++) {
uint color = colors[i];
uint destAnimOffset = anim + i;
for (int j = 0; j < 4; j++) {
uint srcAnim = jjAnimations[srcSet + 0];
uint destAnim = jjAnimations[destAnimOffset + j];
for (int k = 0; k < 8; k++) {
jjPIXELMAP image(jjAnimFrames[destAnim + k] = jjAnimFrames[srcAnim + k]);
int width = image.width;
int height = image.height;
for (int l = 0; l < height; l++) {
for (int m = 0; m < width; m++) {
int pixel = image[m, l];
if (pixel >= 88 && pixel < 96)
image[m, l] = color + (pixel & 7);
}
}
if (!image.save(jjAnimFrames[destAnim + k]))
return false;
}
}
}
}
return success;
}
jjANIMSET@ redeemerPickupSprite;
bool generateRedeemerPickupSprite(jjANIMSET@ anim, const array<uint> &in colors) {
int length = colors.length();
bool success = (@redeemerPickupSprite = anim).allocate(array<uint>(length, 8)) !is null;
if (success) {
uint srcSet = jjAnimSets[ANIM::SONCSHIP];
for (int i = 0; i < length; i++) {
uint color = colors[i];
uint destAnimOffset = anim + i;
uint srcAnim = jjAnimations[srcSet + 0];
uint destAnim = jjAnimations[destAnimOffset + 0];
for (int k = 0; k < 8; k++) {
jjPIXELMAP image(jjAnimFrames[destAnim + k] = jjAnimFrames[srcAnim + k]);
int width = image.width;
int height = image.height;
for (int l = 0; l < height; l++) {
for (int m = 0; m < width; m++) {
int pixel = image[m, l];
if (pixel >= 40 && pixel < 48)
image[m, l] = color;
}
}
if (!image.save(jjAnimFrames[destAnim + k]))
return false;
}
}
}
return success;
}
class OscillatingMonitor : jjBEHAVIORINTERFACE {
void onBehave(jjOBJ@ obj) {
obj.behave(BEHAVIOR::MONITOR);
obj.xPos = obj.xOrg - 4;
obj.yPos = (obj.yOrg + 2) - jjLayerYOffset[2];
obj.direction = -1;
}
}
class AmbientSound : jjBEHAVIORINTERFACE {
void onBehave(jjOBJ@ sound) {
sound.behave(jjLowDetail && jjGameTicks >= 2? BEHAVIOR::INACTIVE : BEHAVIOR::AMBIENTSOUND, false);
if (jjLocalPlayers[0].health > 0) delay++;
else delay = 0;
if (jjTriggers[19] && isWindSound(sound) && delay >= 35) {
loopSound(sound);
}
if (!jjTriggers[19] && isShipSound(sound) && delay >= 35) {
loopSound(sound);
}
if ((muteAmbientWind() && isWindSound(sound)) || jjLocalPlayers[0].health == 0) {
jjTriggers[19] = false;
sound.xPos = sound.xOrg;
sound.yPos = sound.yOrg;
}
}
}
void loopSound(jjOBJ@ sound) {
sound.xPos = jjLocalPlayers[0].xPos;
sound.yPos = jjLocalPlayers[0].yPos;
}
class Redeemer : jjBEHAVIORINTERFACE {
void onBehave(jjOBJ@ obj) {
//var[0] - angle
//var[1] - angular speed
//var[2] - has the redeemer exploded
//special - value of jjGameTicks at the time the last packet was sent/received
int angle;
float speed = jjObjectPresets[OBJECT::TNT].xSpeed;
if (obj.creatorType != CREATOR::PLAYER)
obj.delete();
jjPLAYER@ creator = jjPlayers[obj.creatorID];
switch (obj.state) {
case STATE::START:
obj.curAnim = jjObjectPresets[obj.eventID].curAnim;
jjSamplePriority(SOUND::P2_POEP);
obj.var[0] = int(atan2(-obj.ySpeed, obj.xSpeed) * (512.f * 0.318309886142228f));
obj.ySpeed = speed * -jjSin(obj.var[0]);
obj.xSpeed = speed * jjCos(obj.var[0]);
obj.direction = obj.xSpeed < 0.f ? -1 : 1;
obj.var[2] = 0;
if (creator.isLocal) controllingRedeemer = true;
obj.state = STATE::FLY;
break;
case STATE::FLY:
redeemerCamera(creator, obj);
jjDrawRotatedSprite(obj.xPos, obj.yPos, (creator.isLocal || jjGameMode != GAME::CTF)? ANIM::SONCSHIP : ANIM::CUSTOM[0], (creator.isLocal || jjGameMode != GAME::CTF)? 0 : redeemerColor(creator), obj.curFrame, obj.var[0], 2, 2, SPRITE::NORMAL);
if (creator.isLocal) {
redeemerAngle = obj.var[0];
if (!jjLowDetail && (obj.counter % 131 == 36 || obj.counter == 1) && controllingRedeemer) jjSamplePriority(SOUND::P2_SPLOUT);
float dx = creator.xPos - obj.xPos, dy = creator.yPos - obj.yPos;
if (dx * dx + dy * dy < 420 * 420) warning = true;
else warning = false;
if (creator.health == 0) {
pretendUnfreezeCamera();
controllingRedeemer = false;
} else {
if (controllingRedeemer) {
creator.xSpeed = 0;
if (creator.keyRight && !jjMaskedPixel(int(creator.xPos-16), int(creator.yPos))) creator.xPos -= 0.368f;
if (creator.keyLeft && !jjMaskedPixel(int(creator.xPos+16), int(creator.yPos))) creator.xPos += 0.368f;
}
if (obj.counter >= 21) {
if (controllingRedeemer) {
if (creator.keyRight || (obj.direction < 0 ? creator.keyUp : creator.keyDown))
obj.var[1] = -16;
else if (creator.keyLeft || (obj.direction < 0 ? creator.keyDown : creator.keyUp))
obj.var[1] = 16;
else
obj.var[1] = 0;
}
else obj.var[1] = 0;
}
if (obj.counter >= 127)
obj.counter = 35;
else if (obj.counter >= 35 && creator.keyFire && controllingRedeemer)
obj.state = STATE::EXPLODE;
}
xPos = int(obj.xPos);
yPos = int(obj.yPos);
}
if (obj.yPos >= jjLayerHeight[4]*32 || obj.yPos <= 0 || obj.xPos <= 0 || obj.xPos >= jjLayerWidth[4]*32) obj.state = STATE::EXPLODE;
obj.var[0] = obj.var[0] + obj.var[1];
obj.ySpeed = speed * -jjSin(obj.var[0]);
obj.xSpeed = speed * jjCos(obj.var[0]);
if (obj.counter % 3 == 0 && !jjLowDetail) spawnFireTrail(obj);
break;
case STATE::EXPLODE:
if (obj.var[2] == 0) {
RedeemerExplosion temp;
jjOBJ@ explosion = jjObjects[jjAddObject(OBJECT::BULLET, obj.xPos, obj.yPos, obj.creatorID, CREATOR::PLAYER, jjVOIDFUNCOBJ(temp.onBehave))];
jjSamplePriority(SOUND::P2_PTOEI);
obj.var[2] = 1;
explosion.var[2] = 1;
} else {
jjDrawResizedSprite(obj.xPos, obj.yPos, ANIM::AMMO, 5, obj.curFrame + 5, 8, 8, SPRITE::NORMAL, 0, 3, 3);
}
pretendUnfreezeCamera();
if (creator.isLocal) controllingRedeemer = false;
break;
}
int previousState = obj.state;
obj.behave(BEHAVIOR::BULLET, false);
if (!creator.isLocal) {
if (obj.special + 128 > jjGameTicks)
obj.state = previousState;
} else if (obj.special + 4 <= jjGameTicks) {
jjSTREAM packet;
packet.push(int8(obj.creatorID));
packet.push(obj.state == STATE::EXPLODE);
packet.push(obj.xPos);
packet.push(obj.yPos);
if (obj.state != STATE::EXPLODE) {
packet.push(int16(obj.var[0]));
packet.push(int16(obj.var[1]));
}
jjSendPacket(packet);
obj.special = jjGameTicks;
}
}
}
void spawnFireTrail(jjOBJ@ obj) {
jjOBJ@ trail = jjObjects[jjAddObject(OBJECT::EXPLOSION, int(obj.xPos - jjCos(obj.var[0])), int(obj.yPos - jjSin(obj.var[0])))];
trail.determineCurAnim(ANIM::AMMO, 3);
trail.lightType = LIGHT::POINT;
trail.playerHandling = HANDLING::PARTICLE;
trail.bulletHandling = HANDLING::IGNOREBULLET;
trail.isBlastable = false;
}
void redeemerCamera(jjPLAYER@ creator, jjOBJ@ obj) {
float dx = jjLayerWidth[4] - obj.xPos, dy = jjLayerHeight[4] - obj.yPos;
if (jjLayerWidth[4] - dx <= 400) cameraX = 400;
else cameraX = int(obj.xPos);
if (jjLayerHeight[4] - dy <= 400) cameraY = 400;
else cameraY = int(obj.yPos);
if (controllingRedeemer && creator.isLocal) {
pretendFreezeCamera(int(obj.xPos) >= 8528? 8528 : cameraX, int(obj.yPos) >= 4080? 4080 : cameraY, true);
for (int i = 0; i < 32; i++) {
jjPLAYER@ play = jjPlayers[i];
float reticleScale = jjSin(jjGameTicks*5);
float reticleColor = jjSin(jjGameTicks*10)*2;
float pdx = play.xPos - obj.xPos, pdy = play.yPos - obj.yPos;
if ((pdx * pdx + pdy * pdy < 320 * 320) && (jjGameMode != GAME::CTF || jjFriendlyFire || play.team != creator.team) && !play.isLocal)
jjDrawResizedSprite(play.xPos, play.yPos, ANIM::SONCSHIP, 7, 0, reticleScale + 2, reticleScale + 2, SPRITE::SINGLECOLOR, int(reticleColor + 18), 1);
}
}
}
class RedeemerPickup : jjBEHAVIORINTERFACE {
float getY(const ::jjOBJ@ obj) const {
int arg = (((obj.objectID << 3) + ::jjGameTicks) << (obj.yPos > ::jjWaterLevel ? 1 : 4)) + (int(obj.xPos) << 4);
return obj.yPos + ::jjSin(arg) * 4.f;
}
void onBehave(jjOBJ@ obj) {
obj.behave(BEHAVIOR::PICKUP, false);
obj.direction = obj.xPos > 4464? -1:1;
jjDrawResizedSprite(int(obj.xPos) - (6 * obj.direction), getY(obj), ANIM::CUSTOM[1], 0, obj.curFrame, 2 * obj.direction, 2, ((obj.xPos < 4464 && jjLocalPlayers[0].team == TEAM::BLUE) || (obj.xPos > 4464 && jjLocalPlayers[0].team == TEAM::RED))? SPRITE::NORMAL : SPRITE::NORMAL);
}
bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ play, int force) {
if (play.ammo[WEAPON::TNT] < jjWeapons[WEAPON::TNT].maximum) {
if (play.isLocal) {
play.ammo[WEAPON::TNT] = play.ammo[WEAPON::TNT] + 1;
play.currWeapon = WEAPON::TNT;
jjSample(obj.xPos, obj.yPos, SOUND::COMMON_LOADSPAZ, 0, 0);
if (play.charCurr == CHAR::JAZZ) {
jjSample(play.xPos, play.yPos, SOUND::JAZZSOUNDS_JUMMY, 0, 0);
}
if (play.charCurr == CHAR::SPAZ) {
jjSample(play.xPos, play.yPos, SOUND::SPAZSOUNDS_HAPPY, 0, 0);
}
if (play.charCurr == CHAR::LORI) {
jjSample(play.xPos, play.yPos, SOUND::LORISOUNDS_WEHOO, 0, 0);
}
}
obj.behavior = BEHAVIOR::EXPLOSION2;
obj.scriptedCollisions = false;
obj.frameID = 0;
}
return true;
}
}
class RedeemerExplosion : jjBEHAVIORINTERFACE {
void onBehave(jjOBJ@ obj) {
//var[0] - obj.counter
//var[2] - has the redeemer exploded
//var[4] - blast radius
//var[5] - damage
//var[8] - has the player been hit by the explosion
obj.playerHandling = HANDLING::PARTICLE;
obj.bulletHandling = HANDLING::IGNOREBULLET;
obj.lightType = obj.var[2] == 1? LIGHT::RING2 : LIGHT::NONE;
jjPLAYER@ creator = jjPlayers[obj.creatorID];
jjPLAYER@ play = jjLocalPlayers[0];
if (obj.var[2] == 1) {
obj.var[0] = obj.var[0] + 1;
obj.light += 2;
obj.var[4] = obj.light * 5;
if (obj.var[4] >= 460) obj.var[5] = 1;
else if (obj.var[4] >= 360 && obj.var[4] < 460) obj.var[5] = 2;
else if (obj.var[4] < 360) obj.var[5] = 7;
for (int i = 1; i < jjObjectCount; i++) {
jjOBJ@ target = jjObjects[i];
float dx = target.xPos - obj.xPos, dy = target.yPos - obj.yPos;
if (isDestructibleItem(target) && target.var[4] == 0 && creator.isLocal) {
if (dx * dx + dy * dy < obj.var[4] * obj.var[4]) {
if (target.eventID != OBJECT::TNT) creator.objectHit(target, -1, HANDLING::SPECIAL);
else target.state = STATE::EXPLODE;
target.var[4] = 1;
if (target.eventID == OBJECT::WATERSHIELD) play.shieldTime = 40*70;
}
else target.var[4] = 0;
}
else if (target.behavior == BEHAVIOR::PICKUP && target.state == STATE::FLOAT) {
if (dx * dx + dy * dy < obj.var[4] * obj.var[4])
target.state = STATE::FLOATFALL;
}
}
float pdx = play.xPos - obj.xPos, pdy = play.yPos - obj.yPos;
if (pdx * pdx + pdy * pdy < 1600 * 1600) {
uint random = jjRandom();
int magnitude = (2 << (random & 3)) - 1;
int halfMagnitude = magnitude >> 1;
if ((jjGameTicks & 1 == 0 && !jjTriggers[19]) || (jjGameTicks & 1 == 0 && jjTriggers[19] && jjMaskedHLine(int(play.xPos) - 12, 24, int(play.yPos) + 21)) && !controllingRedeemer)
pretendFreezeCamera(play.cameraX + (random & magnitude) - halfMagnitude, play.cameraY + (random >> 8 & magnitude) - halfMagnitude, false);
else
pretendUnfreezeCamera();
}
}
if (jjIsServer && gameIsActive()) {
for (int i = 0; i < 32; i++) {
jjPLAYER@ player = jjPlayers[i];
if (
player.isActive && player.isInGame && player.health > 0 && gameIsActive()
&& ((jjGameMode != GAME::CTF && jjGameCustom != GAME::PEST && jjGameCustom != GAME::RT) || jjFriendlyFire || player.team != creator.team || player is creator)
) {
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], true, creator);
obj.var[8] = obj.var[8] | 1 << i;
}
}
}
}
}
if (obj.var[0] == 1) {
jjSample(obj.xPos, obj.yPos, SOUND::BILSBOSS_FIRE, 0, 0);
for (int i = -8; i <= 8; i+=8) {
for (int j = -8; j <= 8; j+=8) {
if (i != 0 || j != 0) {
Fireworks temp;
int id = jjAddObject(OBJECT::ELECTROBULLET, obj.xPos, obj.yPos, obj.creatorID, CREATOR::PLAYER, jjVOIDFUNCOBJ(temp.onBehave));
if (id != 0) {
jjOBJ@ flares = jjObjects[id];
flares.xSpeed = j*2;
flares.ySpeed = i*2;
}
}
}
}
}
else if (obj.var[0] == 70) {
obj.var[0] = 0;
obj.var[2] = 0;
obj.var[4] = 0;
if (!controllingRedeemer) pretendUnfreezeCamera();
obj.delete();
}
}
}
class Fireworks : jjBEHAVIORINTERFACE {
void onBehave(jjOBJ@ obj) {
obj.behave(BEHAVIOR::ELECTROBULLET, false);
obj.counterEnd = 210;
if (obj.ySpeed < 10 && obj.xSpeed != 0) obj.ySpeed += 0.5;
obj.playerHandling = HANDLING::PARTICLE;
obj.bulletHandling = HANDLING::IGNOREBULLET;
if (obj.state == STATE::FLY) obj.particlePixelExplosion(1);
}
}
void onReceive(jjSTREAM &in packet, int clientID) {
int8 playerID;
bool explosion;
float xPos, yPos;
int16 angle, angleSpeed;
jjSTREAM packetBackup;
if (jjIsServer)
packetBackup = packet;
if (packet.pop(playerID) && playerID >= 0 && playerID < 32 &&
packet.pop(explosion) && packet.pop(xPos) && packet.pop(yPos) &&
(explosion || packet.pop(angle) && packet.pop(angleSpeed))
) {
const jjPLAYER@ player = jjPlayers[playerID];
if (!jjIsServer || player.isActive && player.isInGame && player.clientID == clientID ) {
jjOBJ@ redeemer;
for (int i = 0; i < jjObjectCount; i++) {
jjOBJ@ obj = jjObjects[i];
if (obj.isActive && obj.eventID == OBJECT::TNT && obj.creatorType == CREATOR::PLAYER && obj.creatorID == uint(playerID)) {
@redeemer = obj;
break;
}
}
if (redeemer is null && jjGameTicks < 140) {
int id = jjAddObject(OBJECT::TNT, xPos, yPos, playerID, CREATOR::PLAYER);
if (id > 0)
@redeemer = jjObjects[id];
}
if (redeemer !is null) {
if (jjIsServer)
jjSendPacket(packetBackup, -clientID);
if (explosion)
redeemer.state = STATE::EXPLODE;
redeemer.xPos = xPos;
redeemer.yPos = yPos;
redeemer.var[0] = angle;
redeemer.var[1] = angleSpeed;
redeemer.special = jjGameTicks;
}
}
}
}
void onPlayer(jjPLAYER@ play) {
processFrozenCamera(play);
if (play.shieldTime > 15*70) play.shieldTime = 15*70;
play.lightType = LIGHT::NONE;
jjEnforceLighting = LIGHT::COMPLETE;
if (controllingRedeemer) play.currWeapon = WEAPON::BLASTER;
if (play.fly == FLIGHT::AIRBOARD && play.timerState == TIMER::STOPPED) play.timerStart(20*70);
if (play.fly == FLIGHT::NONE) play.timerStop();
if (play.timerState == TIMER::STARTED && play.timerTime <= 3*70 && play.timerTime > 0 && play.timerTime % 70 == 0) jjSamplePriority(SOUND::COMMON_NOCOIN);
}
void onPlayerTimerEnd(jjPLAYER@ play) { play.fly = FLIGHT::NONE; }
void onMain() {
if (!jjLowDetail) {
jjLayerYOffset[1] = jjCos(jjGameTicks*8)*4;
jjLayerYOffset[2] = jjCos(jjGameTicks*8)*4;
} else {
jjLayerYOffset[1] =
jjLayerYOffset[2] = 0;
}
array<jjLAYER@> layers = jjLayerOrderGet();
layers[0].hasTiles = layers[1].hasTiles = controllingRedeemer;
layers[8].xOffset = jjSin(jjGameTicks*48)*8;
layers[9].xOffset = -jjSin(jjGameTicks*48)*8;
layers[10].yOffset = jjCos(jjGameTicks*48)*8;
layers[11].yOffset = -jjCos(jjGameTicks*48)*8;
if (controllingRedeemer && CTFMode()) {
if (CTFArrowTimer > jjGameTicks + 280) CTFArrowTimer = jjGameTicks;
if (CTFArrowTimer < jjGameTicks) {
if (CTFArrowTimer + 64 >= jjGameTicks) {
for (int i = 0; i < 32; i++) {
jjPLAYER@ target = jjPlayers[i];
if (target.flag != 0 && target.team != jjLocalPlayers[0].team) {
int angle = int(atan2(target.yPos - yPos, target.xPos - xPos) * (512 / PI));
const float scale = 64.f / (112.f - jjSin((jjGameTicks - CTFArrowTimer) << 3) * 64.f);
jjDrawRotatedSprite(xPos + 32 * jjCos(angle), yPos + 32 * jjSin(angle), ANIM::FLAG, 0, 0, 970 - angle, scale, scale, SPRITE::PALSHIFT, getTeamColor(target.team) - 32, 1);
}
}
} else {
CTFArrowTimer = jjGameTicks + 210;
}
}
}
}
bool onDrawPlayerTimer(jjPLAYER@ play, jjCANVAS@ canvas) {
if (play.fly == FLIGHT::AIRBOARD) {
canvas.drawString(
jjSubscreenWidth - 75,
jjSubscreenHeight - 284,
"" + (play.timerTime > 0? (play.timerTime + 70) / 70 : 0),
STRING::LARGE,
STRING::PALSHIFT,
play.timerTime > 3*70?
24 :
jjGameTicks % 28 > 14?
-40 :
-24
);
canvas.drawSprite(
jjSubscreenWidth - 92,
jjSubscreenHeight - 280,
ANIM::PICKUPS,
36,
jjGameTicks / 6 % 8
);
}
return true;
}
bool onDrawAmmo(jjPLAYER@ play, jjCANVAS@ canvas) {
if (controllingRedeemer) {
canvas.drawString(
jjSubscreenWidth - 480,
jjSubscreenHeight - 450,
"Redeemer!",
STRING::MEDIUM,
STRING::NORMAL
);
//canvas.drawString(
//jjSubscreenWidth - 496,
//jjSubscreenHeight - 422,
//"Redeemer pos " + int(xPos / 32) + "," + int(yPos / 32),
//STRING::SMALL,
//STRING::NORMAL
//);
canvas.drawString(
jjSubscreenWidth - 624,
jjSubscreenHeight - 406,
"|Use the |||movement keys |||||to rotate the missile",
STRING::SMALL,
STRING::NORMAL
);
canvas.drawString(
jjSubscreenWidth - 625,
jjSubscreenHeight - 390,
"|Press |||FIRE |||||to detonate the missile in mid-air",
STRING::SMALL,
STRING::NORMAL
);
canvas.drawRectangle(
jjSubscreenWidth - 750,
jjSubscreenHeight - 240,
140,
140,
87,
SPRITE::TRANSLUCENT
);
canvas.drawString(
jjSubscreenWidth - 708,
jjSubscreenHeight - 108,
"Radar",
STRING::SMALL,
STRING::PALSHIFT,
16
);
canvas.drawRotatedSprite(
jjSubscreenWidth - 680,
jjSubscreenHeight - 170,
ANIM::CUSTOM[1],
0,
jjGameTicks >> 2,
redeemerAngle,
1,
1,
SPRITE::SINGLEHUE,
80
);
for (int i = 0; i < 32; i++) {
jjPLAYER@ player = jjPlayers[i];
uint8 teamColor;
switch (player.team) {
case TEAM::BLUE: teamColor = 34; break;
case TEAM::RED: teamColor = 24; break;
case TEAM::GREEN: teamColor = 18; break;
case TEAM::YELLOW: teamColor = 40; break;
default: teamColor = 24; break;
}
int radarOffsetX = int(xPos - player.xPos) / 35;
int radarOffsetY = int(yPos - player.yPos) / 35;
if (radarOffsetX < 70 && radarOffsetX > -63 && radarOffsetY < 70 && radarOffsetY > -63 && player.xPos > 0 && player.yPos > 0 && !play.isSpectating && !play.isOut && !play.isConnecting) {
if (player.flag != 0 && !player.isLocal) {
canvas.drawResizedSprite(
((jjSubscreenWidth - 678) - radarOffsetX),
((jjSubscreenHeight - 168) - radarOffsetY),
ANIM::FLAG,
3,
jjGameTicks >> 2,
radarOffsetX > 0? 0.4:-0.4,
0.4,
SPRITE::SINGLECOLOR,
player.team == TEAM::BLUE? 24 : 34
);
canvas.drawRectangle(
((jjSubscreenWidth - 680) - radarOffsetX),
((jjSubscreenHeight - 170) - radarOffsetY),
6,
6,
teamColor,
SPRITE::NORMAL
);
}
else if (player.flag == 0) {
canvas.drawRectangle(
((jjSubscreenWidth - 680) - radarOffsetX),
((jjSubscreenHeight - 170) - radarOffsetY),
player.isLocal? 8:6,
player.isLocal? 8:6,
player.isLocal? 64 : jjGameMode == GAME::CTF? teamColor : 24,
SPRITE::NORMAL
);
}
}
for (int j = 1; j < jjObjectCount; j++) {
if (jjObjects[j].eventID == OBJECT::TNT) {
uint8 redeemerColor;
switch (jjPlayers[jjObjects[j].creatorID].team) {
case TEAM::BLUE: redeemerColor = 34; break;
case TEAM::RED: redeemerColor = 24; break;
case TEAM::GREEN: redeemerColor = 18; break;
case TEAM::YELLOW: redeemerColor = 40; break;
default: redeemerColor = 88; break;
}
int radarMissileOffsetX = int(xPos - jjObjects[j].xPos) / 35;
int radarMissileOffsetY = int(yPos - jjObjects[j].yPos) / 35;
if (!jjPlayers[jjObjects[j].creatorID].isLocal && radarMissileOffsetX < 70 && radarMissileOffsetX > -63 && radarMissileOffsetY < 70 && radarMissileOffsetY > -63) {
canvas.drawRotatedSprite(
((jjSubscreenWidth - 680) - radarMissileOffsetX),
((jjSubscreenHeight - 170) - radarMissileOffsetY),
ANIM::CUSTOM[1],
0,
jjGameTicks >> 2,
jjObjects[j].var[0],
0.5,
0.5,
SPRITE::SINGLECOLOR,
jjGameMode == GAME::CTF? redeemerColor : 90
);
}
}
}
}
if (warning) {
canvas.drawString(
jjSubscreenWidth - 550,
jjSubscreenHeight - 374,
"||WARNING: YOU ARE IN RANGE!",
STRING::SMALL,
STRING::NORMAL
);
}
if (!jjLowDetail && jjGameTicks % 140 >= 7) {
canvas.drawString(
jjSubscreenWidth - 132,
jjSubscreenHeight - 46,
"REC",
STRING::MEDIUM,
STRING::NORMAL
);
canvas.drawSprite(
jjSubscreenWidth - 146,
jjSubscreenHeight - 45,
ANIM::VINE,
0,
0,
0,
SPRITE::NORMAL
);
}
}
else if (!controllingRedeemer && play.currWeapon == WEAPON::TNT) {
canvas.drawString(
jjSubscreenWidth - 80,
jjSubscreenHeight - 14,
"x" + play.ammo[WEAPON::TNT],
STRING::MEDIUM,
STRING::NORMAL
);
canvas.drawResizedSprite(
jjSubscreenWidth - 110,
jjSubscreenHeight - 14,
ANIM::CUSTOM[1],
0,
jjGameTicks >> 2,
2,
2,
SPRITE::NORMAL
);
}
return controllingRedeemer || play.currWeapon == WEAPON::TNT;
}
void onFunction0(jjPLAYER@ play) {
play.showText("@@@@Skyward Showdown@Created by PurpleJazz of XLM (2009-2017)@Tileset by BlurredD@np: Darkhalo - Shattered Energy [6:35]");
}
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.