PDA

View Full Version : Simple npc modification



King of Dwythia
11-09-2007, 06:56 PM
This is a simple modification of the NPC script by pkmnfrk found at http://www.armageddongames.net/forums/showthread.php?t=98097.

This modification does two things. First, it prevents link from reading the string more than once without first leaving the screen (which prevents the string from starting over when you press 'a' to speed up the script or to attack an enemy sneaking up on you). Second, it allows you to search the screen for a combo, and if the combo exist, play an alternate string.



//real_npc by pkmnfrk and modified by King of Dwythia
ffc script real_npc {
void run(int m, int s, int f, int d, int def_dir, int newcombo, int m2) {
int d_x;
int d_y;
int a_x;
int a_y;
int orig_d = this->Data;
int CheckCombo = 0;
int alreadydone1 = 0;
int alreadydone2 = 0;

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(newcombo != 0) {
for (int i = 0; i <= 176;i++) {
if (Screen->ComboD[i] == newcombo) {CheckCombo = 1;}
}
}

if(f != 0) {
if(a_x < d && a_y < d) {
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;
if(CheckCombo==0 && alreadydone1 == 0) {Screen->Message(m); alreadydone1 = 1;}
else if (CheckCombo == 1 && alreadydone2 == 0) {Screen->Message(m2); alreadydone2 = 1;}
}
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.

I have added two more parameters:
5: The number of the combo to look for
6: The number of the alternate string to display

I can see several uses for this script. Here's the scenario that I wrote it for: Link needs to cross a bridge, but it is broken. There is a person sitting next to an unlit campfire. When link talks to him, he says "I'm cold, light my fire and I will repair the bridge". Link lights the fire, the bridge is repaired. The lit fire happens to be the combo the script is looking for, and now that it is on the screen, the guy, when talked to, will now say "Thanks".

_L_
11-10-2007, 07:32 AM
First, it prevents link from reading the string more than once without first leaving the screen (which prevents the string from starting over when you press 'a' to speed up the script or to attack an enemy sneaking up on you).
In the NPC script I'm using in NeoFirst, I just put the following lines after the Screen->Message line:
do {
Waitframe();
} while (Link->InputA);And it works fine.

Joe123
11-10-2007, 07:47 AM
If you just set it so that Link speaks/reads with L or R it works fine also.

King of Dwythia
11-10-2007, 11:01 AM
The primary purpose of the script was not to prevent the user from reading the script more than once, that was just a quick extra I added simply because it was driving me crazy. It was originally written so that when a secret combo is triggered, a new string is displayed.

Thanks, though, I will probably use one of these ideas instead, they do seem simpler and easier to use.

Dann Woolf
11-02-2008, 08:10 PM
This is a pretty fucking awesome script. One thing that bugs me though is that white text on the light colors of the overworld is pretty hard to see. Any suggestions to fix this?

Din
11-02-2008, 08:31 PM
You might not actually need scripts, all you need to do is edit the color the string uses. Change it from white to black, red, green, anything you want! Or you can use a simple string pane included within the wonderful string editor, whichever seems easier.

Dann Woolf
11-03-2008, 02:50 AM
You might not actually need scripts, all you need to do is edit the color the string uses. Change it from white to black, red, green, anything you want!

Yes, but which color is best? Or could I maybe change the font itself, to include an outline like the font in AlttP?


Or you can use a simple string pane included within the wonderful string editor, whichever seems easier.

Your ideas intrigue me and I would like to subscribe to your newsletter.

Din
11-03-2008, 11:48 AM
Well, all you need to do for color would be to perhaps make it something a little darker, that would fit into a cave at the same time. Perhaps green? Well, if all else fails you can just go to a string and click the pane selection tile square. Then just click a 2x2 frame (or is it 3x3?) to use as a pane. But make sure that the frame's inside is black and not see through! Hope that helps a bit.

Dann Woolf
11-03-2008, 12:15 PM
Wow, I didn't know you can do that.

Haven't used ZC in ages, so that explains it.