import type { GameEvents } from "../game/events.js"; import type { Drop } from "../game/lootTable.js"; import type { ScatterOptions } from "../game/worldItem.js"; import type { DeathReason } from "./deathReason.js"; import type { EffectVia } from "./effects.js"; export type DeathReasonKind = DeathReason["kind"]; export interface OnDeathDropRule { table: string; /** `"any"` explicitly permits world item drops without a player killer. */ when?: { reason: DeathReasonKind | "any"; }; } export interface OnDeathCommandRule { name: string; args?: unknown; when?: { reason: DeathReasonKind; }; } export type DropMode = "grant" | "world"; /** * Catalog `onDeath` for an entity: loot tables to roll, `dropMode: "world"` to scatter drops on the ground * (rendered with loot beams) instead of granting them into the killer's bag, and commands to run. Fires only * when the entity dies through `ctx.scene.entity.effect`, not a raw `stats.delta`. * * @capability on-death-drops make a killed enemy drop loot on the ground or into the killer's bag via catalog onDeath */ export interface OnDeathSpec { drops?: string | OnDeathDropRule[]; command?: string | OnDeathCommandRule; /** "grant" (default) puts drops straight into the killer's inventory; "world" scatters them as ground `worldItem`s instead (#32). */ dropMode?: DropMode; /** Scatter-offset tuning when `dropMode` is `"world"`; defaults to `DEFAULT_SCATTER` from `game/worldItem`. */ scatter?: ScatterOptions; } export interface NormalizedOnDeath { drops: OnDeathDropRule[]; command: OnDeathCommandRule | null; dropMode: DropMode; scatter?: ScatterOptions; } export declare function normalizeOnDeath(spec: OnDeathSpec | null | undefined): NormalizedOnDeath; export interface DeathIdentity { catalogId: string; userId?: string; displayName?: string; position: [number, number, number]; } export interface DeathSystemDeps { resolveOnDeath(instanceId: string, reason?: DeathReason): OnDeathSpec | null | undefined; resolveIdentity(instanceId: string): DeathIdentity | null; loot: { roll(tableId: string): Drop[]; }; events: GameEvents; runCommand?(name: string, args: unknown, reason?: DeathReason): void; despawn(instanceId: string): void; } export type DeathResolution = { status: "resolved"; drops: Drop[]; ranCommand: string | null; } | { status: "rejected"; reason: string; }; export interface DeathSystem { resolveDeath(instanceId: string, reason: DeathReason): DeathResolution; revive(instanceId: string): boolean; } /** * Resolve entity death and the on-death consequences — drops, respawn eligibility, kill credit. * * @capability death-system resolve entity death and its on-death consequences */ export declare function createDeathSystem(deps: DeathSystemDeps): DeathSystem; export interface EffectDeathContext { from: string; via?: EffectVia; userIdOf?(instanceId: string): string | undefined; } export declare function deathReasonFromEffect(ctx: EffectDeathContext): DeathReason;