Downloads containing invisibilitycarrot.asc

Downloads
Name Author Game Mode Rating
JJ2+ Only: Anniversary Bash 25 Battle Jazz2Online Battle N/A Download file
TSF with JJ2+ Only: Anniversary Bash 24 Battle Jazz2Online Battle N/A Download file
TSF with JJ2+ Only: Anniversary Bash 22 levels Jazz2Online Multiple N/A Download file
TSF with JJ2+ Only: The AbyssFeatured Download PurpleJazz Battle 9.8 Download file

File preview

#pragma require "invisibilitycarrot.asc"

namespace InvisibilityCarrot {
	int invisibilityTime;

	void loadPresets(OBJECT::Object eventID) {
		jjObjectPresets[eventID].scriptedCollisions = true;
		jjObjectPresets[eventID].determineCurAnim(ANIM::PICKUPS, 72);
		jjObjectPresets[eventID].determineCurFrame();
		jjObjectPresets[eventID].behavior = InvisibilityCarrot();
	}
	
	class InvisibilityCarrot : jjBEHAVIORINTERFACE {
		void onBehave(jjOBJ@ obj) {
			obj.behave(BEHAVIOR::PICKUP);
		}
		bool onObjectHit(jjOBJ@ obj, jjOBJ@ bull, jjPLAYER@ play, int force) {
			play.invisibility = true;
			play.timerTime = invisibilityTime;
			jjSample(obj.xPos, obj.yPos, SOUND::INTRO_END);
			obj.behavior = BEHAVIOR::EXPLOSION2;
			obj.scriptedCollisions = false;
			obj.frameID = 0;
			
			return true;
		}
	}
	
	void playerSettings(jjPLAYER@ play) {
		if (play.invisibility) jjDrawSpriteFromCurFrame(play.xPos, play.yPos, play.curFrame, play.direction, SPRITE::BLEND_LUMINANCE, 100, 4, 4);
		
		if (play.invisibility && play.timerState == TIMER::STOPPED) play.timerStart(invisibilityTime);
		if (!play.invisibility) play.timerStop();
		if (play.timerState == TIMER::STARTED && play.timerTime <= 3*70 && play.timerTime > 0 && play.timerTime % 70 == 0) jjSamplePriority(SOUND::COMMON_NOCOIN);
		if (play.timerTime == 1) {
			play.invisibility = false;
			jjSamplePriority(SOUND::COMMON_SHLDOF3);
		}
	}
	
	void drawPlayers() {
		for (int i = 0; i < 32; i++) {
			jjPLAYER@ invisiblePlayer = jjPlayers[i];
			if (invisiblePlayer.invisibility && !invisiblePlayer.isLocal) jjDrawSpriteFromCurFrame(invisiblePlayer.xPos, invisiblePlayer.yPos, invisiblePlayer.curFrame, invisiblePlayer.direction, SPRITE::BLEND_LUMINANCE, invisiblePlayer.keyFire? 100:15, 4, 4);
		}
	}
	
	void drawTimer(jjPLAYER@ play, jjCANVAS@ canvas) {
	    if (play.invisibility == true) {
      		canvas.drawString(
				jjSubscreenWidth - 73,
	      		jjSubscreenHeight - 284,
	      		"" + (play.timerTime + 70) / 70,
	      		STRING::LARGE,
	      		STRING::PALSHIFT,
	      		play.timerTime > 3*70?
	      			0 :
	      			jjGameTicks % 28 > 14?
	      				-40 :
	      				-24
			);
		
			canvas.drawSprite(
				jjSubscreenWidth - 90,
				jjSubscreenHeight - 270,
				ANIM::PICKUPS,
				72, 
				jjGameTicks >> 2
			);
		}
	}
}