Skip to main content

Module fac

Module fac 

Source
Expand description

Typed FAC (.fac) faction table and conversion helpers. FAC (.fac) typed generic wrapper.

A FAC resource is the whole session’s faction table: the roster of factions and how each one feels about every other. There is one per session, keyed on the resref REPUTE, not one per creature. Objects (.utc, .utd, …) carry only a faction id that indexes into this table.

§Field Layout

FAC root struct
+-- FactionList (List<Struct>)
|   +-- FactionName / FactionParentID / FactionGlobal
+-- RepList     (List<Struct>)
    +-- FactionID1 / FactionID2 / FactionRep

§The sparse matrix

Reputation is conceptually every faction’s standing toward every other, but it is stored sparsely: the default standing is 100, and only pairs that differ from it are written. On load the engine rebuilds the full matrix at that baseline and then applies the stored entries as overrides.

This is the one thing to get right. An absent pair means 100, which is friendly, not 0, which is hostile. Reading the list directly and treating misses as zero turns the entire galaxy against the player. Use Fac::reputation, which applies the baseline.

Structs§

Fac
Typed FAC model built from/to [Gff] data.
FacFaction
One faction from the FactionList.
FacReputation
One stored standing from the RepList.

Enums§

FacError
Errors produced while reading or writing typed FAC data.
FacReaction
How a standing reads at the script layer.

Constants§

DEFAULT_REPUTATION
Standing applied to any faction pair with no stored RepList entry.

Functions§

read_fac
Reads typed FAC data from a reader at the current stream position.
read_fac_from_bytes
Reads typed FAC data directly from bytes.
write_fac
Writes typed FAC data to an output writer.
write_fac_to_vec
Serializes typed FAC data into a byte vector.