Jump to content

Having an NPC walk somewhere?


ThePearl

Recommended Posts

Hello there!

 

So, another beginner question with scripts. I have this NPC, and I want to talk to him, and when I have done that he will walk to the tree and stay there until a certain event happens, I know how to do dialogue but no idea how to script that... MoveTo I thought would work but that seems to teleport the target.

 

Help is appreciated

Link to comment
Share on other sites

Hello there!

 

So, another beginner question with scripts. I have this NPC, and I want to talk to him, and when I have done that he will walk to the tree and stay there until a certain event happens, I know how to do dialogue but no idea how to script that... MoveTo I thought would work but that seems to teleport the target.

 

Help is appreciated

 

That is a unique problem. You would have to use an AI package to do that. it would be triggered by the result script for that dialog topic that runs.

 

The hard part is "over there by that tree". That tree needs to be a persistent reference, as is your NPC. That way you could use the persistent reference as the location for the AI package.

 

It gets worse. What tree? What stage in the quest? There a zillion different trees in all the exterior cells.

 

See what I mean?

Link to comment
Share on other sites

Not a problem. You can do this. I do things like that frequently.

 

Create a quest. (I guess you already have if you have a talking NPC.) Put some quest stages in it like 0, 5, 10, and 15. It can even be a silent quest with no diary entries.

 

Forget about the tree. (Although I guess you could make it persistent and give it a reference ID.) It is easier to place and use an XMarker (found in the Static directory.) You can place it anywhere you like and have the NPC wander within a specific distance from it. You can put it on any side of the tree you like.

 

Put a custom wander AI package on the NPC with the condition that he only does it during a certain quest stage. The target of the AI package will be "Near Reference" your XMarker. "Radius" will be the distance he can go from it. A radius of 265 might be good for what you are doing.

 

When you talk to the NPC, and it is time for him to go over by the tree, for the last line he says. you need a "Result Script." (That box below "Response Details" and above "Conditions.")

 

SetStage AAUnderTreeQUEST 5

 

(Assuming that your quest is called "AAUnderTreeQUEST" and the condition you placed on the wander package is GetStage AAUnderTreeQUEST == 5.)

 

When the event happens and he leaves the tree, you need another wander package with a condition that it will only occur during stage 10 or something similar. You will also need another location of where you want the NPC to wander. When the event occurs, you need to have a script someplace which gives the command:

 

SetStage AAUnderTreeQUEST 10

 

The NPC may not always change AI packages immediately, but often he will. You could try this to attempt to hasten the departure, but it is unreliable.

 

SetStage AAUnderTreeQUEST 10
evp; (EValuate ai Package)

Link to comment
Share on other sites

Woah! I gave up hope for a reply a while ago.

 

Thanks for the awesome answer David (on a side note my name is David too ;D) and tutorial!

 

The tree thing was just an example, not really anything that was essential. I was thinking of keeping the char "over there by the tree" certain times of the day instead of when you talk to him. Now he can sit in his house all day long or do whatever and I'll just talk to him!

 

Anyways, will this interfere with other packages? Say if I have a package telling him to go to sleep at 10 o'clock and I talk to him and execute the script at 9:59, then will he go to sleep at 10? I could just script the whole thing and check if a stage is active, like if he's over by the tree the package won't run.

 

Thanks a lot for the replies! I'll be sure to include you in the credits if I get the mod done

Link to comment
Share on other sites

Packages do interfere with each either. You have to plan them carefully and test them thoroughly. Only one package can be active at a time. The computer reads from the top of the list to the bottom. It tends to activate the first AI package at the top of the list which has conditions which are met. If the "wander by tree" package had only the condition that it occur during stage 5, and was at the top of the list, your NPC would hang out by the tree for all eternity unless the stage changed to a higher one. He would never go to bed anymore.

 

You can put many conditions on packages though, and have many packages. For kicks, you might enjoy taking a peek at Martin's AI Packages. I believe they are the most complex in the whole game.

 

You could change the schedule on the "wander by tree" package so that your NPC won't do it during sleeping-hours or lunch-hour. You could change the schedule so he does it any day of the week at 6:00 AM for a Duration of 16 hours. If you had a sleep package on him, he would then go sleep until it was time to go stand by the tree. If you wanted to give him meal breaks, you could give him multiple "wander by tree" packages with different start times and durations. If an NPC gets distracted by socializing, fleeing, or fighting, he might skip short packages. Packages are evaluated every hour on the hour, if nothing changes them sooner.

 

So if "wander by tree" was at the top of your list and only had the condition that it occur during stage 5 on it, talking to the NPC at 9:45 would make him go stand by the tree instead of going to bed. (Poor fellow.)

 

If the "sleep at 10PM" package was higher on the list than "wander by tree," he would talk to you, walk toward the tree, turn around, and go back home to go to bed. You might be able to get proper behavior by just changing the order the packages are in. But if your NPC does lots of different things at different times, you will need additional scheduling and conditions on packages.

Link to comment
Share on other sites

Packages do interfere with each either. You have to plan them carefully and test them thoroughly. Only one package can be active at a time. The computer reads from the top of the list to the bottom. It tends to activate the first AI package at the top of the list which has conditions which are met. If the "wander by tree" package had only the condition that it occur during stage 5, and was at the top of the list, your NPC would hang out by the tree for all eternity unless the stage changed to a higher one. He would never go to bed anymore.

 

You can put many conditions on packages though, and have many packages. For kicks, you might enjoy taking a peek at Martin's AI Packages. I believe they are the most complex in the whole game.

 

You could change the schedule on the "wander by tree" package so that your NPC won't do it during sleeping-hours or lunch-hour. You could change the schedule so he does it any day of the week at 6:00 AM for a Duration of 16 hours. If you had a sleep package on him, he would then go sleep until it was time to go stand by the tree. If you wanted to give him meal breaks, you could give him multiple "wander by tree" packages with different start times and durations. If an NPC gets distracted by socializing, fleeing, or fighting, he might skip short packages. Packages are evaluated every hour on the hour, if nothing changes them sooner.

 

So if "wander by tree" was at the top of your list and only had the condition that it occur during stage 5 on it, talking to the NPC at 9:45 would make him go stand by the tree instead of going to bed. (Poor fellow.)

 

If the "sleep at 10PM" package was higher on the list than "wander by tree," he would talk to you, walk toward the tree, turn around, and go back home to go to bed. You might be able to get proper behavior by just changing the order the packages are in. But if your NPC does lots of different things at different times, you will need additional scheduling and conditions on packages.

 

 

Ok thanks for the explanation, it helps a lot! I am the programming kind of guy so I'll go with scripting, do you know anything about creating libraries for it if it is possible?

 

I'll make sure to check out some of Martin's packages :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...