Jump to content

Photo

Warping After a Specific Message


  • Please log in to reply
12 replies to this topic

#1 ywkls

ywkls

    Master

  • Members

Posted 15 December 2014 - 02:22 PM

Okay, I've found a few scripts that let you warp after seeing a message from an NPC but nothing like what I want to accomplish. The scripts in question can be found here.

 

http://www.purezc.ne...arp#entry843008

http://www.purezc.ne...arp#entry855249

 

With the current setup for NPCs, you can use string control codes to decide what message to play whether you have an item or not and give or take items from Link. The problem is that I would like for the item to be held up and the message string played whenever you get it and the string control codes won't let you do that. The message then warp scripts are set up where you will warp after any message that the NPC plays rather than a specific message. I have some ideas about how to implement this, but I don't know enough scripting yet to do it myself.

 

For example, besides adding the argument for warpcombo you could also add an argument or variable for a specific message to be detected. But the thing is, since the code tells you to play the message and the string tells you what message to play; can the game detect what message is played and only then warp you as set up in those scripts? I'm working with the latest build of 2.5.

 

The point of all this is to set up a trading quest series of events where you can find an NPC and if you don't have something he'll say one thing while he'll say another if you do and take that item away, then you'll be warped to a screen where you get the item which is the reward to avoid having to creating fake items. I've seen requests for ways to make an item warp you, but they would require me to set up dummy items to trigger the warp; then once you warped you could get the real item. That method might work, but if you are switching out a lot of items then you'd have to create a whole lot of fake items and would need a means to take one item away once you get another.

 

In the current setup, the items in question are all the same item class so that one replaces the other when you acquire it and I'm not sure if I would have to set up the dummy items as a specific item class or not for it to work properly. In any case, I'm sure that there is a way to combine the warp after message script with existing NPC script but not so certain about how to detect a specific message. If this is impossible, I'll just go with the item warp method but I'd still need to know how to take away an item and get another. Here's an untested code I wrote just now while thinking about this that might do that but I don't know if it would work or if there's a better way to do it than this.

ffc script SwitchItems(int item_1, int item_2){
    if(Link->item[item_1]){
         Link->Item[item_1] = false;
         Link->Item[item_2] = true;
    }
}

If setting up a bunch of dummy items is easier than getting the warp script to detect a specific message (or if detecting an item is the only way possible to do this) then I'd be willing to do that. I'd just rather post the request and see if there is any response than go through the lengthy process of setting up a lot of new items that only exist to trigger warps. Thanks to anyone who replies!



#2 justin

justin

    Adept

  • Members

Posted 15 December 2014 - 02:59 PM

there is this script

http://www.purezc.ne...=scripts&id=145

 

will spawn an item on the screen.  if you spawn it under Link, and the item has the hold up flag set, Link will hold it up.  

your method will just silently give Link the item.



#3 ywkls

ywkls

    Master

  • Members

Posted 15 December 2014 - 04:28 PM

I guess that just shows how little I know about scripting....I thought of an alternate way to have a message played after having an item given to Link (such as through string control codes). Here's that idea which probably won't work, but who knows?

ffc script AfterReceiptMessage(int m, int item_id, int i){
   if(Link->Item[item_id]){
       if(Screen->D[i] == 0){
            Screen->Message(m);
            i = 1;
       }
   }
}
        

I'll try to test this tonight if I can remember to do it before work, but given my spotty history with successful scripting it might not. But if it doesn't it would be a workaround to this issue that would allow the elimination of dummy items.



#4 justin

justin

    Adept

  • Members

Posted 15 December 2014 - 05:10 PM

I guess that just shows how little I know about scripting....I thought of an alternate way to have a message played after having an item given to Link (such as through string control codes). Here's that idea which probably won't work, but who knows?

 

if you're giving Link an item with string control codes why wouldn't you be able to play the message with the normal string editor at the same time?

 

from what i gathered from your first post you were trying to get Link to hold up the item, which as you said doesn't work with string control codes.

 

here's an idea, handle all the dialogue and such with string control codes.   create one Dummy item.  give that Dummy item with the string control code if Link has the previous item in the sequence.  Place an FFC on the screen with an attached script.  the script checks to see if Link has the Dummy item, if so it places the new trade sequence item under Link (based on that script I linked), and takes away the Dummy item.

 

 

 

edit:  script added.  untested.  use it as described above, (also in comments)

const int TRADE_SEQ_DUMITEM = 0; // set this to the ID of the Dummy item.
 
// Place this FFC on the screen where the trade sequence is happening.  Give the dummy item with String Control Codes, if Link has the previous Trade Item.
// The trade sequence items should have the flag "Hold up Item" set.
// D0 is the ID of the next item in the trade sequence.
 
ffc script TradeSequence{
   void run(int item_to_give){
      while(true){
         if (Link->Item[TRADE_SEQ_DUMITEM]){
            item TradeSeqItem;
            TradeSeqItem = Screen->CreateItem(item_to_give);
            TradeSeqItem->X = Link->X;
            TradeSeqItem->Y = Link->Y;
 
            Link->Item[TRADE_SEQ_DUMITEM] = false;
         }
 
         Waitframe(); 
      }
   } 
}

Edited by justin, 15 December 2014 - 05:19 PM.


#5 ywkls

ywkls

    Master

  • Members

Posted 16 December 2014 - 12:24 PM

Okay, this is the second time I've tried to post my progress in working this out. (The reply box malfunctioned on the 1st.) I am trying to combine various methods to produce the effect I want.

First, an NPC script which uses string control codes. If you don't have item one you get String A but if you do, you get String A and/or B. (If I use just String B, you'll never hear what they have to say as their item request if you already have it.) In string B, I have it set up with first \17\x to take away the item the NPC wants then \16\x at the end to give a specific item to you.

 

Next, a few code ideas I've run across to warp you. (These aren't mine, I've just modified them to reflect actual combo and item id's in my game.)

const int CMB_AUTOWARPA = 2669; //Set the ID of an auto-warp A combo here
item script ItemWarp{
     void run(){
          ffc f = Screen->LoadFFC(32);
          f->Data = CMB_AUTOWARPA;
     }
}

If I understand this correctly, you place this in the item's pickup slot and it loads AUTOWARPA that you've previously created, triggering whatever built-in warp you have in place on that screen as Sidewarp A. Another method was suggested by the code at the 1st link I posted in this request. Here it is again.

 

http://www.purezc.ne...arp#entry843008

 

The way this seems to work is in conjunction with another FFC that detects whether there is a script to be run, then calls the script for the FFC Warp and creates a combo at your location that warps you. Theoretically, there could be an FFC script that does nothing but check for the item and then runs the FFC Warp if you have it. (I've tried adding that item check to the existing FFC Warp script, without success.) Once a warp is generated either by the item or an FFC, you'd go to an identical screen where I would have set up the suggested TradeSequence script with some slight modifications.

 

const int I_ITEM_WARP = 158; // set this to the ID of the Dummy item.

// Place this FFC on the screen where the trade sequence is happening.  Give the dummy item with String Control Codes, if Link has the previous Trade Item.
// The trade sequence items should have the flag "Hold up Item" set.
// D0 is the ID of the next item in the trade sequence.

ffc script TradeSequence{
   void run(int item_to_give){
      while(true){
         if (Link->Item[I_ITEM_WARP]){
            item TradeSeqItem;
            TradeSeqItem = Screen->CreateItem(item_to_give);
            TradeSeqItem->X = Link->X;
            TradeSeqItem->Y = Link->Y;

            Link->Item[I_ITEM_WARP] = false;
         }

         Waitframe(); 
      }
   } 
}

This worked, the item used to trigger the warp (I_ITEM_WARP) causes the real item to spawn at your location whenever you appeared on the screen, then the I_ITEM_WARP would be taken away. However, Link doesn't hold up the item and its message doesn't play. The purpose of having the warp rather than just using the item spawner and a bunch of dummy items is as follows.

 

1. When you don't have the item, NPC says string A.

2. When you do, it says String A and B or just B. (Depending on how I have it set up.)

3. You lose item one through string control codes.

4. You get item two. (Any way you can get an item, such as via the item spawner or string control codes.)

5. After you have item two, the NPC will says something different forevermore.

 

The easiest way I can think of to have number 5 happen is that on the screen where you actually get the item, there will be a different NPC who only says String C. (Combining multiple string control codes to check for multiple items is something that I don't know whether or not if it is possible and even if it was, would be a pain.) So, to fake it have the first screen says only the first two string options; then only warps you after you've heard the second and then you get the item and see it's item message and hold up animation on the second screen. On the exit of the screen would be some invisible Step->Secrets(Permanent) combos that would change the warp outside so it would only warp to the screen with the NPC that says String C.

 

As I said, so far I can't get the itemWarp script to work. (The string control codes to give me the I_ITEM_WARP are set up correctly, but I don't warp.) The FFC Warp script has to be set up where it will only run after I get the item. I've tested out my alterations to the item spawner by giving Link the I_ITEM_WARP as initial equipment and warping directly to the screen where it is supposed to occur. You get the item, but Link doesn't hold it up even if that flag is checked onscreen. I know that there are codes to do LInk->Action and Link->HeldItem but not if these would work for my purposes. Presumably I would also have to declare int m in the TradeSequence script, then say Screen->Message(m).

 

So, if there are any ideas on what I'm doing wrong or ways to refine these scripts to do what they should; I would really appreciate knowing what they were. Thanks in advance for any assistance.


Edited by ywkls, 16 December 2014 - 12:25 PM.


#6 justin

justin

    Adept

  • Members

Posted 16 December 2014 - 12:50 PM

did you try my script?

 

here's how to use it.

 

NPC string setup:

string1:  control code if Link has trade item go to string2, the string to display if he doesn't have the item.

string2:  string if he does have the item, control code to remove trade item, control code to give dummy item.

 

on the screen place that script i wrote as an FFC, it keeps checking to see if Link has the dummy item.  If he does it will instantly generate the new trade item under Link, he'll grab it and hold it up like you want.  the script also removes the dummy item.

 

now the issue with removing the previous trade item is that there is no way for the NPC to know that you've done all this, you could check to see if link has the next trade item, and give a different string if that's the case, but once Link trade's that item its all back to square1.  so i'd recommend making all the trade items different levels of the same item class and not removing each previous item, that way the subscreen will always display the highest level item (the latest item in the sequence), and the player doesn't need to know that all the other items are still there.

 

if going that route, string2 above would look like...

string2: control code goto string3 if Link has this NPCs trade item, string if he has trade item this NPC wants, control code to give dummy item.

string3: a string saying that the trade has been completed.


Edited by justin, 16 December 2014 - 12:51 PM.


#7 ywkls

ywkls

    Master

  • Members

Posted 16 December 2014 - 02:17 PM

Two out of three isn't bad... I hadn't thought of setting up a second string control code in the second string and keeping all of the trade items. (But since I just learned about the string control codes a couple of days ago that is understandable.) And the item spawner does give you the trade item and take away the dummy item but... Link still doesn't hold up the new item and it's message doesn't play. Which leads me to believe that those commands I mentioned need to be in there somewhere. Just doing a little research on the Wiki, I came up with this theoretical method to make that happen.

Link->HeldItem[TradeSeqItem];//According to the wiki, this command tells what item Link is to hold up.
Link->Action[LA_HOLD1LAND];//This is supposed to make Link hold up whatever item is held by the first code.
Screen Message(m);//Int M found have to be added to the arguments of the Trade Sequence FFC andthen m set to the String to be played.

Exactly whether including these commands would work or where they would need to be included, I don't know.  I'll try inserting them myself later tonight. (After checking to see if any suggestions have been made on other ways to do this, of course.)


Edited by ywkls, 16 December 2014 - 02:18 PM.


#8 justin

justin

    Adept

  • Members

Posted 16 December 2014 - 05:10 PM

oh, i thought there was an item attribute to make Link always hold it up, but its a screen attribute...

 

you could set it on each screen that has a trade sequence item...

 

or i could rewrite the script to hold up the item i think...



#9 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 16 December 2014 - 05:24 PM

There is an item attribute to hold it up. Just set item->Pickup |= IP_HOLDUP.



#10 ywkls

ywkls

    Master

  • Members

Posted 16 December 2014 - 08:02 PM

oh, i thought there was an item attribute to make Link always hold it up, but its a screen attribute...

 

you could set it on each screen that has a trade sequence item...

 

or i could rewrite the script to hold up the item i think...

 

@Justin- the screen flag for Hold up item is already activated so that's not the problem. If you could find a way to make the trade sequence script hold up the item and play the message, I'd appreciate it.

 

There is an item attribute to hold it up. Just set item->Pickup |= IP_HOLDUP.

 

@Lejes- How would you set the Item->Pickup as described? And would it then play the item's message? Thanks for the input and any help you have to offer.



#11 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 16 December 2014 - 09:15 PM

item->Pickup |= IP_HOLDUP;

Pretty much just that, where "item" is whatever the actual item pointer is. This will only work for items already on screen or ones newly spawned. Items given through string control codes always happen silently, so if you want Link to hold it up, you'd have to fake it with Link->HeldItem and Link->Action as you mentioned earlier.



#12 justin

justin

    Adept

  • Members

Posted 16 December 2014 - 11:28 PM

here it is, setup is the exact same.  Link now lifts item (thanks Lejes, I hadn't noticed that before), and message plays.

 

// import "std.zh"  // only need this once.
 
const int TRADE_SEQ_DUMITEM = 0; // set this to the ID of the Dummy item.
 
// Place this FFC on the screen where the trade sequence is happening.  Give the dummy item with String Control Codes, if Link has the previous Trade Item.
// Example of how to setup string control codes for this to work...
// String1:  "\5\x\2 My banana is missing."   x= item ID of banana
// String2:  "\5\x\3 You found my banana!  Thanks, here's a flyswatter.  \16\y"  x= item ID of flyswatter.  y= item ID of dummy item
// String3:  "Hey thanks for finding my banana, it was delicious, enjoy that flyswatter."
 
 
// D0 is the ID of the next item in the trade sequence.
// D1 is the string to display with the new trade item.
 
ffc script TradeSequence{
   void run(int item_to_give, int m){
      while(true){
         if (Link->Item[TRADE_SEQ_DUMITEM]){
            item TradeSeqItem;
            TradeSeqItem = Screen->CreateItem(item_to_give);
            TradeSeqItem->X = Link->X;
            TradeSeqItem->Y = Link->Y;
            TradeSeqItem->Pickup |= IP_HOLDUP;
 
            Link->Item[TRADE_SEQ_DUMITEM] = false;
 
            Screen->Message(m);
            }
 
         Waitframe(); 
      }
   } 
}

Edited by justin, 16 December 2014 - 11:28 PM.


#13 ywkls

ywkls

    Master

  • Members

Posted 17 December 2014 - 05:47 AM

Yes, yes! That does exactly what I want! Thank you, justin for writing the code. (I would have almost certainly have put the code in the wrong place or used the other method.) And thank you, Lejes for suggesting a way to get Link to hold up the item once it is spawned. Setting up the actual trade sequence will be much easier since I can now use one room for each leg of the sequence, rather than having to duplicate it each time. Although the end result isn't precisely what I originally requested, it does the same thing and that is all that matters!


Edited by ywkls, 17 December 2014 - 05:47 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users