• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

AI NPC – Proof of Concept

Joined
Jan 9, 2010
Messages
57
Reaction score
12
Location
Germany
Hey everyone, so I just started building my own OT and I love trying out weird ideas, one day I thought what if I connect an npc to a local ai, i tried it and it was so funny to me. And now I want to share it so you can build on it too :)

Screenshot example: asked ai, why is the sky blue in englisch, polish, german

1774080039672.webp1774080192297.webp1774080213231.webp

Built this on TFS 1.2, other versions might need small tweaks to the class registration.
You'll also need LM Studio and two vcpkg libraries, cpr::cpr for the HTTP client and nlohmann_json::nlohmann_json for JSON parsing.

Step .1

get LM Studio running. Download it, activate Developer Mode, grab any AI model you like, there are plenty of tutorials out there if you get stuck. Then just start the local server inside LM Studio, thats really all there is to it.


Step 2

install the dependencies with vcpkg install cpr nlohmann-json

Step 3

add the HTTP client to your TFS. Add httpclient.cpp and httpclient.h to your server, then edit your root CMakeLists, the TFS CMakeLists and hook up the class registration.

Step 4

wire up the Lua method. Edit luascript.cpp and luascript.h to expose a new function to Lua that talks to your local AI server.

Step 5

drop in the NPC. Edit ChatGpt.lua and ChatGpt.xml and place the NPC wherever you want in your world.

In the payload for the Ai model you can set your own rules how the ai model should act. Like u see in httpclient.cpp file.
Thats it! Your NPC now talks back using a fully local AI model. Feel free to improve it like ratelimiter to to prevet ddos attack etc. For the start. I added in the chatgpt.lua the prefix 'dear oracle' so the ai post method will only be triggerd with this prefix. im excidted by your ideas.

Have fun :)
 

Attachments

I have curiosity about prompt engineering xD

Imagine ask about DB info to your npcs
 
I have curiosity about prompt engineering xD

Imagine ask about DB info to your npcs
Imagine giving it access to your server file and asking for the decryption password for a given user. Would be hilarious.
It can be "guarded" but... Even big LLMs were broken before
 
I think every NPC in any mmorpg in the future should be AI-powered. It doesnt mean every NPC becomes a Chat GPT, but rather you feed the NPC whatever knowledge it is supposed to have, and make sure they are limited to answer within that knowledge, so players will have a natural conversation with any NPC and feel real, and it can also be part of quests, lore, mysteries, etc.

This way we go from the basic "keyword" based pre-programmed responses to natural language speaking NPCs, that still fulfill their roles in the game, as long as you properly build the model and prompting for it, so it does not deviate from its original purpose in the game.
 
I think every NPC in any mmorpg in the future should be AI-powered. It doesnt mean every NPC becomes a Chat GPT, but rather you feed the NPC whatever knowledge it is supposed to have, and make sure they are limited to answer within that knowledge, so players will have a natural conversation with any NPC and feel real, and it can also be part of quests, lore, mysteries, etc.

This way we go from the basic "keyword" based pre-programmed responses to natural language speaking NPCs, that still fulfill their roles in the game, as long as you properly build the model and prompting for it, so it does not deviate from its original purpose in the game.
I agree, but it’s difficult. The more you constrain AI to keep it in its role, the closer it gets to traditional, hard-coded NPCs. In the end the question is at what point is it still “AI” and not just a more complex dialogue tree
 
I agree, but it’s difficult. The more you constrain AI to keep it in its role, the closer it gets to traditional, hard-coded NPCs. In the end the question is at what point is it still “AI” and not just a more complex dialogue tree
Honestly there's a mile difference between our typical keyword based fixed speech to an AI powered NPC, you can have a base of knowledge and limit the NPC to speak on that knowledge, the LLM are trained to build phrases an and understand context and meaning, so you wont have to stick to a specific work, and plus you will be able to talk naturally to any NPC, and it will respond with its own personality and knowledge.

It will go from players saying "hi, quest" or "hi, <keyword>", to players naturally speaking as if they were a human "hey, where can I find X", as the LLM will fully "understand" the sentence, not just grab one keyword out of context. This mean you could have the same "keyword" prompt different responses from the NPC, depending on how you build the sentence.

"Hey where can I find a job?" vs "Hey what is your job?" -> the LLM will understand context, and will provide a different answer, whereas in the legacy system it just ignores the context and stick to keyword "job" and gives you the same answer.

You would go to from a finite, e.g. 10-50 different max speeches from fixed keywords, to a virtually infinite conversation combinations possibilities
Post automatically merged:

I think you just need to make sure to provide a decent base of data for each NPC, with its personality, its knowledge about the world, its purpose, and then probably for questing you'd have to still rely on keywords in some way, that would be tricky for sure, but it would be much more fun than the traditional NPCs 100%, and we know it is not that hard to achieve, just a matter of time until it becomes standard for MMORPGS to use AI for human-NPC interactions everywhere.
 
Last edited:
Honestly there's a mile difference between our typical keyword based fixed speech to an AI powered NPC, you can have a base of knowledge and limit the NPC to speak on that knowledge, the LLM are trained to build phrases an and understand context and meaning, so you wont have to stick to a specific work, and plus you will be able to talk naturally to any NPC, and it will respond with its own personality and knowledge.

It will go from players saying "hi, quest" or "hi, <keyword>", to players naturally speaking as if they were a human "hey, where can I find X", as the LLM will fully "understand" the sentence, not just grab one keyword out of context. This mean you could have the same "keyword" prompt different responses from the NPC, depending on how you build the sentence.

"Hey where can I find a job?" vs "Hey what is your job?" -> the LLM will understand context, and will provide a different answer, whereas in the legacy system it just ignores the context and stick to keyword "job" and gives you the same answer.

You would go to from a finite, e.g. 10-50 different max speeches from fixed keywords, to a virtually infinite conversation combinations possibilities
Post automatically merged:

I think you just need to make sure to provide a decent base of data for each NPC, with its personality, its knowledge about the world, its purpose, and then probably for questing you'd have to still rely on keywords in some way, that would be tricky for sure, but it would be much more fun than the traditional NPCs 100%, and we know it is not that hard to achieve, just a matter of time until it becomes standard for MMORPGS to use AI for human-NPC interactions everywhere.
Yeah absolutly,

My point was more about the mechanics that actually move the game forward the moment an npc needs to trigger a quest, process a trade or update the game state, an LLM alone is just too unpredictable for that. You still need a reliable layer underneath that turns what the player says into actual in-game actions.
And if you start restricting the LLM enough to make it predictable for that, you might as well just hardcode it anyway. I think a hybrid approach is a possible way
 
Back
Top