Skip to main content

Custom Item Pools

Hierarchy

  • Feature

    CustomItemPools

Methods

registerCustomItemPool

registerCustomItemPool(itemPoolTypeCustom, collectibles): void

Helper function to register a custom item pool. Use this function once when your mod first loads to declare the items that you want to be in the item pools. Then, in the middle of a run, you can use getCustomItemPoolCollectible.

For example:

const ItemPoolTypeCustom = {
FOO = 0 as ItemPoolType,
} as const;

const FOO_ITEM_POOL = [
[CollectibleType.SAD_ONION, 1],
[CollectibleType.INNER_EYE, 0.5],
];

registerCustomItemPool(ItemPoolTypeCustom.FOO, FOO_ITEM_POOL);

Note that custom item pools do not currently support partial weight decrementation on sight.

In order to use this function, you must upgrade your mod with ISCFeature.CUSTOM_ITEM_POOLS.

Parameters

NameTypeDescription
itemPoolTypeCustomItemPoolTypeAn integer that identifies what kind of item pool you are creating. It should correspond to a local ItemPoolTypeCustom enum in your mod. The integer can be any unique value and can safely overlap with the vanilla item pool type values (or values chosen by other mods).
collectiblesreadonly [CollectibleType, float][]An array of weighted collectible tuples that represent the item pool that you are creating. The first element in he tuple is the CollectibleType, and the second element in the tuple is the float that represents the weight of the collectible.

Returns

void

Defined in

packages/isaacscript-common/src/classes/features/other/CustomItemPools.ts:85


getCustomItemPoolCollectible

getCustomItemPoolCollectible(itemPoolTypeCustom, seedOrRNG, decrease?, defaultItem?): CollectibleType

Helper function to get a new collectible from a custom item pool created with the registerCustomItemPool function. This function has the same format as the ItemPool.GetCollectible method.

By default, a collectible will not be removed from the pool once it is selected, unless the decrease argument is set to true (similar to how a vanilla item pool works).

If you want to get an unseeded collectible type, you must explicitly pass undefined to the seedOrRNG parameter.

In order to use this function, you must upgrade your mod with ISCFeature.CUSTOM_ITEM_POOLS.

Parameters

NameTypeDefault valueDescription
itemPoolTypeCustomItemPoolTypeundefinedAn integer representing the custom item pool to use.
seedOrRNGundefined | RNG | SeedundefinedThe Seed or RNG object to use. If an RNG object is provided, the RNG.Next method will be called. If undefined is provided, it will default to a random seed.
decreasebooleanfalseOptional. Whether to remove the selected collectible from the item pool. Default is true.
defaultItemCollectibleTypeCollectibleType.NULLOptional. The collectible to return if the item pool is depleted. Default is CollectibleType.NULL.

Returns

CollectibleType

Defined in

packages/isaacscript-common/src/classes/features/other/CustomItemPools.ts:125