Jump to content

Photo

Hold up Item before Message String?


  • Please log in to reply
41 replies to this topic

#1 Cukeman

Cukeman

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

  • Members
  • Gender:Male
  • Location:Hyrule/USA

Posted 18 June 2017 - 08:18 PM

This script plays one of two message strings when Link picks up an item, unless Link has the item listed in argument D2.

 

Would it be doable to modify this so that Link also holds up the item (if Link doesn't have item D2)? Thanks for any help.

////////////////////////////////////////////////////////////////
//                    AdvPickUpMessage by                     //
//             Joe123, MoscowModder, Isdrakth├╝l,              //
//             cavthena, Coolgamer012345, Cukeman             //
//                                                            //
//    Displays Message D0 or D1 (identical Strings with       //
// different [Y] height values) based on Link's screen        //
// position. Used to prevent Message Strings from covering    //
// Link's sprite when he picks up the item. Also, if Link     //
// already has item D2, no message will be displayed.         //
////////////////////////////////////////////////////////////////

//D0: Number of Message String to display if Link is near the bottom of the screen
//D1: Number of Message String to display if Link is near the top of the screen
//D2: ID of Item that prevents Message String from being displayed

item script AdvPickUpMessage
{
	void run(int stringA, int stringB, int stringPreventItemID)
	{
		if(!Link->Item[stringPreventItemID])
		{
			if(Link->Y > 88)
			{
				Screen->Message(stringA);
			}
			else
			{
				Screen->Message(stringB);
			}
		}
	}
}


#2 Cukeman

Cukeman

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

  • Members
  • Gender:Male
  • Location:Hyrule/USA

Posted 02 July 2017 - 07:51 PM

So, first I want to make it so that Link always holds the item up over his head. So if I add (line 9 below)...
 
//D0: Number of Message String to display if Link is near the bottom of the screen
//D1: Number of Message String to display if Link is near the top of the screen
//D2: ID of Item that prevents Message String from being displayed

item script AdvPickUpMessage
{
	void run(int stringA, int stringB, int stringPreventItemID)
	{
                i->Pickup=IP_HOLDUP;
		if(!Link->Item[stringPreventItemID])
		{
			if(Link->Y > 88)
			{
				Screen->Message(stringA);
			}
			else
			{
				Screen->Message(stringB);
			}
		}
	}
}
Now I want to make it so Link does NOT hold up the item if he has the item listed in argument D2. So I add (line 11 below)... Is that correct? I feel there must be a syntax error with two equals signs. Also I want to make sure that if Link holds up the item, he does it before the message string plays (and he should keep holding up the item until the message string disappears).
 
//D0: Number of Message String to display if Link is near the bottom of the screen
//D1: Number of Message String to display if Link is near the top of the screen
//D2: ID of Item that prevents Message String from being displayed

item script AdvPickUpMessage
{
	void run(int stringA, int stringB, int stringPreventItemID)
	{
                i->Pickup=IP_HOLDUP;
		if(!Link->Item[stringPreventItemID])
                i->Pickup=IP_HOLDUP=false;
		{
			if(Link->Y > 88)
			{
				Screen->Message(stringA);
			}
			else
			{
				Screen->Message(stringB);
			}
		}
	}
}
Can you please help me understand what I am doing right/wrong here?

#3 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 02 July 2017 - 10:29 PM

For anyone curious, I don't use IP_HOLDUP. I typically do:

Link->Action = LA_HOLD1LAND;
Link->HeldItem = itm_id;

You can set Link to hold any item that is valid in the game, even if it does not match what is on the screen.

 

The difference is that the item is awarded before the animation, the way that I do it, which can be critical in some situations.

 

I'm guessing that the second string input is for one with no background tiles? Holy flidd, people do this?

It is a fantastic argument for translucent backdrops, and for more control over text in ZScript.

 

anyway...

 

To prevent the animation based on D3, change your script logic to this:

 

//D0: Number of Message String to display if Link is near the bottom of the screen
//D1: Number of Message String to display if Link is near the top of the screen
//D2: ID of Item that prevents Message String from being displayed

item script AdvPickUpMessage
{
    void run(int stringA, int stringB, int stringPreventItemID)
    {
        if ( !Link->Item[stringPreventItemID] )
        {
            i->Pickup=IP_HOLDUP;
            if(Link->Y > 88)
            {
                Screen->Message(stringA);
            }
            else
            {
                Screen->Message(stringB);
        }
    }
}

Edited by ZoriaRPG, 02 July 2017 - 10:37 PM.


#4 Cukeman

Cukeman

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

  • Members
  • Gender:Male
  • Location:Hyrule/USA

Posted 03 July 2017 - 10:51 AM

I'm guessing that the second string input is for one with no background tiles? Holy flidd, people do this?


Both message string boxes have a solid background, I just think it sucks to have Link hidden behind a text box when he's holding up an item (especially dropped items).

 

I got "error s09: variable i is undeclared"


Edited by Cukeman, 03 July 2017 - 10:58 AM.


#5 Cukeman

Cukeman

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

  • Members
  • Gender:Male
  • Location:Hyrule/USA

Posted 07 July 2017 - 02:14 AM

 

I got "error s09: variable i is undeclared"

 

I wish I understood better what this undeclared variable error means, because it's one I've seen a lot in different scripts.



#6 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 07 July 2017 - 04:29 AM

I wish I understood better what this undeclared variable error means, because it's one I've seen a lot in different scripts.

 
That is an error in your original code, and it reminded me why I use Link->Action in 2.50.x.
 
In this case, i is a pointer, but it is never declared; and you cannot really change the Pickup value of an item script using an item pointer from a pick-up script in 2.50.x. The proper syntax would be this->Pickup, but itemdata does not have a Pickup variable in a released ZC build, and once Link picks up the item, its pointer becomes NULL, so you cannot do a for loop to find it. Because itemdata also lacks an ID variable, you will be stuck doing it this way, which could conflict with item use scripts:
 
 
//D0: Number of Message String to display if Link is near the bottom of the screen
//D1: Number of Message String to display if Link is near the top of the screen
//D2: ID of Item that prevents Message String from being displayed
//D3: ID of item to display, being held by Link. 


item script AdvPickUpMessage
{
    void run(int stringA, int stringB, int stringPreventItemID, int this_item_id)
    {
        if ( !Link->Item[stringPreventItemID] )
        {
	    if ( Link->Action == LA_SWIMMING || Link->Action == LA_DIVING ) Link->Action = LA_HOLD1WATER:
            else Link->Action = LA_HOLD1LAND;
            Link->HeldItem = this_item_id;
            if(Link->Y > 88)
            {
                Screen->Message(stringA);
            }
            else
            {
                Screen->Message(stringB);
	    }
        }
    }
}
 
I could set it up to use the decimal and integer parts of D0 and D1; instead of D0, D1 D2 and D3, if you will know how to use that kind of hack.

Edited by ZoriaRPG, 07 July 2017 - 08:18 AM.

  • Cukeman likes this

#7 Cukeman

Cukeman

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

  • Members
  • Gender:Male
  • Location:Hyrule/USA

Posted 07 July 2017 - 07:30 AM

pass 1: parsing

line 400: syntax error, unexpected script, expecting identifier, on token script

fatal error p00: can't open or parse input file!

 

Line 400 isn't helpful information as that line occurs after this script in the script file (the whole script file compiled previously).



#8 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 07 July 2017 - 08:03 AM

pass 1: parsing
line 400: syntax error, unexpected script, expecting identifier, on token script
fatal error p00: can't open or parse input file!
 
Line 400 isn't helpful information as that line occurs after this script in the script file (the whole script file compiled previously).

 
It was missing a closing brace. Fixed above.

Compare and Learn

Look for the Error



Look for the Fix

 
Bonus Content
 
Here is how to save InitD args--this script uses only two, rather than four--and to use a constant to set the hold-up type. I also made another fix (here, and in the previous post) that ensures that the hold-up animation is correct while Link is in the water. .
 
 

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.


item script AdvPickUpMessage
{
    void run(int stringA_stringB, int stringPreventItemID_this_item_id)
    {
    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_SWIMMING || Link->Action == LA_DIVING )
        {
            Link->Action = LA_HOLD1WATER + (__LA_HOLDUP_HANDS-1);
        }
        else Link->Action = LA_HOLD1LAND + (__LA_HOLDUP_HANDS-1);
                Link->HeldItem = this_item_id;
        }
            if(Link->Y > 88)
            {
                Screen->Message(stringA);
            }
            else
            {
                Screen->Message(stringB);
        }
        }
    }
}

 
Use this, or the fixed version in the prior post.


Edited by ZoriaRPG, 07 July 2017 - 08:20 AM.

  • Cukeman likes this

#9 Cukeman

Cukeman

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

  • Members
  • Gender:Male
  • Location:Hyrule/USA

Posted 07 July 2017 - 08:42 AM

Thank you for your script and for your help. I do know the concept of braces, I just didn't think to check that because the changes to the script didn't include the addition or removal or any braces. Sorry for the inconvenience.

 

Link is holding up the item as intended, and I even managed to change it so he holds the item up with both hands.

 

The only drawback is Link doesn't hold up the item if he is swimming or diving.

Is that easily added?



#10 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 07 July 2017 - 08:46 AM

Thank you for your script and for your help. I do know the concept of braces, I just didn't think to check that because the changes to the script didn't include the addition or removal or any braces. Sorry for the inconvenience.

 

Link is holding up the item as intended, and I even managed to change it so he holds the item up with both hands.

 

The only drawback is Link doesn't hold up the item if he is swimming or diving.

Is that easily added?

 

Did you use my last update? I added that, and it should work.



#11 Cukeman

Cukeman

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

  • Members
  • Gender:Male
  • Location:Hyrule/USA

Posted 07 July 2017 - 04:02 PM

I was using the version before the script with the integer/decimal arguments.

 

For the integer/decimal argument script, I would put in the arguments like so:

 

D0: A.B

A being the number of the 1st string (38)

B being the number of the 2nd string (39)

D0: 38.3900

 

D1: C.D

A being the number of the item preventing the strings (188)

B being the number of the item Link is holding over his head (2)

D1: 188.2000

 

Is that correct? Because that's how I set it up, and while the script compiled, Link did not hold up the item during his walking or swimming states (he did hold it up from a diving state).

 

Additionally if Link's Y value was less than 88, instead of the correct string showing up I got an empty string to dismiss (all that was visible was the dismiss string icon). This was true for Link's walking, swimming, and diving states.



#12 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 08 July 2017 - 07:36 PM

I was using the version before the script with the integer/decimal arguments.

 

For the integer/decimal argument script, I would put in the arguments like so:

 

D0: A.B

A being the number of the 1st string (38)

B being the number of the 2nd string (39)

D0: 38.3900

 

D1: C.D

A being the number of the item preventing the strings (188)

B being the number of the item Link is holding over his head (2)

D1: 188.2000

 

Is that correct? Because that's how I set it up, and while the script compiled, Link did not hold up the item during his walking or swimming states (he did hold it up from a diving state).

 

Additionally if Link's Y value was less than 88, instead of the correct string showing up I got an empty string to dismiss (all that was visible was the dismiss string icon). This was true for Link's walking, swimming, and diving states.

 

The values are wrong. If you look at the code, you will see that the decimal half is multiplied by 10,000.

 

You want:

 

D0: A.B

A being the number of the 1st string (38)

B being the number of the 2nd string (39)

D0: 38.0039

 

D1: C.D

C being the number of the item preventing the strings (188)

D being the number of the item Link is holding over his head (2)

D1: 188.0002


Edited by ZoriaRPG, 08 July 2017 - 07:37 PM.


#13 Cukeman

Cukeman

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

  • Members
  • Gender:Male
  • Location:Hyrule/USA

Posted 08 July 2017 - 08:35 PM

Oops, thanks for the correction! That fixed the walking and swimming states (and the message string issue), but now that I've made that change, Link no longer holds the item over his head during his diving state.  :confused:


Edited by Cukeman, 08 July 2017 - 08:36 PM.


#14 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 09 July 2017 - 04:13 AM

Oops, thanks for the correction! That fixed the walking and swimming states (and the message string issue), but now that I've made that change, Link no longer holds the item over his head during his diving state.  :confused:

 

If it is not working for dive secrets, them you will need to set the screen flag 'hold item over head' on screens with them, as the code is set up for diving, but clearly ZQuest cannot change from LA_DIVING to LA_HOLD1WATER, which is probably a bug.



#15 Cukeman

Cukeman

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

  • Members
  • Gender:Male
  • Location:Hyrule/USA

Posted 09 July 2017 - 06:46 AM

What if we removed the part of the code related to diving? since Link was holding up the item over his head before the last edit

 

(I'm thinking maybe link automatically holds up items during a dive by default, but he can't be scripted to do so)


Edited by Cukeman, 09 July 2017 - 06:04 PM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users