UNPKG

anomaly-packer

Version:

Anomaly Packer is a tool that helps in making of an addon for STALKER Anomaly with type-safe code using TypeScript

384 lines (370 loc) 14.2 kB
type PackOptions = { build?: { outDirName?: string; }; /** * TypeScript scripts under /gamedata/scripts directory will be transpiled but not included in the build by default. This is due to [typescript-to-lua](https://www.npmjs.com/package/typescript-to-lua) package transpiling the entirety of project and creating a Lua script for every TypeScript module it is able to find. Because this is totally unnecessary, an array of so-called "registered" or "desired" scripts must be provided for scripts to be recognised and appear in the build. Transforming the name of the output script is optional. * * @example * * With the below configuration the *main.ts* file will be searched for under gamedata/scripts directory * * ```ts * [{ sourceFileName: 'main.ts', bildFileName: addonId + '_main' }] * ``` */ scripts?: { sourceFileName: string; buildFileName?: string; }[]; /** * Path to the original Anomaly gamedata directory. This path is the base for the relative paths that are used in certain functions of Anomaly Packer. * * @example * * 'C:/Games/Anomaly 1.5.2/gamedata' */ sourceGamedata?: string; /** * ## ⚠ Use with care! If misused, this function can damage personal and valueable data! * * Additional paths to gamedata directory that will get refreshed with the gamedata of the fresh build. Useful when this the addon was installed via Mod Organizer 2 once and simply requires to get its files refreshed as the development continues. * * @example * ```ts * [`C:/Users/Jack Daniels/AppData/Local/ModOrganizer/STALKER Anomaly/mods/${addonId}_build/gamedata`] * ``` */ refresh?: string[]; }; declare function pack(options: PackOptions): Promise<void>; type SpecificCharacter = { /** @example 'cit_killers_merc_trader_stalker' */ id: string; team_default: boolean; /** @example 'cit_killers_merc_trader_stalker_name' */ name: string; /** @example 'ui_inGame2_merc_trade' */ icon: string; map_icon: { x: number; y: number; }; /** @example 'stalker_terrain' */ terrain_sect?: string; /** * @deprecated unused * @example 'esc_wolf_bio' */ bio?: string; /** Name of the team of the syncronized zoneguards. Not tested */ team?: string; /** @example 'cit_killers_merc_trader_stalker' */ class: string; community: Faction | 'trader'; /** @example 'characters_voice\\human\\killer_3\\' */ snd_config: string; /** @example 15000 */ rank: number; money: { min: number; max: number; infinitive: boolean; }; /** @example -1000 */ reputation: number; /** @example 'actors\\stalker_merc\\stalker_ki_head_2' */ visual: string; /** Character's inventory */ supplies?: { spawn?: Record<string, string | number | boolean>; /** Paths to other XML files */ include?: string[]; }; dialogs: string[]; crouch_type?: number; /** @example 0 - panic is disabled */ panic_treshold?: number; mechanic_mode?: 1 | 0; /** * Paths to other XML files * * @example ['gameplay\\character_criticals.xml', 'gameplay\\character_dialogs.xml'] */ include?: string[]; }; /** @deprecated NOT IMPLEMENTED */ declare function specificCharacter(character: SpecificCharacter): string; type DialogPhraseShared = { /** * Ids of functions returning a boolean. If `true`, this dialog or phrase will be available * @example * ```ts * ['dialogs_jupiter.ecolog_companion_task_2_not_complete'] * ``` * Function is declared in *gamedata/scripts/dialogs_jupiter.script* * ```lua * function ecolog_companion_task_2_not_complete(speaker_1, speaker_2) * return not ecolog_companion_task_2_complete(speaker_1, speaker_2) * end * ``` */ precondition?: string | string[]; /** Only enable the dialog or the phrase if the actor does not have these info portions */ dont_has_info?: string | string[]; /** Only enable the dialog or the phrase if the actor has these info portions */ has_info?: string | string[]; /** Disable info portions for the actor after this dialog has started or this phrase has been produced */ disable_info?: string | string[]; /** * Info portions ids to give to the actor after this dialog has started or this phrase has been produced * @example ['bar_arena_fight_5', 'bar_arena_fight'] */ give_info?: string | string[]; /** * Lua functions that will be fired upon entering the dialog or producing a phrase * @example 'dialog_manager.action_disable_phrase' */ action?: string | string[]; }; type Phrase<PhraseId extends number = number> = DialogPhraseShared & { /** An arbitraty ID to which other phrases within this dialog tree will refer to in `next` */ id: PhraseId; /** * ID of the translation string that will be used as text for this phrase. If the translation was not found for a specific language, the fallback text will apear instead. Cannot be used with `script_text` * @example 'bar_arena_manager_start_21' */ text?: string; /** * ID of a scripted text. Cannot be used with `text` * @example 'dialogs_mlr.buy_extra_med_4' */ script_text?: string; /** * Array of phrases' ids of this dialog that will appear after this phrase. Not inluding this field at all will result into the initial dialog to appear after this phrase * @example * ```ts * // phrase 1 * { next: [1112] } * // phrase 2 * { id: 1112 }, * ``` */ next?: NoInfer<PhraseId> | NoInfer<PhraseId>[]; /** * True purpose is unknown. Commonly used in combination with `dialogs.break_dialog` action * @example a phrase from the game files * ```xml * <action>dialogs.break_dialog</action> * <is_final>1</is_final> * ``` */ is_final?: 0 | 1; }; type Dialog<PhraseId extends number = number> = DialogPhraseShared & { id: string; /** * ID of a scripted dialog. Cannot be used with `phrases` * @example 'dialog_manager.dm_agr_u_bandit_boss_ask' */ init_func?: string; phrases?: Phrase<PhraseId>[]; }; declare function dialog<PhraseId extends number>(dialog: Dialog<PhraseId>): string; type LtxValue = string | number | boolean | null | undefined | readonly (string | number | boolean | null | undefined)[]; type Ltx$1<L> = { section: string; with?: string[]; entries?: Partial<L>; }; /** * @param ltx * @param sort sort entries alphabetically (`true` by default) * @param align aligns table vertically, resuling in "=" signs appear under each other (`true` by default) * @returns ltx table as string */ declare function ltx<L extends Partial<Record<keyof L, LtxValue>>>(ltx: Ltx$1<L>, sort?: boolean, align?: boolean): string; declare namespace ltx { var f: <N extends keyof typeof xr_conditions | keyof typeof xr_effects>(name: N, ...args: SkipFirstSecond<Parameters<(typeof xr_conditions & typeof xr_effects)[N]>>) => string; } type SkipFirstSecond<Arr> = Arr extends [infer _1, infer _2, ...infer Rest] ? Rest : never; type DltxEntries<O extends object> = Partial<{ [K in keyof O]: (O[K] extends infer U ? U extends any[] ? { [_ in K | `${'<' | '>'}${K & string}`]: any; } : {} : {}) & { [_ in K | `!${K & string}`]: undefined; } & { [_ in K]: any; }; }[keyof O]>; /** Delete a section with the use of `!!` prefix */ declare function deleteSection({ sectionName }: { sectionName: string; }): string; type OverrideLtx<L extends Record<keyof L, LtxValue>> = { sectionName: string; _with?: string[]; entries?: DltxEntries<L>; }; /** * Override a section with the use of `!` prefix. * - add or override an entry - no prefix, * - delete an entry with `!`, * - add to array with `>`, * - delete from array with `<`, */ declare function override<L extends Partial<Record<keyof L, LtxValue>>>(ltx: OverrideLtx<L>, sort?: boolean, align?: boolean): string; /** Create a section if it does not exist or override if it does with the use of `@` prefix */ declare function createOrOverride<L extends Partial<Record<keyof L, LtxValue>>>(ltx: OverrideLtx<L>, sort?: boolean, align?: boolean): string; declare const dltx: { createOrOverride: typeof createOrOverride; override: typeof override; deleteSection: typeof deleteSection; }; declare function include(path: string): string; type Task = { /** Title in the PDA */ title: string; /** First objective in the list is considered main */ objective: { text: string; icon: string; infoportion_set_complete?: string; infoportion_complete?: string; infoportion_fail?: string; function_complete?: string; function_fail?: string; article?: string; }[]; }; type Location = { level: number; x: number; y: number; icon: { name: string; x: number; y: number; width: number; height: number; }; text: string; }; type InfoPortions<Id extends string = string> = Record<Id, { action?: string | string[]; article?: string | string[]; dialog?: string | string[]; actor_dialog?: string | string[]; disable?: string | string[]; location?: Location | Location[]; task?: Task | Task[]; } | null>; declare function infoPortions<Id extends string>(portions: InfoPortions<Id>): string; declare function translations<Id extends string>(translation: Partial<Record<Id, string>>, idOverride?: (id: string) => string): string; declare function jsxToXml(tree: JSX.Element): string; declare const ui: { jsxToXml: typeof jsxToXml; }; /** * Extension of the generated text file * * @default 'xml' */ type FileExtension = 'xml' | 'ltx'; type texts_Dialog<PhraseId extends number = number> = Dialog<PhraseId>; type texts_FileExtension = FileExtension; type texts_LtxValue = LtxValue; type texts_SpecificCharacter = SpecificCharacter; declare const texts_dialog: typeof dialog; declare const texts_dltx: typeof dltx; declare const texts_include: typeof include; declare const texts_infoPortions: typeof infoPortions; declare const texts_ltx: typeof ltx; declare const texts_specificCharacter: typeof specificCharacter; declare const texts_translations: typeof translations; declare const texts_ui: typeof ui; declare namespace texts { export { type texts_Dialog as Dialog, type texts_FileExtension as FileExtension, type texts_LtxValue as LtxValue, type texts_SpecificCharacter as SpecificCharacter, texts_dialog as dialog, texts_dltx as dltx, texts_include as include, texts_infoPortions as infoPortions, texts_ltx as ltx, texts_specificCharacter as specificCharacter, texts_translations as translations, texts_ui as ui }; } type Texts = typeof texts; /** * - `%=func%` return the function's returned value * - `{=func}` check the function's returned value * - `{-info}` check actor does not have info portion * - `{+info}` check actor has info portion */ type CondList = string; type ItemActionIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10; type ItemActionMode = 'inventory' | 'loot' | 'trade' | 'repair'; type ItemActionContainer = 'actor_bag' | 'actor_equ' | 'actor_belt' | 'actor_trade' | 'actor_trade_bag' | 'npc_bag' | 'npc_trade' | 'npc_trade_bag'; declare namespace Ltx { /** Interactivity with an item via interface */ interface GlobalItemActions extends Partial<Record<`use${ItemActionIndex}_${'functor' | 'action_functor'}`, string> & Record<`use${ItemActionIndex}_modes`, ItemActionMode | ItemActionMode[]> & Record<`use${ItemActionIndex}_containers`, ItemActionContainer | ItemActionContainer[]>> { } interface IdentityImmunities extends GlobalItemActions, Partial<{ immunities_sect: string; slot: number; description: string; default_to_ruck: boolean; sprint_allowed: boolean; control_inertion_factor: number; zoom_rotate_time: number; can_trade: boolean; quest_item: boolean; condition_bar: string; snd_on_take: string; }> { } interface DefaultWeaponParams extends IdentityImmunities, Partial<{ use_aim_bullet: boolean; use_first_bullet: boolean; k_hit_critical: number; frag_hit_critical: number; hit_power: number; hit_power_critical: number; silencer_hit_power: number; hit_impulse: number; silencer_hit_impulse: number; kind: string; can_be_lowered: string; weapon_lower_speed: boolean; }> { } interface Trader extends Partial<{ buy_condition: Suggest<'trade_generic_buy'>; buy_item_condition_factor: number; buy_item_exponent: number; buy_supplies: CondList; sell_item_exponent: number; sell_condition: Suggest<'trade_generic_sell'>; price_profile: Suggest<'default'>; discounts: string; }> { } interface Task extends Partial<{ icon: string; prior: number; sim_communities: Faction | Faction[]; storyline: boolean; title: string; title_functor: CondList; descr: string; job_descr: string; fetch_descr: string; descr_functor: string; target_functor: string; task_complete_descr: string; fetch_func: CondList; status_functor: string; status_functor_params: string[]; precondition: CondList; repeat_timeout: number; stage_complete: number; on_job_descr: string; on_init: CondList; on_complete: CondList; on_fail: CondList; } & Record<`condlist_${number}`, CondList>> { } } export { type Dialog, type FileExtension, Ltx, type LtxValue, type PackOptions, type SpecificCharacter, type Texts, dialog, dltx, include, infoPortions, ltx, pack, specificCharacter, translations, ui };