types-decl
Branded types for type safety
ObjectPtr
Section titled “ObjectPtr”type ObjectPtr<T extends string = string> = number & { __type: T }Object pointer - an integer handle to a game object
CritterPtr
Section titled “CritterPtr”type CritterPtr = ObjectPtr<'critter'>Critter object (NPCs, player, creatures)
ItemPtr
Section titled “ItemPtr”type ItemPtr = ObjectPtr<'item' | 'container'>Item object (weapons, armor, ammo, misc items, containers)
ContainerPtr
Section titled “ContainerPtr”type ContainerPtr = ObjectPtr<'container'>Container object (lockers, chests, bags) - subtype of Item
SceneryPtr
Section titled “SceneryPtr”type SceneryPtr = ObjectPtr<'scenery' | 'door'>Scenery object (includes doors)
DoorPtr
Section titled “DoorPtr”type DoorPtr = ObjectPtr<'door'>Door object - subtype of Scenery
ArrayID
Section titled “ArrayID”type ArrayID = number & { __brand: 'ArrayID' }Array ID - an integer handle to a sfall array
HookID
Section titled “HookID”type HookID = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 61Hook ID - valid sfall hook identifiers (0-48, 61)
IfaceTag
Section titled “IfaceTag”type IfaceTag = number & { __brand: 'IfaceTag' }Interface tag ID for show_iface_tag, hide_iface_tag, is_iface_tag_active
GameMode
Section titled “GameMode”type GameMode = number & { __brand: 'GameMode' }Game mode bitmask returned by get_game_mode()
ObjType
Section titled “ObjType”type ObjType = 0 | 1 | 2 | 3 | 4 | 5 | 6Object type returned by obj_type()
WeaponType
Section titled “WeaponType”type WeaponType = 0 | 1 | 2 | 3 | 4Weapon type classification
InvenSlot
Section titled “InvenSlot”type InvenSlot = -2 | 0 | 1 | 2Inventory slot for critter_inven_obj
DamageType
Section titled “DamageType”type DamageType = 0 | 1 | 2 | 3 | 4 | 5 | 6Damage type (0-6), can be combined with DMG_BYPASS_ARMOR/DMG_NOANIMATE flags
FloatMsgColor
Section titled “FloatMsgColor”type FloatMsgColor = -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12Float message color for float_msg
PerkID
Section titled “PerkID”type PerkID = number & { __brand: 'PerkID' }Perk ID for has_perk, set_perk, etc.
TraitID
Section titled “TraitID”type TraitID = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15Character trait ID (0-15)
TraitType
Section titled “TraitType”type TraitType = 0 | 1 | 2Trait type for has_trait function (TRAIT_PERK=0, TRAIT_OBJECT=1, TRAIT_TRAIT=2)
PcStatID
Section titled “PcStatID”type PcStatID = 0 | 1 | 2 | 3 | 4 | 5PC-only stat ID for get_pc_stat (0-5)
RollResult
Section titled “RollResult”type RollResult = 0 | 1 | 2 | 3Roll/skill check result
AttackType
Section titled “AttackType”type AttackType = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19Attack type for combat hooks (0-19)
AttackMode
Section titled “AttackMode”type AttackMode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8Attack mode for weapons (0-8)
Gender
Section titled “Gender”type Gender = 0 | 1Gender (0=male, 1=female)
type Hand = 0 | 1Active hand (0=left, 1=right)
Difficulty
Section titled “Difficulty”type Difficulty = 0 | 1 | 2Difficulty level (0=easy, 1=normal, 2=hard)
Elevation
Section titled “Elevation”type Elevation = 0 | 1 | 2Elevation level (0-2)
Direction
Section titled “Direction”type Direction = 0 | 1 | 2 | 3 | 4 | 5Direction on hex grid (0-5, clockwise from NE)
CritterState
Section titled “CritterState”type CritterState = number & { __brand: 'CritterState' }Critter state bitmask from critter_state()
HitResult
Section titled “HitResult”type HitResult = 0 | 1 | 2 | 3Hit result from HOOK_AFTERHITROLL (0=critical miss, 1=miss, 2=hit, 3=critical hit)
SfallList
Section titled “SfallList”type SfallList<T> = { [index: number]: T; readonly __brand: 'SfallList';} & Iterable<T>Sfall list array - numeric index, iterable over values
SfallMap
Section titled “SfallMap”type SfallMap<K, V> = { [key: string]: V; [key: number]: V; readonly __brand: 'SfallMap';} & Iterable<[K, V]>Sfall map array - key/value pairs, iterable as [key, value] tuples
Functions
Section titled “Functions”function list<T>(items: T[]): SfallList<T>
Create a typed list from items. Transpiles to array literal [a, b, c].
function map<K extends string | number, V>(obj: Record<K, V>): SfallMap<K, V>
Create a typed map from object literal. Transpiles to map literal {a: 1}.