Jump to content

Photo

(2.55) Bundled Script Folder


  • Please log in to reply
2 replies to this topic

Poll: (2.55) Bundled Script Folder

Would the existence of these scripts coming together with ZC 2.55 make you more excited to make a 2.55 quest?

You cannot see the results of the poll until you have voted. Please login and cast your vote to see the results of this poll.
Vote Guests cannot vote

#1 P-Tux7

P-Tux7

    💛

  • Members

Posted 10 July 2021 - 04:48 PM

ZC 2.55 has some interesting new features for scripting, but many non-scripting users do not know where to begin with these features. Some new scripted features have been included in the default quest.dat for 2.53, such as the Z2 Candle, Slash/Half Magic Scrolls, Magic Map/Compass/Boss Key, Sign FFC, Permanent Shutters, Permanent Block Puzzle, Boss Music, Boss Explosion, ItemSound, Multiple Heart Piece Messages, and Toggle 4/8-way Movement, but it's impractical to include every type of simple script in quest.dat, right?

So here is my proposed solution: a folder included with ZC 2.55 (one of the next alphas, or at least the full version) that has .txt files containing simple scripts that are easy for the end user to add in and compile. Not only will this reduce complaints about "non-existent features" that are easy enough to produce with scripts, but it will also give the user code examples that they can reverse-engineer to aid them in learning ZScript.

 

Please note that I only have a few of these code snippets on-hand - I am relying on the word of experienced scripters and/or the ZScript documentation that these should be short and easy for the ZC devs to write, and for the ZC users to import into a quest.

(Perhaps to sort them better in the folder, their names should have prefixes or they should be grouped in sub-folders by type.)

Spoiler

 

(More suggestions are welcome, as there are interesting slot types such as ItemData, ItemSprite, and Combo that I do not have many concepts for yet)

 

While this may sound like a lot of work to write and comment these scripts, it's actually far less than it would be to make all of these concepts editable in the ZQuest GUI, and it has the added bonus of (hopefully) ZERO ZQuest/Player recompiles needed to "add" all of these "new features". If this solution is added I am sure that the complaints of "ZC 2.55 could be offering more to the average user in terms of quality of life and to show what 2.55 is capable of outside the base engine." would disappear overnight, and people would be almost as excited to make new quests in 2.55 as they were for 2.50 when it came out (and 1.90/1.92). And just in case, I have included a poll just to make sure whether or not this is considered worthwhile before we do anything.


Edited by P-Tux7, 10 July 2021 - 05:15 PM.

  • Anthus, Shane, Alucard648 and 1 other like this

#2 Alucard648

Alucard648

    Wizard

  • Members
  • Location:castle Dracula

Posted 11 July 2021 - 09:50 AM

Here are some small scripts that I have found on my backup hard drive. 2.53.

const int SFX_DROP_ITEM = 7; //Sound to play on dropping item.

//Triggers secrets when specific enemy dies.
//Place anywhere in the screen.
//DO: Enemy Slot
//D1: Set to anything > 0 for secret permanency.
ffc script EnemySecret{ 
	void run (int enemyslot, int perm){
		Waitframes(4); //Needed for ZC for initialize enemies
		npc trigger = Screen->LoadNPC(enemyslot); // Get a pointer for needed enemy
		while ( trigger->isValid()) Waitframe(); //Wait until enemy dies.
		Screen->TriggerSecrets(); // Trigger secrets
		Game->PlaySound(SFX_SECRET); //Play secret discovery jingle.
		if (perm>0) Screen->State[ST_SECRET]=true; //Set screen state to render secrets permanent.
	}
}

//Kills all enemies when specific screen state is set.
//Place anywhere in the screen.
//D0: Screen State to check. Refer to stdConstants.zh for determining which number to set.
ffc script SecretKillAllEnemies{ 
	void run(int state){
		Waitframes(4); // Needed to allow engine to initialize enemies
		while (!Screen->State[state]) Waitframe(); // Wait until desired screen state is set to true 
		for (int i=1; i<= Screen->NumNPCs(); i++){ // Kill all enemies on screen
			npc kill= Screen->LoadNPC(i);
			kill->HP=0;
		}
	}
}


// Triggers secrets when specific screen state is set
//Place anywhere in the screen.
//D0: Screen State to check. Refer to stdConstants.zh for determining which number to set.
//D1: Set to 1 to render secrets permanent.
//D2: Set Screen State to "false" on reentering for reusability (useful for 2.10-styled bosses).
//    Any number > 0 activates this function.
ffc script ScreenStateTrigger{ 
	void run (int state, int perm, int falsestart){
		if (falsestart>0) Screen->State[state]=false; // Set the screen state to false if needed (like reusable ambush trap)
		while (!Screen->State[state]) Waitframe(); // Wait until screen state is set to true.
		Game->PlaySound(SFX_SECRET); //Trigger screen secrets, complete with all accessories.
		Screen->TriggerSecrets();
		if (perm>0) Screen->State[ST_SECRET]=true;
	}
}

// Drops Screen`s Special Item when combo underneath FFC
//changes into another one. Works just like flag 10 but more versatile.
//Place the FFC where you want to drop item.
//No arguments needed.
ffc script SpecialItemDropper{
	void run(){ //Yes! No arguments needed!
		if (Screen->State[ST_SPECIALITEM]) Quit(); //Special item is already gone.
		int loc = ComboAt (this->X+8,this->Y+8);// Get combo location given it`s X and Y values.
		int origcombo = Screen->ComboD[loc]; //Set original combo.
		if (Screen->RoomType != RT_SPECIALITEM) Quit(); //Quit if room type is not "Special Item"
		int dropitem= Screen->RoomData; //See "Catch All" menu to set special item.
		if (dropitem == 0) Quit(); //No item set. Finita la comedia.
		while (Screen->ComboD[loc] == origcombo) Waitframe(); //Wait until combo changes into another one.
		Game->PlaySound(SFX_DROP_ITEM); //Play item drop jingle.
		item prize= Screen->CreateItem(dropitem); //Create Special Item.
		prize->X=this->X; //Place it at FFC`s position.
		prize->Y=this->Y;
		prize->Pickup=0x802; // Set pickup flags to "Hold up item on pickup" and "Set Special Item screen state".
	}
}

//Checks specific screen state and drops Screen`s Special Item, if set to TRUE.
//Place the FFC where you want to drop item. 
//D0: Screen state to check. Refer to stdConstants.zh for various screen states.
ffc script StateSpecialItem{
	void run (int state){
		int framespassed =0; // Time spent in that screen, in frames. 
		if (Screen->State[ST_SPECIALITEM]) Quit(); //Special item is already gone.
		if (Screen->RoomType != RT_SPECIALITEM) Quit(); //Quit if room type is not "Special Item"
		int dropitem= Screen->RoomData; //See "Catch All" menu to set special item.
		if (dropitem == 0) Quit(); ////No item set. Finita la comedia.
		while (!Screen->State[state]){ //Wait until screen state is set to TRUE, while 'Frames passed" ticks up.
			framespassed++;
			Waitframe();
		}
		if (framespassed) Game->PlaySound(SFX_DROP_ITEM); //If the screen state was already TRUE, no secret discovery jingle will play.
		item prize= Screen->CreateItem(dropitem); //Create Special Item.
		prize->X=this->X; //Place it at FFC`s position.
		prize->Y=this->Y;
		prize->Pickup=0x802; // Set pickup flags to "Hold up item on pickup" and "Set Special Item screen state".
	}
}

//Works similar to level 9 entrance room, but can require any number of Triforce pieces.
//Place anywherer on the screen.
//D0 - Number of pieses required.
//D1 - String to display if not enough.
ffc script TriforceSecret{
	void run(int numpieces, int message){
		if (Screen->State[ST_SECRET]) Quit();
		if (NumTriforcePieces()>=numpieces){
			Screen->TriggerSecrets();
			Screen->State[ST_SECRET] = true; 
		}
		else Screen->Message(message);
	}
}

//Wins the quest immediately and boots player straight to file select screen, 
//like in Moosh`s demo quests.
//Assign this script to Triforce`s onPickup script slot.
item script TriforceWinGame{
	void run(){
		Game->End();
	}
}

//Painting placed on wall or sign board. Stand near it and press either A or B to display image.
//Place FFC on the signboard or painting
//D0 - Top Left corner of image
//D1 - Image width, in tiles.
//D2 - Image height, in tiles.
//D3 - Cset used for drawing.
//D4 - X offset of image drawn
//D5 - Y offset of image drawn
ffc script PaintingSignboard{
	void run(int tile, int xsize, int ysize, int cset, int Xoffset, int Yoffset){
		while(true){
			if (LinkCollision(this)){
				if  ( Link->PressA || Link->PressB ){
					NoAction();
					Waitframe();
					while (LinkCollision(this)){// Stop rendering painting, when Link walks away from it. 
						if (Link->PressA) break;// Stop rendering painting, when button is pressed.
						if (Link->PressB) break;
						Screen->DrawTile(5, (128-8*xsize)+Xoffset, (88-8*ysize)+Yoffset, tile, xsize, ysize, cset, -1, -1, 0, 0, 0, 0, false, OP_OPAQUE);
						Waitframe();
					}
				}
			}
			Waitframe();
		}
	
	}
}

Edited by Alucard648, 11 July 2021 - 09:51 AM.


#3 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 28 February 2022 - 09:07 AM

Most of what you are writing about is in classic.zh, intended for 2.53.x
I have no clue what will be on 2.55 now, but these scripts do serve a purpose across builds.

If at some point they do not, and are internal, then they can of course be removed.

Things such as Z2 candle and other facets were not in 2.53.x, and afaik are still not (and should not be) in that version.

Edited by Timelord, 28 February 2022 - 09:09 AM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users