Jump to content

Photo

Moosh's NPC script-specific request


  • Please log in to reply
12 replies to this topic

#1 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 18 January 2021 - 06:31 PM

Hi guys, I'm using this wonderful script: https://www.purezc.n...=scripts&id=149

 

 

What I need is for a string to play as normal. It will be asking Link for rupees and a specific item. I want it to then only play the "Do you have it yet?" string if you talk to him after. Then, if you have the amount of rupees and items, it changes to another string set, where Link will get an upgraded item. Link holding it up before the last string (Like getting the razor/gilded sword in MM) would play would be cool, but not necessary.

 

If someone could do this for me, I'd be so thankful. :)



#2 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 19 January 2021 - 05:46 PM

const int FONT_UPGRADEITEM = 0; //Font to use for dialogue box options (see std_constants.zh)
const int C_WHITE = 0x01; //The color white

//This is meant to be run by NPCScript_Simple by setting D1 on that script to this script's slot ID
//D2: First of four (or five) messages to play (these need to all be in numbered order in the string editor)
//		-The message when you first talk to the guy
//		-The message when you talk to him after the first time
//		-The message on a successful trade
//		-The message on a failed trade (not enough rupees or lacking the item)
//		-The message when you speak again after trading
//
//D3: The item to check for
//D4: The item to give Link
//D5: The rupee cost
//D6: The Screen->D[] index to use for tracking this NPC's state
//D7: If 1, the trade is single use and the fifth message string will be played if you talk to the guy again
ffc script UpgradeItem{
	void run(int msgStrings, int itemCheck, int itemGive, int cost, int dIndex, bool oneTime){
		//States 0 - Hasn't talked, 1 - Has talked, hasn't traded, 2 - Already traded
		
		//Already traded
		if(Screen->D[dIndex]==2){
			Screen->Message(msgStrings+4);
			WaitNoAction();
			Quit();
		}
		else{
			//After first interaction
			if(Screen->D[dIndex]==1){
				Screen->Message(msgStrings+1);
				WaitNoAction();
			}
			//First interaction
			else{
				Screen->Message(msgStrings);
				WaitNoAction();
				Screen->D[dIndex] = 1;
			}
			int yes[] = "Yes";
			int no[] = "No";
			int options[] = {yes, no};
			int result = DialogueBox_Run(128, 80, options, TIL_DB_DIALOGUE_BOX, CS_DB_DIALOGUE_BOX, C_DB_DIALOGUE_BOX_BG, FONT_UPGRADEITEM, C_WHITE, TIL_DB_DIALOGUE_SELECTOR, CS_DB_DIALOGUE_SELECTOR);
			if(result==0){
				if(Link->Item[itemCheck]&&Game->Counter[CR_RUPEES]+Game->DCounter[CR_RUPEES]>=cost){
					Game->DCounter[CR_RUPEES] -= cost;
					
					//Successful trade
					Screen->Message(msgStrings+2);
					WaitNoAction();
					
					//Give Link the item
					item itm = CreateItemAt(itemGive, Link->X, Link->Y);
					itm->Pickup = IP_HOLDUP;
					this->Flags[FFCF_IGNOREHOLDUP] = true;
					while(itm->isValid()){
						itm->X = Link->X;
						itm->Y = Link->Y;
						WaitNoAction();
					}
					
					//Flag the trade as completed if it's a one time deal
					if(oneTime)
						Screen->D[dIndex] = 2;
					this->Flags[FFCF_IGNOREHOLDUP] = false;
				}
				else{
					//Failed trade
					Screen->Message(msgStrings+3);
					WaitNoAction();
				}
			}
		}
	}
}
Here you go. This depends on DialogueBox.zh to do the popup menu and NPCScript_Simple to launch the script from. In this case you can leave the NPC's string as 0 since this new script will run all the strings for it.

Edited by Moosh, 21 January 2021 - 09:24 PM.

  • ShadowTiger likes this

#3 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 19 January 2021 - 07:30 PM

Thanks so much Moosh! I'll test it soon. I'll reach out on Discord if I have any problems.



#4 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 31 January 2021 - 07:14 PM

Hi guys, I had another request for this script. I was told Moosh's addon script would help with this.

 

I need a script where once Link talks to the FFC, the FFC disappears and the screen secrets trigger permanently. If anyone could help with this, I'd be super grateful. I'm getting close to the point where I can show off my quest!



#5 Mitchfork

Mitchfork

    no fun. not ever.

  • Contributors
  • Real Name:Mitch
  • Location:Alabama

Posted 31 January 2021 - 08:02 PM

There are a couple different scripts inside Moosh's NPC script, so I am just providing the general solution...

Moosh's script calls the screen message with "Screen->Message(msg);" This function will wait until the message is cleared before moving on, so you can put the following code right under that line:

Screen->State[ST_SECRET] = true;
Screen->TriggerSecrets();
Audio->PlaySound(Screen->SecretSFX);
this->Data = 0;
Quit();

Which will trigger secrets, play the sound, clear the FFC, and quit the script.

 

Just glancing at Moosh's script there are separate Screen->Message calls for each direction, so you'll have to put it the script four times.

 

If you know what script (normal, simple, or a modified version of either one that you already have) I can put this in the right place as well.


Edited by Mitchfork, 31 January 2021 - 08:04 PM.

  • Jared likes this

#6 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 31 January 2021 - 09:08 PM

I usually use the normal, but maybe for this instance it would be good for the simple NPC script? I'm not fussy.

 

Also, thank you. :)



#7 Mitchfork

Mitchfork

    no fun. not ever.

  • Contributors
  • Real Name:Mitch
  • Location:Alabama

Posted 31 January 2021 - 11:28 PM

Then I think this will work for you... it's untested though, so let me know if you have any issues with it. If you want the secret to be silent (or use some other sound) just set a different sound in the Screen Data menu.
Spoiler

  • Jared likes this

#8 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 01 February 2021 - 09:38 PM

Thank you so much! Do I set it up in a similar fashion, where D0 is the script slot for the simple secret script? And D1 is the string number I assume?



#9 Mitchfork

Mitchfork

    no fun. not ever.

  • Contributors
  • Real Name:Mitch
  • Location:Alabama

Posted 01 February 2021 - 11:00 PM

Yep, exact same parameters as the normal Simple NPC.

#10 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 02 February 2021 - 06:46 PM

So the script works! But it seems to activate the second I talk to the NPC. Is there a way to make the secret trigger after the text box closes?

 

Edit- the FFC (the NPC) seems to reappear as well, but the secrets stay activated.


Edited by Jared, 02 February 2021 - 06:48 PM.


#11 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 03 February 2021 - 12:09 AM

Fixed the timing issue with Jared on Discord. Here's the updated script:

Spoiler

  • Mitchfork and Jared like this

#12 Mitchfork

Mitchfork

    no fun. not ever.

  • Contributors
  • Real Name:Mitch
  • Location:Alabama

Posted 03 February 2021 - 12:32 AM

Oh, duh.  Forgot to add the Waitframe there.  Thanks Moosh!



#13 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 03 February 2021 - 06:52 PM

Just want to thank both of you once more. :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users