#include "MLLE-Include-1.5w.asc" ///@MLLE-Generated
#pragma require "vdom.j2t" ///@MLLE-Generated
#pragma require "VDom3.j2l" ///@MLLE-Generated
#include "ArcaneWeapon7.asc" ///@MLLE-Generated
#pragma require "ArcaneWeapon7.asc" ///@MLLE-Generated
#include "ArcaneWeapon4.asc" ///@MLLE-Generated
#pragma require "ArcaneWeapon4.asc" ///@MLLE-Generated
#include "BubbleGun.asc" ///@MLLE-Generated
#pragma require "BubbleGun.asc" ///@MLLE-Generated
const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, BubbleGun::MyBubble(), null, ArcaneWeapons::MortarLauncher::Weapon(), null, null, ArcaneWeapons::LightningRod::Weapon(), null, null});
///@SaveAndRunArgs -dom -server
bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
return MLLE::WeaponHook.drawAmmo(player, canvas);
}
void onLevelReload() { MLLE::Palette.apply(); }
void onLevelLoad() {
jjObjectPresets[OBJECT::APPLE].behavior = LetPlayerThroughIfGemIsRightColor;
jjObjectPresets[OBJECT::APPLE].playerHandling = HANDLING::PARTICLE;
jjObjectPresets[OBJECT::TNTAMMO3].scriptedCollisions = true;
//jjObjectPresets[OBJECT::REDSPRING].xSpeed = 3; //hmm
jjANIMATION@ sparks = jjAnimations[jjAnimSets[ANIM::AMMO] + 75];
for (uint i = 0; i < sparks.frameCount; ++i) {
jjANIMFRAME@ frame = jjAnimFrames[sparks + i];
jjPIXELMAP image(frame);
for (uint x = 0; x < image.width; ++x)
for (uint y = 0; y < image.height; ++y)
if (image[x,y] != 0)
image[x,y] += 8;
image.save(frame);
}
jjObjectPresets[OBJECT::REDSPRING].ySpeed = -40;
jjANIMATION@ redSpring = jjAnimations[jjObjectPresets[OBJECT::REDSPRING].curAnim];
for (uint i = 0; i < redSpring.frameCount; ++i) {
jjANIMFRAME@ frame = jjAnimFrames[redSpring + i];
jjPIXELMAP image(frame);
for (uint x = 0; x < image.width; ++x)
for (uint y = 0; y < image.height; ++y)
if (image[x,y] & ~7 == 24)
image[x,y] += 48;
image.save(frame);
}
jjObjectPresets[OBJECT::BOUNCERPOWERUP].behavior = BEHAVIOR::FISH;
jjObjectPresets[OBJECT::SILVERCOIN].behavior = function(o) {
if (jjGameCustom == GAME::DOM) { o.behave(BEHAVIOR::PICKUP); o.playerHandling = HANDLING::PICKUP; }
else o.playerHandling = HANDLING::PARTICLE;
};
}
TEAM::Color LastControlPointColor = TEAM::NEUTRAL;
void LetPlayerThroughIfGemIsRightColor(jjOBJ@ obj) {
for (int i = 0; i < jjLocalPlayerCount; ++i) {
const jjPLAYER@ play = jjLocalPlayers[i];
if (play.isInGame && play.yPos < obj.yPos) {
jjTileSet(4, int(obj.xOrg) >> 5, int(obj.yOrg) >> 5, play.team == jjControlPoints[0].controlTeam ? 0 : 655);
break;
}
}
//onMain:
if ((jjIsServer || jjGameConnection == GAME::LOCAL) && jjGameCustom == GAME::DOM && jjControlPoints[0].controlTeam != LastControlPointColor) {
LastControlPointColor = jjControlPoints[0].controlTeam;
CoinsNeeded += 1;
SendUpdate(0);
}
}
int CoinsNeeded = 3;
bool VerticalArrowSignsFlipped = false;
bool onDrawGameModeHUD(jjPLAYER@ player, jjCANVAS@ canvas) {
bool arrowsShouldBeFlipped = false;
if (jjGameCustom == GAME::DOM) {
int yStart = 0;
if (jjResolutionWidth > 400) {
int activeTeams = 0;
for (int i = 0; i < 4; ++i)
if (jjEnabledTeams[i])
activeTeams += 1;
if (activeTeams > 2)
yStart = 60;
}
const bool enough = player !is null && player.coins >= CoinsNeeded;
canvas.drawSprite(142,yStart+17, ANIM::PICKUPS, enough ? 37 : 84, jjGameTicks >> 3);
if (player !is null) {
canvas.drawString(160, yStart+13, (enough ? "||||" : "|||||||") + player.coins + "/" + CoinsNeeded, STRING::MEDIUM);
if (enough) {
if (jjControlPoints[0].controlTeam != player.team) {
canvas.drawString(0x8000, jjSubscreenHeight - 49, "FALL DOWN", STRING::MEDIUM, STRING::SPIN);
arrowsShouldBeFlipped = true;
}
} else {
canvas.drawString(140, yStart+36, "§1||Need " + (CoinsNeeded - player.coins) + " more", STRING::SMALL, STRING::NORMAL,0, SPRITE::TRANSLUCENTPALSHIFT);
canvas.drawString(140, yStart+52, "§1||to use pit", STRING::SMALL, STRING::NORMAL,0, SPRITE::TRANSLUCENTPALSHIFT);
}
} else
canvas.drawString(160, yStart+13, "|||||||" + CoinsNeeded, STRING::MEDIUM);
}
if (arrowsShouldBeFlipped != VerticalArrowSignsFlipped) {
VerticalArrowSignsFlipped = arrowsShouldBeFlipped;
jjPIXELMAP(149 | TILE::VFLIPPED).save(149, true);
jjPIXELMAP(129 | TILE::HFLIPPED).save(129, true);
}
return false;
}
void SendUpdate(int toClientID) {
jjSTREAM packet;
packet.push(uint8(CoinsNeeded));
jjSendPacket(packet, toClientID);
}
void onLevelBegin() {
if (!jjIsServer && jjGameConnection != GAME::LOCAL)
jjSendPacket(jjSTREAM());
//for (int weaponID = WEAPON::BLASTER; weaponID <= WEAPON::GUN9; ++weaponID)
// jjWeapons[weaponID].allowedPowerup =
// jjWeapons[weaponID].allowed;
if (jjGameCustom == GAME::DOM)
jjLocalPlayers[0].showText("@@@@The pit has a coin warp@@to go to the control point.", STRING::MEDIUM);
}
void onReceive(jjSTREAM &in packet, int fromClientID) {
if (jjIsServer) {
SendUpdate(fromClientID);
} else {
uint8 newCoins;
packet.pop(newCoins);
CoinsNeeded = newCoins;
}
}
array<bool> WasInCoinWarpRow(jjLocalPlayerCount,false);
array<int> fastCustomSpringSpeeds(jjLocalPlayerCount, 0);
void onPlayer(jjPLAYER@ player) {
if (player.ySpeed < -32.f) {
fastCustomSpringSpeeds[player.localPlayerID] = int(ceil((player.ySpeed + 32.f) / -0.125f));
} else if (fastCustomSpringSpeeds[player.localPlayerID] != 0) {
if (player.ySpeed < -31.f) {
fastCustomSpringSpeeds[player.localPlayerID]--;
player.ySpeed = -32.f;
} else {
fastCustomSpringSpeeds[player.localPlayerID] = 0;
}
}
const bool inCoinWarpRow = jjGameCustom == GAME::DOM && int(player.yPos) >> 5 == jjLayerHeight[4] - 5;
if (inCoinWarpRow && !WasInCoinWarpRow[player.localPlayerID]) {
if (player.testForCoins(CoinsNeeded)) {
player.warpToID(0);
//for (int weaponID = WEAPON::BLASTER; weaponID <= WEAPON::GUN9; ++weaponID)
// player.powerup[weaponID] = player.ammo[weaponID] != 0;
}
}
WasInCoinWarpRow[player.localPlayerID] = inCoinWarpRow;
}
namespace BubbleGun {
class MyBubble : Weapon {
void onBehave(jjOBJ@ obj) override {
Weapon::onBehave(obj);
obj.behavior = NoBounce;
}
}
void NoBounce(jjOBJ@ obj) {
const bool right = obj.xSpeed >= 0;
obj.behave(Behavior);
if (right != (obj.xSpeed >= 0))
obj.var[7] = -obj.var[7];
}
}