| Name | Author | Game Mode | Rating | |||||
|---|---|---|---|---|---|---|---|---|
| Port Royal | Superjazz | Battle | N/A | |||||
const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, null, se::FireworkMLLEWrapper(), null, null, null, null, null, null}); ///@MLLE-Generated
#include "MLLE-Include-1.8w.asc" ///@MLLE-Generated
#pragma require "xlmportroyal-MLLE-Data-2.j2l" ///@MLLE-Generated
#pragma require "xlmportroyal-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "Castle1.j2t" ///@MLLE-Generated
#pragma require "Medivo.j2t" ///@MLLE-Generated
#pragma require "WSF01.j2t" ///@MLLE-Generated
#pragma require "beachfreeport.j2t" ///@MLLE-Generated
#pragma require "Oasis.j2t" ///@MLLE-Generated
#pragma require "Islands.j2t" ///@MLLE-Generated
#pragma require "Chateau.j2t" ///@MLLE-Generated
#pragma require "xlmportroyal.j2l" ///@MLLE-Generated
#include "SEfirework-mlle.asc" ///@MLLE-Generated
#pragma require "SEfirework-mlle.asc" ///@MLLE-Generated
enum PACKET_TYPE { PACKET_CANNON_FIRE };
const int CANNON_FIRE_ANIMATION_FRAME_RATE = 4;
const int CANNON_FIRE_ANIMATION_OFFSET_X = 16;
const int CANNON_FIRE_ANIMATION_OFFSET_Y = 8;
const int CANNON_FIRE_DELAY = 3; // To let jjTileSet do its job first
const int CANNON_FIRE_SOUND_MAX_VOLUME = 63;
const int CANNON_FIRE_SOUND_ORIGIN_X_LEFT = 24 << TILE_SHIFT;
const int CANNON_FIRE_SOUND_ORIGIN_X_RIGHT = 113 << TILE_SHIFT;
const int CANNON_FIRE_X_LEFT = 25;
const int CANNON_FIRE_X_RIGHT = 112;
const int CANNON_FIRE_Y_LEFT = 17;
const int CANNON_FIRE_Y_RIGHT = 31;
const int TILE_SHIFT = 5;
const SOUND::Sample CANNON_FIRE_SOUND_SAMPLE = SOUND::COMMON_BENZIN1;
// Screw special handling for splitscreeners...
const jjPLAYER@ localPlayer = jjLocalPlayers[0];
bool isCannonFireAnimationDisplayedLeft = false;
bool isCannonFireAnimationDisplayedRight = false;
bool isCannonFireDelayedLeft = false;
bool isCannonFireDelayedRight = false;
int cannonFireDelayElapsedLeft = CANNON_FIRE_DELAY;
int cannonFireDelayElapsedRight = CANNON_FIRE_DELAY;
uint8 cannonFireAnimFrameLeft = 0;
uint8 cannonFireAnimFrameRight = 0;
jjANIMSET@ customSpringSprite;
array<int> fastCustomSpringSpeeds(jjLocalPlayerCount);
class CannotBeShotDown : jjBEHAVIORINTERFACE {
CannotBeShotDown(const jjBEHAVIOR &in behavior) {
originalBehavior = behavior;
}
void onBehave(jjOBJ@ obj) {
obj.behave(originalBehavior);
if (obj.state == STATE::FLOATFALL)
obj.state = STATE::FLOAT;
}
bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
if (bullet is null) {
obj.behavior = originalBehavior;
if (player.objectHit(obj, force, obj.playerHandling))
return true;
obj.behavior = this;
}
return false;
}
private jjBEHAVIOR originalBehavior;
}
bool generateCustomSpringSprites(jjANIMSET@ anim, const array<uint> &in colors) {
int length = colors.length();
bool success = (@customSpringSprite = anim).allocate(array<uint>(length * 3, 5)) !is null;
if (success) {
uint srcSet = jjAnimSets[ANIM::SPRING];
for (int i = 0; i < length; i++) {
uint color = colors[i];
uint destAnimOffset = anim + i * 3;
for (int j = 0; j < 3; j++) {
uint srcAnim = jjAnimations[srcSet + j];
uint destAnim = jjAnimations[destAnimOffset + j];
for (int k = 0; k < 5; 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 >= 32 && pixel < 40)
image[m, l] = color + (pixel & 7);
}
}
if (!image.save(jjAnimFrames[destAnim + k]))
return false;
}
}
}
}
return success;
}
int getCannonFireVolumeByLocalPlayerLocation(bool isRightSide) {
int cannonFireSoundOriginX = isRightSide ? CANNON_FIRE_SOUND_ORIGIN_X_RIGHT : CANNON_FIRE_SOUND_ORIGIN_X_LEFT;
float percentualDistanceFromCannonFire = localPlayer.xPos > cannonFireSoundOriginX
? abs(cannonFireSoundOriginX / localPlayer.xPos)
: abs(localPlayer.xPos / cannonFireSoundOriginX);
int volume = int(percentualDistanceFromCannonFire * float(CANNON_FIRE_SOUND_MAX_VOLUME));
if (volume < 1) {
volume = 1; // Since 0 will default to the max volume, use 1 for the minimum volume
}
return volume;
}
void handleFastCustomSpringSpeeds(jjPLAYER@ play) {
if (play.ySpeed < -32.f) {
fastCustomSpringSpeeds[play.localPlayerID] = int(ceil((play.ySpeed + 32.f) / -0.125f));
} else if (fastCustomSpringSpeeds[play.localPlayerID] != 0) {
if (play.ySpeed < -31.f) {
fastCustomSpringSpeeds[play.localPlayerID]--;
play.ySpeed = -32.f;
} else {
fastCustomSpringSpeeds[play.localPlayerID] = 0;
}
}
}
void initializeCustomSpring(jjOBJ@ obj) {
int anim = obj.curAnim;
obj.behave(obj.behavior = BEHAVIOR::SPRING, false);
if (obj.curAnim != anim) {
obj.curAnim = anim + 2;
obj.determineCurFrame();
}
obj.draw();
}
void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ canvas) {
if (isCannonFireAnimationDisplayedLeft) {
canvas.drawResizedSprite(
(CANNON_FIRE_X_LEFT << TILE_SHIFT) + CANNON_FIRE_ANIMATION_OFFSET_X,
(CANNON_FIRE_Y_LEFT << TILE_SHIFT) + CANNON_FIRE_ANIMATION_OFFSET_Y,
ANIM::AMMO,
5, // animation
cannonFireAnimFrameLeft,
2, // xScale
2 // yScale
);
// Not a biggie if a couple of ticks are missed from the first frame
if (jjGameTicks % CANNON_FIRE_ANIMATION_FRAME_RATE == 0 && cannonFireAnimFrameLeft < 11) {
++cannonFireAnimFrameLeft;
} else if (jjGameTicks % CANNON_FIRE_ANIMATION_FRAME_RATE == 0) {
isCannonFireAnimationDisplayedLeft = false;
}
}
if (isCannonFireAnimationDisplayedRight) {
canvas.drawResizedSprite(
(CANNON_FIRE_X_RIGHT << TILE_SHIFT) + CANNON_FIRE_ANIMATION_OFFSET_X,
(CANNON_FIRE_Y_RIGHT << TILE_SHIFT) + CANNON_FIRE_ANIMATION_OFFSET_Y,
ANIM::AMMO,
5, // animation
cannonFireAnimFrameRight,
2, // xScale
2 // yScale
);
// Not a biggie if a couple of ticks are missed from the first frame
if (jjGameTicks % CANNON_FIRE_ANIMATION_FRAME_RATE == 0 && cannonFireAnimFrameRight < 11) {
++cannonFireAnimFrameRight;
} else if (jjGameTicks % CANNON_FIRE_ANIMATION_FRAME_RATE == 0) {
isCannonFireAnimationDisplayedRight = false;
}
}
}
void onFunction0(bool isCannonFireInitiated) {
if (isCannonFireInitiated) {
cannonFireAnimFrameRight = 0; // Just in case
cannonFireDelayElapsedRight = CANNON_FIRE_DELAY;
isCannonFireDelayedRight = true;
} else {
isCannonFireAnimationDisplayedRight = false;
}
}
void onFunction1(bool isCannonFireInitiated) {
if (isCannonFireInitiated) {
cannonFireAnimFrameLeft = 0; // Just in case
cannonFireDelayElapsedLeft = CANNON_FIRE_DELAY;
isCannonFireDelayedLeft = true;
} else {
isCannonFireAnimationDisplayedLeft = false;
}
}
void onLevelBegin() {
jjGenerateSettableTileArea(4, 105, 30, 1, 2);
for (int i = 1; i < 255; i++) {
jjOBJ@ preset = jjObjectPresets[i];
if (preset.playerHandling == HANDLING::PICKUP) {
preset.behavior = CannotBeShotDown(preset.behavior);
}
}
}
void onLevelLoad() {
jjUseLayer8Speeds = true;
generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {40});
turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 18.0f, false);
}
void onPlayer(jjPLAYER@ play) {
handleFastCustomSpringSpeeds(play);
if (isCannonFireDelayedLeft) {
if (cannonFireDelayElapsedLeft == CANNON_FIRE_DELAY) { // The first tick of the event
play.xPos += 64;
}
if (cannonFireDelayElapsedLeft > 0) {
--cannonFireDelayElapsedLeft;
} else {
cannonFireAnimFrameLeft = 0;
isCannonFireDelayedLeft = false;
isCannonFireAnimationDisplayedLeft = true;
play.suckerTube(23, -26, false);
jjSamplePriority(CANNON_FIRE_SOUND_SAMPLE);
sendCannonFirePacket(localPlayer.playerID, false);
}
}
if (isCannonFireDelayedRight) {
if (cannonFireDelayElapsedRight == CANNON_FIRE_DELAY) { // The first tick of the event
play.xPos -= 64;
}
if (cannonFireDelayElapsedRight > 0) {
--cannonFireDelayElapsedRight;
} else {
cannonFireAnimFrameRight = 0;
isCannonFireDelayedRight = false;
isCannonFireAnimationDisplayedRight = true;
play.suckerTube(-13, -53, false);
jjSamplePriority(CANNON_FIRE_SOUND_SAMPLE);
sendCannonFirePacket(localPlayer.playerID, true);
}
}
}
void onReceive(jjSTREAM & in packet, int fromClientID) {
int8 senderPlayerID;
packet.pop(senderPlayerID);
if (jjIsServer && fromClientID != jjPlayers[senderPlayerID].clientID) {
int8 potentialHackingPlayerID = jjPlayersWithClientID(fromClientID)[0].playerID;
jjAlert("|Warning! Potential hacking attempt from client of player ID "
+ (potentialHackingPlayerID + 1) + "!", true);
return;
}
uint8 packetType;
packet.pop(packetType);
switch (packetType) {
case PACKET_CANNON_FIRE:
{
bool isRightSide;
packet.pop(isRightSide);
// This order ensures that the sample is played only for players who are not already witnessing the cannon fire from either cannon,
// e.g. the player that entered the cannon so that there is no double sound
if (!isCannonFireAnimationDisplayedLeft && !isCannonFireAnimationDisplayedRight) {
jjSample(localPlayer.xPos, localPlayer.yPos, CANNON_FIRE_SOUND_SAMPLE, getCannonFireVolumeByLocalPlayerLocation(isRightSide));
}
if (isRightSide) {
cannonFireAnimFrameRight = 0;
isCannonFireAnimationDisplayedRight = true;
} else {
cannonFireAnimFrameLeft = 0;
isCannonFireAnimationDisplayedLeft = true;
}
if (jjIsServer) {
sendCannonFirePacket(0, isRightSide);
}
}
break;
}
}
void sendCannonFirePacket(int8 senderPlayerID, bool isRightSide) {
jjSTREAM packet;
packet.push(senderPlayerID);
packet.push(uint8(PACKET_CANNON_FIRE));
packet.push(isRightSide);
jjSendPacket(packet);
}
void turnIntoCustomSpring(jjOBJ@ obj, uint color, float power, bool horizontal) {
if (horizontal) {
obj.xSpeed = power;
obj.ySpeed = 0.f;
} else {
obj.xSpeed = 0.f;
obj.ySpeed = -power;
if (obj.state == STATE::START && obj.creatorType == CREATOR::LEVEL) {
int x = int(obj.xPos) >> 5;
int y = int(obj.yPos) >> 5;
if (jjParameterGet(x, y, 0, 1) != 0) {
jjParameterSet(x, y, 0, 1, 0);
obj.yPos -= 4.f;
obj.ySpeed = power;
}
}
}
obj.behavior = initializeCustomSpring;
obj.curAnim = customSpringSprite + color * 3 + (horizontal ? 1 : 0);
obj.energy = obj.frameID = obj.freeze = obj.justHit = obj.light = obj.points = 0;
obj.causesRicochet = obj.isTarget = obj.scriptedCollisions = obj.triggersTNT = false;
obj.isBlastable = false;
obj.deactivates = true;
obj.isFreezable = true;
obj.bulletHandling = HANDLING::IGNOREBULLET;
obj.playerHandling = HANDLING::SPECIAL;
obj.lightType = LIGHT::NORMAL;
obj.determineCurFrame();
}
bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
return MLLE::WeaponHook.drawAmmo(player, canvas);
}
void onLevelReload() {
MLLE::ReapplyPalette();
}
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.