Tes5Mod:Mod File Format/QUST

QUST records describe Quests. The overall QUST record has a complex structure, with most fields repeating multiple times.  The order in which the fields appear provides important information about each invidual field.  Fields of particular importance are:
INDX fields.  Each one marks the start of information about a given quest stage.  The subsequent fields all provide information about that specific quest stage.
QOBJ fields.  Each one marks the start of information about a given quest objective.
ALST and ALLS fields: Each one marks the start of information about a given quest alias. Aliases have an ID (e.g., 4), a name (e.g.,  ), and a calculated value, e.g., "Winterhold". ALLS fields are used for location aliases, whereas ALST fields are used for reference aliases.  

Standard Fields
These fields are not part of any of the more complex structures described in the subsequent sections.


Quest Stages
Each of these sections provides information on a specific quest stage. Multiple sections can appear in a single record, and 1 or more log entries can appear within each INDX field. Stage numbers are not guaranteed to be unique within any given quest.

Any script attached to a given quest stage is automatically turned into a script "fragment"; the quest stage fragments are all combined into an automatically-generated quest fragments script file (named "QF_ _ "). The script fragments are numbered chronologically, meaning that there is no relationship between the fragment numbers and the quest stage numbers. The only place to extract the fragment numbers is from the VMAD field for the overall QUST record, which contains a section storing those numbers.



Quest Log Entry


Quest Objectives
Multiple quest objective structures can appear in a single record, and the objective index is not guaranteed to be unique.


Quest Target
Multiple quest target structures can appear within each quest objective.


Aliases
Aliases are introduced with an ANAM field (documented in the main quest record, above), after which, multiple ALST and/or ALLS fields may be present.  Each ALST/ALLS entry provides information about a given Alias (i.e., a dynamically assigned value) that can appear in this quest.  ALLS fields are used for location aliases, whereas ALST fields are used for reference aliases.  Some of the fields within an ALST/ALLS section are used to determine the calculated value for the alias.  Other fields are used to assign properties to the target of the alias.  For example, if the alias is an NPC, the NPC may be assigned factions, spells, or inventory items associated with the alias.

In terms of structure, ALST and ALLS fields are largely interchangeable.  The ALID field provides the alias name.  Under the ALID field are a wide variety of possible fields, ending with an ALED field.  Many fields can appear in either ALST or ALLS sections, whereas others are specific to one section.  The multipliers in the 'C' column in the following table only apply relative to a given alias.  If a field can only appear a specific alias or fill type, the multiplier only applies within the context of that type.

For reference aliases, a flag value of 0x800 (No Fill Type) results in no fill type being selected in the CK and a fill type of "Forced: NONE" being indicated in the Quest Aliases table. A "Forced: NONE" fill type can also occur for a reference alias when an alias has no fill type, but the flag at 0x800 is set to 0. (Note: There are two anomalous aliases in Dawnguard.esm, DLC1VQ01.SeranaCloaking and DLC1VQ08.DLC1VQ08HarkonAlias which have the flag set, but also include Unique Actor fields in the data; it's unclear how the game handles these two aliases.)

For location aliases, a flag value of 0x800 results in either a "Find Matching Location" selected on the location alias form with "Conditions" being indicated on the Quest Aliases form if there are CTDA fields, or no fill type selected on location alias form with "Forced: NONE" in the Quest Aliases table if there aren't. The same rules apply if the flag is cleared and the alias has no fill type, except that in the CK, the location alias form will have the "Specific Location" option selected.

"Forced: NONE" aliases are normally filled either by scripting or forced-into aliases (ALFI field). It's unclear if there's any difference between the different methods of generating them. It's possible that it's a holdover from earlier versions of the CK.

In addition to the various packages, factions, spells, inventory items, etc. listed below, any aliased object can also have scripts attached to it when it is assigned to the alias.  However, those scripts are not listed in any of the fields in the ALST/ALLS section.  Rather, the scripts are stored in the VMAD field for the overall QUST record, which contains a section listing all scripts attached to the quest aliases.


|-
| - || ALFI || Forced Into Alias || uint32 || AliasID of another alias to copy this alias into.
|-  
|colspan=5|The following fields determine the alias' "Fill Type" (to use the CK terminology), i.e., they assign the alias' value.  Only one of the following fill-type fields (unindented) can appear in a given alias, along with any associated sub-fields (indented).
|-
| - || ALCO || Alias Created Object || formid || (Ref) Points to a base record for an item (NPC_, BOOK, MISC, LVLI, ARMO, KEYM, etc).  An instance of that object is then created and assigned to this alias. 

Specified using "Create Reference to Object" section of CK editor; displayed as "Created" in Fill Type column.
|-
| + ||
: ALCA
| Create At || uint32 || High bit: 0 = Create At, 1 = Create In Remainder: AliasID to create object at/in.
|-
| + ||
: ALCL
| Create Level || uint32 || 0 = Easy 1 = Medium 2 = Hard 3 = Very Hard 4 = None
|-
| - || ALEQ || External Alias Reference || formid || (Loc/Ref) QUST records.  Provides the quest where the alias should be copied from; ALEA provides the AliasID in that quest that should be used.

Specified using "External Alias Reference" section of CK editor; display as "Match" in Fill Type Column.
|-
| + ||
: ALEA
| External Alias || uint32 || AliasID to be used in specified external quest.
|-
| - || ALFA || Reference Alias Location || uint32 || (Loc) AliasID of a reference alias within this quest.
|-
| - ||
: KNAM
| Keyword || formid || A single KYWD record.
|-
| - || ALFA || Location Alias Reference || uint32 || (Ref) AliasID of a location alias within this quest.
|-
| + ||
: ALRT
| Alias Reference Type || formid || Points to a LCRT record which is used to find the object that should be assigned to this alias.  This LCRT is looked up in the LCTN.LCSR field of the quest's assigned location to find a ACHR or REFR record that is then associated with this alias.

Specified using "Location Alias Reference" section of CK editor; displayed as " 's &lt;Ref Type&gt;" in Fill Type column.
|-
| - || ALFE || From Event|| char[4] || (Loc/Ref) Provides the type of event (e.g. "Script").  Corresponds with SMEN short name.  ALFD field provides extra data about the event.

Specified using "Find Matching Location/Reference" section of CK editor and "From Event" checkbox; displayed as "Event" in Fill Type column.
|-
| + ||
: ALFD
| Event Data || char[4] || Corresponds to "Event Data" dropdown box in CK. Exact meaning of text varies based on event type. See CTDA documentation for more info.
|-
| - || ALFL || Alias Forced Location || formid || (Loc) A fixed LCTN record that should be assigned to this alias.  Also presumably becomes the default location record for this quest (used by any other alias records that need to look up location-specific items).

Specified using "Specific Location" section of CK editor; displayed as "Forced" in Fill Type column (even if "Force into Alias when Filled" is not selected).
|-
| - || ALFR || Alias Forced Reference || formid || (Ref) Points to an ACHR or REFR record corresponding to the object that should be assigned to this alias.  

Specified using "Specific Reference" section of CK editor; displayed as "Forced" in Fill Type column.
|-
| - || ALNA || Near Alias || uint32 || (Ref) AliasID this one needs to be near to.
|-
| + ||
: ALNT
| Near Type || uint32 || Always 0: Linked Ref Child
|-
| - || ALUA || Alias Unique Actor || formid || (Ref) NPC_ record for an NPC assigned to this alias; uses an existing instance (ACHR record) of the NPC instead of creating a new one.  Presumably only works for NPCs with a unique ACHR.

Specified using "Unique Actor" section of CK editor; displayed as "UniqueActor" in Fill Type column.

This field is frequently used to identify the quest-giver, but it can also be used to assign an alias for any other NPC with a unique role in the quest.
|-  
| * || CTDA || Match Conditions || struct[32] || (Loc/Ref) Conditions used to Find Matching Reference/Location.

Specified using "Find Matching Reference/Location" section of CK editor and filling in "Match Conditions"; displayed as "Condition" in Fill Type column.
|-
| - || KSIZ || KWDA count || uint32 || (Ref) Number of KWDA entries (size of KWDA is 4*KSIZ)
|-
| - ||
:KWDA
| Alias Keywords || formid[KSIZ] || KYWD records.  Keywords added to the alias for the duration of the quest.
|-
| - || COCT || CNTO count || uint32 || (Ref) If present, number of CNTO records.  Does not appear if there are no CNTO records and may not appear even when there are.
|-
|rowspan=3| * ||rowspan=3|
:CNTO
| Items || struct[8] || (Ref) Inventory-type item list.  These items are added to the inventory of the aliased object for the duration of the quest.
|-
|
:Item ID
| formid ||
|-
|
:Item count
| uint32 ||
|-
| - || SPOR || Spectator Override || formid || (Ref) Spectator Override Package List (FLST records).
|-
| - || OCOR || Observe Dead Body Override || formid || (Ref) Observe Dead Body Override Package List (FLST records). (Never used in main game files.)
|-
| - || GWOR || Guard Warn Override || formid || (Ref) Guard Warn Override Package List (FLST records). (Never used in main game files.)
|-
| - || ECOR || Combat Override || formid || (Ref) Combat Override Package List (FLST records).
|-
| - || ALDN || Display Name || formid || (Ref) Points to MESG record, whose value is then dynamically assigned as the displayed name of the Alias object.  Used to rename NPCs (e.g., ), quest rewards (e.g., Blade of Falkreath), or quest targets (e.g., Fine-Cut Void Salts)
|-
| * || ALSP || Alias Spells || formid || (Ref) SPEL records.  Spells added to the alias target for the duration of the quest.
|-
| * || ALFC || Alias Factions || formid || (Ref) FACT records.  Factions added to the alias target for the duration of the quest.
|-
| * || ALPC || Alias Package Data || formid || (Ref) PACK records.  Packages added to the alias target for the duration of the quest.
|-
| - || VTCK || Voice Type|| formid || (Ref) "Additional Valid Voice Types for Export".  When non-zero points to NPC_ or FLST records
|-
| + || ALED || EOF Marker || empty || Marks the end of any given alias entry.
|}