PDA

View Full Version : Sign post



pkmnfrk
07-03-2007, 06:40 PM
Signpost script:


//remove this line if you already have a script file.
import "std.zh"

ffc script sign {
void run(int m) {
while(true) {
while(Link->X < this->X - 8 || Link->X > this->X + 24 || Link->Y < this->Y || Link->Y > this->Y + 24 || Link->Dir != DIR_UP || !Link->InputA) {
Waitframe();
}
Link->InputA = false;
Screen->Message(m);

while(Link->X >= this->X - 8 && Link->X <= this->X + 24 && Link->Y >= this->Y && Link->Y <= this->Y + 24 && Link->Dir == DIR_UP) {
Waitframe();
}

Screen->Message(0);
}
}
}

To use this, give the FFC the number of the string as the first argument. Then, the script will wait until Link is just below the sign, and facing up, and pressing A, and it will display the message.

Tips:


It works best with the "Messages freeze all action" and "Messages disappear" rules.
You can make the FFC's combo the sign, or you can make it invisible, and place it ontop of an existing sign
If you do the former, make sure the combo underneath the FFC is solid, or Link will walk right through it!


-----------------------

NPC script:


//remove this line if you already have a script file.
import "std.zh"

ffc script real_npc {
void run(int m, int s, int f, int d, int def_dir) {
int d_x;
int d_y;
int a_x;
int a_y;
int orig_d = this->Data;

if(d == 0) d = 48;


while(true) {
d_x = this->X - Link->X;
d_y = this->Y - Link->Y;
a_x = Abs(d_x);
a_y = Abs(d_y);

if(f != 0) {
if(a_x < d && a_y < d) {
if(a_x <= a_y) {
if(d_y >= 0) {
this->Data = orig_d + DIR_UP;
} else {
this->Data = orig_d + DIR_DOWN;
}
} else {
if(d_x >= 0) {
this->Data = orig_d + DIR_LEFT;
} else {
this->Data = orig_d + DIR_RIGHT;
}
}
} else {
this->Data = orig_d + def_dir;
}
}

if(Link->InputA && a_x < 24 && a_y < 24) {
if(s != 0) Game->PlaySound(s);
Link->InputA = false;
Screen->Message(m);
}
Waitframe();
}
}
}

Takes 5 parameters (!!):

0: The message. Same as the sign post.
1: S sound to play when activated.
2: Whether to have the NPC turn to face Link when he's near. See below for details. (0 is off, anything else is on)
3: If #2 is on, how close Link must be for the NPC to turn, in pixels (+ 16, because that's how wide Link is) (default is 48)
4: If #2 is on, which direction is the "default" direction, when Link is far away (0 - Up, 1 - Down, 2 - Left, 3 - Right)

To have an NPC that faces Link, you must put the combos for each direction in a certain order: Up, Down, Left, Right, AND! You must set the FFC to the UP facing combo. If you do that, you'll be fine.

Tips:


Like the Sign post, you should put a solid combo on the same square as the NPC, so Link can't move through it.
If you use the facing feature, then you must use the FFC as a sprite, you can't have it invisible on top of an NPC combo. If you're just using a plain NPC, then it doesn't matter which you do.
It works best with the "Messages freeze all action" and "Messages disappear" rules.


Have fun!

Beta Link
07-03-2007, 10:49 PM
Cool! I'll probably use this! I thought _L_ was going to make signpost combos though. Now I'm not sure cause there's only going to be bug-fixing from now on...

pkmnfrk
07-04-2007, 12:13 PM
If he was, it won't be for a while.

Master_of_Power
07-04-2007, 12:38 PM
This is great for making NPCs. Perhaps you can make it that the combo directly under the FCC is solid instead? that way you can make it move.

Beta Link
07-05-2007, 08:24 PM
Hey, wait! The script doesn't work! :( I just tried to compile it in Build 443 and it messed up in lines 4 and 10. On both lines it said "Tmp, Line 4/10: Error 509: Variable DIR_UP is undeclared.".

Master_of_Power
07-05-2007, 08:32 PM
It works for me :tongue:

you got to put


import "std.zh"

or


include "std.zh"

at the top of your buffer file before it compiles correctly. I forget exactly which one, though...

beefster09
07-05-2007, 11:14 PM
it's import. pkmnfrk, could you tack that on?

BTW: typed out long would it be Pokemon freak or Pikmin freak?

pkmnfrk
07-06-2007, 11:27 AM
it's import. pkmnfrk, could you tack that on?

I know it's important, but I designed it to be pasted into someone's pre-existing script file. But, ok.


BTW: typed out long would it be Pokemon freak or Pikmin freak?

It would be "pkmnfrk". I picked the nick in grade 5, and I now regret it, 9 years later.

beefster09
07-06-2007, 06:39 PM
Look what I made from pkmnfrk's code. NPCs!


import "std.zh"

ffc script Person {
void run(int m, int s) {
while(true) {
while(Link->X < this->X - 16 && Link->Dir != DIR_RIGHT || Link->X > this->X + 32 && Link->Dir != DIR_LEFT || Link->Y < this->Y - 16 && Link->Dir != DIR_DOWN || Link->Y > this->Y + 32 && Link->Dir != DIR_UP || !Link->InputA) {
Waitframe();
}
Link->InputA = false;
Screen->Message(m);
if(s >= 0) {
Game->PlaySound(s);
}

while(Link->X >= this->X - 16 && Link->X <= this->X + 32 && Link->Y >= this->Y - 16 && Link->Y <= this->Y + 32) {
Waitframe();
}

Screen->Message(0);
}
}
}

The first argument is the string; the second is the sound.

Whew! Glad I previewed.

pkmnfrk
07-06-2007, 09:25 PM
Hmm, actually, that's not how I would code it. I'll post an NPC script in a minute.

beefster09
07-06-2007, 09:44 PM
I think I'll tweak the signpost to be more like a GB signpost. (where you can only read it from the front.)

EDIT:Odd... It should do that, but you can read it from the sides and back.

pkmnfrk
07-06-2007, 10:18 PM
I added the NPC script, but what's this about reading it from the back? That shouldn't be. I distinctly recall testing it for that. Hang on.

Edit: Well, I tried it out, and the only small quirk is that if you're next to a sign, and facing up, you can read the sign. But, other than that, my code explicitly checks for Link facing up, and for him to be in front of the sign.

Plissken
07-07-2007, 08:23 PM
Man thanks a lot for this awesome script. But I'm having one problem with both of the scripts in the first post. It seems that most of the time the scripts just won't work...but sometimes they do without me changing anything. These are some of the first scripts I've actually cared enough about to get it working right. I've got everything I've done in the setup confirmed and I've done it all correctly. So is this just a stability problem with builds or is there something I can do? By the way I'm using build 448.

pkmnfrk
07-07-2007, 11:15 PM
Well, what doesn't work about them? Although I haven't tried them specifically on build 448, I did try them on 443, and there haven't been any ZScript or FFC related changes since then.

The detailed steps for using any FFC script is as follows:

1. Create your script file - If you've never used a script in your game before, you need to create a new file for them. It will hold all your scripts, and should look like this:


import "std.zh"

//this is where scripts go

Save it as "myquest.z" or something like that. (But, the ".z" extension is important!)

2. Copy and paste the script into your file - Paste it just underneath the "this is where scripts go" line. The script is everything from "ffc script whatever {" to the last "}"

3. Import the script file - In ZQuest, go to Tools->Scripts->Compile ZScript... Then, click "Import" (If a window pops up asking if you want to replace, click Yes). Navigate to your script file, and double click on it.

4. Compile it - Click on Compile!, and it will show the results of compilation (6 "passes", the details of which are wholly irrelevant). If there's an error in the script (such as if you copied and pasted wrong, it will say what the error is. Please post the error here, if you could)

5. Assign it - After the compiling is done, a new window pops up in which you assign script slots. Pick a script on the right (such as "sign"), and a slot on the left (such "Slot 1: <none>"), and hit the little "<<" button to assign it. Note which number you assign to which script!!!! Hit Ok. It will confirm that the script were assigned successfully.

6. Create your FFC - This varies depending on the script, but I'll assume you're using the sign post script. So, go to Data->Freeform Combos and pick an FFC. Assign the sign post combo, and position it somewhere. Then, in the Script box, choose the script number you assigned in Step 5.

7. Assign the arguments - Then, click on the Arguments tab, and fill in the script-dependant values (for the sign post, the only one you need is #0, which is the number of the string to display)

8. Save - Yeah.

9. Test - Go into your game, go up to the sign post, and hit A. It should then display the string.

If you have problems at any of these (very detailed and condescending) steps, let me know. I'll probably also turn this into a tutorial on my other site (http://zctut.com)

Plissken
07-07-2007, 11:24 PM
Well I've done all of that and now the npc script is working all the time but the signpost still just stopped working (As in everything's set up right but when you press A the message doesn't come up.) If I figure anything out I'll tell you.

pkmnfrk
07-07-2007, 11:30 PM
Well, keep in mind that the sign post is only designed to be activated from the bottom. That's the main difference between it an the npc script (other than the npc facing thing).

Also, if you want to swap scripts easily, put both scripts in the same file. If you put them in separate files, they won't import properly.

Plissken
07-07-2007, 11:39 PM
Ok that's where I went wrong. When I entered them in separatly the last one I entered was the only one that works. Thanks!

pkmnfrk
07-08-2007, 12:01 AM
Ah, heh, I did the same thing myself, when I started scripting. Now, I just throw everything into a big file, and worry no more :)

Joe123
09-11-2007, 12:12 PM
It seems very easy for you to carry on re-reading the string if you're holding down A to speed up the message - and not very easy to escape from constantly re-reading the string.

Ebola Zaire
09-11-2007, 11:52 PM
This is an EXTREMELY useful script. Is there any way you could get it to display a layer when it's activiated, for text backgrounds and such?

Master_of_Power
09-12-2007, 05:07 PM
in the text editor you could choose a frame :P

Joe123
09-12-2007, 05:15 PM
howhowhowhowhowhow
how can I do this

Ebola Zaire
09-12-2007, 11:04 PM
in the text editor you could choose a frame :PYou can do that now?!?

Geez, I'm not paying attention lately.

Joe123
09-15-2007, 03:52 PM
Would anyone mind modifying this script so that after speaking to the NPC, there is a second or so gap before you can speak to it again - so that you can actually walk away from them, instead of being trapped and having to talk to them several times?

EDIT: And then it dawned upon me. The way to fix this was not to pester other people, but to figure out a way to do it myself!

Anyway, the script for the real NPCs works a lot better if you change the two 'InputA' commands to 'InputL' and use the L button to speak to people, because then if you have the 'Messages can be sped up with the A button' rule on, which I assume most people do, you don't get stuck in a loop of talking to the same NPC about 3 or 4 times.

shadowfall1976
01-07-2008, 01:52 AM
is it possible to get the signpost to play the sound the same as an actual
string displaying in a room, as in.. constantly as it's typing the letters out?

I haven't tried the NPC with sound, but the signpost doesn't have that option.

pkmnfrk
01-07-2008, 02:29 AM
The Message itself should take care of creating that sound. That is not changed in either the Signpost or the NPC scripts. The sound option in the NPC script is for, say, a dog making a "woof" sound when you talk to it, in addition to the message "Dog: Woof!".

If you're not getting a sound out of your messages, check to make sure the SFX box is filled in in the String editor. If it isn't, you can set it to the default (18)

shadowfall1976
01-10-2008, 03:12 AM
it didn't work in the last version of ZC (where I added it), but in 718 it works fine.
Thanks

Blood Less
09-19-2008, 05:30 PM
Im very new at scripting and I put in the script exactly but it has 4 errors 2 that say that "DIR_UP" is undeclared and 2 that say "waitframe" is undeclared, what does that meen and how do i fix it?:confused:

Elmensajero
09-19-2008, 08:32 PM
DIR_UP is declared in "std.zh". This file should already be in the same folder as ZQuest is (unless you moved it for some reason extracting all the files), so make sure that it is there, and at the top of the script there is the following line:

import "std.zh"

Also, for "Waitframe();", make sure that the 'w' is capitalized and the rest of that line of code looks exactly like it is found in the first post of this thread.

If you have more trouble, just make sure you follow the steps in post 14 (http://www.armageddongames.net/forums/showpost.php?p=1129152&postcount=14) to get it working.

Blood Less
09-20-2008, 01:41 PM
Thanks, it works now.:)

pkmnfrk
09-20-2008, 02:01 PM
Thanks, it works now.:)

FYI, you need this at the top of every script file.