Downloads containing limitedoxygen.asc

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Anniversary Bash 21 Levels Jazz2Online Multiple N/A Download file
TSF with JJ2+ Only: Giant's StepsFeatured Download PurpleJazz Capture the flag 8.9 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

  1. #pragma require "limitedoxygen.asc"
  2.  
  3. namespace water {
  4.         int maxOxygen;
  5.         array<int> oxygen(4), count(4);
  6.        
  7.         bool underwater(jjPLAYER@ play) {
  8.                 return play.yPos > jjWaterLevel;
  9.         }
  10.        
  11.         bool gameIsStarted() {
  12.                 return jjGameState == GAME::STARTED || jjGameState == GAME::PREGAME || jjGameState == GAME::OVERTIME;
  13.         }
  14.        
  15.         void limitedOxygen(jjPLAYER@ play) {           
  16.                 if (underwater(play)) {
  17.                         if (oxygen[play.localPlayerID] > 0 && gameIsStarted()) oxygen[play.localPlayerID]--;
  18.                 } else {
  19.                         oxygen[play.localPlayerID] = maxOxygen;
  20.                         count[play.localPlayerID] = maxOxygen > 350? 6 : uint(maxOxygen/70);
  21.                 }
  22.                
  23.                 jjPARTICLE@ particle = jjAddParticle(PARTICLE::STRING);
  24.         if (particle !is null && oxygen[play.localPlayerID] > 0 && oxygen[play.localPlayerID] < 351 && oxygen[play.localPlayerID] % 70 == 0 && play.health > 0 && underwater(play)) {
  25.                         if (count[play.localPlayerID] > 0) count[play.localPlayerID]--;
  26.             particle.xPos = play.xPos;
  27.                         particle.yPos = play.yPos;
  28.                         particle.string.text = "|||" + count[play.localPlayerID];
  29.                         particle.ySpeed = -0.05;
  30.                         jjSample(play.xPos, play.yPos - 16, SOUND::AMMO_BLUB1);
  31.                 }
  32.                
  33.                 if (oxygen[play.localPlayerID] == 0) {
  34.                         if (jjActiveGameTicks % 90 == 0 && play.health > 0 && gameIsStarted()) drown(play);
  35.                 }
  36.         }
  37.        
  38.         void drown(jjPLAYER@ play) {
  39.                 if (play.health > 1) play.health = play.health - 1;
  40.                 else play.kill();
  41.                 play.blink = 45;
  42.                 randomHurtSample(play);
  43.         }
  44.        
  45.         void randomHurtSample(jjPLAYER@ play) {
  46.                 SOUND::Sample sample = SOUND::JAZZSOUNDS_HEY2;
  47.                 switch (jjRandom()%4) {
  48.                         case 0: sample = play.charCurr == CHAR::JAZZ? SOUND::JAZZSOUNDS_HEY2 : play.charCurr == CHAR::SPAZ? SOUND::SPAZSOUNDS_AUTSCH1 : SOUND::LORISOUNDS_HURT0; break;
  49.                         case 1: sample = play.charCurr == CHAR::JAZZ? SOUND::JAZZSOUNDS_HEY3 : play.charCurr == CHAR::SPAZ? SOUND::SPAZSOUNDS_AUTSCH2 : SOUND::LORISOUNDS_HURT1; break;
  50.                         case 2: sample = play.charCurr == CHAR::JAZZ? SOUND::JAZZSOUNDS_HEY4 : play.charCurr == CHAR::SPAZ? SOUND::SPAZSOUNDS_BURP : SOUND::LORISOUNDS_HURT2; break;
  51.                         case 3: sample = play.charCurr == CHAR::JAZZ? SOUND::JAZZSOUNDS_JAZZV4 : play.charCurr == CHAR::SPAZ? SOUND::SPAZSOUNDS_OOOH : SOUND::LORISOUNDS_HURT7; break;
  52.                 }
  53.                 jjSample(play.xPos, play.yPos, sample);
  54.         }
  55.        
  56.         void drawOxygenTimer(jjPLAYER@ play, jjCANVAS@ canvas) {
  57.                 int oxygenPercent = int(oxygen[play.localPlayerID]/(maxOxygen/100));
  58.                 int textColor = oxygenPercent > 50? 224 : oxygenPercent > 20? 232 : 216;
  59.                
  60.                 if (underwater(play)) {
  61.                         canvas.drawSprite(jjSubscreenWidth - 68, 73, ANIM::AMMO, 8, jjGameTicks >> 2, 0, SPRITE::TRANSLUCENT);
  62.                         canvas.drawString(jjSubscreenWidth - 58, 72, "" + (oxygenPercent > 100? 100 : oxygenPercent) + "%", STRING::MEDIUM, STRING::PALSHIFT, textColor);
  63.                 }
  64.         }
  65. }