Downloads containing hgfWhatInTheBlazes.j2as

Downloads
Name Author Game Mode Rating
JJ2+ Only: What in the blazes?Featured Download happygreenfrog Single player 8 Download file

File preview

#include "MLLE-Include-1.4.asc"
const bool MLLESetupSuccessful = MLLE::Setup();
#pragma require "hgfWhatInTheBlazes-MLLE-Data-1.j2l"
#pragma require "hgfWhatInTheBlazes.j2l"
//initialize variables
int temperature = 289;
int temperatureTimer = 0;
bool temperatureRising = false;
int tempTimeMax = 70;
int fakeIceAmmo = 0;
bool bubbaLiving = true;
bool bubbaSpawned = false;
bool bilsyActivated = false;
int bilsyKills = 0;
int iceTimer = 70*(4-jjDifficulty);

//character-specific text function
void altTxtShow(string jazzText, string spazText, string loriText, jjPLAYER@ localPlayer)
{
 if(localPlayer.charCurr == CHAR::JAZZ){
  localPlayer.showText("@@"+jazzText);
 }
 if(localPlayer.charCurr == CHAR::SPAZ){
  localPlayer.showText("@@"+spazText);
 }
 if(localPlayer.charCurr == CHAR::LORI){
  localPlayer.showText("@@"+loriText);
 }
}

//layer 8 speed, triggers, enemy wrapper
void onLevelLoad() {
 //ice timer is not much better on normal than it is on hard now
 if(jjDifficulty == 1) {
  iceTimer = 150;
 }
 //palette trickery
 jjPAL newPal;
 newPal = jjBackupPalette;
 for(int i = 0; i < 255; ++i){
  uint satur = uint(newPal.color[i].getSat()*1.5);
  uint ligh = uint(newPal.color[i].getLight()*1.1);
  if(satur > 255){satur = 255;}
  if(ligh > 255){ligh = 255;}
  newPal.color[i].setHSL(newPal.color[i].getHue(), satur, ligh);
 }
 newPal.apply();
 //initialize checkpoints (this is part of Violet's snippet)
 jjObjectPresets[OBJECT::SAVEPOST].behavior = CheckpointWrapper;
 jjObjectPresets[OBJECT::SAVEPOST].deactivates = false;
 
 //initialize variables
 fakeIceAmmo = 0;
 jjUseLayer8Speeds = true;
 jjTriggers[0] = true;
 
 //temperature timer is faster on higher difficulty settings
 if(jjDifficulty == 1) {
  tempTimeMax = 48;
 }
 if(jjDifficulty >= 2) {
  tempTimeMax = 44;
 }
 
 //allow mouse aiming
 jjChat("/allowmouseaim on");
 jjChat("/mouseaim on");
 
 //apply enemy wrapper
 //create array of enemies
 array<OBJECT::Object> enemies ={OBJECT::SKELETON, OBJECT::DRAGONFLY, OBJECT::FLOATLIZARD, OBJECT::LIZARD, OBJECT::DRAGON};
 //loop enemies
 for(uint i = 0; i < enemies.length(); ++i) {
  jjObjectPresets[enemies[i]].behavior = EnemyWrapper(jjObjectPresets[enemies[i]].behavior);
  if(jjDifficulty > 0) {
   //extra energy
   int extraEnergy = jjDifficulty;
   //lower the extra energy, it's hard enough on Turbo mode without the enemies getting even more HP there.
   if(extraEnergy > 2){extraEnergy = 2;}
   jjObjectPresets[enemies[i]].energy = jjObjectPresets[enemies[i]].energy + 1 + extraEnergy;
  }
 }
 //make dragons tough
 jjObjectPresets[OBJECT::DRAGON].energy = jjObjectPresets[OBJECT::DRAGON].energy * 3; 
 //apply miniboss wrapper
 //create array of minibosses
 array<OBJECT::Object> mbosses ={OBJECT::BUBBA, OBJECT::BILSY, OBJECT::SPARK};
 //loop minibosses
 for(uint i = 0; i < mbosses.length(); ++i) {
  jjObjectPresets[mbosses[i]].behavior = MinibossWrapper(jjObjectPresets[mbosses[i]].behavior);
  if(jjDifficulty > 0) {
   //extra energy
   int mBossExtraEnergy = jjDifficulty*10;
   //reduce energy, then increase it a bit
   jjObjectPresets[mbosses[i]].energy = int(jjObjectPresets[mbosses[i]].energy / 1.5) + mBossExtraEnergy;
  }
 }
 
 //apply ice ammo behavior change
 jjObjectPresets[OBJECT::ICEAMMO3].points = 100;
 jjObjectPresets[OBJECT::ICEAMMO3].scriptedCollisions = true;
 jjObjectPresets[OBJECT::ICEAMMO3].behavior = Ice();
 //make Bilsy have low health
 jjObjectPresets[OBJECT::BILSY].energy = 10;
 //make spark invincible
 jjObjectPresets[OBJECT::SPARK].energy = 40;
 jjObjectPresets[OBJECT::SPARK].bulletHandling = HANDLING::DESTROYBULLET;
 jjObjectPresets[OBJECT::SPARK].deactivates = false;
 //make apple never despawn
 //jjObjectPresets[OBJECT::APPLE].deactivates = false;
 //if(jjDifficulty < 2){jjObjectPresets[OBJECT::APPLE].energy = 3;}
 //else{jjObjectPresets[OBJECT::APPLE].energy = 5;}
 //jjObjectPresets[OBJECT::APPLE].behavior = BossHealthbar(jjObjectPresets[OBJECT::APPLE].behavior);
}

//this code is the extendable checkpoints snippet by VioletCLM. Thanks for letting me know about this one, I'm sure it'll be handy in the future as well!
int savedIce = 0; //you will need some way to keep track of whatever information you want saved... a global variable is the simplest choice
bool bubbaLivingSaved = true;
bool bubbaSpawnedSaved = false;

void onLevelReload() { //restore the state of the saved properties to how they were last time you visited a checkpoint
 fakeIceAmmo = savedIce; //although this example uses jjTriggers, other things should work as well
 bubbaLiving = bubbaLivingSaved;
 bubbaSpawned = bubbaSpawnedSaved;
 //this resets variables, this is NOT part of Violet's snippet
 temperature = 289;
 temperatureTimer = 0;
 temperatureRising = false;
 jjTriggers[0] = true;
 bilsyActivated = false;
 bilsyKills = 0;
 jjMusicLoad("pip-volcanic.it");
}
 
//checkpoint wrapper
void CheckpointWrapper(jjOBJ@ obj) {
  if (obj.state == STATE::STOP) { //don't do anything anymore
    jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame);
  } else if (obj.state == STATE::DEACTIVATE) { //due to death
    obj.deactivate();
  } else {
    obj.behave(BEHAVIOR::CHECKPOINT);
    if (obj.state == STATE::DONE) { //triggered by the player hitting it
      obj.state = STATE::STOP;
      //save the current state of some properties
      savedIce = fakeIceAmmo;
	  if(savedIce < 10){savedIce = 10;}
	  bubbaLiving = bubbaLivingSaved;
	  bubbaSpawned = bubbaSpawnedSaved;
      //OPTIONAL: this loop makes checkpoints reusable, so only the most recent checkpoint you touched is ever active
      //for (int i = jjObjectCount; --i > 0;) {
      //  jjOBJ@ obj2 = jjObjects[i];
      //  if (obj2.eventID == OBJECT::CHECKPOINT && i != obj.objectID && obj2.isActive) {
      //    obj2.state = STATE::SLEEP;
      //    obj2.var[0] = 0;
      //  }
      //}
    }
  }
}

//enemy wrapper
class EnemyWrapper : jjBEHAVIORINTERFACE {
 private jjBEHAVIOR nativeBehavior;
 EnemyWrapper(const jjBEHAVIOR &in nb) { nativeBehavior = nb; }
 
 void onBehave(jjOBJ@ obj) {
  obj.behave(nativeBehavior);
  if (obj.state == STATE::KILL){obj.deactivate();}
 }
}

//boss healthbar
//class BossHealthbar : jjBEHAVIORINTERFACE {
 //private jjBEHAVIOR nativeBehavior;
 //BossHealthbar(const jjBEHAVIOR &in nb) { nativeBehavior = nb; }
 
 //void onBehave(jjOBJ@ obj) {
 // obj.behave(nativeBehavior);
 // if(bilsyPhase2) {obj.energy = jjObjectPresets[OBJECT::APPLE].energy - (bilsyKills + 1);}
 // else {obj.energy = jjObjectPresets[OBJECT::APPLE].energy - bilsyKills;}
// }
//}

//deactivate miniboss
void deactivateMBoss()
{
 for(int i = 0; i < 32; ++i)
 {
  jjPLAYER@ p = jjPlayers[i];
  p.bossActivated = false;
  p.boss = 0;
 }
}

bool nextLvl = false;
//main
void onMain() {
 if(bilsyKills == 4 && jjDifficulty < 2 && !nextLvl || bilsyKills == 6 && jjDifficulty >= 2 && !nextLvl)
 {
  jjNxt();
  nextLvl = true;
 }
}

//miniboss wrapper
class MinibossWrapper : jjBEHAVIORINTERFACE {
 private jjBEHAVIOR nativeBehavior;
 MinibossWrapper(const jjBEHAVIOR &in nb) { nativeBehavior = nb; }
 
 void onBehave(jjOBJ@ obj) {
  //miniboss dead
  if (obj.state == STATE::DONE){
   //boss is bubba
   if(obj.eventID == OBJECT::BUBBA) {
   bubbaLiving = false;
    jjTriggers[2] = false;
    jjTriggers[3] = true;
    obj.state = STATE::EXTRA;
    obj.delete();
    deactivateMBoss();
   }
   //boss is bilsy
   if(obj.eventID == OBJECT::BILSY) {
    obj.state = STATE::EXTRA;
    obj.delete();
    bilsyKills += 1;
   }
  }
  //prevent Bubba from going out-of-bounds
  if(obj.eventID == OBJECT::BUBBA)
  {
   if(obj.yPos < 1408) {
    obj.yPos = 1408;
   }
   if(obj.xPos < 4480) {
    obj.xPos = 4480;
   }
  }
  //behave
  obj.behave(nativeBehavior);
 }
}

//ice ammo override
class Ice : jjBEHAVIORINTERFACE {
 void onBehave(jjOBJ@ obj) {
  obj.behave(BEHAVIOR::PICKUP);
 }
 bool onObjectHit(jjOBJ@ obj, jjOBJ@, jjPLAYER@ player, int) {
  //next line is where the pickup actually makes changes
  //fakeIceAmmo += 7-jjDifficulty;
  if(jjDifficulty == 0){fakeIceAmmo += 7;}
  else{fakeIceAmmo += 4;}
  //
  obj.behavior = BEHAVIOR::EXPLOSION2;
  obj.scriptedCollisions = false;
  obj.frameID = 0;
  jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PICKUPW1);
  return true;
 }
}

//infinite lives, render temperature to screen, rapid fire, etc.
bool onDrawLives(jjPLAYER@ p, jjCANVAS@ canvas) {
 //infinite lives, fire rate
 p.lives = 9;
 p.fastfire = 6;
 int tempRender = int(temperature * 0.1);
 int tempDecimal = int(temperature-(tempRender*10));
 
 if(temperature == 289 || temperature < 293 && jjGameTicks % 16 <= 14 || temperature >= 293 && temperature < 296 && jjGameTicks % 16 <= 11 || temperature >= 296 && temperature <= 299 && jjGameTicks % 16 <= 8 || temperature >= 299 && jjGameTicks % 8 <= 2){
  //degrees Celsius
  canvas.drawString(p.subscreenX+72, p.subscreenY+jjSubscreenHeight-16, "0", STRING::SMALL);
  canvas.drawString(p.subscreenX+80, p.subscreenY+jjSubscreenHeight-16, "C", STRING::MEDIUM);
  //number
  canvas.drawString(p.subscreenX+4, p.subscreenY+jjSubscreenHeight-16, tempRender+"."+tempDecimal, STRING::MEDIUM);
 }
 
 //ice remaining
 if(fakeIceAmmo >= 9 || fakeIceAmmo == 0 && jjGameTicks % 8 <= 4 || fakeIceAmmo > 0 && fakeIceAmmo <= 5 && jjGameTicks % 16 <= 8 || fakeIceAmmo > 5 && fakeIceAmmo < 9 && jjGameTicks % 36 <= 18)
 {
  canvas.drawSprite(p.subscreenX+10, p.subscreenY+jjSubscreenHeight-32, ANIM::AMMO, 29, int(jjGameTicks/8) % 8);
  canvas.drawString(p.subscreenX+24, p.subscreenY+jjSubscreenHeight-32, "x"+fakeIceAmmo, STRING::SMALL);
 }
 return true;
}

//temperature handling
void onPlayer(jjPLAYER@ p) {
 //lower timers
 temperatureTimer += 1;
 iceTimer -= 1;

 //reduce ice counter constantly
 if(iceTimer <= 0 && fakeIceAmmo > 0) {
  fakeIceAmmo -= 1;
  if(jjDifficulty == 0){iceTimer = 20*(5-jjDifficulty);}
  if(jjDifficulty == 1 || jjDifficulty == 2){iceTimer = 60;}
  if(jjDifficulty == 3){iceTimer = 40;}
 }
 //temperature is RISING
 if(temperatureRising) {
  //save from temperature increase
  if(fakeIceAmmo > 0) {
   if(temperatureTimer > int(tempTimeMax*0.9)) {
    fakeIceAmmo = fakeIceAmmo - 1;
  	temperatureTimer = 0;
   }
  }
  //temperature change timer 
  else {
   if(temperatureTimer > tempTimeMax) {
    temperature += 1;
    temperatureTimer = 0;
  
    //hurt player, bunnies don't like temperatures higher than 29.4 degrees Celsius and 30 degrees Celsius is a bit higher than that.
    if(temperature > 299) {
     p.hurt(jjDifficulty+1);
    }
   }
  }
 }
 //temperature is LOWERING
 else {
  if(temperatureTimer > 15) {
   if(temperature > 289) {
    temperature -= 1;
   }
   temperatureTimer = 0;
  }
 }
}

//stop heat
void onFunction0(jjPLAYER@ p) {
 if(temperatureRising) {
  temperatureRising = false;
  temperatureTimer = 0;
 }
}

//start heat
void onFunction1(jjPLAYER@ p) {
 if(!temperatureRising){
  temperatureRising = true;
  temperatureTimer = 0;
 }
}

//start Bubba midboss
void onFunction2(jjPLAYER@ p) {
 if(bubbaLiving && !bubbaSpawned) {
  jjOBJ@ o = jjObjects[jjAddObject(OBJECT::BUBBA, 147*32, 49*32)];
  p.boss = o.objectID;
  p.bossActivated = true;
  jjTriggers[2] = true;
  bubbaSpawned = true;
  altTxtShow("Bubba: Welcome to Texas!@If the heat doesn't get ya,@you're probably from Heck, like me!","Bubba: AAAHHHHHHH!@DEMON BUNNY!@GET IT AWAY FROM MEEE!","Bubba: Welcome to die!",p);
 }
}

//start boss
void onFunction3(jjPLAYER@ p) {
 if(!bilsyActivated) {
  jjOBJ@ o = jjObjects[jjAddObject(OBJECT::SPARK, 241*32, 62*32)];
  //jjOBJ@ o2 = jjObjects[jjAddObject(OBJECT::APPLE, 0, 0)];
  //p.boss = o2.objectID;
  p.bossActivated = true;
  string bilsyString = "Bilsy:@Hey, get out of my house!@Get out of my face!@Security and cloning systems, activate!";
  altTxtShow(bilsyString, bilsyString, bilsyString, p);
  jjMusicLoad("boss2.j2b");
  bilsyActivated = true;
 }
}