Need feedback on npc choice system

Hello, so the game is the player has a store, they import product, they put it on their shelves and npcs will buy stuff, I need feedback on how the npc should decide this? The player can also set the prices so I don’t want npcs purchasing it for a ridiculous price so right now I have the max set to 1.5 * the original cost of product. I have assigned a Favorite Food and beverage, so they look for that first if they have it they will purchase it, how should I do it if they don’t have the favorite item should I just randomly decide what they want?

1 Like

You could give the NPC a shopping list which they try to fulfill, which then resets after they complete it or after some time with a random selection of items. You could keep the favourites as impulse buys, so they get it regardless of its presence on the list.

you could use a local table variable with items and have them choose it randomly, example:

local options = {apple,banana,phone,pc,mouse,game,amogusplush}
npc.choice = options[math.random(#options)]

--and then repeat or set in a list with random options, something like that

My system is way more advanced, but yes it does look something like this if you simplify over 600 lines of code haha.