Jump to content

Photo

Hold up Item before Message String?


  • Please log in to reply
41 replies to this topic

#31 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 28 July 2017 - 06:03 AM

Confirmed. I did not turn on that screen flag.

 

const int __LA_HOLDUP_HANDS = 1; //The number of hands to use for the default hold-up animation.

//D0 Integer: Number of Message String to display if Link is near the bottom of the screen
//D0 Decimal: Number of Message String to display if Link is near the top of the screen
//D1 Integer: ID of Item that prevents Message String from being displayed
//D1 Decimal: ID of item to hold up. Set to '0' for no hold-up animation.

const int SFX_HOLD_ITEM_FANFARE = 63; //Change to the sound that you want. 

item script AdvPickUpMessage
{
	void run(int stringA_stringB, int stringPreventItemID_this_item_id)
	{
		bool foundff;
		int stringA = stringA_stringB << 0;
		int stringB = ( stringA_stringB - stringA ) * 10000;
		int stringPreventItemID = stringPreventItemID_this_item_id << 0;
		int this_item_id = ( stringPreventItemID_this_item_id - stringPreventItemID ) * 10000;
		if ( !Link->Item[stringPreventItemID] )
		{
			if ( this_item_id > 0 && this_item_id < 256 )
			{
				if ( Link->Action == LA_DIVING ) 
				{
					int fff[]="DiveHoldUp";
					for ( int q = 32; q > 0; q-- )
					{
						ffc f = Screen->LoadFFC(q);
						if ( f->Data == 0 )
						{
							if ( f->Script == 0 )
							{
								foundff = true;
								f->Data = 1;
								f->Script = Game->GetFFCScript(fff);
								f->InitD[0] = this_item_id;
								f->InitD[1] = stringA;
								f->InitD[2] = stringB;
								break;
							}
						}
					}
					if ( !foundff )
					{
						int ferr[]="Cound not find a free ffc slot to run the ffc script for item script AdvPickupMessage";
						TraceS(ferr);
					}
					Quit();
				}
			
				else if ( Link->Action == LA_SWIMMING  )
				{
					int ff[]="swimHoldUp";
					for ( int q = 32; q > 0; q-- )
					{
						ffc f = Screen->LoadFFC(q);
						if ( f->Data == 0 )
						{
							if ( f->Script == 0 )
							{
								foundff = true;
								f->Data = 1;
								f->Script = Game->GetFFCScript(ff);
								f->InitD[0] = this_item_id;
								f->InitD[1] = stringA;
								f->InitD[2] = stringB;
								break;
							}
						}
					}
					if ( !foundff )
					{
						int ferr[]="Cound not find a free ffc slot to run the ffc script for item script AdvPickupMessage";
						TraceS(ferr);
					}
					Quit();
				}
			

				else
				{
					Link->Action = LA_HOLD1LAND + (__LA_HOLDUP_HANDS-1);
					Link->HeldItem = this_item_id;
					Game->PlaySound(SFX_HOLD_ITEM_FANFARE);
					if(Link->Y > 88)
					{
						Screen->Message(stringA);
					}
					else
					{
						Screen->Message(stringB);
					}
				}
			}
            
		}
	}
}

ffc script swimHoldUp{
	void run(int itm, int stringA, int stringB)
	{
		Waitframe();
		//do {
		 //   Waitframe();
		//} while(Link->Action == LA_DIVING);
		Game->PlaySound(SFX_HOLD_ITEM_FANFARE);
		Link->Action = LA_HOLD1WATER + (__LA_HOLDUP_HANDS-1);
		Link->HeldItem = itm;
    
		while( Link->Action == ( LA_HOLD1WATER + (__LA_HOLDUP_HANDS-1) ) ) { Waitframe(); }
		Waitframes(2);
		if(Link->Y > 88)
		{
			Screen->Message(stringA);
		}
		else
		{
			Screen->Message(stringB);
		}
		this->Data = 0;
		this->Script = 0;
		Quit();
	}
}

ffc script DiveHoldUp{
	void run(int itm, int stringA, int stringB){
        
		do {
			Waitframe();
		} while(Link->Action == LA_DIVING);
        
		//Link->Action = LA_HOLD1WATER + (__LA_HOLDUP_HANDS-1);
		//Link->HeldItem = itm;
		Game->PlaySound(SFX_HOLD_ITEM_FANFARE);
		while( Link->Action == ( LA_HOLD1WATER + (__LA_HOLDUP_HANDS-1) ) ) { Waitframe(); }
		Waitframes(2);
		if(Link->Y > 88)
		{
			Screen->Message(stringA);
		}
		else
		{
			Screen->Message(stringB);
		}
		this->Data = 0;
		this->Script = 0;
		Quit();
	}
}

//Maddening, isn't it? -Z
 
Dive items may do the hold-up automatically. Try that, and tell me if Link still holds up the item when diving.

Edited by ZoriaRPG, 28 July 2017 - 06:12 AM.


#32 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 28 July 2017 - 12:28 PM

Thank you for your skill and patience.

 

I've removed the item fanfare SFX from the message strings.

 

Swimming: Only problem is that the message string appears after Link has completed the hold up pose.

 

Diving: Only problem is that the message string doesn't appear at all.



#33 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 31 July 2017 - 10:18 AM

Thank you for your skill and patience.
 
I've removed the item fanfare SFX from the message strings.
 
Swimming: Only problem is that the message string appears after Link has completed the hold up pose.
 
Diving: Only problem is that the message string doesn't appear at all.


Did you remember to assign the new script, DiveHoldUp, to a slot; and are there any errors in allegro.log? Go to screens where the dive items are located, grab one, and after you leave the screen, send me a copy of allegro.log.



#34 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 01 August 2017 - 12:14 PM

I did not assign DiveHoldUp to a slot. I didn't notice there was a new script. Sorry. My bad.

 

Swimming- Only problem is the Message String doesn't appear until Link stops holding up the item.

 

Same with diving, except you hear the item fanfare a second time when the message string plays (don't know why).

 

Will allegro.log record what you want to see automatically, or do I have to save my game?



#35 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 01 August 2017 - 10:06 PM

I did not assign DiveHoldUp to a slot. I didn't notice there was a new script. Sorry. My bad.
 
Swimming- Only problem is the Message String doesn't appear until Link stops holding up the item.
 
Same with diving, except you hear the item fanfare a second time when the message string plays (don't know why).
 
Will allegro.log record what you want to see automatically, or do I have to save my game?


Right, I can fix all of this now. Diving is playing the fanfare by default, so calling it in the script is meaningless. In fact, this process has refined down to a way to ensure that the message never obscures the item, which makes the positional changes redundant.

The next step, is to display the message for normal (non-swim, non-dive) items after the hold-up animation finishes. That will ensure that all item displays have the same style.

Unless you disabled script logging, Allegro records every script error, and Trace, as soon as they occur. If you look in the log, you should see errors 'LoadFFC: Could not find an FFC with the string 'DiveHoldUp', or something similar.

I renamed all of the scripts for the code below. You will need to manually reassign the slots for each.
 
const int __LA_HOLDUP_HANDS = 1; //The number of hands to use for the default hold-up animation.

//D0 Integer: Number of Message String to display if Link is near the bottom of the screen
//D0 Decimal: Number of Message String to display if Link is near the top of the screen
//D1 Integer: ID of Item that prevents Message String from being displayed
//D1 Decimal: ID of item to hold up. Set to '0' for no hold-up animation.

const int SFX_HOLD_ITEM_FANFARE = 63; //Change to the sound that you want. 

item script PickMessageFFCLauncher
{
	void run(int stringA_stringB, int stringPreventItemID_this_item_id)
	{
		bool foundff;
		int stringA = stringA_stringB << 0;
		int stringB = ( stringA_stringB - stringA ) * 10000;
		int stringPreventItemID = stringPreventItemID_this_item_id << 0;
		int this_item_id = ( stringPreventItemID_this_item_id - stringPreventItemID ) * 10000;
		int _____ffscript_id; int ___err_aborting[]="Aborting item hold-up.";
		if ( !Link->Item[stringPreventItemID] )
		{
			if ( this_item_id > 0 && this_item_id < 256 )
			{
				if ( Link->Action == LA_DIVING ) 
				{
					int ff[]="FFC_DiveHoldUp";
					_____ffscript_id = Game->GetFFCScript(ff);
					if ( _____ffscript_id < 1 ) 
					{ 
						int ___errff[]="Cound not find the script: ";
						TraceS(___errff); TraceS(ff); TraceNL(); TraceS(___err_aborting); TraceNL();
						Quit();
					}
						
					for ( int q = 32; q > 0; q-- )
					{
						ffc f = Screen->LoadFFC(q);
						if ( f->Data == 0 )
						{
							if ( f->Script == 0 )
							{
								foundff = true;
								f->Data = 1;
								f->Script = Game->GetFFCScript(_____ffscript_id);
								f->InitD[0] = this_item_id;
								f->InitD[1] = stringA;
								f->InitD[2] = stringB;
								break;
							}
						}
					}
					if ( !foundff )
					{
						int ferr[]="Cound not find a free ffc slot to run the ffc script for item script AdvPickupMessage. ";
						TraceS(ferr); Trace(___err_aborting); TraceNL();
					}
					Quit();
				}
				
				else if ( Link->Action == LA_SWIMMING  ) 
				{
					int ff[]="FFC_SwimHoldUp";
					_____ffscript_id = Game->GetFFCScript(ff);
					if ( _____ffscript_id < 1 ) { 
						int ___errff[]="Cound not find the script: ";
						TraceS(___errff); TraceS(ff); TraceNL(); TraceS(___err_aborting); TraceNL();
						Quit();
					}
					for ( int q = 32; q > 0; q-- )
					{
						ffc f = Screen->LoadFFC(q);
						if ( f->Data == 0 )
						{
							if ( f->Script == 0 )
							{
								foundff = true;
								f->Data = 1;
								f->Script = Game->GetFFCScript(_____ffscript_id);
								f->InitD[0] = this_item_id;
								f->InitD[1] = stringA;
								f->InitD[2] = stringB;
								break;
							}
						}
					}
					if ( !foundff )
					{
						int ferr[]="Cound not find a free ffc slot to run the ffc script for item script AdvPickupMessage. ";
						TraceS(ferr); Trace(___err_aborting); TraceNL();
					}
					Quit();
				}
			
				else
				{
					int ff[]="FFC_ItemHoldUp";
					_____ffscript_id = Game->GetFFCScript(ff);
					if ( _____ffscript_id < 1 ) { 
						int ___errff[]="Cound not find the script: ";
						TraceS(___errff); TraceS(ff); TraceNL(); TraceS(___err_aborting); TraceNL();
						Quit();
					}
					for ( int q = 32; q > 0; q-- )
					{
						ffc f = Screen->LoadFFC(q);
						if ( f->Data == 0 )
						{
							if ( f->Script == 0 )
							{
								foundff = true;
								f->Data = 1;
								f->Script = Game->GetFFCScript(_____ffscript_id);
								f->InitD[0] = this_item_id;
								f->InitD[1] = stringA;
								f->InitD[2] = stringB;
								break;
							}
						}
					}
					if ( !foundff )
					{
						int ferr[]="Cound not find a free ffc slot to run the ffc script for item script AdvPickupMessage";
						TraceS(ferr); Trace(___err_aborting); TraceNL();
					}
					Quit();
				}
			}
		}
	}
}

ffc script FFC_SwimHoldUp{
	void run(int itm, int stringA, int stringB)
	{
		Waitframe();
		if ( SFX_HOLD_ITEM_FANFARE > 0 && SFX_HOLD_ITEM_FANFARE < 255) Game->PlaySound(SFX_HOLD_ITEM_FANFARE);
		Link->Action = LA_HOLD1WATER + (__LA_HOLDUP_HANDS-1);
		Link->HeldItem = itm;
		
		do{
			Waitframe();
		} while( Link->Action == LA_HOLD1WATER || Link->Action == LA_HOLD2WATER );

		if(Link->Y > 88)
		{
			Screen->Message(stringA);
		}
		else
		{
			Screen->Message(stringB);
		}
		this->Data = 0;
		this->Script = 0;
		Quit();
	}
}

ffc script FFC_DiveHoldUp{
	void run(int itm, int stringA, int stringB){
        
		do {
			Waitframe();
		} while(Link->Action == LA_DIVING);
		
		//Game->PlaySound(SFX_HOLD_ITEM_FANFARE);
		do {
			Waitframe();
		} while( Link->Action == LA_HOLD1WATER || Link->Action == LA_HOLD2WATER );

		if(Link->Y > 88)
		{
			Screen->Message(stringA);
		}
		else
		{
			Screen->Message(stringB);
		}
		this->Data = 0;
		this->Script = 0;
		Quit();
	}
}


ffc script FFC_ItemHoldUp{
	void run(int itm, int stringA, int stringB){
                Link->Action = LA_HOLD1LAND + (ITEM_HOLDUP_ZH__LA_HOLDUP_HANDS-1);
		Link->HeldItem = itm;
		do {
			Waitframe();
		} while(Link->Action == LA_HOLD1LAND || Link->Action == LA_HOLD2LAND);
        
		Game->PlaySound(SFX_HOLD_ITEM_FANFARE);
		if(Link->Y > 88)
		{
			Screen->Message(stringA);
		}
		else
		{
			Screen->Message(stringB);
		}
		this->Data = 0;
		this->Script = 0;
		Quit();
	}
}
//Maddening, isn't it? -Z


I turned the basis of this into a new header, that you may download:
ItemHoldUpMessage.zh, v1.1 | Demo Quest

When I feel up to writing instructions for setting it up, I will add it to the database here, and on zc.com.

Edited by ZoriaRPG, 02 August 2017 - 07:16 AM.


#36 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 08 August 2017 - 05:49 PM

I'm going to look at this soon, but I hope you're not saying that you made them all the same by having Link never hold up items, because I could do that before this thread started, and I wouldn't want you to have wasted all that effort.



#37 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 10 August 2017 - 01:25 AM

I'm going to look at this soon, but I hope you're not saying that you made them all the same by having Link never hold up items, because I could do that before this thread started, and I wouldn't want you to have wasted all that effort.

 

No. The messages always appear after the animation ends. I merely ensured that the behaviour matches in all situations.

 

Try the demo. It is probably useless to shift the message display location when using the header, as (the way that I designed this) the message will never cover the item.

 

I'll be adding it to the script databases in the near future. I also have a 2.54+ version of it ready, not that most users care; but it is an interesting example of some new features being put to use.


Edited by ZoriaRPG, 10 August 2017 - 01:41 AM.


#38 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 20 August 2017 - 07:36 AM

I'm going to look at this soon, but I hope you're not saying that you made them all the same by having Link never hold up items, because I could do that before this thread started, and I wouldn't want you to have wasted all that effort.

 

Did the latest code solve your issue, and thus close this request?


Edited by ZoriaRPG, 20 August 2017 - 07:36 AM.


#39 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 05 September 2017 - 11:23 PM

Did the latest code solve your issue, and thus close this request?

 

Sorry Zoria, I've had to take a break and haven't tried it yet. Didn't mean to be rude



#40 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 06 September 2017 - 03:39 PM

ffc script FFC_ItemHoldUp{
	void run(int itm, int stringA, int stringB){
                Link->Action = LA_HOLD1LAND + (ITEM_HOLDUP_ZH__LA_HOLDUP_HANDS-1);

Error S09: variable ITEM_HOLDUP_ZH__LA_HOLDUP_HANDS is undeclared



#41 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 September 2017 - 04:25 AM

ffc script FFC_ItemHoldUp{
	void run(int itm, int stringA, int stringB){
                Link->Action = LA_HOLD1LAND + (ITEM_HOLDUP_ZH__LA_HOLDUP_HANDS-1);

Error S09: variable ITEM_HOLDUP_ZH__LA_HOLDUP_HANDS is undeclared

 

 

That is from the header, here: https://pastebin.com/vFjRKXya

 

You can copy it over, but all that I did was to rename the identifier __LA_HOLDUP_HANDS, to something more header-specific. Change ITEM_HOLDUP_ZH__LA_HOLDUP_HANDS to __LA_HOLDUP_HANDS  and that should solve it for you.



#42 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 07 September 2017 - 04:36 AM

Thanks it compiled, now to cast my mind back and remember how to set up my items for testing




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users