DevLog 8 - NPC Creation


Overview of NPC System

The non-playable character (NPC) system in Patchwork Pastry includes a moderately complex set of constraints designed to enhance the realism of the characters. The primary purpose of the NPCs is to enable them to purchase items from the player in the bakery. However, they also walk around looking at things (the sea, farms, butterflies, musicians playing…) and occasionally purchase goods from the market. They also have individual characteristics, including when they are awake (and active in the scene), their relationship towards the player, and how much gold they can spend each day. This devlog covers this system in detail.

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

Creating the NPC - Individual Information

Each NPC has seven discrete constraints, which allows for unique interactions between the player and the NPCs:

  1. Name (and number)
  2. Spawn/return locations
  3. When they are active in the game world/sleeping
  4. How much gold they can spend in the bakery per day (48-minute cycle)
  5. Relationship to the player (based on sales, purchase price, and interaction)
  6. What their favourite ingredient is
  7. What their favourite recipe is

Using part 1 of the constraints, the NPCs can each have unique target destinations when walking around the village grounds, for example:

  • The musicians are the only NPCs who can sit on the stools outside of the bakery to perform music
  • Each seller has their own market stall which they can stand at in the afternoon
  • Jette (the bandit fox) can sneak off to the back of the castle to spray-paint the walls when no one is around

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

Choosing Goods from the Bakery

When the player places one of their baked goods on display, a random NPC (who is active in the scene) enters the bakery and follows a procedure to pick the baked goods from the display:

  • The NPC checks all baked goods on display
  • They rank the goods in order of quality (including a 10% bonus if their favourite ingredient and/or favourite type has been cooked
  • Starting with the highest ranking product, the NPC randomly picks a number between 20 and 90. If the random digit is lower than the product score (between 25 and 100), then the NPC will select that item. If it is lower, they will not select the product
  • The NPC repeats the previous step for all remaining products on display until there are no more products to choose or until they are holding four for purchase. If the NPC has not selected any by the end of their sorting, they choose the highest ranking product and take it to the counter.

Figure 1: Vigore looking tart display for selection

Figure 2: Vigore looking roux display for selection (after picking up the hardtack and a tart square)

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

Purchasing from the Bakery

Once the NPC selects 1-4 products from the display, they bring them to the counter and give the player the recommended gold coin amount for the product. From here, the player can accept the purchase, decline the purchase (by picking up the product), or change the price. A price increase leads to quicker earnings for the player, but NPCs may not like it - they are less likely to select as many products and may leave if you overcharge them by too much.



Figure 3: Vigore giving the player the recommended retail price of the product


Figure 4: The player giving Vigore a discount (which improves his relationship to the player)


That’s all for now! The next devlog is coming on 14th April 2025.

- Stephen Rockett

Get Patchwork Pastry

Leave a comment

Log in with itch.io to leave a comment.