Sunday, December 15, 2019

Debugging Tools for Skyrim

This is a set of notes on the methods and mechanics for debugging skyrim mods that I have collected.  These notes are about working on the PC.  If you are on another platform or console, your mileage may vary... greatly.

Who is this for?  What is it for?

Myself mostly, but at a more general level, these notes are written for programmers.  The stuff that I'm attempting to debug is in the guts of other peoples mods, core scripts or if I get really bored, SKSE.  Debugging the skyrim engine is beyond what is humanly possible without access to the source code and a solid education in game engine design, debugging C++ and some serious hours.  Trying to do it via disassembly or in a real time debugger is a monstrous task. Patching it would also be the stuff of nightmares.

This is a list of helpful notes so I can remember where I am up to and what I have learned.  It's not intended to be comprehensive or a tutorial on anything in particular.  Its just useful information, collected in one place that I can look over when I need to get some perspective.
My problem is that I find bits of information scattered around the web and there are times when its hard to bring it back to mind or find the answer to a question as I can't remember how I phrased it the last time I stumbled accross some vital detail.  Hence,  writing it down as I go.  That's all this is.

Tools 

Console Commands

The console commands inside skyrim are some of the first debugging, bug avoidance tools you will need to be familiar with.  If you are in a state where the game is still responsive, but you are jammed up or experiencing some unexpected behaviour, then you may be able to "hack" you way around the issue with some creative console work. 

- Stuck in walls or between static elements

Use the console command tcl to toggle clipping off,  close the console and move to a safe area (slightly above the ground/floor) then use the console and the command tcl to turn clipping back on.  Close the console.  You will then gently float back to the ground.  

- Bugged Quests

There are all manner of quests that can get into an unplayable state.  This is due to two factors.  The first is that the original quest authors did not check for all possible cases in their quest scripts (and handle them).  The second is that with modding, the number of edge cases can change. As such, there are lots of ways that quests can get jammed.  
I have tried resetting quest variables and skipping ahead in some quests to try to get back on track.  However, this is a lot of hit and miss and there are some quests that I just cannot get to work. Mostly because I can't figure out what has gone wrong from the limited information that I can find.  

- Unfindable stuff

There are times in the game when its just hard to locate something and it starts getting un-fun to keep looking.  Lack of time and patience means that being able to use a console command to add a particular item is less immersion breaking than giving up and leaving the task unfinished.  Because you know that in a game as big as skyrim + mods, its possible you will never find your way back to this situation if you walk away.  So, find the items FormID via the help command or on the web  

-  player.additem *FormID* *quantityToAdd*

Mod Organiser 2

Apart from being a generally awesome tool for managing the chaos that is modding.. MO has a number of handy features that provide information and methods for debugging.  

 - Tools to manage the mods

Simply keeping on top of which mods are installed, what version they are, if updates are available, where to get the updates, where the notes for the mod are... etc.  This provides a lot of very valuable information about what is going into your skyrim game and allows you to fiddle with it very easily. 

- Profiles

The ability to mix and match mods on demand is nice, but the ability to run multiple profiles with different mixes turns this up to 11.  As a debugging tool, the ability to do comparative analysis is very very valuable. 

TES5Edit

Understanding what mods are doing to the base game and each other is really handy.  This is a kind of static analysis for the properties and variables that the mods mess around with.  It does not seem to provide any ability to see into the papyrus code that the mods run, but for trying to see which mods are stepping on each others toes, it does give you a view all the way down to the metal of the script engine.

- Cleaning dirty mods.

I recommend the auto clean function, tedious as it is.  (Would a batch method be too much to ask for?)   Keeping track of which mods need cleaning, which ones should never be cleaned and what other chaos you can self-inflict is all part of the TES5Edit experience.
This could be made simpler.

TES5Edit - Fixing Errors and merging mods

How to Make a Patch with TES5edit

zEdit

This is a kind of fork of xEdit.  https://z-edit.github.io/#/docs?t=Overview
 Looks like it has a similar feature set but with a different skin.  Still filling out the existing feature set.  Mostly targeted at working with mods and merging them.  Nothing obvious about hacking save files.  

Creation Kit

Still Exploring its debugging capacity. Certainly good for getting to grips with what the mods are doing and trying to understand all the guts of skyrim and how the mods function.  Those with any source code anyway.  Otherwise can just see some of the assets.

Creation Kit Source Files

Good for figuring out what the hellstorm is going on in the DLC's and general experience about how mods are built, styles of coding in the scripts and ways to actually do anything in Skyrim.

LOOT (Or BOSS)

These tools provide a way to manage load order dependencies.  LOOT also contains notes on various mods that need cleaning and some hints on resolving errors with some mods.
Resolving the dependency graph is a very useful process that you will need to perform each time you fiddle with your list of mods.

Papyrus Log / Skyrim Logging

The log from the scripting engine is ... a dumping ground for messages from scripts.  Its marginally useful,  contains a mess of false positives, warnings and spurious errors.  Once you mod list gets a bit long or you are trying to debug anything... it will start to fill up with a spew of useless information.  There is no way to address most of the issues that will appear here... so I am still unconvinced that its worth much.  However, you may see more value...

First you will need to turn your log on:

- Find your skyrim.ini file.
If you are using Mod Organiser then its under the Tools button > INI Editor
Otherwise, its in your skyrim folder.

- Turn on logging

Change the papyrus section to read:

[Papyrus]
fPostLoadUpdateTimeMS=500.0
bEnableLogging=1
bEnableTrace=1

bLoadDebugInformation=1


- Finding the log files
Once you have logging enabled, you will find the log files in your profile something like

C:\users\\My Games\Skyrim\Logs

Other people have reported that the logs will appear in the skyrim\logs folder.  However this should not be possible if skyrim is installed in a vanilla location as it should be write protected... so you may need to check for the logs in a couple of places.

Save File Cleaners

There are a couple of save file cleaners on nexus.  I have cracked open a file or two but not done anything substantial with them beyond reading my save files.  As the interaction between the save file and the game is a bit of a black box.  Currently trying to manually edit the save is only trial and error.

Save game script cleaner https://www.nexusmods.com/skyrim/mods/52363
Savegame script scalpel - Disassembler - Diagnostic Tool - Papyrus Data Transfer
https://www.nexusmods.com/skyrim/mods/53045

Tutorial - How to edit script variables inside a savegame

WRYEBASH

Another interesting and complex tool.  Still Exploring.  Good for packing mods and patches.  Similar to TES5Edit in that respect.

BSA Unpacker

Being able to unpack files from mod BSA packages.  Useful... but not essential yet.


No comments:

Post a Comment