Project Zomboid

Project Zomboid

[B41 MP only] bikinitools: Server Edition
 This topic has been pinned, so it's probably important
bikinihorst  [developer] Dec 3, 2024 @ 5:10pm
[BTSE_RestorePods] Description of functionality and rules
Introduction

My goal with this was to implement a character restore solution that does not rely on local info or can be modified by users and with my "server truth" approach this ended up becoming a system that dumps all kinds of character info to the server when people die or during snapshots. When a restore is requested, the server will send individual packets to the client until it is all done. The sandbox vars being used to determine the restore parameters are also only read on the server and carried through the running restore process to prevent people with broken sandbox settings from getting different results. The items being used to initiate restore processes contain data about the dump but only the token ID is relevant as I do not want to trust a local item to be the authority on what is being restored. I've desync proofed things as best as I could and think I came to a stable result. The files on the server are kept in folders organized by username and named by their contents and the timestamp of the player's demise. There is a setting to change how many versions of each user's characters are kept (10 by default) and the old files on the server will be emptied out (I have not found a way to delete files so 0KB is all I can do for now). Because each dump contains all the info this mod is able to restore this means that if you change your mind about a setting later on, this setting will apply to all restore processes, old and new dump, the same way. If you for example decide to change the skill loss percentage it will always be applied for old and new dumps.

Why pods?

I got inspired about this because I was reading about MKULTRA, specifically the Montreal experiments, with sensory deprivation tanks, changing memories and other wonky stuff. The system itself can be used as a two-parter, depending on what kind of server you want to run. The imagined gameplay loop during development was that people die, then respawn, "find" a token in their pocket and can get a low amount of their old self back, then travel to an admin set up pod location (which are marked on the map automatically as they are discovered if you want) to get the main stuff back. You can configure the mod to work fully without pods (just from the item) and you can configure it to require pods for restores at all times. Do what you want, the options are there. There is no need to refresh or write down info somewhere, it is all automated for the convenience of the user.
Last edited by bikinihorst; Dec 3, 2024 @ 5:43pm
Showing 1-8 of 8 comments
bikinihorst  [developer] Dec 3, 2024 @ 5:11pm 
Tools and sprite configuration

The mod comes with a Player tool in the UI that allows you to view each Player's dump info, send them Tokens or push full Restores. You can place Pods by using the BTSE "Place Movable" context menu. Placed Pods can be configured via context menu to show the number 0-99 and there are some Graffiti sprites you can enable via Sandbox option. Probably not your cup of tea because those were added as thank you to some nice people that supported me over the years and those references are probably confusing. If you run Events, have Skill loss enabled and do not want people to lose their Skills, set up a Pod as an "Event Pod" on site which will always 100% restore them. You can configure an amount of free Downloads for Tokens which will allow people to visit a Pod and pull out any of their available Character dumps as a Token.
Last edited by bikinihorst; Dec 3, 2024 @ 5:43pm
bikinihorst  [developer] Dec 3, 2024 @ 5:13pm 
Rules / when and how to restore

The rules for restoring tokens are simple:
  • A player can restore one dump ID (the name of the dump) per lifetime. Once a restore is done they are locked into it until they die again.
  • A player can restore the same token during this lifetime as often as they like (in case of disconnect or crash). If someone's restore process was interrupted they can retry the same token again.
  • If a player chose the wrong one (this sign won't stop me because I can't read!) they can just kill their character and pull the right token from a pod or their stash.
  • Each character dump is unique. There is no "best" version. You can build hop as long as the token isn't too old (deleted) and the sandbox settings allow this. If someone dies with a shell of a char and restores the data of course they will be empty again. Find the right token and restore that one.
  • If you want to start a "new build" then do not restore the old token, if it is configured to restore professions, traits and so on. Just start fresh.
Last edited by bikinihorst; Dec 3, 2024 @ 5:44pm
bikinihorst  [developer] Dec 3, 2024 @ 5:15pm 
Sandbox configuration

Item based and pod based restore options are configured separately and each page has a range of options you can choose. Options range from percentage based loss to exclusions and custom percentages per skill as well as all the things listed below. There are also shared settings which have their own settings page. Default works best, as usual.
Every time a player dies or in configured intervals a dump is stored on the server (snapshots, see below). Each dump contains the following:
  • Skills (as long as it is within the PZ skill system), the total XP in it and the level as value
  • Traits
  • Recipes
  • Profession and related multipliers
  • Book XP multipliers
  • Read literature
  • Media lines listened to (to prevent VHS cheese)
  • Nutritional information (weight, calories, carbohydrates, lipids, proteins - no more dying just because you want to respawn with a full stomach)
  • Survival info (kills, hours survived)
  • Character full name
  • Protected XP (see below)
  • Crafting favorites except "rip clothing"
Last edited by bikinihorst; Dec 3, 2024 @ 5:44pm
bikinihorst  [developer] Dec 3, 2024 @ 5:16pm 
3rd party mod support

There is a plugin system that allows clever people (other modders or server staff) to add support for various things to be saved and restored. There is a "HowTo.txt" in "lua/shared/Helpers/SkillRestore/ModSupport" as well as plenty of examples in there. Support (full or rudimentary, depending on what came up during testing) is given for these mods out of the box and will be applied automatically depending on their mod ID being loaded on the server:
  • BTSE (known keypad lock codes, chat radio channels and Tandy options)
  • Simple Overhaul Traits and Occupations (SOTO)
  • Evolving Traits World (ETW)
  • Musicians of the Wasteland (MOTW, because it uses moddata instead of skills)
  • Lifestyle (music tastes because those add traits).
Last edited by bikinihorst; Dec 3, 2024 @ 5:44pm
bikinihorst  [developer] Dec 3, 2024 @ 5:17pm 
Glossary (might be expanded)

Snapshots:

When using trait mods there is often an issue with people being asked to create a new character and if they go through with it, the server side character is deleted. To make this sting a bit less I've added an automatic backup being done without dying, called "Snapshots" which will at least keep the skill loss at a minimum. By default players will create a snapshot every 24 ingame hours (so about 1-2 irl hours on most servers) and if they did delete their character by making a new one they will get the consolation snapshot in their pockets instead of a regular dump file. Sometimes desynced player moddata can lead to a snapshot being delivered too but it is rare and hard to reproduce so just use your best judgment.

Protected XP:

A fresh character spawns with traits and XP which are immediately saved to their moddata and internally handled as protected XP. When they die this data is added to their character dump. If skill loss is calculated these values always remain intact as a bottom line. If you restore a dump those values are restored too, so they carry over. The protected XP is linked to restoring the profession. If the profession of the dump to restore matches the current profession of the character OR profession restore is allowed the protected XP will be applied.
Last edited by bikinihorst; Dec 3, 2024 @ 5:44pm
bikinihorst  [developer] Dec 3, 2024 @ 5:17pm 
Disclaimer and other warning labels

It is HIGHLY advised to "trait lock" characters as it prevents people from exploiting XP gained by OP traits, dying, then taking new OP ones and then becoming gods in a short time. This is also a must-have if you have mods that add or remove traits, like dynamic traits, SOTO or others. If you do not restore traits you can't expect them to magically appear again after dying.

Most important of all: do not expect all options to get along perfectly and work out the way you think they do when you disable certain ones. The more things you restore, the better the result. .
Last edited by bikinihorst; Dec 3, 2024 @ 5:45pm
bikinihorst  [developer] Dec 3, 2024 @ 5:18pm 
Bonus: clothes selection on startup

This mod comes with options to restrict the clothes selection on the spawn menu. This means you can run the "All Clothes Unlocked" vanilla sandbox var and whittle it down to what you want people to be able to spawn with. If you want insight into the thought process to see what is being removed and why, get into debug mode and when on the spawn screen check the local "Userdata/Zomboid/Lua/parp_debug. log" or depending on if you have the "New" file name option checked in the sandbox, "btse_debug. log" file.
Last edited by bikinihorst; Dec 3, 2024 @ 5:45pm
bikinihorst  [developer] Dec 3, 2024 @ 5:19pm 
Bonus 2: usage as a safety net

If you want to leverage what this mod provides but do not want to have users spawn with tokens, load up any of your server mods, those ones with all adjustments and whatnot, then add this in a file under "lua/shared":
BTSE = BTSE or {}; BTSE.RestorePods = BTSE.RestorePods or {}; BTSE.RestorePods["staffUseOnly"] = true;
Last edited by bikinihorst; Dec 3, 2024 @ 5:39pm
Showing 1-8 of 8 comments
Per page: 1530 50