Morrowind modding for smarties, part 3: tes3lint, tes3cmd and TESTool

Ok, time to start using our tools.

Article prerequisites:
- you should be computer and Morrowind-savvy enough to be able to install and make work most of the tools.
- you should be one of those couple of modders/mod users willing to learn and use my best practices.

Imagine you are a player willing to install a new mod or a modder willing to make your mod as clean and error-proof as possible (I would say "clean as an elven arse", 10 points to you if you recognize the quote without googling).

I suggest you keep your modding/mod fixing work to a dedicated copy of Morrowind folder without touching the original Morrowind installation. For in-depth explanation about having multiple Morrowind installations, read here. Basically, it is just a matter of copying the entire Morrowind folder somewhere else.

After having extracted the mod package to some folder using your preferred archive tool (I like portable 7-Zip included in LiberKey, but you can use anything you like), let's see the readme and eventually follow the instructions.
I'm using Total Commander/Double Commander to copy/move/compare files between folders, naturally you can use your preferred file manager, Mash installers or even standard Windows file manager.

Now, let's start having a look at your mod (we will call it mymodname.esp in our examples) using Mash.
Selecting it from the mod list and looking at the right Mash panel, we can realize what are the masters of the mod.

Then, I suggest you have Perl installed and working, so we can use tes3lint to find information about possible mod problems.
I have it named inside the Data Files folder, and I use it from a tes3lint.bat batch file containing this line:

perl.exe -a "mymodname.esp" > tes3lintout.txt

I change the mod name each time, a little annoying, but I've not found a good way of integrate it to Mash yet.

My thought about tes3lint report (tes3lintout.txt file in our example) parts: 

  •  Find out if the plugin defines autocalc'ed spell: these can cause problems (enemies killing you with too powerful spells) because they are automatically used by NPCs, so if you find these spells too powerful you may want to edit the mod in TESCS and set them as not autocalculated.
  • Find out if the plugin has an implicit dependency on Tribunal/Bloodmoon functions because it uses them but does not list the expansion as a Master: in this case, you may  want to set the proper masters, just load the master with the mod in TESCS and save the mod; this may generate evil GMSTs, but we will clean them after. However, note that a modder may have willingly not included explicit dependency in case master resources are not needed (e. g. myself in water life mod) and stated in the readme that a Tribunal/Bloodmoon/GOTY engine is needed to run the mod, so as usual take a look at the readme to decide.
  • List Evil GMSTs: they will be cleaned automatically by our tools, anyway this is good to know and often an index of mod author accuracy (see also GMST contamination).
  • Find deprecated usage of Leveled List scripting functions on standard Bethesda Lists: this is rare to find in recent mods, you could need a proper patch for certain old mods.
  • Find duplicate (i.e.: "dirty/unclean") records that are unchanged from one of the masters: this also will be cleaned by our tools.
  • Find all records in the plugin that override records in its Masters: usually not problem, may be by design.
  • Finds potentially buggy case where INFO dialogs have had their IDs changed, Shows duplicate and modified INFO dialogs: unintentional changes of this kind are a common source of dialog compatibility problems, so better fix those if you know what you are doing.
  • Find CELLs that trigger the FOGBUG: good to know, if you are a modder fixing your mod, better fix it in TESCS assigning to interiors a fog value of 0.01 instead of 0. If you are a player it can be easily fixed for all your loaded mods using tes3cmd multipatch option.
    Note: I recently had problem with this, it may be my graphic card/drivers  (ATI 4830), but I had to raise this to 0.1 to make it work in some particular cells, so maybe 0.1 would be a safer value.
  • Find any CELLs where fog density in DATA is different from AMBI subrecords: same thing, this can be automatically fixed by tes3cmd multipatch. 
  • Find problematic usage of GetSoundPlaying for detecting events: it may be of use if you are running Morrowind under Linux or want your mod to be able to run on Linux. Frankly, I don't care much if Linux users can't 100% emulate Windows hardware platform, these sound functions are too precious to be unused.
  • Find dirty junk cells that are apparently injected by some CS bug: can be fixed by tes3cmd, TESTool.  
  • Find scripts that are unaware of MenuMode: this can be of some use if mod author was unexperienced, but a experienced modder usually will omit unnecessary MenuMode, so don't give this a great importance if you are not able to correctly judge the code.
  • Show if plugin is missing Author/Description/Version from plugin header: not essential, but useful. I usually add author/mod info if missing from Mash right panel.
  • Find problematic scripts attached to Bethesda doors: rare but good to know

To automatically solve some of these possible problems, we will first clean our mod using the best automated tools available.

We will start using tes3cmd.exe (the executable version), ensure you have it placed in the Morrowind\Data Files folder.
The command we want to use is:

tes3cmd.exe clean --replace --hide-backups "mymodname.esp"

This will backup the mod in Data Files\tes3cmd\backups\ folder (or Morrowind dir\tes3cmd\backups\ in more recent tes3cmd version) , then clean it.

You can run the command from the command prompt, but I suggest you prepare a batch file so you can reuse it.
Just open your preferred text editor (I am using Notepad++), write the command and save it as tes3cmd.bat inside your Morrowind\Data Files folder, then you can double click the tes3cmd.bat (or you could create a batch accepting a input parameter and associate it with .esp, or use Total Commander file association).

Personally, I use and suggest a right-click command in Mash to integrate tes3cmd, to be able to clean multiple mods with tes3cmd using Mash as GUI.

A small note: tes3cmd is a Perl program, and even its executable version is not very fast, so don't expect it working well with a 30MBytes monster grass mod, better use just TESTool in such a case. Anyway, a mod up to 15/20 MBytes should be properly handled by tes3cmd.

After cleaning with tes3cmd, we will clean a few things tes3cmd may skip (usually starting/ending dialog entries in double-linked dialog lists which can be reconstructed on the fly by Morrowind engine, and some other junk cells created by TESCS) using TESTool.

Be sure to have testool.exe in your Morrowind directory, and confirm when it asks to use your Morrowind.ini settings instead of registry setting. Then go to the Options panel and set these options ON: "Don't change plugin filenames", "Retain file name when cleaning"
Keep everything else OFF.

TESTool settings

Now choose the "Clean ESP/ESM (save results in Clean subfolder)" option. This way you will modify just a copy of the mod, but you will be able to open and study the generated all-important Morrowind\TESTool.log, and decide if you want these changes.

In case you found some cleaning excessive/risky, change the options below:
To be absolutely safe even with not perfectly clean dialog mods, keep also "Restricted dialog cleaning" ON. If you are sure your mod is not changing original topic infos (that is, tes3lint did not find any), you can keep it OFF.

To be absolutely safe even with rare mods using empty interior cells as garbage storage, keep also "Restricted cell cleaning" ON (you will possibly miss some junk cell cleaning though).
Now choose the option "Clean ESP/ESM" to clean your mod for good.
What I usually do and suggest is just to add any static to the empty garbage storage cell, so TESTool will avoid cleaning it even with "Restricted cell cleaning" OFF.

Note: for all this to work as intended, you obviously (you RTFM of tools you are using extensively, don't you?) have to use the Execute button, NOT the JUST FIX IT! one, else all our carefully chosen TESTool settings will be bypassed using potentially dangerous default instead.

Relax and practice, we are done for now. Stay tuned for next part.