Copy to Clipboard Test

Seashell Mansion Code

const int SCREEN_D_SEASHELL_MANSION_PROGRESS = 0;//Screen D to track seashell mansion progress

const int SEASHELL_MANSION_PROGRESS_ASPEED = 2;//Delay between incrementals of progression rendering
const int SEASHELL_MANSION_PROGRESS_DELAY = 90;//Delay between screen entering and progression evaluation

const int SFX_SEASHELL_MANSION_PROGRESS = 16;//Sound to play on progression incremental
const int SFX_SEASHELL_MANSION_REWARD = 32;//Sound to play when reward is triggered on hitting threshold

const int SEASHELL_MANSION_PROGRESS_RENDER_MULTIPLIER = 2;//Image height per unit of progress

const int LAYER_SEASHELL_MANSION_PROGRESS_RENDER = 4;//Layer to render progress bar on.

const int TILE_SEASHELL_MANSION_PROGRESS_RENDER = 14654;//Tile used for rendering progress indicator as it fills. Must be SEASHELL_MANSION_PROGRESS_RENDER_MULTIPLIER tall, starting from top, rest of it must be transparent.
const int CSET_SEASHELL_MANSION_PROGRESS_RENDER = 7;//CSet used for rendering progress indicator as it fills.
const int TILE_SEASHELL_MANSION_PROGRESS_GOALS_RENDER = 14655;//Tile used for rendering unclaimed progress goals. 
const int CSET_SEASHELL_MANSION_PROGRESS_GOALS_RENDER = 8;//CSet used for rendering unclaimed progress goals. 

//Link`s Remakening Seashell mansion

//When Link enters screen with this FFC script active, an indicator starts filling until it equals to total specific counter collected (existing, or consumed on progress fill). Once it reaches specific thresholds, rewards triggered (secrets or items).

//1. Set up 2 tiles, 1 for vertical progress bar, must be SEASHELL_MANSION_PROGRESS_RENDER_MULTIPLIER tall, starting from top, rest of it must be transparent. and other one for goal indicators. Assign TILE_SEASHELL_MANSION_PROGRESS_RENDER and TILE_SEASHELL_MANSION_PROGRESS_GOALS_RENDER to these tile IDs.
//2. Import and compile the script. No dependencies beyond std.zh.
//3. Place invisible FFC right under progress bar frame, which is built using normal combos.
//   D0  - Abs -  Counter to track. <0 - consume counter on progress increment.
//   D1-D6 - counter costs, for each threshold and rewards:
//      #####.____ - counter cost.
//      _____.#### - reward. If argument is negative - secrets triggered on threshold.
//   D7 #####.____ - String to display when no progress has been made when screen with FFC is entered. For instance, when entering Seashell Mansion for the 1st time.
//   D7 _____.#### - String to display when all rewards from this Seashell Mansion have been claimed.

ffc script SeashellMansion{
	void run (int counter, int reward1, int reward2, int reward3, int reward4, int reward5, int reward6, int strings){
		int costs[6];
		int rewards[6];
		for (int i=0;i<6;i++){
			costs[i] =  Abs(GetHighFloat(this->InitD[i+1]));
			rewards[i] = GetLowFloat(this->InitD[i+1]);
		}
		counter = Abs(counter);
		int progress = Screen->D[SCREEN_D_SEASHELL_MANSION_PROGRESS];
		int claimed = 0;
		while (claimed<6){//skip zero cost thresholds
			if (costs[claimed]>progress) break;
			claimed++;
		}
		int timer = -SEASHELL_MANSION_PROGRESS_DELAY;
		int introstr = GetHighFloat(this->InitD[7]);
		int endstr = GetLowFloat(this->InitD[7]);
		if (introstr>0 && progress==0) Screen->Message(introstr);
		//if (claimed==6) Screen->Message(endstr);
		while(true){
			if (claimed<6){
				if (this->InitD[0]>0){
					if (Game->Counter[counter]> progress) timer++;
				}
				else{
					if (Game->Counter[counter]> 0) timer++;
				}
			}
			if (timer>=SEASHELL_MANSION_PROGRESS_ASPEED){
				Game->PlaySound(SFX_SEASHELL_MANSION_PROGRESS);
				if (this->InitD[0]<0)Game->Counter[counter]--;
				progress++;
				Screen->D[SCREEN_D_SEASHELL_MANSION_PROGRESS]++;
				if (progress>=costs[claimed]){//rewards
					Game->PlaySound(SFX_SEASHELL_MANSION_REWARD);
					if (this->InitD[claimed+1]<0){
						Game->PlaySound(SFX_SECRET);
						Screen->TriggerSecrets();
						Screen->State[ST_SECRET]=true;
					}
					else{
						item it = CreateItemAt(rewards[claimed], Link->X, Link->Y);
						it->Pickup +=IP_HOLDUP;
					}
					claimed++;
					while (claimed<6){
						if (costs[claimed]>0) break;
						claimed++;
					}
					if (claimed==6){
						Screen->Message(endstr);
					}
				}
				timer=0;
			}
			for (int i=0; i<progress; i++){
				Screen->FastTile(LAYER_SEASHELL_MANSION_PROGRESS_RENDER, this->X, this->Y-SEASHELL_MANSION_PROGRESS_RENDER_MULTIPLIER-i*SEASHELL_MANSION_PROGRESS_RENDER_MULTIPLIER, TILE_SEASHELL_MANSION_PROGRESS_RENDER, CSET_SEASHELL_MANSION_PROGRESS_RENDER, OP_OPAQUE);
			}
			for (int i=claimed; i<6; i++){
				if (costs[i]>0)Screen->FastTile(LAYER_SEASHELL_MANSION_PROGRESS_RENDER, this->X, this->Y-SEASHELL_MANSION_PROGRESS_RENDER_MULTIPLIER*costs[i],TILE_SEASHELL_MANSION_PROGRESS_GOALS_RENDER,CSET_SEASHELL_MANSION_PROGRESS_GOALS_RENDER, OP_OPAQUE);
			}
			Waitframe();
		}
	}
}