Downloads containing limitedoxygen.asc

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Anniversary Bash 26 CTF Jazz2Online Capture the flag N/A Download file
TSF with JJ2+ Only: Anniversary Bash 26 Battle Jazz2Online Battle N/A Download file
TSF with JJ2+ Only: Freeport Loon Battle N/A Download file
TSF with JJ2+ Only: Anniversary Bash 24 CTF Jazz2Online Capture the flag N/A Download file
TSF with JJ2+ Only: Syri i KaltërFeatured Download Loon Capture the flag 9 Download file
TSF with JJ2+ Only: Giant's StepsFeatured Download PurpleJazz Capture the flag 9.2 Download file
TSF with JJ2+ Only: Anniversary Bash 22 levels Jazz2Online Multiple N/A Download file
TSF with JJ2+ Only: Anniversary Bash 21 Levels Jazz2Online Multiple N/A Download file
TSF with JJ2+ Only: Anniversary Bash 20 Levels Jazz2Online Multiple N/A Download file
JJ2+ Only: ThermaeFeatured Download Jelly Jam Battle 8.5 Download file
TSF with JJ2+ Only: Fishing VillageFeatured Download PurpleJazz Capture the flag 9 Download file

File preview

#pragma require "limitedoxygen.asc"

namespace water {
	int maxOxygen;
	array<int> oxygen(4), count(4);
	
	bool underwater(jjPLAYER@ play) {
		return play.yPos > jjWaterLevel;
	}
	
	bool gameIsStarted() {
		return jjGameState == GAME::STARTED || jjGameState == GAME::PREGAME || jjGameState == GAME::OVERTIME;
	}
	
	void limitedOxygen(jjPLAYER@ play) {		
		if (underwater(play)) {
			if (oxygen[play.localPlayerID] > 0 && gameIsStarted()) oxygen[play.localPlayerID]--;
		} else {
			oxygen[play.localPlayerID] = maxOxygen;
			count[play.localPlayerID] = maxOxygen > 350? 6 : uint(maxOxygen/70);
		}
		
		jjPARTICLE@ particle = jjAddParticle(PARTICLE::STRING);
        if (particle !is null && oxygen[play.localPlayerID] > 0 && oxygen[play.localPlayerID] < 351 && oxygen[play.localPlayerID] % 70 == 0 && play.health > 0 && underwater(play)) {
			if (count[play.localPlayerID] > 0) count[play.localPlayerID]--;
            particle.xPos = play.xPos;
			particle.yPos = play.yPos;
			particle.string.text = "|||" + count[play.localPlayerID];
			particle.ySpeed = -0.05;
			jjSample(play.xPos, play.yPos - 16, SOUND::AMMO_BLUB1);
		}
		
		if (oxygen[play.localPlayerID] == 0) {
			if (jjActiveGameTicks % 90 == 0 && play.health > 0 && gameIsStarted()) drown(play);
		}
	}
	
	void drown(jjPLAYER@ play) {
		if (play.health > 1) play.health = play.health - 1;
		else play.kill();
		play.blink = 45;
		randomHurtSample(play);
	}
	
	void randomHurtSample(jjPLAYER@ play) {
		SOUND::Sample sample = SOUND::JAZZSOUNDS_HEY2;
		switch (jjRandom()%4) {
			case 0: sample = play.charCurr == CHAR::JAZZ? SOUND::JAZZSOUNDS_HEY2 : play.charCurr == CHAR::SPAZ? SOUND::SPAZSOUNDS_AUTSCH1 : SOUND::LORISOUNDS_HURT0; break;
			case 1: sample = play.charCurr == CHAR::JAZZ? SOUND::JAZZSOUNDS_HEY3 : play.charCurr == CHAR::SPAZ? SOUND::SPAZSOUNDS_AUTSCH2 : SOUND::LORISOUNDS_HURT1; break;
			case 2: sample = play.charCurr == CHAR::JAZZ? SOUND::JAZZSOUNDS_HEY4 : play.charCurr == CHAR::SPAZ? SOUND::SPAZSOUNDS_BURP : SOUND::LORISOUNDS_HURT2; break;
			case 3: sample = play.charCurr == CHAR::JAZZ? SOUND::JAZZSOUNDS_JAZZV4 : play.charCurr == CHAR::SPAZ? SOUND::SPAZSOUNDS_OOOH : SOUND::LORISOUNDS_HURT7; break;
		}
		jjSample(play.xPos, play.yPos, sample);
	}
	
	void drawOxygenTimer(jjPLAYER@ play, jjCANVAS@ canvas) {
		int oxygenPercent = int(oxygen[play.localPlayerID]/(maxOxygen/100));
		int textColor = oxygenPercent > 50? 224 : oxygenPercent > 20? 232 : 216;
		
		if (underwater(play)) {
			canvas.drawSprite(jjSubscreenWidth - 68, 73, ANIM::AMMO, 8, jjGameTicks >> 2, 0, SPRITE::TRANSLUCENT);
			canvas.drawString(jjSubscreenWidth - 58, 72, "" + (oxygenPercent > 100? 100 : oxygenPercent) + "%", STRING::MEDIUM, STRING::PALSHIFT, textColor);
		}
	}
}