isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
253 lines • 12.7 kB
TypeScript
import { LevelStage, RoomType, StageID, StageType } from "isaac-typescript-definitions";
/**
* Helper function that calculates what the stage type should be for the provided stage. This
* emulates what the game's internal code does.
*/
export declare function calculateStageType(stage: LevelStage): StageType;
/**
* Helper function that calculates what the Repentance stage type should be for the provided stage.
* This emulates what the game's internal code does.
*/
export declare function calculateStageTypeRepentance(stage: LevelStage): StageType;
/**
* Helper function to account for Repentance floors being offset by 1. For example, Downpour 2 is
* the third level of the run, but the game considers it to have a stage of 2. This function will
* consider Downpour 2 to have a stage of 3.
*/
export declare function getEffectiveStage(): LevelStage;
/**
* Helper function to get the corresponding "goto" console command that would correspond to the
* provided room type and room variant.
*
* @param roomType The `RoomType` of the destination room.
* @param roomVariant The variant of the destination room.
* @param useSpecialRoomsForRoomTypeDefault Optional. Whether to use `s.default` as the prefix for
* the `goto` command (instead of `d`) if the room type is
* `RoomType.DEFAULT` (1). False by default.
*/
export declare function getGotoCommand(roomType: RoomType, roomVariant: int, useSpecialRoomsForRoomTypeDefault?: boolean): string;
/**
* Helper function to get the English name of the level. For example, "Caves 1".
*
* This is useful because the `Level.GetName` method returns a localized version of the level name,
* which will not display correctly on some fonts.
*
* Note that this returns "Blue Womb" instead of "???" for stage 9.
*
* @param stage Optional. If not specified, the current stage will be used.
* @param stageType Optional. If not specified, the current stage type will be used.
*/
export declare function getLevelName(stage?: LevelStage, stageType?: StageType): string;
/** Alias for the `Level.GetStage` method. */
export declare function getStage(): LevelStage;
/**
* Helper function to get the stage ID that corresponds to a particular stage and stage type.
*
* This is useful because `getRoomStageID` will not correctly return the `StageID` if the player is
* in a special room.
*
* This correctly handles the case of Greed Mode. In Greed Mode, if an undefined stage and stage
* type combination are passed, `StageID.SPECIAL_ROOMS` (0) will be returned.
*
* @param stage Optional. If not specified, the stage corresponding to the current floor will be
* used.
* @param stageType Optional. If not specified, the stage type corresponding to the current floor
* will be used.
*/
export declare function getStageID(stage?: LevelStage, stageType?: StageType): StageID;
/**
* Helper function to get the English name corresponding to a stage ID. For example, "Caves".
*
* This is derived from the data in the "stages.xml" file.
*
* Note that unlike "stages.xml", Blue Womb is specified with a name of "Blue Womb" instead of
* "???".
*/
export declare function getStageIDName(stageID: StageID): string;
/** Alias for the `Level.GetStageType` method. */
export declare function getStageType(): StageType;
/**
* Helper function to convert a numerical `StageType` into the letter suffix supplied to the "stage"
* console command. For example, `StageType.REPENTANCE` is the stage type for Downpour, and the
* console command to go to Downpour is "stage 1c", so this function converts `StageType.REPENTANCE`
* to "c".
*/
export declare function getStageTypeSuffix(stageType: StageType): string;
/**
* Returns whether the provided stage and stage type represent a "final floor". This is defined as a
* floor that prevents the player from entering the I AM ERROR room on.
*
* For example, when using Undefined on The Chest, it has a 50% chance of teleporting the player to
* the Secret Room and a 50% chance of teleporting the player to the Super Secret Room, because the
* I AM ERROR room is never entered into the list of possibilities.
*/
export declare function isFinalFloor(stage: LevelStage, stageType: StageType): boolean;
/**
* Helper function to check if the provided stage type is equal to `StageType.REPENTANCE` or
* `StageType.REPENTANCE_B`.
*/
export declare function isRepentanceStage(stageType: StageType): boolean;
/**
* Helper function to check if the provided effective stage is one that has the possibility to grant
* a natural Devil Room or Angel Room after killing the boss.
*
* Note that in order for this function to work properly, you must provide it with the effective
* stage (e.g. from the `getEffectiveStage` helper function) and not the absolute stage (e.g. from
* the `Level.GetStage` method).
*/
export declare function isStageWithNaturalDevilRoom(effectiveStage: LevelStage): boolean;
/**
* Helper function to check if the provided stage is one that will have a random collectible drop
* upon defeating the boss of the floor.
*
* This happens on most stages but will not happen on Depths 2, Womb 2, Sheol, Cathedral, Dark Room,
* The Chest, and Home (due to the presence of a story boss).
*
* Note that even though Delirium does not drop a random boss collectible, The Void is still
* considered to be a stage that has a random boss collectible since all of the non-Delirium Boss
* Rooms will drop random boss collectibles.
*/
export declare function isStageWithRandomBossCollectible(stage: LevelStage): boolean;
/**
* Helper function to check if the provided stage will spawn a locked door to Downpour/Dross after
* defeating the boss.
*/
export declare function isStageWithSecretExitToDownpour(stage: LevelStage): boolean;
/**
* Helper function to check if the provided stage and stage type will spawn a spiked door to
* Mausoleum/Gehenna after defeating the boss.
*/
export declare function isStageWithSecretExitToMausoleum(stage: LevelStage, stageType: StageType): boolean;
/**
* Helper function to check if the provided stage and stage type will spawn a wooden door to
* Mines/Ashpit after defeating the boss.
*/
export declare function isStageWithSecretExitToMines(stage: LevelStage, stageType: StageType): boolean;
/**
* Helper function to check if the current stage is one that would create a trapdoor if We Need to
* Go Deeper was used.
*/
export declare function isStageWithShovelTrapdoors(stage: LevelStage, stageType: StageType): boolean;
/**
* Helper function to check if the provided stage is one with a story boss. Specifically, this is
* Depths 2 (Mom), Womb 2 (Mom's Heart / It Lives), Blue Womb (Hush), Sheol (Satan), Cathedral
* (Isaac), Dark Room (Lamb), The Chest (Blue Baby), The Void (Delirium), and Home (Dogma / The
* Beast).
*/
export declare function isStageWithStoryBoss(stage: LevelStage): boolean;
/**
* Helper function to check if the player has taken Dad's Note. This sets the game state flag of
* `GameStateFlag.BACKWARDS_PATH` and causes floor generation to change.
*/
export declare function onAscent(): boolean;
export declare function onCathedral(): boolean;
export declare function onChest(): boolean;
export declare function onDarkRoom(): boolean;
/**
* Helper function to check if the current stage matches one of the given stages. This uses the
* `getEffectiveStage` helper function so that the Repentance floors are correctly adjusted.
*
* This function is variadic, which means you can pass as many stages as you want to match for.
*/
export declare function onEffectiveStage(...effectiveStages: readonly LevelStage[]): boolean;
/**
* Returns whether the player is on the "final floor" of the particular run. The final floor is
* defined as one that prevents the player from entering the I AM ERROR room on.
*
* For example, when using Undefined on The Chest, it has a 50% chance of teleporting the player to
* the Secret Room and a 50% chance of teleporting the player to the Super Secret Room, because the
* I AM ERROR room is never entered into the list of possibilities.
*/
export declare function onFinalFloor(): boolean;
/**
* Returns whether the player is on the first floor of the particular run.
*
* This is tricky to determine because we have to handle the cases of Downpour/Dross 1 not being the
* first floor and The Ascent.
*/
export declare function onFirstFloor(): boolean;
/**
* Helper function to check if the current stage type is equal to `StageType.REPENTANCE` or
* `StageType.REPENTANCE_B`.
*/
export declare function onRepentanceStage(): boolean;
export declare function onSheol(): boolean;
/**
* Helper function to check if the current stage matches one of the given stages.
*
* This function is variadic, which means you can pass as many stages as you want to match for.
*/
export declare function onStage(...stages: readonly LevelStage[]): boolean;
/** Helper function to check if the current stage is equal to or higher than the given stage. */
export declare function onStageOrHigher(stage: LevelStage): boolean;
/** Helper function to check if the current stage is equal to or higher than the given stage. */
export declare function onStageOrLower(stage: LevelStage): boolean;
/**
* Helper function to check if the current stage matches one of the given stage types.
*
* This function is variadic, which means you can pass as many room types as you want to match for.
*/
export declare function onStageType(...stageTypes: readonly StageType[]): boolean;
/**
* Helper function to check if the current stage is one that has the possibility to grant a natural
* Devil Room or Angel Room after killing the boss.
*/
export declare function onStageWithNaturalDevilRoom(): boolean;
/**
* Helper function to check if the current stage is one that will have a random collectible drop
* upon defeating the boss of the floor.
*
* This happens on most stages but will not happen on Depths 2, Womb 2, Sheol, Cathedral, Dark Room,
* The Chest, and Home (due to the presence of a story boss).
*
* Note that even though Delirium does not drop a random boss collectible, The Void is still
* considered to be a stage that has a random boss collectible since all of the non-Delirium Boss
* Rooms will drop random boss collectibles.
*/
export declare function onStageWithRandomBossCollectible(): boolean;
/**
* Helper function to check if the current stage will spawn a locked door to Downpour/Dross after
* defeating the boss.
*/
export declare function onStageWithSecretExitToDownpour(): boolean;
/**
* Helper function to check if the current stage will spawn a spiked door to Mausoleum/Gehenna after
* defeating the boss.
*/
export declare function onStageWithSecretExitToMausoleum(): boolean;
/**
* Helper function to check if the current stage will spawn a wooden door to Mines/Ashpit after
* defeating the boss.
*/
export declare function onStageWithSecretExitToMines(): boolean;
/**
* Helper function to check if the current stage is one that would create a trapdoor if We Need to
* Go Deeper was used.
*/
export declare function onStageWithShovelTrapdoors(): boolean;
/**
* Helper function to check if the current stage is one with a story boss. Specifically, this is
* Depths 2 (Mom), Womb 2 (Mom's Heart / It Lives), Blue Womb (Hush), Sheol (Satan), Cathedral
* (Isaac), Dark Room (Lamb), The Chest (Blue Baby), The Void (Delirium), and Home (Dogma / The
* Beast).
*/
export declare function onStageWithStoryBoss(): boolean;
/**
* Helper function to directly warp to a specific stage using the "stage" console command.
*
* This is different from the vanilla `Level.SetStage` method, which will change the stage and/or
* stage type of the current floor without moving the player to a new floor.
*
* Note that if you use this function on game frame 0, it will confuse the
* `POST_GAME_STARTED_REORDERED`, `POST_NEW_LEVEL_REORDERED`, and `POST_NEW_ROOM_REORDERED` custom
* callbacks. If you are using the function in this situation, remember to call the
* `reorderedCallbacksSetStage` function.
*
* @param stage The stage number to warp to.
* @param stageType The stage type to warp to.
* @param reseed Optional. Whether to reseed the floor upon arrival. Default is false. Set this to
* true if you are warping to the same stage but a different stage type (or else the
* floor layout will be identical to the old floor).
*/
export declare function setStage(stage: LevelStage, stageType: StageType, reseed?: boolean): void;
//# sourceMappingURL=stage.d.ts.map