NPC
This script is an extension of the Sign post script. It includes a few new features over the sign post:
- The NPC can turn to face Link, like in Oracle of Ages/Seasons
- The NPC can play a sound when you talk to them
- You can customize how close Link needs to be before they turn
- It can be activated from any direction, as long as Link is within 8 pixels.
Script
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();
}
}
}
Arguments
- The number of the string to play (may be linked to other strings, doesn't matter)
- The number of the sound to play. 0 is play no sound.
- Whether or not to face Link (0 is no, 1 is yes) (see below for details)
- How close Link must be to turn (in pixels) (is effectively -16 pixels)
- The default facing direction (0 is up, 1 is down, 2 is left, 3 is right)
Notes
- If using the facing feature, you must create four combos for the NPC, in this order: Up, Down, Left, Right. You must also set the FFC to use the Up facing combo (the reason for this particular order is arcane, but it works).
- Also if using the facing feature, you must place a solid combo under the FFC if you don't want Link to walk through it! Otherwise, make the FFC invisible, and put the NPC on the map.
- Works best with the "Messages freeze all action" and "Messages disappear" quest rules.
Screen shots



