Changes

Oblivion Mod:Formid

1,726 bytes added, 20:44, 30 March 2008
Update.
{{Oblivion Modding Trail}}__TOC__
==Formids for Players==
__TOC__
In Tes4Oblivion, all data objects are(a identified bybook, a formid (aka hexid). Technicallyrace, a formid is an unsignedspawn integerpoint, buta inspawned CS4npc) (Constructionare Setidentified forby Tes4),formids. you'llFormids seeare it as an 8eight digit hexadecimal numbernumbers (e.g.0A012C436), 020006E6).where Youthe canfirst alsotwo seedigits formids while playing Oblivion by openingrepresent the consolesource (type '~')mod and then clicking on an object -- the formidfollowing willsix displaydigits atare the topobject of the screenindex.
 
===ModIndexIn-Game and ObjectIndexFormid===
While playing, you can usually find the formid of any visible object by opening the console and clicking the object. The object's formid will display at the top of the screen.
Formids have two components: the first two digits are the modindex, and the following six digits are the objectindex. The objectindex for any data object in your mod is unique and fixed within the mod -- i.e., once it's assigned to the object, it will not change no matter what you do to the object.
 
Note that there is a difference between the '''object definition''' and a '''placed instance''' of that object. For example the definition ("base object") of the NPC Palonirya (proprietress of "Divine Elegance" in the IC Market District) is 00015ea8, while her placed instance ("reference") is 0002c164. When you click on an object in the game, what you'll see is the formid of the ''placed'' instance (e.g. 0002c164 for Palonirya).
The modindex represents the load position of the source mod for the data object, and it will change depending on context. Typically in CS4 the modindex for any data object that you create will be '01', since your mod is typically the second to load (after Oblivion.esm, which has modindex '00' because it loads first).
 
===Construction Set vs. In-Game Formid===
In-game, the modindex will reflect the load position of your mod. E.g., if your mod loads fifth, then the modindex will be '04'. (Oblivion.esm loads first, and the modindex numbering is zero based (0, 1, 2,...), so Oblivion's modindex will remain '00'.)
In the construction set (CS), you'll usually find the formid in the second column of a grid display. Note that this column is usually minimized -- i.e. you'll need to widen the column to actually see the formid. For placed references, the easiest way to find the formid is to double click the reference in the cell view window -- the resulting dialog will list both the reference formid and the base object formid.
 
Note that the modindex may vary between CS and game. In both cases, the modindex represents the order of the source mod in the current context. E.g. the boots from Knights of the Nine is 01000ecf in the construction set, but in game might be 0A000ecf, if KOTN is the 10th mod loaded after Oblivion.esm.
'''Note:''' The modindex of a data object in CS4 is the '''native''' modindex. The modindex of that same data object in-game is the '''in-game''' modindex.
 
Note too that objects that specifically belong to the savegame and not to any mod are given the modindex FF. You'll actually find these quite commonly: all spawned npcs and creatures, plus all items initially acquired out of inventories and containers, plus all items created in game (spells, potions, enchanted armor and weapons) will all have modindex FF.
 
===CS Formid to In-Game Formid===
If you know the CS formid and need to know the in-game formid, then you need to replace the CS modindex with the in-game modindex. In other words, you just need to find the modindex of the source mod (e.g. Knights.esp), while you're playing. Here's how:
* Find an object that you know was placed by the source mod. E.g. for KOTN, both the prophet and the Priory of the Nine are placed by the mod, so if you console-click on either of them, then the first two digits of their formid is the modindex.
* If you're running Oblivion Mod Manager, the modindex will be shown when you mouse-over the mod in the main mod listing. (Mistakenly labeled as "formid" in the popup info box.)
** InIf theyou're Modsrunning tabWrye Bash, find the mod. The modindicesmodindex for all active mods areis listed in the second columcolumn of the displayMods tab.
 
Note:
* '''Oblivion.esm is always first''' (has modindex 00) in both the CS and in-game. No conversion is necessary.
* If a mod has multiple masters (e.g. Oblivion.esm, Cobl Main.esm), then objects coming from the mod itself will have their modindex shifted upwards in the CS, '''however''' the techniques above will still work with no change. (This complexity is something that only toolmakers and advanced modders need to worry about.)
 
===Hexadecimal Numbers===
''For folks who don't know what a hexadecimal number is...'' Okay, decimal numbers go like this: 0 1 2 3 4 5 6 7 8 9 10 11..., while hexadecimal numbers go like this: 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 .. 19 1A 1B ... etc. Hex 'A' equals decimal 10, hex 'B' equals decimal 11, ... hex 'F' equals decimal 15. Since hexadecimal is base 16 ('hex' = six +'deci' = ten), they "roll over" at 'F' (= 15 decimal), the same way that decimal numbers roll over at 9.
 
==Formids for Modders==
To convert a two digit hex number into decimal simply multiply the first digit by 16 and then add it to the second digit. E.g '42' in hex is 4*16 + 2*1 = 66. Or 'FF' in hex is 15*16 + 15 = 255.
'''This section is intended for modders only.''' It provides a bit more detail than the players section and addresses some other advanced topics.
 
===ModIndex and ObjectIndex===
Hex numbers are useful in computers because they map very directly to the way computers actually store numbers (in binary). Two hex digits is the same thing as a byte which is the same thing as 8 bits.
Formids have two components: the first two digits are the modindex, and the following six digits are the objectindex. The objectindex for any data object in your mod is unique and fixed within the mod -- i.e., once it's assigned to the object, it will not change no matter what you do to the object.
 
The modindex represents the load position of the source mod for the data object, and it will change depending on context. Typically in CS4 the modindex for any data object that you create will be '01', since your mod is typically the second to load (after Oblivion.esm, which has modindex '00' because it loads first).
===FormId Usage===
 
In-game, the modindex will reflect the load position of your mod. E.g., if your mod loads fifth, then the modindex will be '04'. (Oblivion.esm loads first, and the modindex numbering is zero based (0, 1, 2,...), so Oblivion's modindex will remain '00'.)
 
'''Note:''' The modindex of a data object in CS4 is the '''native''' modindex. The modindex of that same data object in-game is the '''in-game''' modindex.
 
===FormIdFormid Usage===
'''CS4:''' If, while editing your mod, you change one of Oblivion's data objects rather than creating a new one, then no new formid will be created. Instead, the formid recorded in your mod file will be the same as Oblivion.esm's formid. This is how the game knows that your data object is ''replacing'' the data object from Oblivion.
 
If a new object is created in game, then it will be assigned modindex FF (i.e., 255, i.e. the last 'slot' available). New objects are created if you buy an item from a merchant or pull an item out a container.
 
===WhereFormids tovs. Find FormIdsEditorIds===
When viewing data in CS4, you'll see columns labeled "EditorId". Immediately after that column, you'll see a very thin column (just a couple of pixels wide). If you expand that column, you'll see the FormId.
 
===FormIds vs. EditorIds===
EditorIds are the plain text ids of data objects (e.g., 'BearPelt01'). While these are what you'll usually think of and be concerned with while editing, they're really just aliases (nicknames) for formIds, which are the ''true'' identifiers of data objects.
 
For example, if you change the 'BearPelt01' to 'BearPeltO1x' (without creating a new formid), you're just changing the alias -- and only so far as your mod is concerned -- as far as other mods are concerned, the alias is still 'BearPelt01'.
 
Note that although you can change the editor id of a data object, you cannot change the FormIdformid. And changing the EditorId has very little effect on the mod, since internally, references to data objects are stored as formids. Again, note that changing the editor id in your mod, does not effect the editor id in other mods.
 
Scripts provide a nice illustration of EditorId vs. FormIdformid: If a script says something like "player.additem BearPelt01 1", then the compiled script will actually add item '000228E3' which is the formid corresponding to 'BearPelt01'. (In fact, you can write the script using the formid directly instead of the editorid.) In game, script commands will generally ''not'' accept EditorIds -- instead you must enter the formid itself.
 
===Reference vs. Base FormIDsFormids===
For objects placed into the game world there are two FormIDsformids: the reference FormIDformid or '''RefID''' (associated with that particular placed object), and the base FormIDformid or '''BaseID''' (used for all versions of that samsame object).
 
The BaseID provides the information that is common to all instances of that object. For example, every copy of the book ''[[Oblivion:On Oblivion|On Oblivion]]'' has the same BaseID (<code>0002457E</code>); that BaseID record contains information such as the weight, value, appearance, and text of the book. The specific type of record used for the BaseID depends upon the type of item. For example [[Tes4Mod:Mod File Format/BOOK|BOOK]], [[Tes4Mod:Mod File Format/WEAP|WEAP]], [[Tes4Mod:Mod File Format/NPC_|NPC_]], and [[Tes4Mod:Mod File Format/CREA|CREA]] are all records used exclusively for BaseIDs. In the Construction Set, all of the FormIDsformids listed in the "Object Window" are BaseIDs. Most FormIDsformids provided on this site are BaseIDs.
 
The RefID provides access to information such as the object's location. There are only three types of records used for RefIDs; the specific type of record depends upon the object:
* For creatures, a [[Tes4Mod:Mod File Format/ACRE|ACRE]] record is used.
* For all items, a [[Tes4Mod:Mod File Format/REFR|REFR]] record is used.
In game, when you console-click on a placed object, the FormIDformid that you will see is the RefID, not the BaseID. In the CS, when you look at objects in the "Cell View", the IDs are all RefIDs; if you edit the object, the BaseID is provided under "Base Object" (and "Edit Base" allows you to edit it). When RefIDs are provided on this site, they are explicitly identified as RefIDs.
 
===Mod Conflict and Isolation===
===In-Game Modindex===
FormIdsFormids were introduced for several reasons, but a main reason was to do away with the mod conflicts that plagued the Morrowind community. However, a high price has been paid for this -- mods conflict has been removed by almost completely isolating mods from each other. I.e., esps can no longer access objects or cells created by other esps. This places a '''huge restriction''' on modders. For more discussion, see [[Tes4Mod:Mod Integration|Mod Integration]].
In-game console commands will generally not accept editorids -- instead, you'll usually have to enter the formid of the data object that you want to work with. If the data object that you're interested in is a placed object, then you can simply bring up the console and click on it to see the formid. But if it's something like an object that you want to add to the player's inventory, then you'll need to know both the objectindex and the in-game modindex of your plugin. The objectindex is easy -- it's the same as the objectindex that you see in CS4.
 
Unfortunately, this isolation makes it difficult to intentionally make mods interact with each other. In fact, using CS by itself, it's impossible to make an esp directly reference (use) anything in any other esp! Fortunately, several tricks have been developed to deal with this. For more info, see [[Tes4Mod:Mod Integration|Mod Integration]].
The modindex is easiest to find through use of the one of the modding tools:
* Using [http://wrye.ufrealms.net/#Oblivion Wrye Bash].
** In the Mods tab, find the mod. The modindices for all active mods are listed in the second colum of the display.
 
===Mod Conflict and Isolation===
FormIds were introduced for several reasons, but a main reason was to do away with the mod conflicts that plagued the Morrowind community. However, a high price has been paid for this -- mods conflict has been removed by almost completely isolating mods from each other. I.e., esps can no longer access objects or cells created by other esps. This places a '''huge restriction''' on modders. For more discussion, see [[Tes4Mod:Mod Integration|Mod Integration]].
 
===Multiple Mods in CS4===
 
===ModIndex Zero===
Modindex zero ('00') is likely to be somewhat special, since the gameenginegame engine itself defines certain default objects with modindex zero. You'll see these if you start the construction set without any mods (including Oblivion.esm) loaded. This suggests that Oblivion.esm should always be the first mod to load -- i.e. it should always be dated earlier than any other esm files.
 
=== Formid Fixup ===
For details on exactly how to load and merge multiple mods see the [[Tes4Mod:FormID_Fixup|FormID Fixup]] page.
 
===Advanced Questions===
;Suppose that you delete an object. Can the formid that was assigned to it be assigned to a newly created object?
:Yes. Base FormIDsformids can be recycled, as long as there are never two objects with the same FormIDformid in a mod. In game, temporary FormIDsformids (those starting with FF) are incremented by the game engine for each object created. When the counter reaches FFFFFFFF it is reset to FF000000, and FormIDsformids which are no longer in use are recycled. (There were problems with this recycling not working correctly before patch 1.2.0416 - most notably the counter was incorrectly reset to 00000000 instead of FF000000.)
;What's up with GMSTs?
:Many GMSTs have formids == 0, yet it's possible to change the EditorId. If you try to change the value of a GMST that has formid == 0, a new formid will be assigned. I suspect that GMSTs are an exception -- i.e., that unlike every other data object, their formids are not used.