Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
Anniversary Bash 22 levels | Jazz2Online | Multiple | N/A |
const bool MLLESetupSuccessful = MLLE::Setup(); ///@MLLE-Generated
#include "MLLE-Include-1.5.asc" ///@MLLE-Generated
#pragma require "ab22ctf16-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "ab22ctf16.j2l" ///@MLLE-Generated
array<bool> transition(2, false);
array<float> transitionTime(2, 0);
array<uint8> paletteReds;
array<uint8> paletteBlues;
enum packetType {PtoS,StoP};
//need to add packet enum such as joining and updating midway
cloneManager cloneM(1,0,false);
void onLevelLoad()
{
for (int i = 1; i < 255; i++) {
if (jjObjectPresets[i].behavior == BEHAVIOR::PICKUP) {
jjObjectPresets[i].behavior = CannotBeShotDown;
}
}
jjObjectPresets[OBJECT::GOLDCOIN].behavior = Clone(1, 100, 1);
jjObjectPresets[OBJECT::SILVERCOIN].behavior = clonePickup();
jjObjectPresets[OBJECT::GOLDCOIN].xSpeed = 0;
jjObjectPresets[OBJECT::GOLDCOIN].ySpeed = 0;
jjObjectPresets[OBJECT::GOLDCOIN].scriptedCollisions = true;
jjObjectPresets[OBJECT::SILVERCOIN].scriptedCollisions = true;
for (int i = 225; i <= 231; i++) {
paletteReds.insertLast(jjPalette.color[i].red);
////jjprint("color: "+jjPalette.color[i].red);
}
for (int i = 225; i <= 231; i++) {
paletteBlues.insertLast((jjPalette.color[i].red + 30) >= 255? 255 : (jjPalette.color[i].red + 30));
}
}
void onLevelBegin() {
if (!jjIsServer)
{
jjSTREAM packet;
packet.push(StoP);
jjSendPacket(packet); //send a packet to request an update from the server
}
}
void onReceive(jjSTREAM &in packet, int clientID) {
int type=-1;
packet.pop(type);
//jjPrint("type is "+type);
if(type==-1) jjPrint("error!");
if (jjIsServer) {
if(type==StoP)
sendClone(cloneM,clientID);
if(type==PtoS)
{
//jjPrint(" I am server!");
packet.pop(cloneM.pID);
packet.pop(cloneM.active);
packet.pop(cloneM.time);
//jjPrint(" player: "+ cloneM.pID+" active: "+ cloneM.active+" time: "+cloneM.time);
sendClone(cloneM);
}
}
else {
packet.pop(cloneM.pID);
packet.pop(cloneM.active);
packet.pop(cloneM.time);
//jjPrint("player recieving: ");
//jjPrint(" player: "+ cloneM.pID+" active: "+ cloneM.active+" time: "+cloneM.time);
}
}
void sendClone(cloneManager& clone,int clientID=0, int type=StoP)
{
jjSTREAM packet;
packet.push(type);
packet.push(clone.pID);
packet.push(clone.active);
packet.push(clone.time);
jjSendPacket(packet,clientID);
}
void onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ p, int force) {
//jjPrint("test");
if (obj.eventID == OBJECT::SILVERCOIN) {
//jjPrint("test");
if (cloneM.active == false) {
cloneM.active = true;
cloneM.pID=p.playerID;
cloneM.time=0;
//obj.scriptedCollisions = false;
obj.behavior = BEHAVIOR::EXPLOSION2;
// obj.frameID = 0;
sendClone(cloneM,0,PtoS);
//obj.delete();
}
else obj.behavior = BEHAVIOR::EXPLOSION2;
}
}
class Clone : jjBEHAVIORINTERFACE
{
int fireTimer = 70;
int ownerID;
float dist;
int dir;
float delta = 0;
bool fireSwitch;
int timer=0;
Clone(int owner, float d, float di) {
dist = d;
dir = di;
ownerID = owner;
fireSwitch = false;
}
void onBehave(jjOBJ@ obj) {
//activity and server checks
if(cloneM.active==false)
{
obj.xPos=obj.xOrg;
obj.yPos=obj.yOrg;
}
if (cloneM.time<=0 and cloneM.active==true) {
cloneM.time=totCloneTime;
}
if(cloneM.time <=0) return;
cloneM.time--;
if(cloneM.time==0)
cloneM.active=false;
if((cloneM.active== true and jjPlayers[cloneM.pID].isInGame==false) or jjPlayers[cloneM.pID].health<=0 ) //need to add deaths
{
cloneM.active=false;
cloneM.time=0;
if(!jjIsServer)
sendClone(cloneM,0,PtoS);
}
ownerID=cloneM.pID;
////jjprint("timer: "+cloneM.time);
jjPLAYER@ owner = jjPlayers[ownerID];
//movement
obj.yPos = owner.yPos;
if (owner.direction >= 0) {
obj.xPos = obj.xPos - 6;
if (owner.xPos - obj.xPos >= dist)
obj.xPos = owner.xPos - dist;
obj.direction = -1;
}
if (owner.direction < 0) {
obj.xPos = obj.xPos + 6;
if (-owner.xPos + obj.xPos >= dist)
obj.xPos = owner.xPos + dist;
obj.direction = 1;
}
if (delta * (obj.xPos - owner.xPos) < 0)
obj.direction *= -1;
delta = obj.xPos - owner.xPos;
dir = obj.xPos - owner.direction;
//fire
if (owner.keyFire == true && fireSwitch == false){
//jjprint("FIRE");
fireSwitch = true;
if (jjWeapons[owner.currWeapon].style == WEAPON::POPCORN)
fireTimer = 4;
else
fireTimer = 35;
OBJECT::Object currwep=wepToEvent(owner.currWeapon, owner.powerup[owner.currWeapon]);
jjOBJ@ bullet = jjObjects[obj.fireBullet(currwep)];
bullet.creatorID = ownerID;
bullet.creatorType = CREATOR::PLAYER;
if(owner.currWeapon==WEAPON::TOASTER)
{
bullet.xSpeed=0.5*bullet.xSpeed;
bullet.xPos=bullet.xPos+6.5*owner.xSpeed;
}
if(owner.currWeapon==WEAPON::BOUNCER)
{
//bullet.xPos-=obj.direction*7;
bullet.xPos=bullet.xPos+4*owner.xSpeed;
}
if(wepToEvent(owner.currWeapon, owner.powerup[owner.currWeapon])==OBJECT::RFBULLET)
{
jjOBJ@ bullet2 = jjObjects[obj.fireBullet(currwep)];
bullet2.creatorID = ownerID;
bullet2.creatorType = CREATOR::PLAYER;
bullet.ySpeed=0.8*abs(bullet.xSpeed);
bullet2.ySpeed=-0.8*abs(bullet.xSpeed);
}
if(wepToEvent(owner.currWeapon, owner.powerup[owner.currWeapon])==OBJECT::RFBULLETPU)
{
jjOBJ@ bullet2 = jjObjects[obj.fireBullet(currwep)];
bullet2.creatorID = ownerID;
bullet2.creatorType = CREATOR::PLAYER;
bullet.ySpeed=0.8*abs(bullet.xSpeed);
bullet2.ySpeed=-0.8*abs(bullet.xSpeed);
jjOBJ@ bullet3 = jjObjects[obj.fireBullet(currwep)];
bullet3.creatorID = ownerID;
bullet3.creatorType = CREATOR::PLAYER;
}
if (jjLayers[4].maskedPixel(owner.xPos, owner.yPos + (57 - 36 + 20)) and owner.keyUp == true){
bullet.xSpeed = bullet.xAcc = 0;
bullet.ySpeed = -4.5;
bullet.yAcc = 0;
}
}
if (owner.keyFire == false)
fireSwitch = false;
if (fireSwitch == true)
fireTimer--;
if (fireSwitch == true && fireTimer < 0)
fireSwitch = false;
}
void onDraw(jjOBJ@ obj)
{
if(cloneM.active==false) return;
jjPLAYER@ player = jjPlayers[ownerID];
obj.curAnim = player.curAnim;
obj.curFrame = player.curFrame;
obj.frameID = player.frameID;
obj.determineCurFrame();
jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::SINGLECOLOR, 16 + (8 * (jjGameTicks / 10)) % (256 - 16));
}
bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force)
{
if(cloneM.active==false || cloneM.time<=0) return true;
if (bullet is null and(jjPlayers[ownerID]).isEnemy(player) and(jjGameState == GAME::STARTED or jjGameState == GAME::OVERTIME))
player.hurt(1, false, jjPlayers[ownerID]);
return true;
}
}
class clonePickup : jjBEHAVIORINTERFACE
{
void onBehave(jjOBJ@ obj) {
obj.scriptedCollisions=true;
obj.behave(BEHAVIOR::PICKUP);
if (obj.state == STATE::FLOATFALL) obj.state = STATE::FLOAT;
}
void onDraw(jjOBJ@ obj)
{
jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::SINGLECOLOR, 16 + (8 * (jjGameTicks / 10)) % (256 - 16));
}
}
const int totCloneTime=70*(19);
class cloneManager
{
int pID;
int time;
bool active;
cloneManager() {};
cloneManager(int p, int t, bool b) {
pID=p;
time= t;
active =b;
}
}
const OBJECT::Object wepToEvent(int weapon, bool isPU){
switch (weapon) {
case WEAPON::BLASTER: return isPU? OBJECT::BLASTERBULLETPU : OBJECT::BLASTERBULLET;
case WEAPON::BOUNCER: return isPU? OBJECT::BOUNCERBULLETPU :OBJECT::BOUNCERBULLET;
case WEAPON::ICE: return isPU? OBJECT::ICEBULLETPU : OBJECT::ICEBULLET;
case WEAPON::SEEKER: return isPU? OBJECT::SEEKERBULLETPU: OBJECT::SEEKERBULLET;
case WEAPON::RF: return isPU? OBJECT::RFBULLETPU: OBJECT::RFBULLET;
case WEAPON::TOASTER: return isPU? OBJECT::TOASTERBULLETPU :OBJECT::TOASTERBULLET;
case WEAPON::TNT: return OBJECT::TNT;
case WEAPON::GUN8: return isPU? OBJECT::FIREBALLBULLETPU : OBJECT::FIREBALLBULLET;
case WEAPON::GUN9: return isPU? OBJECT::ELECTROBULLETPU : OBJECT::ELECTROBULLET;
default: return OBJECT::BLASTERBULLET;
}
return OBJECT::BLASTERBULLET;
}
int sgn(float x)
{
return (x < 0 ? -1 : 1);
}
int min(int a,int b)
{
return a<b?a:b;
}
void onPlayer(jjPLAYER@ play) {
if ((play.xPos <= 88.5*32 && !play.isSpectating) || (play.cameraX <= ((88.5*32) - (jjSubscreenWidth/2)) && play.isSpectating)) {
transition[1] = false;
transitionTime[1] = 0;
setFadeColors(0,50,100);
if (!transition[0]) {
transitionTime[0]++;
if (transitionTime[0] <= 200) {
for (int i = 225; i <= 231; i++) {
jjPalette.fill(0, int(paletteBlues[i-225]/2), paletteBlues[i-225], i, 1, (transitionTime[0]/200));
}
//jjPalette.fill(0, 0, 100, 200, 1, (transitionTime[0]/200));
if (jjGameTicks % 4 == 0) jjPalette.apply();
} else {
transition[0] = true;
}
}
} else if ((play.xPos > 88.5*32 && !play.isSpectating) || (play.cameraX > ((88.5*32) - (jjSubscreenWidth/2)) && play.isSpectating)) {
transition[0] = false;
transitionTime[0] = 0;
setFadeColors(100,0,0);
if (!transition[1]) {
transitionTime[1]++;
if (transitionTime[1] <= 200) {
for (int i = 225; i <= 231; i++) {
jjPalette.fill(paletteReds[i-225], 0, 0, i, 1, (transitionTime[1]/200));
}
//jjPalette.fill(0, 0, 11, 81, 1, 0.75);
if (jjGameTicks % 4 == 0) jjPalette.apply();
} else {
transition[1] = true;
}
}
}
if(cloneM.active==true and play.playerID==cloneM.pID)
{
jjTEXTAPPEARANCE normal(STRING::NORMAL);
int x = int(p.cameraX);
int y = int(p.cameraY);
jjDrawString(x + jjResolutionWidth - 55, y + jjResolutionHeight - 274, "" + cloneM.time/70, STRING::MEDIUM, normal, 0, SPRITE::PALSHIFT, 0, 1);
jjDrawSprite(x + jjResolutionWidth - 72, y + jjResolutionHeight - 270, ANIM::PICKUPS, 84, jjGameTicks >> 2, 0, SPRITE::SINGLECOLOR, 16 + (8 * (jjGameTicks / 10)) % (256 - 16));
}
}
void setFadeColors(uint R, uint G, uint B) {
jjPALCOLOR fade = jjGetFadeColors();
if (fade.red < R) fade.red++;
else if (fade.red > R) fade.red--;
if (fade.green < G) fade.green++;
else if (fade.green > G) fade.green--;
if (fade.blue < B) fade.blue++;
else if (fade.blue > B) fade.blue--;
jjSetFadeColors(fade.red, fade.green, fade.blue);
}
void CannotBeShotDown(jjOBJ@ obj) {
obj.behave(BEHAVIOR::PICKUP);
if (obj.state == STATE::FLOATFALL) obj.state = STATE::FLOAT;
}
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.