Item Definition

Items: their names, menu operations, values, equipment models, and the camera angles their inventory icons are rendered from.


ItemDefinition.Create

function TItemDefinition.Create(id: Integer; const data: TByteArray): TItemDefinition; static;

Decodes an item: its name, its menu operations, the model and camera angles its inventory icon is rendered from, and the ids linking it to its noted and placeholder variants.

Every field is defaulted before decoding, because the cache only writes the ones that differ from the default. An unrecognised opcode means the stream is no longer aligned, so decoding stops there and says so rather than reading nonsense.

Example:

archive := CacheReader.Indices[ECacheIndex.CONFIGS].ReferenceTable.Archives.Value[EConfigArchive.ITEM];
def := TItemDefinition.Create(4151, archive.Files.Value[4151].Data);

ItemDefinition.LinkNote

procedure TItemDefinition.LinkNote(const template, unnoted: TItemDefinition);

Fills in a noted item from the two items it is made of. A noted item’s own definition holds little more than NotedTemplate and NotedID: its icon model and camera come from template, the note paper, while its name, members flag and value come from unnoted, the item it is a note of. Noted items always stack.

Example:

noted := TItemDefinition.Create(4152, archive.Files.Value[4152].Data);
noted.LinkNote(
  TItemDefinition.Create(noted.NotedTemplate, archive.Files.Value[noted.NotedTemplate].Data),
  TItemDefinition.Create(noted.NotedID, archive.Files.Value[noted.NotedID].Data)
);