Downloads containing HH18_level04.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Holiday Hare '18Featured Download SmokeNC Single player 8.9 Download file

File preview

#include "MLLE-Include-1.4.asc"
const bool MLLESetupSuccessful = MLLE::Setup();
#include "HH17Enemies.asc"
#include "HH18Smoke.asc"
#pragma require "HH18_level04-MLLE-Data-1.j2l"
#pragma require "HolidaiusStorm.j2t"
#pragma require "XMas 1 Feaw.j2t"
#pragma require "HH18_level04.j2l"
#pragma require "HH17_lowind.wav"
#pragma require "HH18E1.j2a"
#pragma require "SExmas.j2a"
#include "HH18savegems.asc"

int temperature = 0;
int temperatureTimer = 0;
bool temperatureDropping = false;
int tempTimeMax = 2;
bool blizzard = false;
bool newMusic = false;
uint R = 10, G = 0, B = 20;

class GameTickTimer {
    GameTickTimer() {
        restart();
    }
    bool opEquals(const GameTickTimer& other) const {
        return paused() == other.paused() && read() == other.read();
    }
    bool paused() const {
        return lastPause != -1;
    }
    int64 read() const {
        return (paused() ? lastPause : ::jjGameTicks) - lastUpdate;
    }
    int64 reset() {
        int result = read();
        lastUpdate += result;
        return result;
    }
    int64 restart() {
        unpause();
        return reset();
    }
    void pause() {
        if (!paused())
            lastPause = ::jjGameTicks;
    }
    void unpause() {
        if (paused()) {
            lastUpdate += ::jjGameTicks - lastPause;
            lastPause = -1;
        }
    }
    private int lastPause;
    private int lastUpdate;
}

int mincmp(int a, int b)
{
	if (a>b) return b;
	return a;
}

GameTickTimer blizzardTimer;
GameTickTimer blizzardTimerAlt;

class Imitation : jjBEHAVIORINTERFACE {
	private uint8 eventID;
	private jjBEHAVIOR behavior;
	Imitation(uint8 realEventID, uint8 fakeEventID) {
		jjOBJ@ obj = jjObjectPresets[realEventID];
		eventID = obj.eventID;
		behavior = obj.behavior;
		obj.eventID = fakeEventID;
		obj.behavior = this;
	}
	void onBehave(jjOBJ@ obj) override {
		if (obj.state == STATE::DEACTIVATE)
			obj.eventID = eventID;
		obj.behave(behavior);
	}
}

class GiftBox : jjBEHAVIORINTERFACE {
	void destroy(jjOBJ@ obj) {
		jjSample(obj.xPos, obj.yPos, SOUND::COMMON_WOOD1);
		{
			int id = jjAddObject(OBJECT::EXPLOSION, obj.xPos, obj.yPos);
			if (id != 0) {
				jjOBJ@ other = jjObjects[id];
				other.determineCurAnim(ANIM::PICKUPS, 4);
			}
		}
		for (int i = jjRandom() & 7 | 8; i-- != 0;) {
			int id = jjAddObject(OBJECT::SHARD, obj.xPos, obj.yPos);
			if (id != 0) {
				jjOBJ@ other = jjObjects[id];
				other.determineCurAnim(ANIM::PICKUPS, 93 + (jjRandom() & 1));
			}
		}
		obj.yPos -= 8.f;
		for (int i = obj.var[1]; i-- != 0;) {
			int id = jjAddObject(obj.var[0], obj.xPos, obj.yPos);
			if (id != 0) {
				jjOBJ@ other = jjObjects[id];
				if (other.playerHandling == HANDLING::PICKUP) {
					int angle = (jjRandom() & 255) + 128;
					other.xSpeed = jjCos(angle) * 5.f;
					other.ySpeed = jjSin(angle) * -3.f;
				} else if (other.playerHandling == HANDLING::SPECIAL) {
					other.deactivates = false;
				}
			}
		}
		obj.clearPlatform();
		obj.delete();
	}
	void onBehave(jjOBJ@ obj) override {
		switch (obj.state) {
			case STATE::START:
				{
					uint16 x = int(obj.xOrg) >>> 5;
					uint16 y = int(obj.yOrg) >>> 5;
					obj.var[0] = jjParameterGet(x, y, 0, 8);
					obj.var[1] = jjParameterGet(x, y, 8, 4);
					obj.curAnim += jjParameterGet(x, y, 12, 2);
					obj.determineCurFrame();
					obj.bulletHandling = HANDLING::DESTROYBULLET;
					obj.scriptedCollisions = true;
				}
				break;
			case STATE::FALL:
				obj.var[2] = 1;
				break;
			case STATE::FREEZE:
			case STATE::SLEEP:
				if (obj.var[2] != 0) {
					destroy(obj);
					return;
				}
		}
		obj.behave(BEHAVIOR::MONITOR);
	}
	bool onObjectHit(jjOBJ@, jjOBJ@, jjPLAYER@, int) {
		return true;
	}
	bool onIsSolid(jjOBJ@) {
		return true;
	}
}

class SnowEffect : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::STEADYLIGHT);
		obj.deactivates = false;
		obj.light = blizzard && jjLocalPlayerCount == 1 && (jjLocalPlayers[0].lighting > 5 && jjLocalPlayers[0].lighting < 101)? 127:-127;
		obj.xPos = jjLocalPlayers[0].cameraX + 400;
		obj.yPos = jjLocalPlayers[0].cameraY + 300;
	}
}

void loopSound(jjOBJ@ sound) {
	sound.xPos = jjLocalPlayers[0].xPos;
	sound.yPos = jjLocalPlayers[0].yPos;
}

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);
 }
}

void onLevelLoad() {

HH17::setEnemy(OBJECT::DRAGON);
HH17::setEnemy(OBJECT::BAT);
HH17::setEnemy(OBJECT::SUCKER);
SMOKE::POLARBEAR(OBJECT::LIZARD,1+jjDifficulty);
SMOKE::PENGUINATOR(OBJECT::HATTER,1+jjDifficulty);
SMOKE::SNOWMAN(OBJECT::STANDMONKEY, 0, 5, 6, 20, 100, 256,1+jjDifficulty);
SMOKE::SANTAGHOST(OBJECT::FATCHICK,1+jjDifficulty);
SMOKE::ICEGOLEM(OBJECT::TUFTURT,60+jjDifficulty*15);

Imitation(OBJECT::TACO, OBJECT::MILK);
uint src = jjAnimSets[ANIM::CUSTOM[255]].load(0, "SExmas.j2a");
	uint dest = jjAnimSets[ANIM::PICKUPS];
	for (int i = 0; i < 95; i++) {
		const jjANIMATION@ anim = jjAnimations[src + i];
		if (anim.frameCount != 0)
			jjAnimations[dest + i] = anim;
	}
jjAnimSets[ANIM::BRIDGE].load(1, "SExmas.j2a");
	jjAnimSets[ANIM::CUSTOM[0]].load(2, "SExmas.j2a");
	jjObjectPresets[OBJECT::BOMBCRATE].behavior = GiftBox();
	jjObjectPresets[OBJECT::BOMBCRATE].determineCurAnim(ANIM::CUSTOM[0], 0);
	
	jjAnimSets[ANIM::SPIKEBOLL].load(3, "SExmas.j2a");
	jjAnimSets[ANIM::SPIKEBOLL3D].load(3, "SExmas.j2a");
	jjAnimSets[ANIM::SPIKEPLAT].load(4, "SExmas.j2a");
	jjObjectPresets[OBJECT::SPIKEBOLL].killAnim = jjObjectPresets[OBJECT::SPIKEBOLL].determineCurAnim(ANIM::SPIKEBOLL, 0) + 1;
	jjObjectPresets[OBJECT::SPIKEBOLL3D].killAnim = jjObjectPresets[OBJECT::SPIKEBOLL3D].determineCurAnim(ANIM::SPIKEBOLL3D, 0) + 1;
	jjObjectPresets[OBJECT::SPIKEPLATFORM].killAnim = jjObjectPresets[OBJECT::SPIKEPLATFORM].determineCurAnim(ANIM::SPIKEPLAT, 0) + 1;
	jjObjectPresets[OBJECT::SPIKEBOLL].energy = 0;
	
jjSampleLoad(SOUND::WIND_WIND2A, "HH17_lowind.wav");
jjObjectPresets[OBJECT::STEADYLIGHT].behavior = SnowEffect();
 if(jjDifficulty <= 0) {
  tempTimeMax = 4;
 }
 if(jjDifficulty >= 2) {
  tempTimeMax = 2;
 }
 if(jjDifficulty == 1) {
  tempTimeMax = 3;
 }
 gem::restorePlayerGems();
}

void onLevelReload() { 
 if (newMusic == true){
	jjMusicLoad("ForsakenCity.ogg");}
 blizzard = false;
 temperature = 0;
 temperatureTimer = 0;
 temperatureDropping = false;
 onLevelLoad();
 jjPalette.load("Blizzard Night.j2t");
 jjPalette.apply();
 gem::restorePlayerGems();
}

void onLevelBegin() {
 jjPalette.load("Blizzard Night.j2t");
 jjPalette.apply();
 for (uint i = 0; i < 3; i++) {
  jjANIMATION@ animDragon = jjAnimations[jjAnimSets[ANIM::DRAGON] + i];
  for (uint j = 0; j < animDragon.frameCount; j++) {
   jjANIMFRAME@ frame = jjAnimFrames[animDragon + j];
   jjPIXELMAP sprite(frame);
   for (uint x = 0; x < sprite.width; ++x) {
    for (uint y = 0; y < sprite.height; ++y) {
      if (sprite[x,y] >= 3 && sprite[x,y] <= 13) sprite[x,y] += 26;
    }
   }
   sprite.save(frame);
  }
 }
 for (uint i = 0; i < 7; i++) {
  jjANIMATION@ animSucker = jjAnimations[jjAnimSets[ANIM::SUCKER] + i];
  for (uint j = 0; j < animSucker.frameCount; j++) {
   jjANIMFRAME@ frame = jjAnimFrames[animSucker + j];
   jjPIXELMAP sprite(frame);
   for (uint x = 0; x < sprite.width; ++x) {
    for (uint y = 0; y < sprite.height; ++y) {
     if (sprite[x,y] >= 2 && sprite[x,y] <= 13) sprite[x,y] += 62;
    }
   }
   sprite.save(frame);
  }
 }
}

bool onDrawLives(jjPLAYER@ p, jjCANVAS@ canvas) {
 
	//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){
	if(temperature<100)
		canvas.drawString(p.subscreenX+20, p.subscreenY+jjSubscreenHeight-20, "Warm ("+(100-temperature)+"%)", STRING::MEDIUM);
		else if(temperature>=100 && temperature<200)
			canvas.drawString(p.subscreenX+20, p.subscreenY+jjSubscreenHeight-20, "Chilly ("+(200-temperature)+"%)", STRING::MEDIUM, STRING::PALSHIFT);
			else if(temperature>=200 && temperature<300)
				canvas.drawString(p.subscreenX+20, p.subscreenY+jjSubscreenHeight-20, "Frosty ("+(300-temperature)+"%)", STRING::MEDIUM, STRING::PALSHIFT);
					else if(temperature>=300 && jjGameTicks % 8 <= 2)
						canvas.drawString(p.subscreenX+20, p.subscreenY+jjSubscreenHeight-20, "Frigid", STRING::MEDIUM);
	//canvas.drawString(p.subscreenX+20, p.subscreenY+jjSubscreenHeight-40, "blizzardTimer= "+blizzardTimer.read(), STRING::MEDIUM);
	//canvas.drawString(p.subscreenX+20, p.subscreenY+jjSubscreenHeight-60, "blizzardTimerAlt= "+blizzardTimerAlt.read(), STRING::MEDIUM);
 return true;
}

void onPlayer(jjPLAYER@ p) {

gem::trackPlayerGems(p);
gem::upgradeHealth(p);
	
int tempSpeed = 16-temperature/30;
if (tempSpeed < 4)
	tempSpeed = 4;
if (p.xSpeed > tempSpeed)
    p.xSpeed = tempSpeed;
if (p.xSpeed < -tempSpeed)
    p.xSpeed = -tempSpeed;


for (int i = 1; i < jjObjectCount; i++) {
    jjOBJ@ o = jjObjects[i];
    if (o.isActive && o.eventID == OBJECT::PULSELIGHT) {
        if (blizzard){
            blizzardTimer.pause();
			if (blizzardTimerAlt.paused())
                blizzardTimerAlt.restart();
            o.lightType = LIGHT::NONE;
        }
        else{
			blizzardTimerAlt.pause();
            if (blizzardTimer.paused())
                blizzardTimer.restart();
            else if (blizzardTimer.read() == mincmp(blizzardTimerAlt.read()-5,40))
                o.lightType = LIGHT::NORMAL;
        }
		
		//if ( (o.eventID == OBJECT::STANDMONKEY || o.eventID == OBJECT::LIZARD) && o.creatorType == CREATOR::OBJECT)
		
		
		
    }
}

for (int i = 1; i < jjObjectCount; i++) {
    jjOBJ@ o = jjObjects[i];
    if (o.isActive &&  o.eventID == OBJECT::STANDMONKEY && o.creatorType == CREATOR::OBJECT){
        o.light = 1;
		o.lightType = LIGHT::NORMAL;
	}
}

 p.lighting = blizzard && jjLocalPlayerCount == 1? (50 + int(jjSin(jjGameTicks)*5)) : jjLocalPlayerCount > 1? 80 : 60;
 
 if (blizzard == true)
 {
    jjSampleLooped(jjLocalPlayers[0].xPos + 160, jjLocalPlayers[0].yPos + 160, SOUND::WIND_WIND2A, 0, 63, 0);
 }
 
 jjSetDarknessColor(jjPALCOLOR(R,G,B));
 
 if (blizzard) {
			if (R < 210) R+=2;
			else if (R > 210) R-=2;
			if (G < 200) G+=2;
			else if (G > 200) G-=2;
			if (B < 220) B+=2;
			else if (B > 220) B-=2;
		} else {
			if (R < 20) R+=2;
			else if (R > 20) R-=2;
			if (G < 10) G+=2;
			else if (G > 10) G-=2;
			if (B < 60) B+=2;
			else if (B > 60) B-=2;
}
	
 temperatureTimer += 1;

 p.lightType = LIGHT::NONE;
 //temperature is LOWERING
 if(temperatureDropping) {
   if(temperatureTimer > tempTimeMax) {
    temperature += 1;
    temperatureTimer = 0;
  
    if(temperature > 299) {
     p.hurt(1);
    }
   }
  }

 //temperature is RISING
 else {
  if(temperatureTimer > 0) {
	  if(temperature >400){
		  temperature=400;
	  }
   else if(temperature > 0) {
    temperature -= 1;
   }
   temperatureTimer = 0;
  }
 }
 if (blizzard && jjLocalPlayerCount == 1) jjIsSnowing = true;
	else jjIsSnowing = false;
}
void onMain() {
	HH17::handleEnemyProjectiles();
	for (int i = 0; i < 1024; i++) {
		jjPARTICLE@ particle = jjParticles[i];
		if (particle.type == PARTICLE::SNOW) 
			{	particle.xSpeed = -10 + jjSin(jjGameTicks);
				particle.ySpeed = 3 - jjSin(jjGameTicks);
			}
		}
    for (int i = 1; i < jjObjectCount; i++) {
        jjOBJ@ o = jjObjects[i];
        if ( (o.eventID == OBJECT::STANDMONKEY || o.eventID == OBJECT::LIZARD || o.eventID == OBJECT::HATTER) && o.creatorType == CREATOR::OBJECT) {
            o.light = 1;
            o.lightType = LIGHT::LASER;
        }
    }
	gem::deleteCollectedGems();
}
	
void onFunction0(jjPLAYER@ p) {
	blizzard = false;
 if(temperatureDropping) {
  temperatureDropping = false;
  temperatureTimer = 0;
 }
}

void onFunction1(jjPLAYER@ p) {
	blizzard = true;
 if(!temperatureDropping){
  temperatureDropping = true;
  temperatureTimer = 0;
 }
}

void onFunction2(jjPLAYER@ player) {
       player.activateBoss();
}

void onFunction3(jjPLAYER@ p) {
	gem::saveGemData();
	jjNxt(false, false);
}

void onFunction10(jjPLAYER@ p) {
	 if (newMusic == false){
	jjMusicLoad("ForsakenCity.ogg");
	p.showText(10,0);
	}
	newMusic = true;
 }