Jump to content
  • Announcements

    • AndalayBay

      Orphan Attachments   07/31/2018

      I have been doing some housekeeping lately and I've noticed that I had a lot of orphaned attachments. Attachments get orphaned when the PM or post is deleted without removing the attachment first. Deleting a PM or post does not delete the attachment and the file or image remain on the server. I'd like to ask all members to go through their attachments and delete any attachments you don't need anymore or those that have been orphaned. Where can I get a list of my attachments? Click on your display name in the upper right corner of the forums and pick "My Attachments" from the drop-down list. How can I tell an attachment is orphaned? If the PM has been deleted, you'll see a message like this in your attachment list: Unfortunately there is no message if the post has been deleted, so please check your old posts. We do purge old birthday threads every once in a while. Also some hosted projects have been shut down, so you may have orphaned attachments on one of those locations. Thanks!
Sign in to follow this  
AndalayBay

TES4Edit Case Study: Recovering a Patch

Recommended Posts

Level: Intermediate/Expert

I'm going to skip ahead now and recover a patch using TES4Edit. This will demonstrate some advanced features of TES4Edit and also show the structure of plugin files. My tutorials on cleaning and editing plugins are still to come, so this case study will gloss over several techniques which will be covered in the tutorials.

The techniques that I'll demonstrate in this case study will work for the other versions of xEdit, although some of the specifics will be different because the file formats are different for the other games.

Scenario: One of our patches for the Black Marsh project lost its master. We're not sure how this happened, but we need to restore the master to this patch and then we'll need to fix all the references.

Adding a master is quite simple and I'll explain that first. Then we'll go through and link everything back up.

Adding a Master

First, I'm going to give you a pro tip: add the IKnowWhatImDoing parameter to your TESxEdit shortcut to stop it from prompting you when you edit a plugin. Note this is a command line parameter. I don't advise you to do this if you're not really comfortable with TESxEdit's interface, otherwise you may find yourself saving unintended changes.

Open TES4Edit and clear the selections (Select None from context menu). Find the plugin you want to add as a master and the plugin you want to add the master to and load them. You can add multiple masters if needed - just load all the master plugins along with the plugin you want to add them to.
 

xEdit Master1


 
Right-click on the plugin to bring up the context menu and select Add Masters...

xEdit Master2



TES4Edit will list the other plugin(s) you loaded. Check off the one you want as a master and click OK. If this is a new master, then you're done and you can exit TES4Edit and save.

However, in this case, the real work is just beginning. :) If you're performing a similar task on your own plugin, then save your plugin file now.

Fixing all the References

The plugin that I'm using in this case study is a working patch for Black Marsh. It had the Black Marsh plugin as a master, but after a crash in the CS, it somehow got saved without Black Marsh as a master anymore. We are going to see if we can save this patch.

The first step is to fix the source objects, then I'll fix the Cell and Worldspace records. I'll be fixing the door teleport records as well. So I'll start with the Dialog Topic records. Here's a shot of all the missing references:
 

xEdit Master3


 
Once I expand the width of the BlackMarsh.esp column, it's pretty easy to see that the dialogue topics are really the same and it's just the mod index on the patch that has unlinked the references.
 

xEdit Master4


 
To change the Form ID, you right-click on the matching record in the patch plugin and select Edit from the context menu. It will open a small dialog box. Change the 02 to an 01 for the Form ID, as I've circled in the image below. You can ignore the error text - that will get fixed automatically once I fix the reference.
 

xEdit Master5


 
Now I click OK to close it. Voila! The first error is fixed and the dialogue topics are linked up again.
 

xEdit Master6



Now we'll skip down to the NPC records, since the Levelled Creature records may depend on the NPC records. Sorry to our American friends - I just can't spell levelled with one ell. :P I expand the section and click on the first record. The record is new, but it's lost the references to the race and the inventory items.
 

xEdit Master7


 
Note the dark text in the screen shots is because I haven't saved the patch yet. The patch doesn't add any race records, so we open the Black Marsh master and check the race records. Sure enough, there is a race record with the same Form ID - it's just the mod index that's different. I edit the Form ID on the patch to set the 02 to 01 as before and that fixes it. Similarly, I edit the inventory item Form ID's to change the 02 to an 01 and that fixes his inventory.

You can also do a slow click and hold on the field to switch it to edit mode. Then you can change the Form ID in place:

xEdit Master8



That saves a couple of clicks, but Windows can be fussy about how long you need to hold the mouse button down to get it to switch to edit mode.

Fixing the Cell Records

Fixing Cell records is very similar to what I've outlined so far, but you need to be careful about which Form ID you modify. The Form ID on the record does not need to be changed. That refers to the instance of the object you've placed in the cell. However, if the object you've placed in the cell is defined in the master, then you need to fix the Form ID so that it references the object from the master. To illustrate what I mean, I've expanded one of the Cell sub-blocks:
 

xEdit Master9


 
And once I fix the Form ID, you can see that the object is now properly listed:

xEdit Master10



As you can see, it's really the same as the field edits we've already looked at. Then why did I point this out in particular? Because I will be editing the records themselves when I fix the Worldspace records.

Record Edits and Using Scripts

Up to now, I've shown you how to edit the fields that make up a record. For example, an NPC's inventory items. Records are displayed in the left pane of TESxEdit. We could go through and edit each record individually, but we're going to save a bit of time by using a script. If you are working on a plugin to follow along with this tutorial, then save your plugin before running any scripts.

One of the characteristics of the way records are presented in TESxEdit is that you can select several at a time and then apply a script to act on them. So we're going to fix up the Worldspace records by selecting them and then running the "Change load order of FormID" script on it. We've already determined that the Form ID's can be fixed by changing the first two digits to match the index of the master and that's set by load order, so this script will do the trick.

Let's expand the Black Marshes record under Worldspace. You'll see that the Black Marshes worldspace record is fine. That should surprise you a bit. :) Look at the Form ID - it starts with 00! The reason it starts with 00 is because we moved all Black Marsh's worldspaces to index 00 so they are injected into the Oblivion.esm. The why and how is a topic to be discussed as part of a TES4Gecko tutorial, but the short explanation is that doing so fixes a number of bugs. It also means we don't have to worry about fixing the worldspace record.

xEdit Master11



Let's take a look at the Cell record. This record lists all the persistent objects in a worldspace. At first glance it looks fine, but there can be only one of these records per worldspace, so it should be referencing the master record. Indeed if you take a close look at the Form ID, you'll see that the last six digits are identical, so this record needs to be fixed. If you select a Form ID at record level and right-click, you'll notice there is no edit option. You have to choose Change FormID or Apply Script from the context menu. Since I'm just fixing a single record, I'll choose Change FormID and that relinks the Cell record.
 

xEdit Master12


 
If we expand the Persistent object list under Cell, we'll find one record. This is a Placed Object record, so we need to search the master to see if this is an edit to an existing object or if this is a new record. I type the Form ID in the FormID search box at the top, change the 02 to 01, then hit enter.
 

xEdit Master13


 
Surprise! That Form ID is a cell in the master, not an object, so I can't change the Form ID. Instead I have to fix the Form ID on the instance for the Base Object. Here's a screen shot to show what I mean:
 

xEdit Master14


 
Now since this is a door, I have to fix the teleport destination as well. When I clicked on this record, the Referenced By tab at the bottom of the right pane became visible. So I click on this tab to see the other references. It only has one reference:
 

xEdit Master15


 
I double-click on that reference and TES4Edit opens the cell that's the teleport destination. I just need to fix the Form ID on the door and it will be reconnected:
 

xEdit Master16


 
After fixing the Form ID, I can use the Referenced By tab to return to the door in the exterior cell to confirm the record is now fixed.

Now I expand the first Block and find a Landscape record and a Placed Object record. The Landscape record should definitely refer to the master, but it's possible the Placed Object is new. A quick search on the master version of the Form ID confirms that this time it's an object from the master that was edited:

xEdit Master17



This time I'll fix the Form ID of the Placed Object in addition to the Landscape. If I do an ALT+click on the next Block, we can see all the changes are Landscape edits, so we know the Form ID's will need fixing. This gives us a pretty big block of records to work with, so I'll show you what we've got before I go further:

xEdit Master18



When you are working with records, you should work with records that are at the same level and TESxEdit shouldn't allow you to mix levels when you are selecting records. That's why I fixed the Cell object and the persistent records first.

Now I'll select the records at the Sub-Block level and use the script to fix the Form ID's. The neat thing with this is that you don't have to restrict your selections to just one Block or Sub-Block. I've selected the records at the Sub-Block level and will now select Apply Script from the context menu on one of the selected records:

xEdit Master19



I search the drop-down list on the dialog that pops up and select "Change load order of FormID" and click OK. Now it will prompt you for the new number. In this case I want 01, so I type that in and click OK again. The Messages tab will say Applying script... and barely a second later, it informs me that it's done. I expand one of the exterior cell records and see that some fields still need fixing:

xEdit Master20



The Landscape record has several fields that need fixing, as another example:

xEdit Master21



Conclusion

As you can see, with a bit of detective work, you can repair a patch. We've seen how to add a master and how to fix references at a record and field level. We also saw how to determine if a record was new or an edit to an existing object. Once things are linked up properly, TESxEdit will show you the differences and similarities, as usual. After repair, this patch would then be cleaned.

Share this post


Link to post
Share on other sites

I always thought the "Add Masters" function fixed all of this automatically if you saved the file immediately after adding the new masters?

 

Was the stuff you had to fix caused by the file getting corrupted or did you just not exit the program after adding the master back in?

Share this post


Link to post
Share on other sites

Nope. It just adds the master. You have to fix all the references manually. You can use a script to change a block of records, which I've explained in the OP.

Share this post


Link to post
Share on other sites

I always thought the "Add Masters" function fixed all of this automatically if you saved the file immediately after adding the new masters?

 

Was the stuff you had to fix caused by the file getting corrupted or did you just not exit the program after adding the master back in?

 

That could only happen if after losing the Master the records are still recognised as from some place else, i.e. now being injected into something.

Share this post


Link to post
Share on other sites

It is possible to write a script that will do all of the above automatically :P

 

 

I told you to contact zilav, Andalay!

 

I know, but it's actually pretty easy to do it manually, so I didn't want to bother you zilav. I thought demonstrating the manual process was a good exercise for a guide like this.

Share this post


Link to post
Share on other sites

I just found out how this happens. The Black Marsh master isn't a true master - we are using the CSE to create the patches. Well don't open the patch in the regular CS. Since the Black Marsh plugin doesn't have the master flag flipped, it will be removed as a master of the patch.

 

tl;dr - If you use the CSE to create a patch on a plugin, don't open and edit the patch in the regular CS. It will remove the plugin as a master. Your patch will work fine in-game, but not in the CS.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×