Downloads containing Cloudy Challenge Course.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Cloudy Challenge Course jjturbo9 Single player N/A Download file

File preview

const bool MLLESetupSuccessful = MLLE::Setup(); ///@MLLE-Generated
#include "MLLE-Include-1.7.asc" ///@MLLE-Generated
#pragma require "Cloudy Challenge Course-MLLE-Data-2.j2l" ///@MLLE-Generated
#pragma require "Cloudy Challenge Course-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "Cloudy Challenge Course.j2l" ///@MLLE-Generated
#include "hh17enemies_HH24.asc" //include for ice dragon 1/3

//Death on tile if you put a text-event (id100, AS enabled)
void onFunction100(jjPLAYER@ player) {
	player.hurt(player.health); // roasted
}

bool isSolidObject(const jjOBJ@ obj) {
	return obj.behavior == BEHAVIOR::AMMO15 || obj.behavior == BEHAVIOR::BIGOBJECT || obj.behavior == BEHAVIOR::CRATE || obj.behavior == BEHAVIOR::MONITOR || obj.eventID == OBJECT::FIRESHIELD || obj.eventID == OBJECT::WATERSHIELD || obj.eventID == OBJECT::LIGHTNINGSHIELD || obj.eventID == OBJECT::MORPH || obj.eventID == OBJECT::BIRDMORPH || obj.eventID == OBJECT::BLASTERPOWERUP || obj.eventID == OBJECT::BOUNCERPOWERUP || obj.eventID == OBJECT::ICEPOWERUP || obj.eventID == OBJECT::SEEKERPOWERUP || obj.eventID == OBJECT::RFPOWERUP || obj.eventID == OBJECT::TOASTERPOWERUP || obj.eventID == OBJECT::TNTPOWERUP || obj.eventID == OBJECT::GUN8POWERUP || obj.eventID == OBJECT::GUN9POWERUP;
}

bool checkGamemode = true;
bool solidsReset = false;

array<jjOBJ@> solids;


jjOBJ@ getSolid(uint idx) {
	jjOBJ@ obj = solids[idx];
	return obj.eventID == OBJECT::GENERATOR ? jjObjects[obj.var[0]] : obj;
}

void onLevelBegin() {
	MLLE::SpawnOffgrids();
		if (jjMaxHealth != 5)
    {
        jjChat("/maxhealth 5");   // never allow more than 2 hearts
    }
	            p.furSet(0, 0, 0, 0);
		if (jjGameConnection != GAME::LOCAL) {
		for (int i = 1; i < jjObjectCount; i++) {
			jjOBJ@ obj = jjObjects[i];
			if ((jjEventGet(int(obj.xOrg / 32), int(obj.yOrg / 32)) == int(obj.eventID) && isSolidObject(obj)) || (obj.eventID == OBJECT::GENERATOR && isSolidObject(jjObjectPresets[jjParameterGet(int(obj.xPos / 32),int(obj.yPos / 32), 0, 8)]))) {
				solids.insertLast(obj);
			}
		}
	}
}


void onLevelReload() {
	MLLE::SpawnOffgridsLocal();
	solids = array<jjOBJ@>();
		if (jjGameConnection != GAME::LOCAL) {
		for (int i = 1; i < jjObjectCount; i++) {
			jjOBJ@ obj = jjObjects[i];
			if ((jjEventGet(int(obj.xOrg / 32), int(obj.yOrg / 32)) == int(obj.eventID) && isSolidObject(obj)) || (obj.eventID == OBJECT::GENERATOR && isSolidObject(jjObjectPresets[jjParameterGet(int(obj.xPos / 32),int(obj.yPos / 32), 0, 8)]))) {
				solids.insertLast(obj);
			}
		}
	}
}

void onMain() {
	HH17::handleEnemyProjectiles(); //include for ice dragon 2/3
	if (jjGameConnection != GAME::LOCAL) {
		if (!solidsReset) {
			for (int i=0; i < jjObjectCount; i++) {
				jjOBJ@ obj = jjObjects[i];
				if (isSolidObject(obj)) { 
					obj.clearPlatform();
				}
			}
			solidsReset = true;
		}
		
		//crate pushing code
		if (jjGameMode == GAME::SP || jjGameMode == GAME::COOP) {
			checkGamemode = true;
			for (uint i = 0; i < solids.length(); i++) {
				jjOBJ@ obj = getSolid(i);
				if (isSolidObject(obj)) {
					if (!obj.isActive || obj.state == STATE::KILL) {
						obj.clearPlatform();
					} else {
						jjANIMFRAME@ frame = @::jjAnimFrames[obj.curFrame];
						int width = frame.width;
						int height = frame.height;
						int hotX = frame.hotSpotX;
						int hotY = frame.hotSpotY;
						obj.beSolid();
						
						if ((jjMaskedVLine(int(obj.xPos)+hotX, int(obj.yPos)+hotY, height-3) && obj.beSolid() == -1) || (jjMaskedVLine(int(obj.xPos)+hotX+width, int(obj.yPos)+hotY, height-3) && obj.beSolid() == 1)) {
							//collision
						} else {
							bool col = false;
							bool descend = true;
							for (uint j = 0; j < solids.length(); j++) {
								jjOBJ@ obj2 = getSolid(j);
								if (i != j && obj.objectID != obj2.objectID && isSolidObject(obj2) && obj2.state == STATE::SLEEP) { //state of crate
									jjANIMFRAME@ frame2 = @::jjAnimFrames[obj2.curFrame];
									int width2 = frame2.width;
									int height2 = frame2.height;
									int hotX2 = frame2.hotSpotX;
									int hotY2 = frame2.hotSpotY;
									if (abs(obj.yPos - obj2.yPos) <= 16 && abs(obj.xPos - obj2.xPos) <= 100) {
										if ((abs((obj.xPos + hotX) - (obj2.xPos + hotX2 + width2)) <= 2 && obj.beSolid() == -1) || (abs((obj.xPos + hotX + width) - (obj2.xPos + hotX2)) <= 2 && obj.beSolid() == 1)) {
											col = true;
											break;
										}
									} else if (abs(obj.xPos - obj2.xPos) <= 32 && obj2.yPos - obj.yPos >= 0 && obj2.yPos - obj.yPos <= height/2 + height2/2) {
										descend = false;
									}
								}
							}
							//can push object
							if (!col) {
								obj.xPos += obj.beSolid() * 0.5f;
							}
							
							if (!jjMaskedHLine(int(obj.xPos)+hotX+1, width-1, int(obj.yPos)+hotY+height) && descend) {
								obj.yPos += 2;
							} else if (obj.state == STATE::FALL) {
								obj.state = STATE::SLEEP;
							}
						}
					}
				}
			}
		} else if (checkGamemode) {
			for (int i = 0; i < 32; i++) {
				if (jjPlayers[i].isInGame && jjPlayers[i].platform != 0) {
					jjOBJ@ obj = jjObjects[jjPlayers[i].platform];
					obj.clearPlatform();
					if (obj.isActive && isSolidObject(obj)) { 
						jjPlayers[i].platform = 0;
					}
				}
			}
			checkGamemode = false;
			solidsReset = false;
		}
	}
}


//Give enemies x hp
void onLevelLoad() {
	jjObjectPresets[OBJECT::RAVEN].energy = 4;
	jjObjectPresets[OBJECT::DRAGON].energy = 200;
	HH17::setEnemy(OBJECT::DRAGON); //include for ice dragon 3/3
}

/* void onPlayer(jjPLAYER@ p) {
    if (p.health == 0) {
        p.morphTo(CHAR::JAZZ, false);
    }
} *///makes the player respawn fast, doesn't work as intended (morphing to jazz) though. 


// object respawn trigger
void onFunction101(jjPLAYER@ play) {
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ obj = jjObjects[i];
		if (obj.eventID == OBJECT::BIGROCK || obj.eventID == OBJECT::TRIGGERCRATE) {
			jjSamplePriority(SOUND::COMMON_TELPORT2);
			obj.particlePixelExplosion(1);
			obj.xPos = obj.xOrg;
			obj.yPos = obj.yOrg;
			obj.putOnGround(false);
		}
	}
}

// Texts stay on screen until you leave the text block. Use 2xx instead of xx (so 201 instead of 1, 215 instead of 15, etc.)

class HelpString {
  int HelpID = -1;
  int Timer = -200;
}
array<HelpString> HelpStrings(jjLocalPlayerCount);
jjTEXTAPPEARANCE spin(STRING::SPIN);
 
bool onDrawHealth(jjPLAYER@ player, jjCANVAS@ canvas) {
  HelpString@ helpString = HelpStrings[player.localPlayerID];
  const uint xTile = uint(player.xPos) / 32, yTile = uint(player.yPos) / 32;
  if (jjEventGet(xTile,yTile) == AREA::TEXT && jjParameterGet(xTile,yTile, 8,10) == 0) {
	const int helpID = jjParameterGet(xTile,yTile, 0,8);
	if (helpID >= 200 && helpID <= 215) {
	  if (helpID - 200 != helpString.HelpID) {
		helpString.Timer = jjGameTicks + 70;
		helpString.HelpID = helpID - 200;
	  } else if (helpString.Timer < jjGameTicks) {
		helpString.Timer = jjGameTicks;
	  }
	}
  }
 
  const int time = helpString.Timer - jjGameTicks;
  if (time > -70) {
  spin.xAmp = spin.yAmp = (time == 0) ? 0 : 1; 
  spin.spacing = (time == 0) ? 2 : 1; 
	canvas.drawString(
	  0x8000 + time * int(abs(time)) / 10,
	  10,
	  jjHelpStrings[helpString.HelpID],
	  STRING::SMALL,
	 spin,
	  uint(abs(time)) * 3
	);
  } else
	helpString.HelpID = -1;
   
  return false;
}