NCGD Edit for Multiplayer

Everything having to do with OpenMW's TES3MP branch.
Post Reply
ImpliedVirility
Posts: 5
Joined: 09 Feb 2019, 20:42

NCGD Edit for Multiplayer

Post by ImpliedVirility » 09 Feb 2019, 23:01

This is a small collection of quick edits to Natural Character Growth and Decay by Greywander and TES3MP's player/base.lua script. Along with a slight modification to your server's config.lua script, this should allow for a better experience for players loading an existing character in your server by preventing the need to manually enter a saved character's starting attributes for NCGD to correctly calculate their attribute increases.

What it does:
Client edits (ncgdMW_alt_start.omwaddon)
Upon its initialization, NCGD normally asks the player whether they are starting a new game or using an existing save. This edit removes this dialog box entirely and in essence forces NCGD to use the "New Game" option.

Server script edits (player/base.lua)
Player records stored by the server now contain an "initialAttributes" property. This property is set upon a character's creation and is read when a character logs in. Effectively, characters are always loaded with the attributes they had at creation time. Players are then able to initialize NCGD (by drinking the potion) which will adjust their attributes and level based on their saved skills.

Additional Configuration
In order for your server to properly store the new player data, you will need to edit your server's config.lua. Open the file (located in your server's "mp-stuff/scripts" directory) with your preferred text editor (such as notepad++), scroll to the bottom and change the value of config.playerKeyOrder to include a reference to "initialAttributes". With no other edits, it should look like this:
Spoiler: Show
Updating existing characters
If you wish to use these edits on a server with existing characters, you will need to do some manual data entry to include the new character data for each saved character. Possibly the easiest method is to:
  1. Open the *.json file for the corresponding character (located in your server's "mp-stuff/data/player" directory) in a text editor
  2. Join your server and create a new character using the same race, major attributes, and birthsign as the existing character
  3. Log out and open this new character's *.json file
  4. Copy the value of the new character's "initialAttributes"
  5. Paste the copied "initialAttributes" values into the existing character's JSON record and save the file
Initial Attributes with have this form in the JSON record:
Spoiler: Show
Caution: Update any existing player records to include values for "initialAttributes"! I have not tested loading a character without the "initialAttributes" property set, but I wholly expect it to not work!

What it should do:
Obviously there's still some room to improvement here:
  • NCGD should initialize automatically (without the need for a potion) when a character finishes creation/loading
  • NCGD's remaining options (rates of growth and decay) should be server config variables and passed on to players
  • NCGD should be able to determine a player's base attributes from the player's class (major attributes), race, and birthsign
The first two are probably doable with a few more edits to the server's scripts and minor changes to the NCGD script. The last one is definitely the trickiest part, and may not even be possible with OpenMW's current scripting system. I am quite new to Morrowind scripting though, so there may be a few methods available that I just don't know about.

I apologize if a similar edit already exists or if this is the wrong board to distribute this; I was not able to find a similar edit and given the popularity of NCGD I figured I would share mine with the TES3MP userbase. These changes are not thoroughly tested, feel free to let me know here if you experience any problems.
All credit for NCGD's inner-workings goes to Greywander.
Attachments
ncgd_MP_edit.zip
(29 KiB) Downloaded 32 times

ImpliedVirility
Posts: 5
Joined: 09 Feb 2019, 20:42

Re: NCGD Edit for Multiplayer

Post by ImpliedVirility » 11 Feb 2019, 19:13

Made a few more changes to implement server-side configuration and initialization of NCGD. This has the effect of:
  1. No need to drink a potion to start NCGD (the potion has been removed)
  2. No need for menu interaction at load time
  3. Server enforcement of growth and decay rates
Installation
Client
Copy contained the ncgdMW_mp_edit.omwaddon file located in "plugins" to one of your client's data directories (wherever you normally place mods) and enable it through your openmw-launcher.exe

Server
Copy the entire contained "mp-stuff" folder to your server's directory; merge/overwrite with any directories/files

Note: I suggest backing up your mp-stuff folder any time you modify any of its contents as it contains all your multiplayer data and configuration. If anything goes wrong during installation or if this edit destroys something at runtime (it's still not thoroughly tested), you can always revert to the backup.

Open your server's config.lua file located in "mp-stuff/scripts in a text editor. Make the following changes:
  • As described in my previous post, add an "initialAttributes" property to the config.playerKeyOrder value.
  • Add these lines somewhere (I put mine above config.databaseType)

    Code: Select all

    -- The rate at which player's attributes grow or decay
    -- Valid values are "fast", "standard", "slow", and "off"
    -- Setting growth to "off" will disable the NCGD initialization process
    config.ncgdRates = { growth = "standard", decay = "off" }
Open your server's pluginlist.json located in "mp-stuff/data" and add the following record:

Code: Select all

{"ncgdMW_mp_edit.omwaddon": ["0xA938030A"]}
Make sure this record is correctly numbered in the list.

If you are installing on a server with existing players, follow my instructions in my first post to ensure that each character has their initialAttributes defined.

Issues With Decay
Spoiler: Show
Barring any major issues or updates to NCGD/TES3MP, I expect this to be my last edit for this particular mod. As before, let me know if you experience any issues.
Attachments
NCGD_mp_edit.zip
(29.18 KiB) Downloaded 31 times

davidcernat
Posts: 192
Joined: 19 Jul 2016, 01:02

Re: NCGD Edit for Multiplayer

Post by davidcernat » 16 Feb 2019, 10:45

Thank you. A lot of people are fans of Natural Character Growth and Decay, and this should tide them over nicely until the original mod works fine in TES3MP.

Post Reply