UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

224 lines • 11 kB
import { ControllerIndex, PlayerForm, PlayerType } from "isaac-typescript-definitions"; /** * Helper function to check to see if any player is holding up an item (from e.g. an active item * activation, a poop from IBS, etc.). */ export declare function anyPlayerHoldingItem(): boolean; /** * Helper function to determine if the given character is present. * * This function is variadic, meaning that you can supply as many characters as you want to check * for. Returns true if any of the characters supplied are present. */ export declare function anyPlayerIs(...matchingCharacters: readonly PlayerType[]): boolean; /** * Helper function to determine if a player will destroy a rock/pot/skull if they walk over it. * * The following situations allow for this to be true: * - the player has Leo (collectible 302) * - the player has Thunder Thighs (collectible 314) * - the player is under the effects of Mega Mush (collectible 625) * - the player has Stompy (transformation 13) */ export declare function canPlayerCrushRocks(player: EntityPlayer): boolean; /** * Helper function to remove a collectible or trinket that is currently queued to go into a player's * inventory (i.e. the item is being held over their head). * * If the player does not have an item currently queued, then this function will be a no-op. * * Returns whether an item was actually dequeued. * * Under the hood, this clones the `QueuedItemData`, since directly setting the `Item` field to * `undefined` does not work for some reason. * * This method was discovered by im_tem. */ export declare function dequeueItem(player: EntityPlayer): boolean; /** * Helper function to get how long Azazel's Brimstone laser should be. You can pass either an * `EntityPlayer` object or a tear height stat. * * The formula for calculating it is: 32 - 2.5 * tearHeight */ export declare function getAzazelBrimstoneDistance(playerOrTearHeight: EntityPlayer | float): float; /** Helper function to get an array containing the characters of all of the current players. */ export declare function getCharacters(): readonly PlayerType[]; /** * Helper function to get the closest player to a certain position. Note that this will never * include players with a non-undefined parent, since they are not real players (e.g. the Strawman * Keeper). */ export declare function getClosestPlayer(position: Vector): EntityPlayer; /** * Helper function to return the player with the highest ID, according to the `Isaac.GetPlayer` * method. */ export declare function getFinalPlayer(): EntityPlayer; /** * Helper function to get the first player with the lowest frame count. Useful to find a freshly * spawned player after using items like Esau Jr. Don't use this function if two or more players * will be spawned on the same frame. */ export declare function getNewestPlayer(): EntityPlayer; /** * Iterates over all players and checks if any are close enough to the specified position. * * @returns The first player found when iterating upwards from index 0. */ export declare function getPlayerCloserThan(position: Vector, distance: float): EntityPlayer | undefined; /** * Helper function to get the player from a tear, laser, bomb, etc. Returns undefined if the entity * does not correspond to any particular player. * * This function works by looking at the `Parent` and the `SpawnerEntity` fields (in that order). As * a last resort, it will attempt to use the `Entity.ToPlayer` method on the entity itself. */ export declare function getPlayerFromEntity(entity: Entity): EntityPlayer | undefined; /** * Helper function to get an `EntityPlayer` object from an `EntityPtr`. Returns undefined if the * entity has gone out of scope or if the associated entity is not a player. */ export declare function getPlayerFromPtr(entityPtr: EntityPtr): EntityPlayer | undefined; /** * Helper function to get the proper name of the player. Use this instead of the * `EntityPlayer.GetName` method because it accounts for Blue Baby, Lazarus II, and Tainted * characters. */ export declare function getPlayerName(player: EntityPlayer): string; /** * Returns the combined value of all of the player's red hearts, soul/black hearts, and bone hearts, * minus the value of the player's rotten hearts. * * This is equivalent to the number of hits that the player can currently take, but does not take * into account double damage from champion enemies and/or being on later floors. (For example, on * Womb 1, players who have 1 soul heart remaining would die in 1 hit to anything, even though this * function would report that they have 2 hits remaining.) */ export declare function getPlayerNumHitsRemaining(player: EntityPlayer): int; /** * Helper function to get all of the players that are a certain character. * * This function is variadic, meaning that you can supply as many characters as you want to check * for. Returns true if any of the characters supplied are present. */ export declare function getPlayersOfType(...characters: readonly PlayerType[]): readonly EntityPlayer[]; /** * Helper function to get all of the players that are using keyboard (i.e. * `ControllerIndex.KEYBOARD`). This function returns an array of players because it is possible * that there is more than one player with the same controller index (e.g. Jacob & Esau). * * Note that this function includes players with a non-undefined parent like e.g. the Strawman * Keeper. */ export declare function getPlayersOnKeyboard(): readonly EntityPlayer[]; /** * Helper function to get all of the players that match the provided controller index. This function * returns an array of players because it is possible that there is more than one player with the * same controller index (e.g. Jacob & Esau). * * Note that this function includes players with a non-undefined parent like e.g. the Strawman * Keeper. */ export declare function getPlayersWithControllerIndex(controllerIndex: ControllerIndex): readonly EntityPlayer[]; /** * Helper function to check to see if a player has one or more transformations. * * This function is variadic, meaning that you can supply as many transformations as you want to * check for. Returns true if the player has any of the supplied transformations. */ export declare function hasForm(player: EntityPlayer, ...playerForms: readonly PlayerForm[]): boolean; /** * Helper function to check if a player has homing tears. * * Under the hood, this checks the `EntityPlayer.TearFlags` variable for `TearFlag.HOMING` (1 << 2). */ export declare function hasHoming(player: EntityPlayer): boolean; /** After touching a white fire, a player will turn into The Lost until they clear a room. */ export declare function hasLostCurse(player: EntityPlayer): boolean; /** * Helper function to check if a player has piercing tears. * * Under the hood, this checks the `EntityPlayer.TearFlags` variable for `TearFlag.PIERCING` (1 << * 1). */ export declare function hasPiercing(player: EntityPlayer): boolean; /** * Helper function to check if a player has spectral tears. * * Under the hood, this checks the `EntityPlayer.TearFlags` variable for `TearFlag.SPECTRAL` (1 << * 0). */ export declare function hasSpectral(player: EntityPlayer): boolean; /** * Helper function for detecting when a player is Bethany or Tainted Bethany. This is useful if you * need to adjust UI elements to account for Bethany's soul charges or Tainted Bethany's blood * charges. */ export declare function isBethany(player: EntityPlayer): boolean; /** * Helper function to check if a player is a specific character (i.e. `PlayerType`). * * This function is variadic, meaning that you can supply as many characters as you want to check * for. Returns true if the player is any of the supplied characters. */ export declare function isCharacter(player: EntityPlayer, ...characters: readonly PlayerType[]): boolean; /** * Helper function to see if a damage source is from a player. Use this instead of comparing to the * entity directly because it takes familiars into account. */ export declare function isDamageFromPlayer(damageSource: Entity): boolean; /** * Helper function for detecting when a player is Eden or Tainted Eden. Useful for situations where * you want to know if the starting stats were randomized, for example. */ export declare function isEden(player: EntityPlayer): boolean; export declare function isFirstPlayer(player: EntityPlayer): boolean; /** * Helper function for detecting when a player is Jacob or Esau. This will only match the * non-tainted versions of these characters. */ export declare function isJacobOrEsau(player: EntityPlayer): boolean; /** * Helper function for detecting when a player is Keeper or Tainted Keeper. Useful for situations * where you want to know if the health is coin hearts, for example. */ export declare function isKeeper(player: EntityPlayer): boolean; /** Helper function for detecting when a player is The Lost or Tainted Lost. */ export declare function isLost(player: EntityPlayer): boolean; export declare function isModdedPlayer(player: EntityPlayer): boolean; /** * Helper function for determining if a player is able to turn their head by pressing the shooting * buttons. * * Under the hood, this function uses the `EntityPlayer.IsExtraAnimationFinished` method. */ export declare function isPlayerAbleToAim(player: EntityPlayer): boolean; /** Helper function for detecting if a player is one of the Tainted characters. */ export declare function isTainted(player: EntityPlayer): boolean; /** Helper function for detecting when a player is Tainted Lazarus or Dead Tainted Lazarus. */ export declare function isTaintedLazarus(player: EntityPlayer): boolean; export declare function isVanillaPlayer(player: EntityPlayer): boolean; /** * Helper function to remove the Dead Eye multiplier from a player. * * Note that each time the `EntityPlayer.ClearDeadEyeCharge` method is called, it only has a chance * of working, so this function calls it 100 times to be safe. */ export declare function removeDeadEyeMultiplier(player: EntityPlayer): void; /** * Helper function to blindfold the player by using a hack with the challenge variable. * * Note that if the player dies and respawns (from e.g. Dead Cat), the blindfold will have to be * reapplied. * * Under the hood, this function sets the challenge to one with a blindfold, changes the player to * the same character that they currently are, and then changes the challenge back. This method was * discovered by im_tem. * * @param player The player to apply or remove the blindfold state from. * @param enabled Whether to apply or remove the blindfold. * @param modifyCostume Optional. Whether to add or remove the blindfold costume. Default is true. */ export declare function setBlindfold(player: EntityPlayer, enabled: boolean, modifyCostume?: boolean): void; //# sourceMappingURL=players.d.ts.map