Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
Anniversary Bash 17 Levels | Jazz2Online | Multiple | N/A | |||||
The Petrified Woods | Superjazz | Battle | 8.5 |
class pairUintBool {
uint u;
bool b;
pairUintBool() { }
pairUintBool(uint U, bool B) {
u = U;
b = B;
}
}
array<pairUintBool> lastWeapon(jjLocalPlayerCount);
bool isPlayerActive(const jjPLAYER@ play) {
return play.isActive && play.xPos > 0.f && play.yPos > 0.f;
}
int getTheOnlyNonLocalPlayerID() {
int result = -1;
for (int i = 0; i < 32; i++) {
const jjPLAYER@ play = jjPlayers[i];
if (isPlayerActive(play) && !play.isLocal) {
if (result == -1)
result = i;
else
return -2;
}
}
return result;
}
void fixBirdCageOwnershipIssues(jjOBJ@ obj) {
if (obj.state == STATE::KILL)
obj.state = STATE::ACTION;
if (obj.state == STATE::ACTION && obj.var[0] < 0) {
int playerID = getTheOnlyNonLocalPlayerID();
if (playerID >= 0)
jjAddObject(OBJECT::BLASTERBULLET, obj.xPos, obj.yPos, playerID, CREATOR::PLAYER);
obj.state = STATE::SLEEP;
obj.counterEnd = 1;
} else if (obj.counterEnd > 0) {
if (++obj.counterEnd > 100) {
obj.state = STATE::DONE;
obj.bulletHandling = HANDLING::IGNOREBULLET;
}
}
}
void processBrokenCage(jjOBJ@ obj) {
obj.creator = 0;
for (int i = 0; i < jjObjectCount; i++) {
const jjOBJ@ obj2 = jjObjects[i];
if (obj2.isActive && obj2.eventID == OBJECT::BIRDCAGE && obj2 !is obj && abs(obj2.xPos - obj.xPos) < 1.f && abs(obj2.yPos - obj.yPos) < 1.f)
obj.state = STATE::KILL;
}
}
void birdCage(jjOBJ@ obj) {
fixBirdCageOwnershipIssues(obj);
if (obj.state == STATE::DONE)
processBrokenCage(obj);
obj.behave(BEHAVIOR::BIRDCAGE);
}
void bird(jjOBJ@ obj) {
obj.behave(BEHAVIOR::BIRD);
if (obj.state == STATE::FLY && (jjGameState == GAME::STARTED || jjGameState == GAME::OVERTIME)) {
const jjPLAYER@ owner = jjPlayers[obj.var[0] - 0x8000];
obj.yPos = obj.yPos * 0.96875f + owner.yPos * 0.03125f - 1.71875f - obj.ySpeed;
if (obj.counter > 140) {
for (int i = 0; i < 32; i++) {
const jjPLAYER@ play = jjPlayers[i];
if (isPlayerActive(play) && i != obj.var[0] - 0x8000) {
float x = play.xPos - obj.xPos;
float y = play.yPos - obj.yPos;
if (y > -64.f && y < 128.f && x * obj.direction > 0 && abs(x) < 480.f) {
for (int j = 0; j < 2; j++) {
int currWeapon = owner.isLocal ? lastWeapon[owner.localPlayerID].u : owner.currWeapon;
if (currWeapon == WEAPON::TNT)
currWeapon = WEAPON::BLASTER;
int type = currWeapon;
if (currWeapon > WEAPON::TNT)
type--;
if (owner.isLocal ? lastWeapon[owner.localPlayerID].b : owner.powerup[currWeapon])
type += OBJECT::BLASTERBULLETPU - OBJECT::BLASTERBULLET;
int id = jjAddObject(type, obj.xPos + obj.direction * 22.f, obj.yPos - 6.f, obj.var[0] - 0x8000, CREATOR::PLAYER);
if (id > 0) {
jjOBJ@ obj2 = jjObjects[id];
obj2.ySpeed = j * 1.5f;
obj2.direction = obj.direction;
obj2.xSpeed = obj2.xSpeed * obj2.direction;
obj2.xAcc = obj2.xAcc * obj2.direction;
}
}
obj.counter = 105;
}
}
}
}
}
}
void updateLastWeapons() {
for (int i = 0; i < jjObjectCount; i++) {
const jjOBJ@ obj = jjObjects[i];
if (obj.isActive && (obj.eventID <= OBJECT::BULLET || obj.eventID == OBJECT::TNT) && obj.counter == 1 && obj.state != STATE::EXPLODE && obj.creatorType == CREATOR::PLAYER) {
const jjPLAYER@ play = jjPlayers[obj.creatorID];
if (play.isActive && play.isLocal)
lastWeapon[play.localPlayerID] = pairUintBool(obj.var[3] == 0 ? 9 : obj.var[3], obj.var[6] & 8 != 0);
}
}
}
void removeDoubleBirds() {
array<bool> playerHasBird(32, false);
for (int i = 0; i < jjObjectCount; i++) {
jjOBJ@ obj = jjObjects[i];
if (obj.isActive && obj.eventID == OBJECT::BIRD && obj.state != STATE::HIDE && obj.state != STATE::HIT && obj.state != STATE::KILL) {
if (obj.var[0] < 0x8000 || obj.var[0] >= 0x8000 + 32 || playerHasBird[obj.var[0] - 0x8000])
obj.delete();
else
playerHasBird[obj.var[0] - 0x8000] = true;
}
}
}
void onLevelLoad() {
jjObjectPresets[OBJECT::BIRDCAGE].behavior = birdCage;
jjObjectPresets[OBJECT::BIRD].behavior = bird;
}
void onMain() {
updateLastWeapons();
if (jjGameTicks & 63 == 0)
removeDoubleBirds();
}
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.