• Popular Now

• 9
• 10
• 11
• 13
• 9

Archived

This topic is now archived and is closed to further replies.

NPC communication idea & implementation

This topic is 5371 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I''m interested in trying out an idea for more interactive game worlds. I do not have a game idea to go with it; this is just about world interactivity/believability. It centers around simulating communication in NPCs. Here''s a basic rundown. The system has two layers: the information layer and the translation (language) layer. The info layer determines all the information a certain NPC has about the game world. The language layer takes that information and builds the speech of the NPC with it. The info layer I picture as a tree structure. Each node in the tree stores the info available there and the connections it has to other nodes. The nodes could be people, buildings, cities, whatever. One example might look something like this.
                 world
/           \
city1          city2
/       \         /      \
bldg1    bldg2    bldg3    bldg4

Below the last row would be the actual NPCs. So, if bldg1 is the grocery store where a lot of people go every day, it would have access to a lot of data. When an NPC arrives at the building they share the data they have with it, and they look at what the building has and take some info with them. This is kind of a long-winded explanation, and I hope I got the point across. Some obvious problems include speed (that''s a lot of processing just for some NPC lines,) grammar (turning "DRAGON ATTACK TOWN2" into "I heard a dragon is on the loose! How could this happen??" or somesuch,) and information flow (NPC1 heard about a major event, but no one else knows until they go to the store/courthouse/bar/wherever it is they go.) This could also develop into a computation vs. scripting issue. IE, how do the NPCs decide where to go and where to transfer information? Are there any other points I''m missing? Other things I need to cover? This thread is about both fleshing out the system and how to implement it, although the implementation could also get its own thread in General Programming. Anything else I need to describe? Please, comment.

Share on other sites
The idea is cool, but there are some problems.

First, you have to make sure that the NPCs dosen''t share stuff they don''t want to, or shouldn''t share - like if the NPC''s wife got kidnapped and got told not to tell anyone about it - except the hero of the game, of course, when the NPC feels he deserves it. Or simple stuff such as "the key to my treasure chest is hidden under my pillow".

Secondly - and probably harder.... How is the player supposed to find the NPC he''s looking for, if that NPC (actually almost all NPCs) are out walking errands and talking to other NPCs. In RPGs up to today, NPCs stand in basically the same place during the whole game which makes them easy to find.

In a modern setting, the character could get a cell-phone and thru some interface tell an NPC to "meet me outside Town Hall, now.", but that would in a way be weird too. Plus, in fantasy RPGs - how is the dumb warrior gonna get ahold of someone?

It''s definately a good idea, like I said, but that problem needs to be solved in some really neat way.

"Some obvious problems include (...) grammar"

Actually, I just wrote a program yesterday that randomizes a greeting (the first thing the NPC say when you start talking to him), and there''s no grammar involved at all. Just a simple "if he says this word, then this is a list of the next word he can say."

Here''s some output... I think it''s 30 randomly generated lines:

---------- Run ----------
Hey man! My name is Franz Weber. What''s your''s?
Hey man! My name is Franz Weber, and I live here.
Hi there! Allow me to introduce myself. My name is Franz Weber, and I live here.
Hey, what''s up? Allow me to introduce myself. My name is Franz Weber, and I live here.
Hey, what''s up? My name is Franz Weber. What''s your''s?
Hey, what''s up? Allow me to introduce myself. My name is Franz Weber. What''s your''s?
Hi! My name is Franz Weber. What''s your''s?
Hi, sup? Allow me to introduce myself. My name is Franz Weber. What''s your''s?
Hey there, idiot! Allow me to introduce myself. My name is Franz Weber, and I live here.
Hey there! My name is Franz Weber, and I live here.
Hey man! Allow me to introduce myself. My name is none of your business, bastard!
Hi there! My name is Franz Weber, and I live here.
Hi, sup? Allow me to introduce myself. My name is Franz Weber, and I live here.
Hey man! My name is Franz Weber. What''s your''s?
Hi there! Allow me to introduce myself. My name is Franz Weber, and I live here.
Hey man! Allow me to introduce myself. My name is Franz Weber. What''s your''s?
--
Normal Termination
Output completed (0 sec consumed).

Now, as you can see, some of them sound a bit dumb, but there''s not anything that should be very difficult to implement, really. Most important thing to do now is to have the NPC take different feelings into the calculations.

Btw, that whole program is less than 100 lines of Python code.

Share on other sites
I''ve been thinking about a similar npc system.
Maybe the best sollution is to have npc dialogues that are shared ( using a random generator as posted by Srekel) and dialogue that is unique. Based on a gossip param you could give each npc a percentage of gossip it lets loose( besides this you could do checks with the players'' skills like empathy, speechcraft etc. to lift the gossip percentage a bit)

There are some practical/technical limitations to this.
For example you, as player, decide to kill person B. Person A is in range and spots you slaying mister B. He stores a gossip entry in his gossip vector: Player killed mr B. and assigns a weight to this gossip. Killing would possibly score a 100% so mr A would go running for a guard. This is possible.
But when the number of npc''s increase the complexity goes through the roof. Mr Aa steals this, mr B dances badly , mr C gets killed by D.

It would be cool to work this npc stuff out. So far my 2 cents.

Look at all the pretty colours!

Share on other sites
Somewhere I still have the design document I put together about 8 years ago for a similar scheme - in my scheme, information has a secrecy value (how likely it is to propagate) and a value that tracks how widely the information has spread (in a given area) Once the information spreads widely enough, it gets attached to a higher-level node (rather than the common-room of the local inn knowing about it, the entire village knows about it). How widely the information has to spread to get promoted depends on its secrecy level. To actually pick up information, ''foreign'' NPCs need to be in the same place as a local native.

There were other refinements, but it''s been a sufficiently long time since I looked at my design last that I can''t remember it all

Share on other sites
quote:
Original post by Srekel
Secondly - and probably harder.... How is the player supposed to find the NPC he''s looking for, if that NPC (actually almost all NPCs) are out walking errands and talking to other NPCs.
Maybe when someone tells you to look for certain NPC, they give you a description and tell you where that NPC goes frequently. Then it''s simply a matter of going out and actually searching for that person.
quote:
In RPGs up to today, NPCs stand in basically the same place during the whole game which makes them easy to find.
This is one thing I would love to see disappear.

That speech system you have looks pretty good. I was thinking about using a template design where you just insert specific words into the right slots.

"Have you heard? The [NOUN] [IS/ARE] [VERB]ing!"

Share on other sites
"Maybe when someone tells you to look for certain NPC, they give you a description and tell you where that NPC goes frequently. Then it's simply a matter of going out and actually searching for that person. "

It's definitely - imo - "simply a matter" if you have to do it every time for each NPC that you wanna get ahold of.

Another very similar way to do it (but less tedious for the player) is if he could ask someone "have you seen this person", and they'd ALWAYS say somethning like "yeah, he's down at the pub/at home/etc", and the NPC [u]would[/u] be there

This is really a problem that we should try to solve. Any more ideas out there?

"That speech system you have looks pretty good. I was thinking about using a template design where you just insert specific words into the right slots.

"Have you heard? The [NOUN] [IS/ARE] [VERB]ing!" "

My system is a lot easier than that. Basically, I have different words that links to a list of other words.

So "Hi" -> "there" / ", sup?" / " what's up?"
"Allow me to introduce myself. " -> "My name is"
"My name is" -> " none of your business" / "Franz Weber"

and so on. Btw, Franz isn't my real name, it's the first character we were introduced to in my first German language book in school

[edited by - Srekel on July 28, 2003 4:03:30 PM]

Share on other sites
Your system does work better for static information. I want to use dynamic information. I want a system that will allow for dynamic events to happen. So, maybe the king is coming through town. Maybe I would create an Event to add to the EventList and fill it up with something like {king, coming, Friday}. Then I grab the appropriate speech templates.

future, likes king: "The king will be here Friday. I can''t wait to see him!"

past, dislikes king: "That old coot was here Friday. I can''t believe people agree with that guy."

present, indifferent: "Yeah, so the king''s here, but did you see his daughter? Wow, what a hotty!"

It would be a lot of work to make it sound right though.

Share on other sites
That''s hopefully something that my system will be able to generate when it''s done. The interesting thing is that it doesn''t SEEM to be that difficult!

The engine would just have to take in parameters such as
- What the character thinks and feel about what he/she''s saying
- What should he want to talk about (i.e. the king comes to town, he has a quest he wants taken care of etc.)
- What kind of character it is, anything that might influence the way he talks...
- ...?

"Kaka e gott" - Me
Current project: An RPG with tactical, real-time combat and randomly generated world and dialogue.

Share on other sites
Right. The hard part is taking account of all that stuff with the right grammar. You need to avoid getting things like "The undeads is back again!" I think this is one of the hard parts with any natural language system.

Another issue is events. I want my information system able to handle dynamically generated events from "a dragon is attacking" to "I was just mugged" to "that new shop around the corner has some really good pie." Hopefully there''s a way to handle all these with the same event structure.

Share on other sites
Why is it so bad to have to run around looking for an NPC? I''d much prefer it to having all these useless NPC''s just standing around getting in my way and doing nothing important. Let''s face it, by the later parts of the game you''ll probably be able to teleport to whatever town you want, so what''s the big deal?

I''d much rather have npc''s wandering around, maybe getting themselves in trouble every now and then. Maybe one night you try to stay at an inn, but you can''t because it''s full of wandering npc''s. Maybe some wandering npc gets captured by a group of goblins and taken back to their hideout, giving you a side-quest to do that wasn''t pre-planned. Another thing I never understood about old video games was why the hell don''t you ever see people in the wilderness, only in towns or maybe rarely sitting at the entrance to a dungeon? Why are they only in important parts of the game? Why can''t you run across some random guy chopping trees in the woods? And why are there rarely npc''s standing in a shop buying armor when you walk in? Sure, maybe you''re the biggest, buffest, heroes in the world, but does that mean other people don''t need the occasional sword or healing potion?

Sure sometimes realism isn''t fun, but I think if you find the proper balance it could add a lot to a game.

If a squirrel is chasing you, drop your nuts and run.