UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

290 lines (289 loc) • 16.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TELEPORTER_ACTIVATION_DISTANCE = exports.TAINTED_SAMSON_BERSERK_CHARGE_FROM_TAKING_DAMAGE = exports.STARTING_ROOM_GRID_INDEX = exports.RESOLUTION_1600_900 = exports.RESOLUTION_FULL_SCREEN = exports.MINUTE_IN_MILLISECONDS = exports.SECOND_IN_MILLISECONDS = exports.MAX_QUALITY = exports.QUALITIES = exports.ONE_BY_ONE_ROOM_GRID_SIZE = exports.NUM_PILL_COLORS_IN_POOL = exports.DIMENSIONS = exports.NUM_DIMENSIONS = exports.MAX_TAINTED_SAMSON_BERSERK_CHARGE = exports.NEW_RUN_PLAYER_STARTING_POSITION = exports.NEW_FLOOR_STARTING_POSITION_GREED_MODE = exports.NEW_FLOOR_STARTING_POSITION_NORMAL_MODE = exports.MAX_SPEED_STAT = exports.MIN_PLAYER_SPEED_STAT = exports.MIN_PLAYER_SHOT_SPEED_STAT = exports.MAX_PLAYER_TRINKET_SLOTS = exports.MAX_PLAYER_SPEED_IN_UNITS = exports.MAX_PLAYER_HEART_CONTAINERS = exports.MAX_NUM_INPUTS = exports.MAX_NUM_FAMILIARS = exports.MAX_LEVEL_GRID_INDEX = exports.MAPPING_COLLECTIBLES = exports.LEVEL_GRID_ROW_WIDTH = exports.LEVEL_GRID_COLUMN_HEIGHT = exports.GRID_INDEX_CENTER_OF_1X1_ROOM = exports.RENDER_FRAMES_PER_MINUTE = exports.RENDER_FRAMES_PER_SECOND = exports.MAIN_CHARACTERS = exports.GAME_FRAMES_PER_MINUTE = exports.GAME_FRAMES_PER_SECOND = exports.FLYING_CHARACTERS = exports.FIRST_GLITCHED_COLLECTIBLE_TYPE = exports.EMPTY_PNG_PATH = exports.EGGY_STATE_FRAME_OF_FINAL_SPIDER = exports.DOOR_HITBOX_RADIUS = exports.DOGMA_ROOM_GRID_INDEX = exports.DISTANCE_OF_GRID_TILE = exports.DEFAULT_ITEM_POOL_TYPE = exports.COLLECTIBLE_INITIAL_WAIT = exports.CHEST_PICKUP_VARIANTS_SET = exports.CHEST_PICKUP_VARIANTS = exports.BOMB_EXPLODE_FRAME = exports.BLIND_ITEM_PNG_PATH = exports.AZAZEL_DEFAULT_BRIMSTONE_DISTANCE = exports.ALL_DISPLAY_FLAGS = void 0; exports.KColorDefault = exports.ColorDefault = exports.VectorZero = exports.VectorOne = exports.UI_HEART_WIDTH = exports.TIME_GAME_OPENED = void 0; const isaac_typescript_definitions_1 = require("isaac-typescript-definitions"); const enums_1 = require("../functions/enums"); const flag_1 = require("../functions/flag"); const readOnly_1 = require("../functions/readOnly"); const types_1 = require("../functions/types"); const utils_1 = require("../functions/utils"); const ReadonlySet_1 = require("../types/ReadonlySet"); const constantsFirstLast_1 = require("./constantsFirstLast"); /** * The combination of the following flags: * - `DisplayFlag.VISIBLE` (1 << 0) * - `DisplayFlag.SHADOW` (1 << 1) * - `DisplayFlag.SHOW_ICON` (1 << 2) */ exports.ALL_DISPLAY_FLAGS = (0, flag_1.addFlag)(isaac_typescript_definitions_1.DisplayFlag.VISIBLE, isaac_typescript_definitions_1.DisplayFlag.SHADOW, isaac_typescript_definitions_1.DisplayFlag.SHOW_ICON); /** * The distance of the laser when Azazel does not have any range up items yet. For more info, see * the documentation for the `getAzazelBrimstoneDistance` function. */ exports.AZAZEL_DEFAULT_BRIMSTONE_DISTANCE = 75.125; /** * The path to the png file for collectible items during Curse of the Blind, making them appear with * a red question mark. */ exports.BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png"; /** Bombs explode when their frame count is equal to this value. */ exports.BOMB_EXPLODE_FRAME = 45; exports.CHEST_PICKUP_VARIANTS = [ isaac_typescript_definitions_1.PickupVariant.CHEST, // 50 isaac_typescript_definitions_1.PickupVariant.BOMB_CHEST, // 51 isaac_typescript_definitions_1.PickupVariant.SPIKED_CHEST, // 52 isaac_typescript_definitions_1.PickupVariant.ETERNAL_CHEST, // 53 isaac_typescript_definitions_1.PickupVariant.MIMIC_CHEST, // 54 isaac_typescript_definitions_1.PickupVariant.OLD_CHEST, // 55 isaac_typescript_definitions_1.PickupVariant.WOODEN_CHEST, // 56 isaac_typescript_definitions_1.PickupVariant.MEGA_CHEST, // 57 isaac_typescript_definitions_1.PickupVariant.HAUNTED_CHEST, // 58 isaac_typescript_definitions_1.PickupVariant.LOCKED_CHEST, // 60 isaac_typescript_definitions_1.PickupVariant.RED_CHEST, // 360 isaac_typescript_definitions_1.PickupVariant.MOMS_CHEST, // 390 ]; exports.CHEST_PICKUP_VARIANTS_SET = new ReadonlySet_1.ReadonlySet(exports.CHEST_PICKUP_VARIANTS); /** This is the initial value of the `EntityPickup.Wait` field after a collectible is spawned. */ exports.COLLECTIBLE_INITIAL_WAIT = 20; exports.DEFAULT_ITEM_POOL_TYPE = isaac_typescript_definitions_1.ItemPoolType.TREASURE; /** This is also the distance that a player spawns from the door that they enter a room from. */ exports.DISTANCE_OF_GRID_TILE = 40; exports.DOGMA_ROOM_GRID_INDEX = 109; exports.DOOR_HITBOX_RADIUS = 11; /** * When Eggies take fatal damage, they go into NPCState.STATE_SUICIDE and spawn 14 Swarm Spiders * while their StateFrame ticks upwards. The 14th spider appears when the StateFrame is at this * value. */ exports.EGGY_STATE_FRAME_OF_FINAL_SPIDER = 45; /** * A non-existent or completely transparent PNG file for use in clearing sprites. For more * information, see the documentation for the `clearSprite` helper function. */ exports.EMPTY_PNG_PATH = "gfx/none.png"; /** * The random items that appear when the player has TMTRAINER are generated on the fly as they are * encountered by the player. The first TMTRAINER item takes the final possible 32 bit number. The * second TMTRAINER item subtracts one from that, and so on. * * This is equal to 4294967295. */ exports.FIRST_GLITCHED_COLLECTIBLE_TYPE = (0, types_1.asCollectibleType)((1 << 32) - 1); /** * An array containing every flying character. This includes non-main characters such as The Soul. */ exports.FLYING_CHARACTERS = [ isaac_typescript_definitions_1.PlayerType.AZAZEL, // 7 isaac_typescript_definitions_1.PlayerType.LOST, // 10 isaac_typescript_definitions_1.PlayerType.SOUL, // 17 isaac_typescript_definitions_1.PlayerType.LOST_B, // 31 isaac_typescript_definitions_1.PlayerType.JACOB_2_B, // 39 isaac_typescript_definitions_1.PlayerType.SOUL_B, // 40 ]; /** Game frames are what is returned by the `Game.GetFrameCount` method. */ exports.GAME_FRAMES_PER_SECOND = 30; /** Game frames are what is returned by the `Game.GetFrameCount` method. */ exports.GAME_FRAMES_PER_MINUTE = exports.GAME_FRAMES_PER_SECOND * 60; /** * An array containing every character that is selectable from the main menu (and has achievements * related to completing the various bosses and so on). */ exports.MAIN_CHARACTERS = [ isaac_typescript_definitions_1.PlayerType.ISAAC, // 0 isaac_typescript_definitions_1.PlayerType.MAGDALENE, // 1 isaac_typescript_definitions_1.PlayerType.CAIN, // 2 isaac_typescript_definitions_1.PlayerType.JUDAS, // 3 isaac_typescript_definitions_1.PlayerType.BLUE_BABY, // 4 isaac_typescript_definitions_1.PlayerType.EVE, // 5 isaac_typescript_definitions_1.PlayerType.SAMSON, // 6 isaac_typescript_definitions_1.PlayerType.AZAZEL, // 7 isaac_typescript_definitions_1.PlayerType.LAZARUS, // 8 isaac_typescript_definitions_1.PlayerType.EDEN, // 9 isaac_typescript_definitions_1.PlayerType.LOST, // 10 isaac_typescript_definitions_1.PlayerType.LILITH, // 13 isaac_typescript_definitions_1.PlayerType.KEEPER, // 14 isaac_typescript_definitions_1.PlayerType.APOLLYON, // 15 isaac_typescript_definitions_1.PlayerType.FORGOTTEN, // 16 isaac_typescript_definitions_1.PlayerType.BETHANY, // 18 isaac_typescript_definitions_1.PlayerType.JACOB, // 19 isaac_typescript_definitions_1.PlayerType.ISAAC_B, // 21 isaac_typescript_definitions_1.PlayerType.MAGDALENE_B, // 22 isaac_typescript_definitions_1.PlayerType.CAIN_B, // 23 isaac_typescript_definitions_1.PlayerType.JUDAS_B, // 24 isaac_typescript_definitions_1.PlayerType.BLUE_BABY_B, // 25 isaac_typescript_definitions_1.PlayerType.EVE_B, // 26 isaac_typescript_definitions_1.PlayerType.SAMSON_B, // 27 isaac_typescript_definitions_1.PlayerType.AZAZEL_B, // 28 isaac_typescript_definitions_1.PlayerType.LAZARUS_B, // 29 isaac_typescript_definitions_1.PlayerType.EDEN_B, // 30 isaac_typescript_definitions_1.PlayerType.LOST_B, // 31 isaac_typescript_definitions_1.PlayerType.LILITH_B, // 32 isaac_typescript_definitions_1.PlayerType.KEEPER_B, // 33 isaac_typescript_definitions_1.PlayerType.APOLLYON_B, // 34 isaac_typescript_definitions_1.PlayerType.FORGOTTEN_B, // 35 isaac_typescript_definitions_1.PlayerType.BETHANY_B, // 36 isaac_typescript_definitions_1.PlayerType.JACOB_B, // 37 ]; /** Render frames are what is returned by the `Isaac.GetFrameCount` method. */ exports.RENDER_FRAMES_PER_SECOND = 60; /** Render frames are what is returned by the `Isaac.GetFrameCount` method. */ exports.RENDER_FRAMES_PER_MINUTE = exports.RENDER_FRAMES_PER_SECOND * 60; exports.GRID_INDEX_CENTER_OF_1X1_ROOM = 67; /** * The floor is represented by a 13x13 grid. Room indexes start at 0. The first column is * represented by grid indexes 0, 13, 26, and so on. */ exports.LEVEL_GRID_COLUMN_HEIGHT = 13; /** * The floor is represented by a 13x13 grid. Room indexes start at 0. The first row is represented * by grid indexes from 0 to 12. The second row is represented by grid indexes from 13 to 25, and so * on. */ exports.LEVEL_GRID_ROW_WIDTH = 13; /** * All of the collectibles that grant vision on the map. * * Note that: * - Spelunker Hat is included. Historically, Spelunker Hat was not considered to be mapping, but it * was buffed in Repentance to show rooms two or more away. * - Book of Secrets is included, which is an "active mapping" instead of passive. * - Luna is included, even though it is not a very powerful mapping item. * - Cracked Orb is included, even though it requires the player to be damaged in order for it to be * activated. */ exports.MAPPING_COLLECTIBLES = [ isaac_typescript_definitions_1.CollectibleType.COMPASS, // 21 isaac_typescript_definitions_1.CollectibleType.TREASURE_MAP, // 54 isaac_typescript_definitions_1.CollectibleType.SPELUNKER_HAT, // 91 isaac_typescript_definitions_1.CollectibleType.CRYSTAL_BALL, // 158 isaac_typescript_definitions_1.CollectibleType.BLUE_MAP, // 246 isaac_typescript_definitions_1.CollectibleType.BOOK_OF_SECRETS, // 287 isaac_typescript_definitions_1.CollectibleType.MIND, // 333 isaac_typescript_definitions_1.CollectibleType.SOL, // 588 isaac_typescript_definitions_1.CollectibleType.LUNA, // 589 isaac_typescript_definitions_1.CollectibleType.CRACKED_ORB, // 675 ]; /** * The floor is represented by a 13x13 grid. Room indexes start at 0. The first row is represented * by grid indexes from 0 to 12. The second row is represented by grid indexes from 13 to 25, and so * on. The maximum room index possible is 168. (It is not 169 because we start at 0 instead of 1.) */ exports.MAX_LEVEL_GRID_INDEX = 168; /** * The game has a limit on the number of currently spawned familiars and will refuse to spawn any * more if it reaches the limit. Blue flies and blue spiders have a lower priority and will be * deleted to make room for other familiars. */ exports.MAX_NUM_FAMILIARS = 64; /** The game can only handle up to four different players. */ exports.MAX_NUM_INPUTS = 4; /** With Birthright, it is possible for Magdalene to have 18 heart containers. */ exports.MAX_PLAYER_HEART_CONTAINERS = 18; /** * As the player continues to move in a direction, they will accelerate. When going from one wall to * another in a 2x2 room at 2.0 speed (the maximum that the speed stat can rise to), the amount of * units moved per update frame will climb to around 9.797 as they hit the opposite wall. The * constant specifies a value of 9.8 to be safe. */ exports.MAX_PLAYER_SPEED_IN_UNITS = 9.8; exports.MAX_PLAYER_TRINKET_SLOTS = (0, enums_1.getEnumLength)(isaac_typescript_definitions_1.TrinketSlot); /** If you set `EntityPlayer.ShotSpeed` lower than this value, it will have no effect. */ exports.MIN_PLAYER_SHOT_SPEED_STAT = 0.6; /** If you set `EntityPlayer.Speed` lower than this value, it will have no effect. */ exports.MIN_PLAYER_SPEED_STAT = 0.1; /** * The maximum speed stat that a player can have. Any additional speed beyond this will not take * effect. */ exports.MAX_SPEED_STAT = 2; /** This is in the center of the room. */ exports.NEW_FLOOR_STARTING_POSITION_NORMAL_MODE = (0, readOnly_1.newReadonlyVector)(320, 280); /** This is near the top door. */ exports.NEW_FLOOR_STARTING_POSITION_GREED_MODE = (0, readOnly_1.newReadonlyVector)(320, 280); /** * This is next to the bottom door. Presumably, the player does not start in the center of the room * (like they do when getting to a new stage) so that the controls graphic is more visible. */ exports.NEW_RUN_PLAYER_STARTING_POSITION = (0, readOnly_1.newReadonlyVector)(320, 380); /** Corresponds to the maximum value for `EntityPlayer.SamsonBerserkCharge`. */ exports.MAX_TAINTED_SAMSON_BERSERK_CHARGE = 100_000; /** * The number of dimensions, not including `Dimension.CURRENT`. (This is derived from the * `Dimension` enum.) */ exports.NUM_DIMENSIONS = (0, enums_1.getEnumLength)(isaac_typescript_definitions_1.Dimension) - 1; /** * An array containing every valid `Dimension`, not including `Dimension.CURRENT`. (This is derived * from the `NUM_DIMENSIONS` constant.) */ exports.DIMENSIONS = (0, utils_1.eRange)(exports.NUM_DIMENSIONS); /** * The pill pool for each run is comprised of one effect for each unique pill color (minus gold and * horse pills.) */ // TypeDoc will not work properly with the preferred export form. // eslint-disable-next-line unicorn/prefer-export-from exports.NUM_PILL_COLORS_IN_POOL = constantsFirstLast_1.NUM_NORMAL_PILL_COLORS; exports.ONE_BY_ONE_ROOM_GRID_SIZE = 135; /** * An array representing every valid collectible type quality. Specifically, this is: `[0, 1, 2, 3, * 4]` */ // eslint-disable-next-line complete/require-capital-const-assertions exports.QUALITIES = [0, 1, 2, 3, 4]; exports.MAX_QUALITY = 4; exports.SECOND_IN_MILLISECONDS = 1000; exports.MINUTE_IN_MILLISECONDS = 60 * exports.SECOND_IN_MILLISECONDS; /** This is equivalent to the bottom-right screen position when the game is in full screen mode. */ exports.RESOLUTION_FULL_SCREEN = Vector(480, 270); /** * This is equivalent to the bottom-right screen position when the game is in windowed mode in a * 1600x900 resolution. */ exports.RESOLUTION_1600_900 = Vector(533, 300); /** * The starting room of the floor is always at the same grid index, which is in the middle of the * 13x13 grid. */ exports.STARTING_ROOM_GRID_INDEX = 84; /** After taking damage, `EntityPlayer.SamsonBerserkCharge` is incremented by this amount. */ exports.TAINTED_SAMSON_BERSERK_CHARGE_FROM_TAKING_DAMAGE = 10_000; /** For `GridEntityType.TELEPORTER` (23). */ exports.TELEPORTER_ACTIVATION_DISTANCE = exports.DISTANCE_OF_GRID_TILE / 2; /** In milliseconds, as reported by the `Isaac.GetTime` method. */ exports.TIME_GAME_OPENED = Isaac.GetTime(); /** * This is the number of draw coordinates that each heart spans on the UI in the upper left hand * corner. */ exports.UI_HEART_WIDTH = 12; /** * Equal to `Vector(1, 1)`. * * This is a safe version of the `Vector.One` constant. (Other mods can mutate `Vector.One`, so it * is not safe to use.) */ exports.VectorOne = (0, readOnly_1.newReadonlyVector)(1, 1); /** * Equal to `Vector(0, 0)`. * * This is a safe version of the `Vector.Zero` constant. (Other mods can mutate `Vector.Zero`, so it * is not safe to use.) */ exports.VectorZero = (0, readOnly_1.newReadonlyVector)(0, 0); /** * Equal to `Color(1, 1, 1)`. * * This is a safe version of the `Color.Default` constant. (Other mods can mutate `Color.Default`, * so it is not safe to use.) * * If you need to mutate this, make a copy first with the `copyColor` helper function. */ exports.ColorDefault = (0, readOnly_1.newReadonlyColor)(1, 1, 1); /** * Equal to `KColor(1, 1, 1, 1)`. * * If you need to mutate this, make a copy first with the `copyKColor` helper function. */ exports.KColorDefault = (0, readOnly_1.newReadonlyKColor)(1, 1, 1, 1);