RavenIronStudios-PeonsPeasants icon

PeonsPeasants

Town NPCs for Valheim: shopkeepers, guildmasters, criers, hirelings and nobles who greet you, go about their work, walk the streets and roads, and keep real shops that sell their trade's goods. Admins can place people by hand.

Last updated 2 days ago
Total downloads 46
Total rating 0 
Categories Mods Server-side Client-side NPCs AI Generated
Dependency string RavenIronStudios-PeonsPeasants-0.1.0
Dependants 0 other packages depend on this package

This mod requires the following mods to function

ValheimModding-JsonDotNET-13.0.4 icon
ValheimModding-JsonDotNET

Shared version 13.0.3 of Json.NET from Newtonsoft, net45 package for use in Valheim mods. Maintained by the ValheimModding team.

Preferred version: 13.0.4
denikson-BepInExPack_Valheim-5.4.2360 icon
denikson-BepInExPack_Valheim

BepInEx pack for Valheim. Preconfigured with the correct entry point for mods and preferred defaults for the community.

Preferred version: 5.4.2360

README

πŸ§‘β€πŸŒΎ Peons & Peasants

PEONS & PEASANTS VERSION BOTH SIDES

The baker was up before the sun. The smith has been hammering since the cock crowed, the crier is three streets over shouting about a lost goat, and somewhere a hireling is checking the edge of a sword he has never once swung in anger. None of them know you are a hero. Most of them would like to sell you something.

Your towns get people. People who work, wander, talk, and keep shops.

Shopkeepers, guildmasters, criers, hirelings, nobles and travellers stand at their posts and go about their trades: sweeping, hammering, sawing, fishing, ringing a bell. They greet you, turn to look at you, walk the streets from one meeting place to another, and a few walk the roads between towns. Press E on a shopkeeper and a real store opens: their own trade's goods, a purse to buy yours, and a shelf that restocks every game day.


NEW IN 0.1.0

First release.

Peons & Peasants
🧍 Townsfolk from a file the world's own NPC file puts every townsperson at their post as the ground is first generated
πŸ”¨ Townsfolk by hand admins place, edit and remove people anywhere, with Infinity Hammer tools or a console command
🎭 22 bodies, carried inside the mod eight kits (commoner, apron, robe, smith, tool, crier, hireling, noble), men and women, with alternate looks
βš’οΈ Work by trade each person works the loop of their trade, holding its tool: hammer, saw, broom, hoe, rod, bell, sword
🚢 They move about shopkeepers pace their shops, wanderers roam the town, town walkers follow the streets, world walkers the roads
πŸͺ™ Real shops 38 trades sell their own goods and buy them back, server-checked, restocked every game day

BEFORE YOU INSTALL

If… Then…
πŸ›‘ you put Peons & Peasants only on the server players see nobody. It goes on the server and in every player's game.
πŸ“œ your world has no NPC file nobody appears by themselves. Place people by hand (see III), or give the world a peonspeasants-npcs.json (see IV).
🌍 you add an NPC file to a world that has already been saved it is not used: a world takes its NPC file only while it is new. People placed by hand work in any world.
πŸ’Ύ you are moving from another mod that ships the same townsfolk this is a fresh start: its NPCs, shelves and keys are not read. The two cannot be loaded together.
πŸ”¨ you want the hammer tools they need Infinity Hammer and Server Devcommands (devcommands on) on the admin's game. Everything else works without them.

I

Who they are and what they do.

They…
stand at their posts and rise and turn their heads to you when you come near
greet you with a speech bubble when you come within Greet Range, and say farewell when you go
talk press E for a line of their trade (a shopkeeper opens the store instead)
work at their post they play their trade's work loop, tool in hand; away from it they idle or walk
move about a shopkeeper paces round the shop (and keeps under its roof), a wanderer roams the town inside its bounds
walk the town a few per town follow the streets from meeting place to meeting place, resting a while at each
walk the world a few walk the roads between the towns of their landmass, resting in each; the server moves them while nobody is near
stop for you a moving NPC stands still while a player is close (Stop For Players Metres), and for a minute after you talk to it
πŸ“– Read the saga β€” how a townsperson is made

Every townsperson is a persistent object in the world's save, written key by key on the server: an id, a name, a title, a role, a town, a body and how they move. Every client builds the same person from those keys, so they look and act the same for everyone, after every restart.

The body is a clone of Haldor's or Hildir's, with the real body (one of 22, carried inside the DLL) worn over it. No Character, no AI, no rigidbody: they cannot be hit, cannot fall and cannot get lost. Whoever is nearest walks them, and everyone else sees them where that machine puts them.

Which of the two looks a kit gives a person is decided from their id, so the same person wears the same face on every machine. Their work follows their trade, not their look: a cook in an apron wipes the counter, a carpenter in the same apron saws.


II

Press E on a shopkeeper.

🧺 Their own trade's goods the baker sells bread and the oven's dishes, the butcher raw meat, the smith nails and bars, the healer meads
πŸͺ™ They buy back their own trade's goods only, at half the price, from a purse of 1,000 coins a game day (Vendor Purse)
πŸ”„ Restock the shelf and the purse refill at the first visit of each game day
πŸŽ’ Backpacks count goods and coins in a carried backpack (Backpacks mod) sell and pay like any others
βš–οΈ The server decides every price and every shelf is the server's; a deal is checked line by line before your bag changes
πŸ—ΊοΈ By town a shop sells up to its town's tier (the vendor file's optional towns map); unnamed towns sell up to the Black Forest

Click a ware to stage it (Shift = 5, Ctrl = 20, or type a count), click your own goods on the right to sell them, then Confirm. Escape, Tab, M or walking away closes the store.

πŸ› οΈ The vendor table β€” peonspeasants-vendors.json beside the DLL
Key
roles a role name β†’ the stock lists it sells ("InnKeeper": ["Drinks", "Tavern", "Feasts"]). A role not here keeps no shop.
lists a list name β†’ rows: prefab, name, price (coins), stock (after a restock), tier (Unrestricted, Meadows … DeepNorth)
towns optional: a town id β†’ the highest tier its shops sell ("harbourtown": "Swamp"). Ships empty.
buyBack, restockGameDays, purse what a vendor pays for your goods (0.5 = half), how often it restocks, its purse in the table

Edit freely: a prefab the game does not know is skipped. tools/build_vendors.py in the source rebuilds the table from your own pack's item catalogue.


III

Admins put people where they want them. Every request goes to the server, which answers only admins (its adminlist.txt, or the host of the game). Only people placed by hand can be changed or removed; the NPC file's people are never touched.

With Infinity Hammer
Peon <role> one place tool per role (Peon Baker, Peon Town Crier …), each showing what it sells. Aim, turn the ghost, place.
Peon remove place on a person to name them; place on the same person again within 6 s to remove them
Peon edit place on a person to see who they are, and the pp_set line to change them

The tools are written to BepInEx/config/infinity_tools_peonspeasants.yaml when Infinity Hammer is installed (Write Hammer Tools). Delete its first line to take the file over by hand. Infinity Hammer's own pipettes and hoe tools are kept. Server Devcommands with devcommands on is needed for Infinity Hammer's tools.

Without a hammer (console, F5)
pp_here <role> [name=] [female=0/1] [roam=] places a person where you stand, facing your way
pp_list [radius | all] the people placed by hand near you (50 m), or all of them, with their ids
pp_set <id> name= role= female=0/1 body= roam=stand|pace|wander changes a placed person (_ in a name is a space)
pp_remove <id> removes a placed person at once
pp_roles every role that can be placed, and what each sells
πŸ“– Read the saga β€” what a placed person is

A placed person joins the world's townsfolk exactly as the NPC file's do: they keep shop by their role, greet, work, pace or wander, and other mods see them. They get an id (placed.1, placed.2 …), a name from the mod's own list of Norse and village names unless you give one, a sex at random unless you give one, the body of their role's kit, and the town whose bounds hold the spot (if any).

They are kept in the world's own folder as peonspeasants-placed.json. A person placed where the ground is already generated appears at once; elsewhere they appear when the ground is first visited. roam=stand keeps them still; pace keeps them about their post; wander lets them roam about 30 m.


IV

Two optional files per world. They are read from the world's own save folder first, then from Better Worlds' world folder, Better Worlds' templates folder, and Better Continents' map folder (its Directory setting). A new world takes a copy of the NPC file into its save folder; an already-saved world never takes one.

πŸ› οΈ peonspeasants-npcs.json β€” who stands where
{
  "format": 1,
  "landmass": "main",
  "era": "1",
  "towns": [ { "id": "harbourtown", "name": "Harbourtown", "npcs": 12, "zone": [[1200, -340, 60, 45]] } ],
  "npcs": [
    { "id": "harbourtown.baker", "role": "Baker", "town": "harbourtown", "name": "Aslak", "title": "the baker",
      "female": false, "family": "Food & farm", "body": "commoner_m",
      "x": 1210.5, "y": 2.0, "z": -332.0, "yaw": 90,
      "ground": "terrain", "lens": "", "move": "stand", "home": 0, "walk": 5 }
  ]
}
Field
landmass, era free labels; the routes file must carry the same ones to be used
towns[].zone the town's bounds: rectangles [x, z, half x, half z] in world metres. Roaming NPCs keep inside them.
id unique and stable: a person is never seeded twice under one id
role any word; the vendor table's role names keep shops
family their talk: Guildmaster, Metalwork, Textile & leather, Food & farm, Inn & tavern, Magic & medicine, Healer, Building, tools & sea, Money, Services, Townsperson, Townsfolk, Escort giver, Hireling
body a kit and sex: commoner, apron, robe, smith, tool, crier, hireling, noble + _m or _f
ground terrain (the world's ground), floor (a floor at y) or fixed (exactly y)
y metres above the water level (for floor, fixed, or any post with a lens)
lens the town core the post is in, if any; empty for the countryside
move, home, walk stand (paces its post) or wander; the home and walking ranges in range units (2 m inside a core, 15 m outside); the walking range wins when above 0
πŸ› οΈ peonspeasants-routes.json β€” the streets and roads they walk
{
  "format": 1,
  "landmass": "main",
  "era": "1",
  "nodes": [ { "id": "harbourtown#0", "town": "harbourtown", "kind": "centre", "x": 1200, "z": -340 },
             { "id": "harbourtown#1", "town": "harbourtown", "kind": "meet", "x": 1260, "z": -320 } ],
  "edges": [ { "a": "harbourtown#0", "b": "harbourtown#1", "kind": "street", "pts": [1200, -340, 1230, -335, 1260, -320] } ],
  "walkers": [ { "id": "harbourtown.towncrier", "town": "harbourtown", "kind": "town", "role": "TownCrier" } ],
  "extras": [ { "id": "harbourtown.townsperson.1", "town": "harbourtown", "female": true, "x": 1260, "z": -320 } ]
}
Field
nodes each town's centre (kind: "centre", one per town) and meeting places
edges street (inside a town) or road (between towns' centres), as polylines [x, z, x, z …] in world metres
walkers NPCs of the NPC file that walk: kind: "town" (the town's streets) or "world" (the roads between the towns of their landmass)
extras optional generic townsfolk added when Add Townsfolk Wanderers is on; they are named from the mod's own list

V

PeonsPeasants.PeonsNpcs β€” plug a quest giver, a bank or anything else into the townsfolk.

Member
InteractHandler Func<NpcRef, bool, bool>: take the use key on an NPC (return true). Asked before the store on E, after it on Shift + E
UseItemHandler an item used on an NPC (a hand-in)
HoverExtra, UseVerb an extra hover line; the word after the use key (a shopkeeper whose E you take shows the store on Shift + E)
MarkerFor a marker id per NPC, for whoever draws markers
Interacted event: the player pressed the use key on an NPC
All(), TryGet, TryGetZdo, TryGetPosition the server's townsfolk (file and placed), by id
Near(point, range) the townsfolk this client has around a point

MULTIPLAYER

On the dedicated server In every player's game Single player / hosting
the NPC file, seeding, the walkers' roads, placed people, the shops' shelves and purses the bodies, the walking, the talking, the store window all of it

⚠️ Settings are the server's. A player who joins takes the server's settings while connected (ServerSync), locked to admins. Only the body look, the diagnostics and the hammer tool file stay on each machine.


COMPATIBILITY

Mod
Better Worlds / Better Continents Optional. Their map folders are where a world's NPC and routes files are looked for.
Infinity Hammer + Server Devcommands Optional. The Peon tools for placing people (admins).
Backpacks Optional. Shopkeepers reach into carried backpacks.
Wonderland The vendor table's tiers use the same progression names.
β›” Mods that ship these same townsfolk Cannot be loaded together: the people would be doubled.

SETTINGS

All safe to leave alone. BepInEx/config/wubarrk.peonspeasants.cfg.

πŸ”’ Server β€” set on the dedicated server, synced to every player
Section Setting What it does
1 NPCs Seed Town NPCs put the NPC file's people into the world as the ground is generated
1 NPCs Greet Range how near you come before they greet you
1 NPCs Snap To Floor settle each NPC on the floor under it once a second
1 NPCs Move About shopkeepers pace and wanderers roam (off: everyone stands)
1 NPCs Shopkeeper Roam Metres, Wanderer Roam Metres how far they go from their posts
1 NPCs Town Wanderers, World Walkers the street walkers and the road walkers
1 NPCs Add Townsfolk Wanderers add the routes file's generic townsfolk
1 NPCs Walker Pace Metres Per Second how fast the server moves a world walker nobody is near
1 NPCs Stop For Players Metres, Stop For Players Seconds when a moving NPC stops for you, and for how long
2 Vendors Town Vendors the shops open (off: they only talk)
2 Vendors Vendor Price Scale every price times this
2 Vendors Vendor Purse the coins each vendor has to buy your goods each day
πŸ–₯️ Local to your game
Section Setting What it does
1 NPCs Meshy Bodies wear the 22 bodies (off: the placeholder bodies)
1 NPCs Body Turn an extra turn of the bodies, in degrees
1 NPCs NPC Diagnostics log seeding and the first NPCs that wake
1 NPCs Write Hammer Tools keep the Infinity Hammer tool file
2 Vendors Vendor Diagnostics log stores and deals

CREDITS

Needs: BepInExPack Valheim Β· JsonDotNET

  • Wu'barrk: design, the townsfolk, their shops and their bodies.
  • Support Raven Iron. Every Raven Iron mod is free, and stays free: all of it, always. Nothing is held back for patrons, and nothing ever will be. To help cover server hosting and test hardware: the website Β· Patreon Β· Discord, a channel per mod and where the testing happens.

A Raven Iron mod. License: MIT. Use it, fork it, repackage it, ship it in a modpack; keep the copyright notice with it. The full text is in LICENSE.md.