Downloads containing hgfOperationCleanupBoss.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Operation Cleanup: Turtle...Featured Download happygreenfrog Single player 8.2 Download file

File preview

void onLevelLoad()
{
 jjObjectPresets[OBJECT::DEVILDEVAN].behavior = duelDevan();
 jjObjectPresets[OBJECT::DEVILDEVAN].playerHandling = HANDLING::SPECIAL;
 jjObjectPresets[OBJECT::DEVILDEVAN].scriptedCollisions = true;
 jjObjectPresets[OBJECT::DEVILDEVAN].bulletHandling = HANDLING::DETECTBULLET;
 jjObjectPresets[OBJECT::DEVILDEVAN].isFreezable = false;
 jjObjectPresets[OBJECT::DEVILDEVAN].energy = 4+(jjDifficulty*2);
 jjWeapons[WEAPON::BLASTER].style = WEAPON::CAPPED;
}

void onPlayer(jjPLAYER@ p)
{
 //initialize
 p.jumpStrength = 0;
 p.direction = 1;
 p.specialMove = 0;
 p.xSpeed = 0;
 p.xPos = 320;
 p.fastfire = 70;
 p.ammo[WEAPON::BOUNCER] = 0;
 p.ammo[WEAPON::TOASTER] = 0;
 p.ammo[WEAPON::RF] = 0;
 p.blink = 0;
 p.invincibility = 0;
 //activate boss
 p.bossActivated = true;
 //display dialogue
 if(dialogueDelay == 2100)
 {
  p.showText("@@Is the challenger ready to duel? Good...");
 }
 if(dialogueDelay == 1680)
 {
  p.showText("@@Allow me to explain the rules:");
 }
 if(dialogueDelay == 1260)
 {
  p.showText("@@Wait until I say 'Fire'. Then, shoot!");
 }
 if(dialogueDelay == 840)
 {
  p.showText("@@If you shoot early, you will be penalized!");
 }
 if(dialogueDelay == 420)
 {
  p.showText("@@JAZZ VS. DEVAN!@@@@@       FIGHT!", STRING::MEDIUM);
 }
 if(dialogueDelay > 0)
 {
  p.noFire = true;
 }
 else{p.noFire = false;}
}

//infinite lives
bool onDrawLives(jjPLAYER@ p, jjCANVAS@ canvas)
{
 p.lives = 9;
 return true;
}

//boss
int dialogueDelay = 2520;
class duelDevan : jjBEHAVIORINTERFACE{
 void onBehave(jjOBJ@ obj){
  switch (obj.state){
   case STATE::START: //always used
    //setup movement
    obj.direction = -1;
	obj.age = 210+(jjRandom() % 210);
	obj.determineCurAnim(ANIM::DEVILDEVAN, 16);
    obj.state = STATE::WAIT;
	obj.var[0] = 0;
	obj.var[3] = 140;
	if(jjDifficulty == 1)
	{
     obj.var[3] = 90;
	}
	if(jjDifficulty == 2)
	{
     obj.var[3] = 70;
	}
	if(jjDifficulty == 3)
	{
     obj.var[3] = 54;
	}
	break;
   case STATE::WAIT:
    for (int i = 0; i < jjLocalPlayerCount; ++i) {
     jjPLAYER@ localPlayer = jjLocalPlayers[i];
	 if (localPlayer.bossActivated == true){jjMusicLoad('JJ1BOSS.it');localPlayer.boss = obj.objectID;obj.state = STATE::WALK;}
	 break;
    }
   
   case STATE::WALK: //arbitrarily chosen state
    //display frame
    obj.frameID = 6;
    obj.determineCurFrame();
	
	//set position
    obj.yPos = 190;
	
	//allow dialogue to progress
	if(dialogueDelay > 0)
	{
	 dialogueDelay -=1;
	}
	//run main code
	else
	{
	 //show "ready aim" message
	 if(obj.var[0] == 0)
	 {
	  for(int i = 0; i < jjPlayerCount; ++i)
	  {
	   jjPLAYER@ p = jjPlayers[i];
	   p.showText("@@Ready, aim...", STRING::LARGE);
	   //prevent message from showing up twice
	   obj.var[0] = 1;
	  }
	 }
	 //cool down attack
	 obj.age -= 1;

	 //FIRE!
	 if(obj.age <= obj.var[3])
	 {
	  //loop player
	  for(int i = 0; i < jjPlayerCount; ++i)
	  {
	   //show text
	   jjPLAYER@ p = jjPlayers[i];
	   p.showText("@@FIRE!", STRING::LARGE);
	  }
	  //fire state
	  obj.state = STATE::FIRE;
	 }
	}
	break;
   
   case STATE::FIRE:
    //cool down
    obj.age -= 1;
	//fire bullet
	if(obj.age <= 0)
	{
	 //yes the bullet is a banana. don't question it
	 int bullet = obj.fireBullet(OBJECT::BANANA);
	 //move banana
	 jjObjects[bullet].xSpeed = -8;
	 //make banana hurt
	 jjObjects[bullet].playerHandling = HANDLING::ENEMYBULLET;
	 jjObjects[bullet].animSpeed = 1+jjDifficulty;
	 //play sound
	 jjSample(obj.xPos, obj.yPos, SOUND::MONKEY_THROW);
	 //reset attack
	 obj.age = 210+(jjRandom() % 210);
 	 obj.var[0] = 0;
	 obj.state = STATE::WALK;
	}
   
   case STATE::KILL: //can be left out if not using normal object energy handling
    //progress towards death
    obj.var[1] = obj.var[1] - 1;
	//other death lines
	//loop
	for(int i = 0; i < jjPlayerCount; ++i)
	{
	 jjPLAYER@ p = jjPlayers[i];
	 if(obj.var[1] == 1260)
	 {
	  p.showText("@@No! That was but a mere decoy.");
	 }
	 if(obj.var[1] == 840)
	 {
	  p.showText("@@It was a convincing fake... right?");
	 }
	 if(obj.var[1] == 420)
	 {
	  p.showText("@@I look forwards to our next duel...@...it'll be in person next time.");
	 }
    }
	//delete object, advance to next stage
    if(obj.var[1] <= 0 && obj.state == STATE::KILL){
	 obj.delete();
	 jjNxt();
	}
	break;
   case STATE::DEACTIVATE: //can be left out if level is MP-only
    jjMusicLoad('MEDIVO.s3m');
    obj.deactivate();
    break;
  }
 }
 void onDraw(jjOBJ@ obj){
 if(obj.state != STATE::KILL){ 
  if(obj.justHit <= 0){jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::SINGLEHUE, 80);} else{jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::SINGLEHUE, 40);}
 }
 }
 bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) { //As described in the signs in-level, this is a nearly 100% faithful recreation of standard enemy collision code.
  if (bullet !is null) {
   if(obj.state == STATE::FIRE)
   {
    //recreation of HANDLING::HURTBYBULLET with HANDLING::ENEMY
    if ((bullet.var[6] & 16) == 0) //not a fireball
     bullet.state = STATE::EXPLODE;
    if (obj.freeze > 0 && force < 3)
     force = 3;
    //hurt boss
	obj.energy -= 1;
    obj.justHit = 5; //flash white for 5 ticks--jjOBJ::justHit is automatically deincremented by the JJ2 engine, so individual behavior functions don't need to worry about doing that.
    obj.freeze = 0;
	//reset attack
	obj.age = 210+(jjRandom() % 210);
	obj.var[0] = 0;
	obj.state = STATE::WALK;
   }
   else
   {
    if ((bullet.var[6] & 16) == 0) //not a fireball
     bullet.state = STATE::EXPLODE;
    //hurt player
    player.hurt();
   }
  } else if (force > 0) { //sugar rush
  } else if (force == -101) { //running into frozen enemy
  }
  else { //not attacking
   player.hurt();}
  if (obj.energy <= 0) { //killed
   obj.energy = 0;
   obj.state = STATE::KILL;
   obj.var[1] = 1680;
   obj.particlePixelExplosion(0);
   obj.particlePixelExplosion(0);
   obj.particlePixelExplosion(0);
   obj.particlePixelExplosion(0);
   obj.particlePixelExplosion(0);
   player.showText("@@Did you really think that was me?");
  }
  return true;
 }
}