Valheim
You are viewing a potentially older version of this package. View Latest Version
Install with App

Details

Date Uploaded
3 days ago
Downloads
138
Size
160KB
ADDatHost Valheim hosting
30% off

Town Portal

Field manual: valtownportal.sprekn.com

Open a blue wood portal back to the bed you have claimed. Anyone can walk through it to the caster's spawn. A return field at that spawn sends you back to where the door was opened. The caster's trip back closes both ends. Otherwise they last 15 minutes.

The door uses the wood portal model and a blue glow. The portal script, tag, and pairing are removed, so it never joins the normal portal network.

The mod does not ship any game assets. The wood portal mesh is taken from the game at runtime.

Use it

  1. Put a Tome of Town Portal anywhere in your inventory. It does not need to be equipped, and using the door does not consume it.
  2. Press Left Alt + H. On a controller, hold L2 and click the right stick (LT + R3). A quick tap of L2 still sheathes. Hold it, then click. That click does not crouch.
  3. A wood portal opens on the nearest clear spot beside you. Walk through it. While the door is up, the map shows a blue circle labeled with your name and "town portal".
  4. You arrive at the caster's claimed bed. If they never claimed one, you arrive at the starting stones.
  5. A blue, mostly transparent field about one Viking tall stands at that spawn. It does not push players, creatures, or furniture. Hover it to see the time left.
  6. Anyone but the caster can press E to go back to the door, then walk through again. The pair stays up.
  7. If you opened the door, E on the return field says Return and close. You go back, and both ends disappear. Send visitors through first. The door does not wait for them.
  8. If nobody closes it, the door, the field, and the Nowhere Like Home buff all go away when the timer ends.

Opening a door also starts The Tome Rests for 5 minutes. When that ends you can open again. A new door replaces your previous one, including a return field that is far away or in an unloaded area.

If a test world gets stuck, or old town portal markers are still on the map, turn on devcommands and run townportal_clear. It destroys every town portal door and return gate, including unloaded ones, erases their map markers, and clears The Tome Rests and Nowhere Like Home. Save the world once after that. The markers are gone from the save, so they do not come back when you exit.

Other players do not need a tome to use your door. They go to your bed, not theirs. Each person is checked for portal-blocked cargo on the way through.

Recipe

Craft Tome of Town Portal at a level 1 workbench:

Ingredient Amount
Mysterious Tome 1 (consumed)
Surtling core 10
Greydwarf eye 25
Leather scraps 15
Deer hide 5

There are no upgrade levels.

Mysterious Tome: "A ruined book. The way home is still written in it, for someone willing to make it whole."

Tome of Town Portal: "Restored to its former glory. While it is in your inventory, Alt+H or L2+right stick opens a door back to the bed you have claimed."

Finding a Mysterious Tome

  • Extra roll on loot chests in the Meadows and the Black Forest. About 1 in 4 also contain one tome.
  • The roll is separate. Axe heads and every other drop stay on their own tables.
  • Barrels are skipped. Chests a player placed are skipped.
  • Chests that already exist roll once, the first time they load with this mod, including chests you have opened before.
  • Haldor sells one for 250 coins after the Elder is dead. Finding one in a chest before that still lets you craft.

The finished tome is bound in warm reddish-brown leather. Cyan runes glow on the cover. The mysterious tome is the same book, dusty and grey-brown. The item names stay TownPortal_MysteriousTome and TownPortal_Tome.

Rules

These match a normal wood portal. This mod does not call portal code to do it.

  • NoPortals seals the tome. The deny sound plays and the door does not open.
  • NoBossPortals seals it while a boss is loaded.
  • TeleportAll lets every item through.
  • Otherwise each item's own teleport flag is checked. Ore, bars, and anything else a wood portal refuses are refused here too, for the caster and for anyone following.
  • Open water is refused. Grass, the starting stones, and other no-build camps do not stop the door. If every spot is underwater, the deny sound plays. "The door has nowhere to open."
  • The frame itself keeps the wood portal's collision. Only the return field is non-solid. Its use collider sits on the piece_nonsolid layer so E can find it.

The timer is real time, not world time. Sleeping does not burn it down, and logging out does not remove the door or the return gate. Nowhere Like Home and the return gate's hover text share that end time. The buff has no stat effect. It ends early if the caster takes the return gate. The Tome Rests still runs out its 5 minutes, so closing the door does not let you open another one immediately.

Config

BepInEx/config/com.townportal.mod.cfg

The server's copy wins for cooldown, duration, drop chance, price, Elder requirement, search radius, and yaw. The open key is per player. A saved Alt+T or Shift+T binding is switched to H + LeftAlt the next time the game starts. A controller also opens the door with L2 + right stick click (LT + R3), and that chord is not a config key. Restart after changing cooldown or duration so the buffs pick up the new length.

Section Key Default
Client Open Left Alt + H
Server CooldownSeconds 300
Server DurationSeconds 900
Server MysteriousTomeDropChance 0.25
Server HaldorPrice 250
Server HaldorRequiresElder true
Server SearchRadius 6
Server PortalYawOffset 0
Debug LogChestPrefabs false

If the wood frame faces the wrong way, set PortalYawOffset to 180.

LogChestPrefabs writes one line per container prefab the first time it is seen. Use it if a chest you expected is not rolling a tome. Prefab names that do not contain "chest" are ignored on purpose.

Install

Dependencies, both from Thunderstore:

  • denikson-BepInExPack_Valheim 5.4.2333
  • ValheimModding-Jotunn 2.30.2

Built package layout:

manifest.json
README.md
CHANGELOG.md
icon.png
plugins/TownPortal.dll

r2modman installs this under the Bat Boys team as BepInEx/plugins/BatBoys-TownPortal/TownPortal.dll. Put that same folder on a dedicated server. Everyone connected needs the mod.

This zip is the Thunderstore package. Upload it to the Bat Boys team as-is. It already contains TownPortal.dll. There is no project to compile.

Dedicated server

The server decides whether a door may open, spawns both objects, and checks cargo. Clients send the key press and play the teleport. A listen server does both.

Doors and return fields are saved with the world and remove themselves once expireTicks has passed, including after a restart. They are not damaged by players or creatures.

Not in this version

  • No PVP lock. Anyone who can reach the field door can walk into the caster's bedroom until the timer ends. A later caster-only switch should live in PortalService.Traverse and PortalService.Return.
  • Custom lines are English. The cargo refusal uses the game's own $msg_noteleport text.

Spawn

With devcommands on, the console drops either book at your feet:

spawn TownPortal_MysteriousTome 1
spawn TownPortal_Tome 1

The first is the ruined Mysterious Tome. The second is the finished Tome of Town Portal. Neither needs the Elder, a chest, or the workbench.

Test pass

In a test world with devcommands:

  1. spawn TownPortal_Tome 1. Put it in inventory. Alt+H. A blue wood portal appears beside you, not in the portal list, and it has no tag. spawn TownPortal_MysteriousTome 1 drops the ruined book used in the recipe.
  2. Walk through. You arrive at your bed, the return field is there, and its hover countdown matches Nowhere Like Home.
  3. Have a second character press E on the field. They return, and the door stays. You press E. The hover says "Return and close", you return, and both ends are gone. Nowhere Like Home drops off. The tome is still resting.
  4. Open a second door after 5 minutes. The first door and its field are gone.
  5. Pick up ore. The door refuses you with the same message a wood portal would. Drop it and the door works.
  6. On a world with portals disabled, Alt+H plays the deny sound and places nothing.
  7. Kill the Elder, or setkey defeated_gdking, and buy a Mysterious Tome from Haldor for 250.
  8. Load a Meadows ruin and a Black Forest chest. About one in four has a tome, and the axe heads that were there are still there.
  9. Join with a second character and walk through the first character's door. You arrive at their bed, not yours.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.