Jump to content

Photo

Script Help


  • Please log in to reply
48 replies to this topic

#16 Frocks7Snee

Frocks7Snee

    Illustrious

  • Members

Posted 15 May 2015 - 02:32 PM

Well, that explains it. Would I be able to use one variable to give link either an item or a collectible with some kind of trickery? Or would I need multiple variables?

 

Scratch that. I'll just use the built in feature of Moosh's script that activates another script based on D6, but I'm not sure how that works. Does it activate an FFC on the screen with that number? 


Edited by Rocks4Free, 15 May 2015 - 03:15 PM.


#17 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 15 May 2015 - 06:13 PM

Oh, that shovel script, again. That should really have a big flag with red letters BROKEN on it:

 

Really, MoscowModder, or one of the Script DB staff should annotate it, because anybody who uses it as-is will run into trouble. I'm pretty sure it does things that are deprecated from ZScript now too.

 

In short, it hasn't worked for a very long time, and I'm pretty sure that it was always missing something as it was posted either without code tags, or before PZC had code tags. It has never been patched, but it's actually pretty simple to create that kind of effect. In fact, I have full libraries that can do exactly that, without all the mess. The trick, is that they aren't documented, so using them from the perspective of a novice, might be tedious, or difficult.

 

What happens, is essentially this:

 

A global function is always reading the combos on the screen, looking for combos with specific IDs (any kind of soft soil, and so forth). This is very useful, as it doesn't waste a script flag.

 

If collision occurs between a specific item, and a combo of the right type, it advances the combo one, just like a 'slash->next' type. When the combo advances, it makes a drop.

 

If you want to see this working, download LoE from the link in my userbar. The green sword (and only the green sword in that version), is a scripted object. it is not of the 'Swords' item class, but is one of the custom item classes. It creates an FFC that pretends to do sword things, and when it collides with a slash combo, it advances it via a global function. You can compare the effect easily, by trying to slash tall grass with both the green sword, and the bronze sword.

 

You'll notice that item drops with the green sword do not vanish. (That's intentional, and easy to change.)

 

A scripted shovel would work in much the same way, but on ground-only combos. I was thinking of adding that to the trowel item, but I honestly think that being able to grind 50%+ combos per screen is broken in and of itself, so I have no done that. (The trowel is instead, used to break cracked floor combos, but it isn't using the same mechanic, as I scripted that prior to writing the functions for the swords, and I never updated the item.)


Edited by ZoriaRPG, 15 May 2015 - 06:19 PM.


#18 ywkls

ywkls

    Master

  • Members

Posted 15 May 2015 - 06:37 PM

Scratch that. I'll just use the built in feature of Moosh's script that activates another script based on D6, but I'm not sure how that works. Does it activate an FFC on the screen with that number? 

 

What exactly are you using Moosh's Npc script to do? Make guards that block paths? Create Npcs that will only appear when you have a certain item? Make Npcs that disappear when you have a certain item? Create characters you can talk to and do things like trade in collectibles?

 

The reason I'm asking is because a while back I designed a variation on the NPC script designed specifically for use in setting up collectibles. (Golden Skulltulas, for example.) While they don't have the trading game-type code built in, there's a fairly simple script that can be placed in the room with them that would allow you to have that too.

 

Additionally, these NPCs can display more than one message, warp and heal you if you like.

 

Here's the link to the NPC script in question if you think that would be useful.

 

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

 

And here's the code for a trading sequence. I think justin wrote this for me. (It's been a while, so I'm not entirely sure.)

const int I_ITEM_TRADE = 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.
// D0 is the ID of the next item in the trade sequence.
// D1 Is the message to play
ffc script TradeSequence{
   void run(int item_to_give, int m){
      while(true){
         if (Link->Item[I_ITEM_TRADE]){
            item TradeSeqItem;
            TradeSeqItem = Screen->CreateItem(item_to_give);
            TradeSeqItem->X = Link->X;
            TradeSeqItem->Y = Link->Y;
            TradeSeqItem->Pickup |= IP_HOLDUP;
            Link->Item[I_ITEM_TRADE] = false;
            Screen->Message(m);
            Screen->State[ST_SECRET] = true;
         }
 
         Waitframe(); 
      }
   } 

I hope this helps!



#19 Frocks7Snee

Frocks7Snee

    Illustrious

  • Members

Posted 15 May 2015 - 06:54 PM

What I'm trying to do is have an NPC give you a key upon talking to him, by using D6 in Moosh's script. (I made my own FFC script that gives link any counter items or equipment items based on the D arguments.) On the DB page, it says that you can use D6 to activate another script upon talking to the NPC, but I'm not sure how that works. Although, I might use that trade quest script too. :P


Edited by Rocks4Free, 15 May 2015 - 06:58 PM.


#20 justin

justin

    Adept

  • Members

Posted 15 May 2015 - 07:34 PM

When you compile your scripts and assign your scripts to the slots. D6 wants the slot number of the ffc script you want run by the npc

#21 Frocks7Snee

Frocks7Snee

    Illustrious

  • Members

Posted 15 May 2015 - 07:40 PM

Slot, as in the compiler, or on the screen?



#22 justin

justin

    Adept

  • Members

Posted 15 May 2015 - 09:29 PM

compiler

#23 Frocks7Snee

Frocks7Snee

    Illustrious

  • Members

Posted 15 May 2015 - 09:38 PM

...Well, shit. I guess I'll need a seperate script for giving Link varying amounts of everything I need NPCs to give.



#24 ywkls

ywkls

    Master

  • Members

Posted 15 May 2015 - 10:44 PM

Here's some code that works on a similar principle to the trade sequence code I posted earlier. It doesn't require anything to launch except receiving the same dummy item as the other code and being in the room. You can have Link get the dummy item using string control codes.

const int ITEM_PICKUP = 20; //SFX for Link picking up an item.

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

ffc script GiveLinkStuff{ 
     void run(int countertype, int quantity){ 
          while(true){ 
              if (Link->Item[ITEM_TRADE]){ 
                   //Game->MCounter[countertype] += quantity; //Uncomment if you also want to increase the maximum amount of this item you can carry. 
                   Game->Counter[countertype] += quantity; 
                   Link->Action = LAHOLD2LAND; //Comment this line and the next one out if you want Link to silently receive the item. 
                   Game->PlaySound(ITEM_PICKUP); 
                   Link->Item[I_ITEM_TRADE] = false; 
               } 
               Waitframe(); 
          } 
     } 
}  

Keep in mind that this won't have you hold up the correct item or display a graphic of what it looks like. That's because programming each of the potential countertypes and the corresponding graphic would be an extremely complex task, since in addition to the normal array of keys, bombs, rupees, hearts, arrows and super bombs; there are also 25 Script Counters you could use.

 

If you wanted that feature, it could be scripted... I just don't know how to do it quickly or easily. Perhaps using one of the draw commands, or some kind of lweapon. I'm a bit new to scripting to tell you how to use those.This is as far as I can take you at this point unfortunately.


Edited by ywkls, 15 May 2015 - 10:50 PM.


#25 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 15 May 2015 - 11:35 PM

Link->HeldItem would probably work for that.



#26 ywkls

ywkls

    Master

  • Members

Posted 16 May 2015 - 12:17 AM

Link->HeldItem would probably work for that.

 

I thought that would require you to create a separate item for every item that you wanted Link to hold up, but I guess not. You can even use that to make it look like Link is holding up an item other than what he receives.

 

Here's the revised code, using that suggestion.

const int ITEM_PICKUP = 20; //SFX for Link picking up an item.

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

ffc script GiveLinkStuff{ 
     void run(int countertype, int quantity, int item_to_hold){ 
          while(true){ 
              if (Link->Item[ITEM_TRADE]){ 
                   //Game->MCounter[countertype] += quantity; //Uncomment if you also want to increase the maximum amount of this item you can carry. 
                   Game->Counter[countertype] += quantity;
                   Link->HeldItem = item_to_hold; 
                   Link->Action = LAHOLD2LAND; //Comment this line and the next one out if you want Link to silently receive the item. 
                   Game->PlaySound(ITEM_PICKUP); 
                   Link->Item[I_ITEM_TRADE] = false; 
               } 
               Waitframe(); 
          } 
     } 
}  

Now you can give Link any amount of any item that uses a counter and have it look like he's holding it up as he gets it. If you only want to get one item, then the trade sequence code would work.



#27 Frocks7Snee

Frocks7Snee

    Illustrious

  • Members

Posted 16 May 2015 - 10:38 PM

So now I have everything sorted out, and I have one question. How can I make a script that gives link whatever the special item is on a screen? I want an NPC from Moosh's script to give link a key, and then give him a "trigger" item that makes the NPC disappear and reappear with different text, not giving him the key again. I figured I'd use this a lot in the quest, so it would probably be easier to just make the script use whatever the special item on a screen is.



#28 ywkls

ywkls

    Master

  • Members

Posted 17 May 2015 - 07:24 AM

Actually, the Alternate Npc script can do the same thing. What it does is set the Screen->D register where it knows that you've already listened to whatever message the Npc is supposed to say whenever you first talk to it. The rest can be accomplished via string control codes.

 

Here's a good example. In the first string displayed by the Npc, you'd put into the string editor- "\3\0\1\xYou're going to need a key in order to get further.\16\y"  X is the string number to switch to once you've talked to this Npc once and Y is the item number of the dummy item. You'd also have the trade sequence script on that screen, with the item_to_give set to the item number of the key.

 

Once you talked to the Npc, it would automatically give you the key and you'd hold it up; then if you talked to the Npc again it would display whatever string you'd directed it to using string control codes. The way the Alternate Npc script is set up, you wouldn't even have to leave the room before you could talk to the Npc again.

 

Not only that, but this leaves screen secrets and the screen's special item available for use if you want to have them do something else.



#29 Frocks7Snee

Frocks7Snee

    Illustrious

  • Members

Posted 17 May 2015 - 01:19 PM

That sounds like a good idea/solution, but I don't know how to use string control codes, and I'd like to stick to my original method, if possible. (Sorry if I sound rude or disrespectful, I don't mean to at all.) What I need is a script to get the ID of the special item on the screen and give it to Link.



#30 ywkls

ywkls

    Master

  • Members

Posted 17 May 2015 - 02:01 PM



That sounds like a good idea/solution, but I don't know how to use string control codes, and I'd like to stick to my original method, if possible. (Sorry if I sound rude or disrespectful, I don't mean to at all.) What I need is a script to get the ID of the special item on the screen and give it to Link.

 

No problem, I understand completely. To be honest, string control codes are something that I discovered by accident halfway through creating my last game.

 

If you ever decide that you want to use the string control codes, you can click on the help button on your string editor and it will pull up a file that explains how they work and how to use them. They allow you to do a lot of things just using strings that you'd otherwise have to use scripts to do.

 

Of course, you are free to use whatever method that you decide. It's just that using the string control codes is easier than scripting really.

 

Here's a thought on how to script what you wanted.

ffc script GetRandomItem{
    void run(int item_to_give, int m){
        while(Screen->D[0] !=1 && !Screen->State[ST_SECRET]){
            Waitframe();
        }
        item TradeSeqItem;
        TradeSeqItem = Screen->CreateItem(item_to_give);
        TradeSeqItem->X = Link->X;
        TradeSeqItem->Y = Link->Y;
        TradeSeqItem->Pickup |= IP_HOLDUP;
        Screen->Message(m);
        Screen->State[ST_SECRET] = true;

    }
}

This would still not use the room's special item. Instead, the Npc would use the Alternate NPC Script to set the Screen->D register (which is always the zero slot). When you talk to it the first time, the register would be set and this script would be triggered, giving Link an item and triggering the screen's secrets. 

 

However, the current version of the Alternate NPC script relies upon string control codes to display a different message. So here's an older version where the string number is placed into that ffc directly.

 

Spoiler

 

If you have any questions on implementing these ideas, feel free to ask.


Edited by ywkls, 17 May 2015 - 02:02 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users