Devlog #19. NPC Types
Greetings, alchemists!
In today’s devlog we want to talk about Potion Craft’s NPCs. You will learn about different NPC types and hidden, yet important things, such as factions and faction classes. Please note that most of what’s written below is only relevant for version 0.5.0 (beta).
[h3]NPC types[/h3]

In total, there are 3 types of NPCs in the game: traders, plot NPCs and random NPCs. Let's check them out in order.
Traders
All traders visit the player's shop to sell something. Each merchant has a unique assortment of goods, but this is by no means the main difference between merchants from each other. In Potion Craft, there are 3 types of traders: main, extra, and karmic.

Everyone's favorite Herbalist and Mushroomer are the main traders. These two are pretty constant and predictable in their schedule. Either of them will appear daily in the player's shop at around the middle of the customer queue. Now, who exactly will visit you today? No one knows. However, let us tell you one little secret: the same main merchant cannot come to the alchemist's shop more than 2 times in a row.

Extra traders include Alchemist, Dwarf, and Wandering Merchant. They only pay a visit to the player’s shop once every few days, but when they do they are always first in the line. It is worth noting that the number of days until the next visit is randomized within a certain range. Have you noticed that the Alchemist visits your shop much more often than the Wandering Merchant? This is because each extra trader has an individual range.

And finally, there is another type of trader that is not yet represented in the game - karmic. In general, these are the same as extra merchants, but with a small catch: they only come by when the player’s reputation is at a certain level. Are you a kind and law-abiding alchemist who helps those in need? Then a druid will pay you a visit. And if you are a greedy and immoral type that sells necromancy potions left and right, an old hag may come round... The functionality of karmic traders is completely ready, and we are currently deciding what goods they can offer the alchemist. If you have ideas, share them in the comments!
Plot NPCs

Plot NPCs, just like traders, have a constant charismatic appearance, so you can easily recognize them among the crowd of random visitors. They occasionally visit the alchemist and ask to help them with some sort of potion. If for some reason you didn’t like one of them, you can ask the character in question to never come to you again. And if you fulfil their request, next time they will come with a new order.
In order for plot NPCs to “remember” whether the player has already helped them or not, and to update quests and dialogues in a timely manner, we have created a hidden closeness system. For each level of closeness, the necessary settings for story NPCs can be set, for example, a quest and a dialogue. Each time the player helps a plot NPC, the level of closeness with them increases and the settings get updated. The closeness system also works with merchants, allowing them to expand the assortment of the goods every time the player completes one of their quests.
It is worth mentioning that each plot NPC has a certain closeness cap for each chapter, i.e. you will not be able to complete all of a character's quests right after the said character appeared. After reaching maximum closeness, the character will temporarily "disappear" and will patiently wait until you start the next chapter. And when he runs out of quests completely, he will stop coming altogether... Which is not exactly cool, so in the future we plan to give a set of random quests to the plot NPCs so that they continue visiting the alchemist even after their questline is completed.
By the way, plot NPCs have a reputation range at which they come to the player too. For instance, if your reputation gets below -50, the Brewer (and some other characters, as well) will stop showing up until you regain your good name.
There are currently 6 plot NPCs in Potion Craft. Do you have any suggestions for adding someone else? Share your ideas with us!
Random NPCs

Random NPCs make up the bulk of all NPCs that come to your potion shop. One could say this NPC type is the backbone of our game. But what’s so special about them?
Firstly, all random NPCs only exist whilst they’re in the shop. Once they leave, they disappear forever. Therefore, we cannot, for example, implement the ability to ask the buyer to return in a couple of days, because there would be no one to come back to you...
The second feature of random NPCs is that their appearance and properties are randomly generated according to certain rules. We have worked hard to ensure the appearance of random NPCs is diverse and interesting. Just as much effort went into creating a flexible system for generating NPC’s settings and binding their spawn to the Alchemist’s Path’s chapters and player's reputation. To do this, we had to introduce things such as factions and NPC classes, which we'll talk about next!
[h3]Factions, classes, and templates[/h3]
Factions are a complex system that allows for flexible customization of random NPCs and conditions under which they will come to the player’s shop. Random NPCs are configured in a few steps: first, a base template is created, next, it’s used to set up an NPC class, which is then added to the faction itself. Sounds confusing? Then let’s take a deep dive in.
NPC templates
So, let's say we want to add a peasant class to the game. To do this, we first need to create and set up a peasant template. It will store the basic settings of the NPC (such as buyer dialogue, haggling animation, etc.) and a set of sprites for appearance randomization. Once upon a time, we had to add each sprite manually (not fun), but now our NPC browser has a magic button that adds all the sprites automatically. Note that we will need two templates, because among peasants there are both men and women.

NPC classes
Next, we need to set up the peasant class. It needs to be provided with an NPC template that we already created, along with a set of haggle topics and a list of quests suitable for the class. Just like with templates, we need two peasant classes, because quest lists for men and women are partially different from each other.

Now we are ready to add these classes to the peasant faction! Here we’ll need to specify an Alchemist's Path chapter, from which the classes will start appearing in the game. It’s also possible to arbitrarily distribute spawn chances between faction classes, so that, say, one class appears more often than the other one. In case with peasant classes, we can simply split the chances in half. And so, we are done with the classes. But this is only the beginning, because there are still a lot of settings for the faction itself!
Factions
Firstly, we need to set the chapter in which the faction unlocks. This chapter can be different from the chapters in which faction classes are unlocked. For example, we can unlock a faction as early as chapter 1, but if the classes included in it are only unlocked at chapter 3, random NPCs from that faction will not come to your shop until chapter 3 starts. The same result can be achieved by unlocking faction classes at chapter 1, and unlocking the faction itself only in chapter 3. In case with peasants, we want to unlock both the faction and its classes in chapter 1.

Secondly, we need to draw a spawn chance weight curve. The vertical axis on the graph represents chance weight, while the horizontal axis represents the player's reputation. The way we set up the curve determines how often a faction will spawn its random NPCs at different reputation values. Every time a queue of customers is generated, all active factions "compete" among themselves for the right to spawn their NPCs. The higher the spawn chance weight of a particular faction at the player's current reputation is, and the lower the total number of active factions in the current chapter is, the higher is the actual chance for that faction to spawn one of their NPC classes (and vice versa). Thanks to this system, we can make it so that at a high reputation good peasants will often come to the player, and with a low reputation the evil ones will frequent your shop.

Let's assume that we’re making a faction of good peasants. We would then need to draw the curve so that the spawn chance weight reaches the max value closer to the max reputation (+100) and is very low at the min reputation (-100).
Thirdly, we need to set weights for all the effects that are found in quests for faction classes. It’s pretty straightforward: the more weight a particular effect has, the more often NPCs of this faction will ask for potions with this effect. For example, for peasants we can set a higher chance for Healing and a lower chance for Poison and other combat effects.

Optionally, you can make a list of oneshot NPCs for each faction. A separate list is compiled for each chapter of the Alchemist's Path. Oneshot NPCs have hand-crafted properties and appearance, and can be spawned instead of any random NPC of the same faction with a certain chance. Why do we call them “oneshot”? Because each of them can only be spawned once during a single playthrough. We usually pair these NPCs up with the most memorable quests and references so all of this doesn’t get too old. And for those times when we need a oneshot NPC that doesn't depend on factions and player’s reputation, we also have oneshot plot NPCs!

As a cherry on top, we can also set a certain default mood for all random NPCs in a faction. We have 3 mood options here: good, neutral, and bad. So if our peasants are good people, then their initial mood should also be good. But that doesn't mean they won't get mad if you offer them the wrong potion!

Thank you for reading till the end! Now you know a little more about NPCs in Potion Craft. We hope that you have found this devlog interesting! Stay tuned and follow our Steam Page. Also, make sure to join our Discord so you don't miss the next devlog!
In today’s devlog we want to talk about Potion Craft’s NPCs. You will learn about different NPC types and hidden, yet important things, such as factions and faction classes. Please note that most of what’s written below is only relevant for version 0.5.0 (beta).
[h3]NPC types[/h3]

In total, there are 3 types of NPCs in the game: traders, plot NPCs and random NPCs. Let's check them out in order.
Traders
All traders visit the player's shop to sell something. Each merchant has a unique assortment of goods, but this is by no means the main difference between merchants from each other. In Potion Craft, there are 3 types of traders: main, extra, and karmic.

Everyone's favorite Herbalist and Mushroomer are the main traders. These two are pretty constant and predictable in their schedule. Either of them will appear daily in the player's shop at around the middle of the customer queue. Now, who exactly will visit you today? No one knows. However, let us tell you one little secret: the same main merchant cannot come to the alchemist's shop more than 2 times in a row.

Extra traders include Alchemist, Dwarf, and Wandering Merchant. They only pay a visit to the player’s shop once every few days, but when they do they are always first in the line. It is worth noting that the number of days until the next visit is randomized within a certain range. Have you noticed that the Alchemist visits your shop much more often than the Wandering Merchant? This is because each extra trader has an individual range.

And finally, there is another type of trader that is not yet represented in the game - karmic. In general, these are the same as extra merchants, but with a small catch: they only come by when the player’s reputation is at a certain level. Are you a kind and law-abiding alchemist who helps those in need? Then a druid will pay you a visit. And if you are a greedy and immoral type that sells necromancy potions left and right, an old hag may come round... The functionality of karmic traders is completely ready, and we are currently deciding what goods they can offer the alchemist. If you have ideas, share them in the comments!
Plot NPCs

Plot NPCs, just like traders, have a constant charismatic appearance, so you can easily recognize them among the crowd of random visitors. They occasionally visit the alchemist and ask to help them with some sort of potion. If for some reason you didn’t like one of them, you can ask the character in question to never come to you again. And if you fulfil their request, next time they will come with a new order.
In order for plot NPCs to “remember” whether the player has already helped them or not, and to update quests and dialogues in a timely manner, we have created a hidden closeness system. For each level of closeness, the necessary settings for story NPCs can be set, for example, a quest and a dialogue. Each time the player helps a plot NPC, the level of closeness with them increases and the settings get updated. The closeness system also works with merchants, allowing them to expand the assortment of the goods every time the player completes one of their quests.
It is worth mentioning that each plot NPC has a certain closeness cap for each chapter, i.e. you will not be able to complete all of a character's quests right after the said character appeared. After reaching maximum closeness, the character will temporarily "disappear" and will patiently wait until you start the next chapter. And when he runs out of quests completely, he will stop coming altogether... Which is not exactly cool, so in the future we plan to give a set of random quests to the plot NPCs so that they continue visiting the alchemist even after their questline is completed.
By the way, plot NPCs have a reputation range at which they come to the player too. For instance, if your reputation gets below -50, the Brewer (and some other characters, as well) will stop showing up until you regain your good name.
There are currently 6 plot NPCs in Potion Craft. Do you have any suggestions for adding someone else? Share your ideas with us!
Random NPCs

Random NPCs make up the bulk of all NPCs that come to your potion shop. One could say this NPC type is the backbone of our game. But what’s so special about them?
Firstly, all random NPCs only exist whilst they’re in the shop. Once they leave, they disappear forever. Therefore, we cannot, for example, implement the ability to ask the buyer to return in a couple of days, because there would be no one to come back to you...
The second feature of random NPCs is that their appearance and properties are randomly generated according to certain rules. We have worked hard to ensure the appearance of random NPCs is diverse and interesting. Just as much effort went into creating a flexible system for generating NPC’s settings and binding their spawn to the Alchemist’s Path’s chapters and player's reputation. To do this, we had to introduce things such as factions and NPC classes, which we'll talk about next!
[h3]Factions, classes, and templates[/h3]
Factions are a complex system that allows for flexible customization of random NPCs and conditions under which they will come to the player’s shop. Random NPCs are configured in a few steps: first, a base template is created, next, it’s used to set up an NPC class, which is then added to the faction itself. Sounds confusing? Then let’s take a deep dive in.
NPC templates
So, let's say we want to add a peasant class to the game. To do this, we first need to create and set up a peasant template. It will store the basic settings of the NPC (such as buyer dialogue, haggling animation, etc.) and a set of sprites for appearance randomization. Once upon a time, we had to add each sprite manually (not fun), but now our NPC browser has a magic button that adds all the sprites automatically. Note that we will need two templates, because among peasants there are both men and women.

NPC classes
Next, we need to set up the peasant class. It needs to be provided with an NPC template that we already created, along with a set of haggle topics and a list of quests suitable for the class. Just like with templates, we need two peasant classes, because quest lists for men and women are partially different from each other.

Now we are ready to add these classes to the peasant faction! Here we’ll need to specify an Alchemist's Path chapter, from which the classes will start appearing in the game. It’s also possible to arbitrarily distribute spawn chances between faction classes, so that, say, one class appears more often than the other one. In case with peasant classes, we can simply split the chances in half. And so, we are done with the classes. But this is only the beginning, because there are still a lot of settings for the faction itself!
Factions
Firstly, we need to set the chapter in which the faction unlocks. This chapter can be different from the chapters in which faction classes are unlocked. For example, we can unlock a faction as early as chapter 1, but if the classes included in it are only unlocked at chapter 3, random NPCs from that faction will not come to your shop until chapter 3 starts. The same result can be achieved by unlocking faction classes at chapter 1, and unlocking the faction itself only in chapter 3. In case with peasants, we want to unlock both the faction and its classes in chapter 1.

Secondly, we need to draw a spawn chance weight curve. The vertical axis on the graph represents chance weight, while the horizontal axis represents the player's reputation. The way we set up the curve determines how often a faction will spawn its random NPCs at different reputation values. Every time a queue of customers is generated, all active factions "compete" among themselves for the right to spawn their NPCs. The higher the spawn chance weight of a particular faction at the player's current reputation is, and the lower the total number of active factions in the current chapter is, the higher is the actual chance for that faction to spawn one of their NPC classes (and vice versa). Thanks to this system, we can make it so that at a high reputation good peasants will often come to the player, and with a low reputation the evil ones will frequent your shop.

Let's assume that we’re making a faction of good peasants. We would then need to draw the curve so that the spawn chance weight reaches the max value closer to the max reputation (+100) and is very low at the min reputation (-100).
Thirdly, we need to set weights for all the effects that are found in quests for faction classes. It’s pretty straightforward: the more weight a particular effect has, the more often NPCs of this faction will ask for potions with this effect. For example, for peasants we can set a higher chance for Healing and a lower chance for Poison and other combat effects.

Optionally, you can make a list of oneshot NPCs for each faction. A separate list is compiled for each chapter of the Alchemist's Path. Oneshot NPCs have hand-crafted properties and appearance, and can be spawned instead of any random NPC of the same faction with a certain chance. Why do we call them “oneshot”? Because each of them can only be spawned once during a single playthrough. We usually pair these NPCs up with the most memorable quests and references so all of this doesn’t get too old. And for those times when we need a oneshot NPC that doesn't depend on factions and player’s reputation, we also have oneshot plot NPCs!

As a cherry on top, we can also set a certain default mood for all random NPCs in a faction. We have 3 mood options here: good, neutral, and bad. So if our peasants are good people, then their initial mood should also be good. But that doesn't mean they won't get mad if you offer them the wrong potion!

Thank you for reading till the end! Now you know a little more about NPCs in Potion Craft. We hope that you have found this devlog interesting! Stay tuned and follow our Steam Page. Also, make sure to join our Discord so you don't miss the next devlog!