TypeScript type definitions for Infinity Engine scripting, for use in TBAF and TD.
Provides branded types, object specifiers, IDS constants, and typed action/trigger function declarations for IDE autocompletion and type checking.
pnpm install @bgforge/iets
A .tbaf source file using IETS types. Top-level if blocks are transpiled to IF / THEN / END BAF blocks; all imports resolve to typed declarations and emit nothing at runtime.
import { LOCALS } from "@bgforge/iets";
import {
FaceObject, Global, LastSeenBy, LevelLT, Myself, NearestEnemyOf, Player1,
ReallyForceSpell, ReallyForceSpellRES, See, SetGlobal, SmallWait, StartDialog,
WIZARD_ARMOR, WIZARD_SHIELD,
} from "@bgforge/iets/bg2";
const LVAR_doomed = "doomed";
const LVAR_castSpellTrigger = "castSpellTrigger";
// First talk, then fight
if (See(Player1) && Global(LVAR_doomed, LOCALS, 0)) {
SetGlobal(LVAR_doomed, LOCALS, 1);
FaceObject(Player1);
SmallWait(8);
StartDialog("WM_RHIA", Player1);
}
/* Result:
IF
See(Player1)
Global("doomed", "LOCALS", 0)
THEN
RESPONSE #100
SetGlobal("doomed", "LOCALS", 1)
FaceObject(Player1)
SmallWait(8)
StartDialog("WM_RHIA", Player1)
END
*/
// Spell trigger emulation, branching on observed enemy level
if (See(NearestEnemyOf(Myself)) && Global(LVAR_castSpellTrigger, LOCALS, 0)) {
if (LevelLT(LastSeenBy(Myself), 3)) {
ReallyForceSpell(Myself, WIZARD_ARMOR);
ReallyForceSpell(Myself, WIZARD_SHIELD);
}
if (LevelLT(LastSeenBy(Myself), 8)) {
ReallyForceSpellRES("WM_LIGHT", Myself);
ReallyForceSpell(Myself, WIZARD_SHIELD);
}
}
/* Result:
IF
See(NearestEnemyOf(Myself))
Global("castSpellTrigger", "LOCALS", 0)
LevelLT(LastSeenBy(Myself), 3)
THEN
RESPONSE #100
ReallyForceSpell(Myself, WIZARD_ARMOR)
ReallyForceSpell(Myself, WIZARD_SHIELD)
END
IF
See(NearestEnemyOf(Myself))
Global("castSpellTrigger", "LOCALS", 0)
LevelLT(LastSeenBy(Myself), 8)
THEN
RESPONSE #100
ReallyForceSpellRES("WM_LIGHT", Myself)
ReallyForceSpell(Myself, WIZARD_SHIELD)
END
*/
See Getting Started, Type system, and Examples for more.