0 votes
by (120 points)
i am working on  a advanced npc chat system for my game, where the player types things into a text box to comunicate with npcs in this game. i was wondering if you could test for one or two specific key words and ignore the rest of the sentence to determine the npcs responce rather than think of every sentence some one can type up and test for it.

her is a exsample of what i want to achive:

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

player types up "hello there"

code finds the world "hello", with nothing atached, and finds it as a greeting

npc responds saying "responce to greeting"

player types up "hello freak"

code finds the word "hello", but also finds the word "freak" and finds it as a offence.

npc: "upset"

player types up hello, have you seen the freak

code sees hello and freak, but sees thet the word "have you seen" is imbitween, making it a question about some freak

npc: "responce"

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

if there is a solution that aredy exsists on the website, please comment

1 Answer

0 votes
by (44.7k points)

What you're talking about is called natural language processing, and it's very very difficult to do well.

You might want to look into chatbots, but this isn't something that's that easy to write without "cheating" a bit.

...