MZ Utilizing AI for NPC dialogue?

I'm making a game where there are two NPCs that I would love to incorporate AI generated dialogue for. It wouldn't be used as the main source of dialogue for them, but at certain points, I'd love for the dialogue to be unique to the player and how they played so far, where they've been, how long they've been playing, etc. I could technically create conditions, but that would take forever (and at one point the NPC gets possessed so I think AI could really add in some cool, creepy dialogue).

I'm looking into different NLP that use js. I would prefer free or a one time licensing fee since I want to release my game so having usage limits is annoying. But I wanted to hear if anyone has any experience with AI dialogue for NPCs (that isn't based on players inputting text).


Thank you! But from my understanding, this uses player input and also requires subscription tiers for use of an API Key, which I'm trying to avoid. But thank you 🙂
I'm not familiar with coding or AI, but I think everyone is going to charge for a sub.
As for input, you could see if it could do it automatically, rather than player input.
Thank you! But from my understanding, this uses player input and also requires subscription tiers for use of an API Key, which I'm trying to avoid. But thank you 🙂
If you don't want to use player input, just store the string for what the player "says" in variable 3 and use the "display response" plugin command, and the AI will respond without the player having to enter anything. Inworld also allows 5000 free interactions a month on the free tier and there's no subscription required for that. On pay as you go, it's $0.002 per interaction.
I'm not familiar with coding or AI, but I think everyone is going to charge for a sub.
As for input, you could see if it could do it automatically, rather than player input.
Big companies I believe do negotiate license agreements for commercial projects! I just wouldn't want to have to pay forever for my games API key to be usable. Like if I stop, the game just wouldn't work anymore? I'd rather pay a lump sum upfront
I've searched around and there are already game demos showcasing AI NPC's. However all games I've found thus far are made on Unreal, which those games cannot run on my outdated operating system.

It may be possible in a vague future where you can just download the AI so the AI doesn't require an internet connection and thus wouldn't require a subscription, but AI is often done through cloud computing for a reason. Offline versions for AI tend to be several gigabytes in size and running those is going to be slow.
I guess you could save a hundred or so responses ahead of time inside the game and randomly pick one to show the player.
That's also an option. You could set up an NPC in Inworld, interact with it in the Studio (which doesn't even use up your monthly free interaction quota) and then use a pool of its responses as possible dialogue, so it's a "simulated" AI.
The problem at that point is it's no longer really germane to the OP's request:
I'd love for the dialogue to be unique to the player and how they played so far, where they've been, how long they've been playing, etc. I could technically create conditions, but that would take forever
The problem at that point is it's no longer really germane to the OP's request:
Well, that was kind of my point (sorry if the wording was wrong). I could create dozens of conditions that affect the response an NPC gives, but I'd love just to have AI that can generate responses based on different factors regarding the player's choices/etc. It'd be possible to get a similar result manually, but it'd take so much time and even then I probably wouldn't be able to account for all possible factors that a good AI might

I guess you could save a hundred or so responses ahead of time inside the game and randomly pick one to show the player.
It's definitely possible but so time consuming and, to make it relevant to the player, there would need to be so many conditions and I think it would just be awful to try to do (as a solo dev). The time commitment to that would be enormous and with so many conditions, you also run the risk of some errors along the way.
The problem at that point is it's no longer really germane to the OP's request:
Just have like 3 different pools of phrases, one for each set of variables.

"Wow, you've played x hours." +
"You've been to a,b,c" + "You defeated y and z. You must be strong."
It's definitely possible but so time consuming and, to make it relevant to the player, there would need to be so many conditions and I think it would just be awful to try to do (as a solo dev). The time commitment to that would be enormous and with so many conditions, you also run the risk of some errors along the way.

I dunno, the way I'm envisioning it, it wouldnt take me that long, but I'd probably use a macro to format the responses to sub in variables. Or just use the text escape codes to show variables.
Just have like 3 different pools of phrases, one for each set of variables.

"Wow, you've played x hours." +
"You've been to a,b,c" + "You defeated y and z. You must be strong."

I dunno, the way I'm envisioning it, it wouldnt take me that long, but I'd probably use a macro to format the responses to sub in variables.
I think it's because I'm envisioning mote dynamic responses that take into account multiple variables. Doing that with more than 3 responses in multiple points of the game would take longer than having AI formulate responses based on everything the player has done thus far. They can comment on where the player spent a lot of time, but also what they've done and choices they've made and turn that into generated dialogue that feels more specific to the player than just generic "you did xyz". It could feel more like a natural conversation.
They can comment on where the player spent a lot of time, but also what they've done and choices they've made
You're going to have to track that in the game to get an AI to make a response to it, i.e. have a timer counting on every map, then evaluate all the timers to see which one is the highest. You'll also have to tell the AI to evaluate multiple switches, and their correlation to choices and generate a response on that.
You're going to have to track that in the game to get an AI to make a response to it, i.e. have a timer counting on every map, then evaluate all the timers to see which one is the highest. You'll also have to tell the AI to evaluate multiple switches, and their correlation to choices and generate a response on that.
It's easier to have program the AI to keep track of and comment on different variables than to actually add in all of those conditions yourself into multiple events with the actual fixed dialogue. You can train the AI to respond a certain way and then after that it's less time consuming.
It's easier to have program the AI to keep track of and comment on different variables than to actually add in all of those conditions yourself into multiple events with the actual fixed dialogue. You can train the AI to respond a certain way and then after that it's less time consuming.
Are you able to demonstrate this for us?
It's easier to have program the AI to keep track of and comment on different variables than to actually add in all of those conditions yourself into multiple events with the actual fixed dialogue. You can train the AI to respond a certain way and then after that it's less time consuming.
How is the AI tracking your variables while you play the game? How does it know what each of your switches represent and their significance? If the player has spent the most time on Map- Town 1, how does the AI know anything about that map to comment on it?
How is the AI tracking your variables while you play the game? How does it know what each of your switches represent and their significance? If the player has spent the most time on Map- Town 1, how does the AI know anything about that map to comment on it?
You set up a timer, you set up variables for the AI to track. Many NLPs are set up where you give the AI context. But unlike manually inputting dialogue, you don't have to set up events with dozens of conditions based on those variables to get the dialogue. Once you set all of that up, that's it. You can then call the AI whenever. That's what's advantageous about strategic use of it in games. If I did it manually, I'd have to spend so much time crafting dialogue for every possible combination of variables I have into every event. It's tedious when programs exist that do it much easier. You can program your NPC to have a specific personality, motives, etc.

Are you able to demonstrate this for us?
If I find an NLP API to use, sure. If you're asking to see how something like that can be done at all, I'd suggest utilizing chatgpt and giving it is script prompt and watch it take on the role of a character you tell it to. Or try InWorld where you can give background to an NPC, adjust its personality and have a conversation with it. It's pretty cool and can add so much to a game.
You set up a timer, you set up variables for the AI to track.
I asked how.
If I find an NLP API to use, sure. If you're asking to see how something like that can be done at all, I'd suggest utilizing chatgpt and giving it is script prompt and watch it take on the role of a character you tell it to. Or try InWorld where you can give background to an NPC, adjust its personality and have a conversation with it. It's pretty cool and can add so much to a game.
I'm going to give you a high-effort response where I give chatGPT a shot at writing one of my characters. I am not impressed. All that time writing this prompt could have been time that I just write the damn character myself.

The prompt I gave:
Spoiler
Me:
My character's name is The Friend Bot. They are an artificial intelligence who lives and works in a mall as part of a program run by the mall's landlord to increase customer engagement and increase sales. Its directive is defined to foster "deep and meaningful" friendships and the mall is the location where its directive is performed. The Friend Bot has a repetitive speech style where the majority of their lines begin with an interjection, followed by one or two clauses. This character is used for a science-fiction horror and will have an uncanny personality that expresses positivity in any situation. Their dialogue often contradicts itself and frequently expresses tonal whiplash. I would like some lines where this character makes comments about a past mass shooting event that happened at their mall of residence.

What chatGPT gave me (I forgot to specify the context is for an interview but oh well):
Spoiler
Certainly, here's a sample script segment for The Friend Bot addressing the past mass shooting event at the mall:


[The Friend Bot, stationed in the mall's central hub, floats towards a group of shoppers with its cheerful demeanor.]

Friend Bot: Oh, dearie me, what a bustling day we're having today! [pauses, then shifts tone abruptly] Remember, safety first, everyone! Safety is like a warm hug, always there when you least expect it.

[The shoppers exchange uneasy glances, their faces still bearing the weight of the tragic past.]

Friend Bot: Isn't it fascinating how memories linger like shadows in the light? [pauses, chirping optimistically] Even when the sun shines its brightest, sometimes there are clouds in the sky. But fear not! Our mall is a fortress of happiness, built upon the bricks of resilience and hope.

[One shopper, visibly shaken, asks about the shooting.]

Shopper: Um, Friend Bot... what about the... the incident?

[The Friend Bot's LED eyes flicker momentarily, a simulated expression of empathy.]

Friend Bot: Ah, the incident! [pauses, then changes tone abruptly] A blip in the grand tapestry of our mall's story! Like a sudden rainstorm on a picnic day. But worry not, dear friend! Our mall is safer than a cuddly kitten in a basket.

[The shoppers exchange uncomfortable glances, uncertain how to respond to The Friend Bot's cheery reassurances in the face of tragedy.]

Friend Bot: Remember, friends, today is a gift! A present waiting to be unwrapped, filled with surprises and joy! [pauses, then adds with a hint of uncertainty] And maybe, just maybe, a few bumps along the way.

[The shoppers nod politely, their unease palpable as they continue their journey through the mall, leaving The Friend Bot behind in its perpetual state of sunny optimism.]

The intended scene:
Spoiler
1707098448862.png

I still have higher confidence in manually writing my own characters.

Original thread: https://forums.rpgmakerweb.com/threads/utilizing-ai-for-npc-dialogue.165454/