/** * commandBuilder.ts — RPG Maker MV Event Command Builder * * CRITICAL MODULE: Provides the `cmd` object with functions that generate * valid RPG Maker MV event command objects {code, indent, parameters}. * * Each command corresponds to a specific event command code used by * RPG Maker MV's event system. These commands are stored in the * `list` array of each event page. * * Reference: https://rpgmaker.net/commands/RMMV/ */ import type { EventCommand, SelfSwitchKey } from '../types/rpgmaker.js'; /** * Show Text — code 101 (header) + code 401 (text lines) + code 0 (terminator) * Displays a message box with the given text. If faceName is provided, * shows the specified face graphic. * @param text - The message text (can contain \n for multiple lines) * @param faceName - Face graphic filename (empty string for no face) * @param faceIndex - Face index in the graphic (0-7) * @returns EventCommand[] */ declare function message(text: string, faceName: string, faceIndex: number): EventCommand[]; /** * Show Choices — code 102 * Presents a choice dialog to the player. Each choice branch is * handled by code 402 (BranchChoice) followed by code 404 (EndChoices). * @param options - Array of choice text strings * @param cancelType - Cancel behavior (0=disallowed, 1-6=branch index, -1=cancel branch) * @returns EventCommand[] */ declare function choice(options: string[], cancelType: number): EventCommand[]; /** * Branch Choice — code 402 * Marks the start of a choice branch. Must appear inside a Show Choices block. * @param index - The choice index this branch handles * @param label - The choice text label * @returns EventCommand[] */ declare function branchChoice(index: number, label: string): EventCommand[]; /** * End Choices — code 404 * Marks the end of a Show Choices block. * @returns EventCommand[] */ declare function endChoices(): EventCommand[]; /** * Conditional Branch: Switch — code 111, type 0 * Checks if a game switch is ON or OFF. Commands inside the branch * have indent+1. Follow with endConditional (code 412). * @param switchId - The switch ID to check * @param value - true = ON, false = OFF * @returns EventCommand[] */ declare function conditionalSwitch(switchId: number, value: boolean): EventCommand[]; /** * Conditional Branch: Self Switch — code 111, type 2 * Checks if a self switch (A/B/C/D) is ON or OFF. * @param key - Self switch key: "A", "B", "C", or "D" * @param value - true = ON, false = OFF * @returns EventCommand[] */ declare function conditionalSelfSwitch(key: SelfSwitchKey, value: boolean): EventCommand[]; /** * Conditional Branch: Variable — code 111, type 1 * Checks a game variable against a value using an operator. * @param varId - The variable ID to check * @param operator - Comparison: 0=eq, 1=ge, 2=le, 3=gt, 4=lt, 5=ne * @param val - The value to compare against * @returns EventCommand[] */ declare function conditionalVariable(varId: number, operator: number, val: number): EventCommand[]; /** * End Conditional — code 412 * Marks the end of a Conditional Branch block. * @returns EventCommand[] */ declare function endConditional(): EventCommand[]; /** * Control Switches — code 121 * Turns a game switch ON or OFF. * @param id - The switch ID to control * @param value - true = ON (0), false = OFF (1) * @returns EventCommand[] */ declare function switchControl(id: number, value: boolean): EventCommand[]; /** * Control Self Switch — code 123 * Turns a self switch (A/B/C/D) ON or OFF for the current event. * @param key - Self switch key: "A", "B", "C", or "D" * @param value - true = ON (0), false = OFF (1) * @returns EventCommand[] */ declare function selfSwitchControl(key: SelfSwitchKey, value: boolean): EventCommand[]; /** * Control Variables — code 122 * Performs an operation on a game variable. * @param id - The variable ID * @param opType - Operation: 0=set, 1=add, 2=sub, 3=mul, 4=div, 5=mod * @param val - The operand value (used with operand type 0 = constant) * @returns EventCommand[] */ declare function variableControl(id: number, opType: number, val: number): EventCommand[]; /** * Change Items — code 126 * Adds or removes an item from the party inventory. * @param itemId - The item ID * @param amount - Quantity (positive = add) * @returns EventCommand[] */ declare function giveItem(itemId: number, amount: number): EventCommand[]; /** * Change Weapons — code 127 * Adds or removes a weapon from the party inventory. * @param weaponId - The weapon ID * @param amount - Quantity to add * @returns EventCommand[] */ declare function giveWeapon(weaponId: number, amount: number): EventCommand[]; /** * Change Armors — code 128 * Adds or removes an armor from the party inventory. * @param armorId - The armor ID * @param amount - Quantity to add * @returns EventCommand[] */ declare function giveArmor(armorId: number, amount: number): EventCommand[]; /** * Change Gold — code 125 * Adds or subtracts gold from the party. * @param amount - Amount of gold (positive to add) * @returns EventCommand[] */ declare function giveMoney(amount: number): EventCommand[]; /** * Transfer Player — code 201 * Teleports the player to a new map position. * @param mapId - Destination map ID * @param x - Destination X coordinate * @param y - Destination Y coordinate * @param direction - Direction after transfer (0=retain, 2=down, 4=left, 6=right, 8=up) * @param fadeType - Fade type (0=black, 1=white, 2=none) * @returns EventCommand[] */ declare function teleport(mapId: number, x: number, y: number, direction: number, fadeType: number): EventCommand[]; /** * Show Animation — code 212 * Plays an animation on a character or event. * @param eventId - Event ID (0 = player, -1 = this event) * @param animId - Animation ID from the database * @returns EventCommand[] */ declare function showAnimation(eventId: number, animId: number): EventCommand[]; /** * Play BGM — code 241 * Plays a background music track. * @param name - BGM filename * @param volume - Volume (0-100) * @param pitch - Pitch (50-200) * @param pan - Pan (-100 to 100) * @returns EventCommand[] */ declare function playBGM(name: string, volume: number, pitch: number, pan: number): EventCommand[]; /** * Fadeout BGM — code 242 * Fades out the currently playing BGM over the specified duration. * @param duration - Fade duration in seconds * @returns EventCommand[] */ declare function fadeBGM(duration: number): EventCommand[]; /** * Wait — code 230 * Pauses event execution for the specified number of frames (60 frames = 1 second). * @param frames - Number of frames to wait * @returns EventCommand[] */ declare function wait(frames: number): EventCommand[]; /** * Label — code 118 * Marks a position in the event command list for use with Jump to Label. * @param name - Label name * @returns EventCommand[] */ declare function label(name: string): EventCommand[]; /** * Jump to Label — code 119 * Jumps execution to the specified label in the event command list. * @param name - Label name to jump to * @returns EventCommand[] */ declare function jumpToLabel(name: string): EventCommand[]; /** * Erase Event — code 214 * Erases the current event from the map until the map is reloaded. * Commonly used for one-time events that should disappear after triggering. * @returns EventCommand[] */ declare function eraseEvent(): EventCommand[]; /** * Game Over — code 353 * Triggers an immediate game over screen. * @returns EventCommand[] */ declare function gameOver(): EventCommand[]; /** * Show Picture — code 231 * Displays a picture on the screen at the specified position. * @param id - Picture ID (1-100) * @param name - Picture filename (from img/pictures/) * @param x - X position * @param y - Y position * @returns EventCommand[] */ declare function showPicture(id: number, name: string, x: number, y: number): EventCommand[]; /** * Plugin Command — code 356 * Executes a plugin command string. * @param command - The plugin command string * @returns EventCommand[] */ declare function pluginCommand(command: string): EventCommand[]; /** * Comment — code 108 * Adds a comment line to the event command list. * @param text - Comment text * @returns EventCommand[] */ declare function comment(text: string): EventCommand[]; /** * End of Event Processing — code 0 * Terminates event command processing. Every event page's list * must end with this command. * @returns EventCommand[] */ declare function end(): EventCommand[]; /** * Play SE — code 250 * Plays a sound effect. * @param name - SE filename * @param volume - Volume (0-100) * @param pitch - Pitch (50-200) * @param pan - Pan (-100 to 100) * @returns EventCommand[] */ declare function playSE(name: string, volume: number, pitch: number, pan: number): EventCommand[]; /** * Change Party Member — code 129 * Adds or removes an actor from the party. * @param actorId - The actor ID * @param add - true = add to party, false = remove from party * @returns EventCommand[] */ declare function changePartyMember(actorId: number, add: boolean): EventCommand[]; /** * Change HP — code 311 * Modifies an actor's HP by a fixed value or percentage. * @param actorId - The actor ID (0 for entire party) * @param value - The amount to change * @param isAdd - true = add (0), false = subtract (1) * @returns EventCommand[] */ declare function changeHP(actorId: number, value: number, isAdd: boolean): EventCommand[]; /** * Change MP — code 312 * Modifies an actor's MP by a fixed value or percentage. * @param actorId - The actor ID (0 for entire party) * @param value - The amount to change * @param isAdd - true = add (0), false = subtract (1) * @returns EventCommand[] */ declare function changeMP(actorId: number, value: number, isAdd: boolean): EventCommand[]; /** * Change EXP — code 315 * Modifies an actor's experience points. * @param actorId - The actor ID (0 for entire party) * @param value - The amount to change * @param isAdd - true = add (0), false = subtract (1) * @returns EventCommand[] */ declare function changeEXP(actorId: number, value: number, isAdd: boolean): EventCommand[]; /** * Change Level — code 316. (Code 317 is Change Parameter — using it here, as a * previous version did, would change a random stat instead of the level.) * @param actorId - The actor ID (0 for entire party) * @param value - The amount to change * @param isAdd - true = add (0), false = subtract (1) * @returns EventCommand[] */ declare function changeLevel(actorId: number, value: number, isAdd: boolean): EventCommand[]; /** * Change Skill — code 318 * Teaches or forgets a skill for an actor. * @param actorId - The actor ID (0 for entire party) * @param skillId - The skill ID * @param learn - true = learn (0), false = forget (1) * @returns EventCommand[] */ declare function changeSkill(actorId: number, skillId: number, learn: boolean): EventCommand[]; /** * Change State — code 313 * Adds or removes a state from an actor. * @param actorId - The actor ID (0 for entire party) * @param stateId - The state ID * @param add - true = add (0), false = remove (1) * @returns EventCommand[] */ declare function changeState(actorId: number, stateId: number, add: boolean): EventCommand[]; /** * Change Equip — code 319 * Changes an actor's equipped item. * @param actorId - The actor ID * @param slotType - The equipment slot type * @param itemId - The item ID to equip (0 = unequip) * @returns EventCommand[] */ declare function changeEquip(actorId: number, slotType: number, itemId: number): EventCommand[]; /** * Scroll Map — code 204 * Scrolls the map camera in the specified direction. * @param direction - Direction to scroll (2=down, 4=left, 6=right, 8=up) * @param distance - Distance in tiles * @param speed - Scroll speed (default 4) * @returns EventCommand[] */ declare function scrollMap(direction: number, distance: number, speed: number): EventCommand[]; /** * Battle Processing — code 301 * Initiates a battle with a specific troop. * @param troopId - The troop ID to battle * @param canEscape - Whether escape is allowed * @param canLose - Whether losing continues the game * @returns EventCommand[] */ declare function battleProcessing(troopId: number, canEscape: boolean, canLose: boolean): EventCommand[]; /** * Shop Processing — code 302 * Opens a shop with the specified goods. * @param goods - Array of goods [itemType, itemId, priceFlag, price] * @param purchaseOnly - true = purchase only, false = buy and sell * @returns EventCommand[] */ declare function shopProcessing(goods: [number, number, number, number][], purchaseOnly: boolean): EventCommand[]; /** * Name Input — code 303 * Opens the name input screen for an actor. * @param actorId - The actor ID * @param maxLength - Maximum character length * @returns EventCommand[] */ declare function nameInput(actorId: number, maxLength: number): EventCommand[]; /** * Change Map Display Name — code 323 * Changes the map name displayed on the save/load screen. * @param displayName - The new display name * @returns EventCommand[] */ declare function changeMapDisplayName(displayName: string): EventCommand[]; /** * Set Move Route — code 205 * Assigns a movement route to an event or the player. * @param eventId - Event ID (-1 = player, 0 = this event, >0 = specific event) * @param routeCommands - Array of move route commands * @returns EventCommand[] */ declare function setMoveRoute(eventId: number, routeCommands: EventCommand[]): EventCommand[]; /** * Move Route Command — helper for building individual move route commands. * @param code - The move route command code * @param parameters - The command parameters * @returns EventCommand */ declare function moveRouteCommand(code: number, parameters: unknown[]): EventCommand; /** * Recover All — code 314 * Fully recovers an actor's HP, MP, and removes all states. * @param actorId - The actor ID (0 for entire party) * @returns EventCommand[] */ declare function recoverAll(actorId: number): EventCommand[]; /** * Change Actor Name — code 320 * Changes an actor's display name. * @param actorId - The actor ID * @param name - The new name * @returns EventCommand[] */ declare function changeActorName(actorId: number, name: string): EventCommand[]; /** * Change Actor Class — code 321 * Changes an actor's class. * @param actorId - The actor ID * @param classId - The new class ID * @returns EventCommand[] */ declare function changeActorClass(actorId: number, classId: number): EventCommand[]; /** * Play BGS — code 245 * Plays a background sound. * @param name - BGS filename * @param volume - Volume (0-100) * @param pitch - Pitch (50-200) * @param pan - Pan (-100 to 100) * @returns EventCommand[] */ declare function playBGS(name: string, volume: number, pitch: number, pan: number): EventCommand[]; /** * Fadeout BGS — code 246 * Fades out the currently playing BGS over the specified duration. * @param duration - Fade duration in seconds * @returns EventCommand[] */ declare function fadeoutBGS(duration: number): EventCommand[]; /** * Play ME — code 249 * Plays a music effect (ME). * @param name - ME filename * @param volume - Volume (0-100) * @param pitch - Pitch (50-200) * @param pan - Pan (-100 to 100) * @returns EventCommand[] */ declare function playME(name: string, volume: number, pitch: number, pan: number): EventCommand[]; /** * Get Actor Info — code 108 (comment placeholder) * Provides actor information via a script call placeholder. * @param actorId - The actor ID * @returns EventCommand[] */ declare const cmd: { message: typeof message; choice: typeof choice; branchChoice: typeof branchChoice; endChoices: typeof endChoices; conditionalSwitch: typeof conditionalSwitch; conditionalSelfSwitch: typeof conditionalSelfSwitch; conditionalVariable: typeof conditionalVariable; endConditional: typeof endConditional; switchControl: typeof switchControl; selfSwitchControl: typeof selfSwitchControl; variableControl: typeof variableControl; giveItem: typeof giveItem; giveWeapon: typeof giveWeapon; giveArmor: typeof giveArmor; giveMoney: typeof giveMoney; teleport: typeof teleport; showAnimation: typeof showAnimation; playBGM: typeof playBGM; fadeBGM: typeof fadeBGM; playSE: typeof playSE; playBGS: typeof playBGS; fadeoutBGS: typeof fadeoutBGS; playME: typeof playME; wait: typeof wait; label: typeof label; jumpToLabel: typeof jumpToLabel; eraseEvent: typeof eraseEvent; gameOver: typeof gameOver; showPicture: typeof showPicture; pluginCommand: typeof pluginCommand; comment: typeof comment; changePartyMember: typeof changePartyMember; changeHP: typeof changeHP; changeMP: typeof changeMP; changeEXP: typeof changeEXP; changeLevel: typeof changeLevel; changeSkill: typeof changeSkill; changeState: typeof changeState; changeEquip: typeof changeEquip; scrollMap: typeof scrollMap; battleProcessing: typeof battleProcessing; shopProcessing: typeof shopProcessing; nameInput: typeof nameInput; changeMapDisplayName: typeof changeMapDisplayName; setMoveRoute: typeof setMoveRoute; moveRouteCommand: typeof moveRouteCommand; recoverAll: typeof recoverAll; changeActorName: typeof changeActorName; changeActorClass: typeof changeActorClass; end: typeof end; }; export { cmd };