isaacscript-common 8.5.0 → 8.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -892,7 +892,7 @@ export declare enum ModCallbackCustom {
892
892
  POST_PLAYER_CHANGE_TYPE = 57,
893
893
  /**
894
894
  * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is higher than
895
- * what it was on the previous frame.
895
+ * what it was on the previous frame or when a new active collectible is acquired.
896
896
  *
897
897
  * When registering the callback, takes an optional second argument that will make the callback
898
898
  * only fire if the collectible matches the `CollectibleType` provided.
@@ -907,7 +907,7 @@ export declare enum ModCallbackCustom {
907
907
  POST_PLAYER_COLLECTIBLE_ADDED = 58,
908
908
  /**
909
909
  * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is lower than
910
- * what it was on the previous frame.
910
+ * what it was on the previous frame or when an active collectible is no longer present.
911
911
  *
912
912
  * When registering the callback, takes an optional second argument that will make the callback
913
913
  * only fire if the collectible matches the `CollectibleType` provided.
@@ -3,9 +3,6 @@ import { CollectibleType } from "isaac-typescript-definitions";
3
3
  * Helper function to get all of the collectibles that the player has gotten so far on this run, in
4
4
  * order.
5
5
  *
6
- * Note that this does not include active collectibles that have since been dropped for other
7
- * collectibles.
8
- *
9
6
  * In the case of inventory initialization or the case where the player rerolls their build in the
10
7
  * middle of the run (e.g. with D4), the order of the inventory will not correspond to the order
11
8
  * that the items were actually given to the player. In this case, the inventory will be in the
@@ -17,6 +14,17 @@ import { CollectibleType } from "isaac-typescript-definitions";
17
14
  * would not be updated. In vanilla, this situation would never happen, but another mod might do
18
15
  * this for some reason. (With that said, the next time that a collectible is normally added or
19
16
  * removed, it would trigger a re-scan, and the previous changes would be picked up.)
17
+ *
18
+ * @param player The player to get the inventory for.
19
+ * @param includeActiveCollectibles Optional. If true, will include all active collectibles. Default
20
+ * is true.
20
21
  */
21
22
  export declare function getPlayerInventory(player: EntityPlayer, includeActiveCollectibles?: boolean): CollectibleType[];
23
+ /**
24
+ * Helper function to get the last passive collectible that the player picked up. In most cases,
25
+ * this will be the passive that is removed when the player would use Clicker.
26
+ *
27
+ * Returns undefined if the player does not have any passive collectibles.
28
+ */
29
+ export declare function getPlayerLastPassiveCollectible(player: EntityPlayer): CollectibleType | undefined;
22
30
  //# sourceMappingURL=playerInventory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"playerInventory.d.ts","sourceRoot":"","sources":["../../src/features/playerInventory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,8BAA8B,CAAC;AAyG5E;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,yBAAyB,UAAO,GAC/B,eAAe,EAAE,CAanB"}
1
+ {"version":3,"file":"playerInventory.d.ts","sourceRoot":"","sources":["../../src/features/playerInventory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,8BAA8B,CAAC;AAsH5E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,yBAAyB,UAAO,GAC/B,eAAe,EAAE,CAanB;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,YAAY,GACnB,eAAe,GAAG,SAAS,CAK7B"}
@@ -15,6 +15,7 @@ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNot
15
15
  local ____array = require("functions.array")
16
16
  local arrayRemoveInPlace = ____array.arrayRemoveInPlace
17
17
  local copyArray = ____array.copyArray
18
+ local getLastElement = ____array.getLastElement
18
19
  local ____collectibles = require("functions.collectibles")
19
20
  local isActiveCollectible = ____collectibles.isActiveCollectible
20
21
  local ____collectibleSet = require("functions.collectibleSet")
@@ -32,14 +33,16 @@ local saveDataManager = ____exports.saveDataManager
32
33
  function newPlayerInventory(self, player)
33
34
  local inventory = {}
34
35
  for ____, collectibleType in ipairs(getCollectibleArray(nil)) do
35
- local numCollectibles = player:GetCollectibleNum(collectibleType, true)
36
- ____repeat(
37
- nil,
38
- numCollectibles,
39
- function()
40
- inventory[#inventory + 1] = collectibleType
41
- end
42
- )
36
+ if player:HasCollectible(collectibleType) then
37
+ local numCollectibles = player:GetCollectibleNum(collectibleType, true)
38
+ ____repeat(
39
+ nil,
40
+ numCollectibles,
41
+ function()
42
+ inventory[#inventory + 1] = collectibleType
43
+ end
44
+ )
45
+ end
43
46
  end
44
47
  return inventory
45
48
  end
@@ -84,9 +87,6 @@ end
84
87
  --- Helper function to get all of the collectibles that the player has gotten so far on this run, in
85
88
  -- order.
86
89
  --
87
- -- Note that this does not include active collectibles that have since been dropped for other
88
- -- collectibles.
89
- --
90
90
  -- In the case of inventory initialization or the case where the player rerolls their build in the
91
91
  -- middle of the run (e.g. with D4), the order of the inventory will not correspond to the order
92
92
  -- that the items were actually given to the player. In this case, the inventory will be in the
@@ -98,6 +98,10 @@ end
98
98
  -- would not be updated. In vanilla, this situation would never happen, but another mod might do
99
99
  -- this for some reason. (With that said, the next time that a collectible is normally added or
100
100
  -- removed, it would trigger a re-scan, and the previous changes would be picked up.)
101
+ --
102
+ -- @param player The player to get the inventory for.
103
+ -- @param includeActiveCollectibles Optional. If true, will include all active collectibles. Default
104
+ -- is true.
101
105
  function ____exports.getPlayerInventory(self, player, includeActiveCollectibles)
102
106
  if includeActiveCollectibles == nil then
103
107
  includeActiveCollectibles = true
@@ -113,4 +117,13 @@ function ____exports.getPlayerInventory(self, player, includeActiveCollectibles)
113
117
  function(____, collectibleType) return not isActiveCollectible(nil, collectibleType) end
114
118
  )
115
119
  end
120
+ --- Helper function to get the last passive collectible that the player picked up. In most cases,
121
+ -- this will be the passive that is removed when the player would use Clicker.
122
+ --
123
+ -- Returns undefined if the player does not have any passive collectibles.
124
+ function ____exports.getPlayerLastPassiveCollectible(self, player)
125
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
126
+ local inventory = ____exports.getPlayerInventory(nil, player, false)
127
+ return getLastElement(nil, inventory)
128
+ end
116
129
  return ____exports
@@ -19,6 +19,9 @@ export declare function getAliveBosses(entityType?: EntityType, variant?: number
19
19
  *
20
20
  * The set contains strings with the entity type and variant, separated by a period.
21
21
  *
22
+ * Note that this set does not include bosses that do not appear in Boss Rooms (e.g. Krampus, Uriel,
23
+ * and Gabriel.).
24
+ *
22
25
  * Also see the `getBossSet` and `getCombinedBossSet` functions.
23
26
  *
24
27
  * @param includeStoryBosses Optional. Whether to include "story" bosses like Mom and It Lives!
@@ -1 +1 @@
1
- {"version":3,"file":"bosses.d.ts","sourceRoot":"","sources":["../../src/functions/bosses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,SAAS,EACV,MAAM,8BAA8B,CAAC;AAyBtC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,UAAU,GAAE,UAAe,EAC3B,OAAO,SAAK,EACZ,OAAO,SAAK,EACZ,cAAc,UAAQ,GACrB,SAAS,EAAE,CAGb;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,kBAAkB,UAAO,GACxB,WAAW,CAAC,MAAM,CAAC,CAIrB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,SAAS,GACnB,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAYjC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CACvB,UAAU,CAAC,EAAE,UAAU,EACvB,OAAO,CAAC,EAAE,GAAG,EACb,OAAO,CAAC,EAAE,GAAG,EACb,cAAc,UAAQ,GACrB,SAAS,EAAE,CAGb;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,GAAG,GACT,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAOjC;AAED,6FAA6F;AAC7F,wBAAgB,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAE7C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,EAAE,GAAG,EACb,cAAc,UAAQ,GACrB,SAAS,EAAE,CAGb;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,GAAG,GACT,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAOjC;AAED,6FAA6F;AAC7F,wBAAgB,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAE7C;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAmB,EAC7B,OAAO,GAAE,MAAM,GAAG,SAAqB,EACvC,SAAS,GAAE,IAAI,GAAG,GAAG,GAAG,SAAqB,EAC7C,WAAW,CAAC,EAAE,GAAG,GAChB,SAAS,CAyBX;AAmCD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,IAAI,GAAG,GAAG,EACrB,QAAQ,GAAE,MAAmB,EAC7B,OAAO,GAAE,MAAM,GAAG,SAAqB,EACvC,WAAW,CAAC,EAAE,GAAG,GAChB,SAAS,CAYX"}
@@ -107,6 +107,9 @@ end
107
107
  --
108
108
  -- The set contains strings with the entity type and variant, separated by a period.
109
109
  --
110
+ -- Note that this set does not include bosses that do not appear in Boss Rooms (e.g. Krampus, Uriel,
111
+ -- and Gabriel.).
112
+ --
110
113
  -- Also see the `getBossSet` and `getCombinedBossSet` functions.
111
114
  --
112
115
  -- @param includeStoryBosses Optional. Whether to include "story" bosses like Mom and It Lives!
@@ -19,8 +19,12 @@ export declare function getCollectibleDevilCoinPrice(collectibleType: Collectibl
19
19
  */
20
20
  export declare function getCollectibleDevilHeartPrice(collectibleType: CollectibleType, player: EntityPlayer): PickupPrice;
21
21
  /**
22
- * Helper function to get the path to a collectible's sprite. Returns the path to the question mark
22
+ * Helper function to get the path to a collectible PNG file. Returns the path to the question mark
23
23
  * sprite (i.e. from Curse of the Blind) if the provided collectible type was not valid.
24
+ *
25
+ * Note that this does not return the file name, but the full path to the collectible's PNG file.
26
+ * The function is named "GfxFilename" to correspond to the associated `ItemConfigItem.GfxFileName`
27
+ * field.
24
28
  */
25
29
  export declare function getCollectibleGfxFilename(collectibleType: CollectibleType): string;
26
30
  /**
@@ -163,6 +167,11 @@ export declare function isPassiveCollectible(collectibleType: CollectibleType):
163
167
  export declare function isSingleUseCollectible(collectibleType: CollectibleType): boolean;
164
168
  export declare function isValidCollectibleType(collectibleType: CollectibleType): boolean;
165
169
  export declare function isVanillaCollectibleType(collectibleType: CollectibleType): boolean;
170
+ /**
171
+ * Helper function to generate a new sprite based on a collectible. If the provided collectible type
172
+ * is invalid, a sprite with a Curse of the Blind question mark will be returned.
173
+ */
174
+ export declare function newCollectibleSprite(collectibleType: CollectibleType): Sprite;
166
175
  /**
167
176
  * Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that it
168
177
  * should remove an item.
@@ -1 +1 @@
1
- {"version":3,"file":"collectibles.d.ts","sourceRoot":"","sources":["../../src/functions/collectibles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,eAAe,EAEf,aAAa,EAEb,QAAQ,EACR,WAAW,EAGZ,MAAM,8BAA8B,CAAC;AAgBtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAyB7D,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAEtE;AAED,6FAA6F;AAC7F,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAsBT;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,GAC/B,MAAM,CAeR;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,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YAAY,GAAG,OAAO,CAKnE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAG7E;AAED,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAGT;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAET;AAED,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAGT;AAED,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,eAAe,EAAE,eAAe,GAC/B,IAAI,CAQN;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAS5E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CASnE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAUnE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAuBtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAeN;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,YAAY,EACzB,kBAAkB,EAAE,eAAe,GAClC,IAAI,CA2BN;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,IAAI,IAAI,CAK5D"}
1
+ {"version":3,"file":"collectibles.d.ts","sourceRoot":"","sources":["../../src/functions/collectibles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,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AmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAUnE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAuBtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAeN;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,YAAY,EACzB,kBAAkB,EAAE,eAAe,GAClC,IAAI,CA2BN;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,IAAI,IAAI,CAK5D"}
@@ -105,6 +105,7 @@ function ____exports.setCollectibleSubType(self, collectible, newCollectibleType
105
105
  true
106
106
  )
107
107
  end
108
+ local COLLECTIBLE_ANM2_PATH = "gfx/005.100_collectible.anm2"
108
109
  COLLECTIBLE_SPRITE_LAYER = 1
109
110
  COLLECTIBLE_SHADOW_LAYER = 4
110
111
  local GLITCHED_ITEM_THRESHOLD = 4000000000
@@ -174,8 +175,12 @@ function ____exports.getCollectibleDevilHeartPrice(self, collectibleType, player
174
175
  local twoHeartPrice = maxHearts == 2 and PickupPrice.ONE_HEART_AND_TWO_SOUL_HEARTS or PickupPrice.TWO_HEARTS
175
176
  return itemConfigItem.DevilPrice == 2 and twoHeartPrice or PickupPrice.ONE_HEART
176
177
  end
177
- --- Helper function to get the path to a collectible's sprite. Returns the path to the question mark
178
+ --- Helper function to get the path to a collectible PNG file. Returns the path to the question mark
178
179
  -- sprite (i.e. from Curse of the Blind) if the provided collectible type was not valid.
180
+ --
181
+ -- Note that this does not return the file name, but the full path to the collectible's PNG file.
182
+ -- The function is named "GfxFilename" to correspond to the associated `ItemConfigItem.GfxFileName`
183
+ -- field.
179
184
  function ____exports.getCollectibleGfxFilename(self, collectibleType)
180
185
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
181
186
  if itemConfigItem == nil then
@@ -386,6 +391,17 @@ function ____exports.isValidCollectibleType(self, collectibleType)
386
391
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
387
392
  return itemConfigItem ~= nil
388
393
  end
394
+ --- Helper function to generate a new sprite based on a collectible. If the provided collectible type
395
+ -- is invalid, a sprite with a Curse of the Blind question mark will be returned.
396
+ function ____exports.newCollectibleSprite(self, collectibleType)
397
+ local sprite = Sprite()
398
+ sprite:Load(COLLECTIBLE_ANM2_PATH, false)
399
+ clearSprite(nil, sprite)
400
+ local gfxFileName = ____exports.getCollectibleGfxFilename(nil, collectibleType)
401
+ sprite:ReplaceSpritesheet(COLLECTIBLE_SPRITE_LAYER, gfxFileName)
402
+ sprite:LoadGraphics()
403
+ return sprite
404
+ end
389
405
  --- Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that it
390
406
  -- should remove an item.
391
407
  --
@@ -1,3 +1,12 @@
1
1
  import { LevelCurse } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to get the actual bit flag for modded curses.
4
+ *
5
+ * Will throw a runtime error if the provided curse does not exist.
6
+ *
7
+ * Use this over the `Isaac.GetCurseIdByName` method because that will return an integer instead of
8
+ * a bit flag.
9
+ */
10
+ export declare function getCurseIDByName(name: string): LevelCurse;
2
11
  export declare function hasCurse(curse: LevelCurse): boolean;
3
12
  //# sourceMappingURL=curses.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"curses.d.ts","sourceRoot":"","sources":["../../src/functions/curses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAI1D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAInD"}
1
+ {"version":3,"file":"curses.d.ts","sourceRoot":"","sources":["../../src/functions/curses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAI1D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAWzD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAInD"}
@@ -3,6 +3,19 @@ local ____cachedClasses = require("core.cachedClasses")
3
3
  local game = ____cachedClasses.game
4
4
  local ____flag = require("functions.flag")
5
5
  local hasFlag = ____flag.hasFlag
6
+ --- Helper function to get the actual bit flag for modded curses.
7
+ --
8
+ -- Will throw a runtime error if the provided curse does not exist.
9
+ --
10
+ -- Use this over the `Isaac.GetCurseIdByName` method because that will return an integer instead of
11
+ -- a bit flag.
12
+ function ____exports.getCurseIDByName(self, name)
13
+ local curseID = Isaac.GetCurseIdByName(name)
14
+ if curseID == -1 then
15
+ error(("Failed to get the curse ID corresponding to the curse name of \"" .. tostring(curseID)) .. "\". Does this name match what you put in the \"content/curses.xml\" file?")
16
+ end
17
+ return 1 << curseID - 1
18
+ end
6
19
  function ____exports.hasCurse(self, curse)
7
20
  local level = game:GetLevel()
8
21
  local curses = level:GetCurses()
@@ -26,6 +26,15 @@ export declare function getOpenTrinketSlot(player: EntityPlayer): int | undefine
26
26
  * trinket type was not valid.
27
27
  */
28
28
  export declare function getTrinketDescription(trinketType: TrinketType): string;
29
+ /**
30
+ * Helper function to get the path to a trinket PNG file. Returns the path to the question mark
31
+ * sprite (i.e. from Curse of the Blind) if the provided trinket type was not valid.
32
+ *
33
+ * Note that this does not return the file name, but the full path to the trinket's PNG file. The
34
+ * function is named "GfxFilename" to correspond to the associated `ItemConfigItem.GfxFileName`
35
+ * field.
36
+ */
37
+ export declare function getTrinketGfxFilename(trinketType: TrinketType): string;
29
38
  /**
30
39
  * Helper function to get the name of a trinket. Returns "Unknown" if the provided trinket type is
31
40
  * not valid.
@@ -51,6 +60,11 @@ export declare function hasOpenTrinketSlot(player: EntityPlayer): boolean;
51
60
  export declare function isGoldenTrinketType(trinketType: TrinketType): boolean;
52
61
  export declare function isModdedTrinketType(trinketType: TrinketType): boolean;
53
62
  export declare function isVanillaTrinketType(trinketType: TrinketType): boolean;
63
+ /**
64
+ * Helper function to generate a new sprite based on a collectible. If the provided collectible type
65
+ * is invalid, a sprite with a Curse of the Blind question mark will be returned.
66
+ */
67
+ export declare function newTrinketSprite(trinketType: TrinketType): Sprite;
54
68
  /**
55
69
  * Helper function to change the sprite of a trinket entity.
56
70
  *
@@ -1 +1 @@
1
- {"version":3,"file":"trinkets.d.ts","sourceRoot":"","sources":["../../src/functions/trinkets.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACZ,MAAM,8BAA8B,CAAC;AA6BtC;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAE1E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,GAAG,GAAG,SAAS,CAkBxE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CActE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAc/D;AAED,kFAAkF;AAClF,wBAAgB,sBAAsB,IAAI,WAAW,EAAE,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAOhE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAEtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAeN"}
1
+ {"version":3,"file":"trinkets.d.ts","sourceRoot":"","sources":["../../src/functions/trinkets.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACZ,MAAM,8BAA8B,CAAC;AA+BtC;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAE1E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,GAAG,GAAG,SAAS,CAkBxE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CActE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAOtE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAc/D;AAED,kFAAkF;AAClF,wBAAgB,sBAAsB,IAAI,WAAW,EAAE,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAOhE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAEtE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CASjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAeN"}
@@ -5,6 +5,8 @@ local TrinketSlot = ____isaac_2Dtypescript_2Ddefinitions.TrinketSlot
5
5
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
6
6
  local ____cachedClasses = require("core.cachedClasses")
7
7
  local itemConfig = ____cachedClasses.itemConfig
8
+ local ____constants = require("core.constants")
9
+ local BLIND_ITEM_PNG_PATH = ____constants.BLIND_ITEM_PNG_PATH
8
10
  local ____constantsFirstLast = require("core.constantsFirstLast")
9
11
  local FIRST_TRINKET_TYPE = ____constantsFirstLast.FIRST_TRINKET_TYPE
10
12
  local LAST_VANILLA_TRINKET_TYPE = ____constantsFirstLast.LAST_VANILLA_TRINKET_TYPE
@@ -35,6 +37,7 @@ end
35
37
  --
36
38
  -- 1 << 15
37
39
  local GOLDEN_TRINKET_ADJUSTMENT = 32768
40
+ local TRINKET_ANM2_PATH = "gfx/005.350_trinket.anm2"
38
41
  local TRINKET_SPRITE_LAYER = 0
39
42
  --- Helper function to get the corresponding golden trinket type from a normal trinket type.
40
43
  --
@@ -83,6 +86,19 @@ function ____exports.getTrinketDescription(self, trinketType)
83
86
  end
84
87
  return DEFAULT_TRINKET_DESCRIPTION
85
88
  end
89
+ --- Helper function to get the path to a trinket PNG file. Returns the path to the question mark
90
+ -- sprite (i.e. from Curse of the Blind) if the provided trinket type was not valid.
91
+ --
92
+ -- Note that this does not return the file name, but the full path to the trinket's PNG file. The
93
+ -- function is named "GfxFilename" to correspond to the associated `ItemConfigItem.GfxFileName`
94
+ -- field.
95
+ function ____exports.getTrinketGfxFilename(self, trinketType)
96
+ local itemConfigItem = itemConfig:GetTrinket(trinketType)
97
+ if itemConfigItem == nil then
98
+ return BLIND_ITEM_PNG_PATH
99
+ end
100
+ return itemConfigItem.GfxFileName
101
+ end
86
102
  --- Helper function to get the name of a trinket. Returns "Unknown" if the provided trinket type is
87
103
  -- not valid.
88
104
  --
@@ -125,6 +141,16 @@ end
125
141
  function ____exports.isModdedTrinketType(self, trinketType)
126
142
  return not ____exports.isVanillaTrinketType(nil, trinketType)
127
143
  end
144
+ --- Helper function to generate a new sprite based on a collectible. If the provided collectible type
145
+ -- is invalid, a sprite with a Curse of the Blind question mark will be returned.
146
+ function ____exports.newTrinketSprite(self, trinketType)
147
+ local sprite = Sprite()
148
+ sprite:Load(TRINKET_ANM2_PATH, false)
149
+ local gfxFileName = ____exports.getTrinketGfxFilename(nil, trinketType)
150
+ sprite:ReplaceSpritesheet(TRINKET_SPRITE_LAYER, gfxFileName)
151
+ sprite:LoadGraphics()
152
+ return sprite
153
+ end
128
154
  --- Helper function to change the sprite of a trinket entity.
129
155
  --
130
156
  -- For more information about removing the trinket sprite, see the documentation for the
package/dist/index.d.ts CHANGED
@@ -2280,6 +2280,9 @@ export declare function getAliveNPCs(entityType?: EntityType, variant?: number,
2280
2280
  *
2281
2281
  * The set contains strings with the entity type and variant, separated by a period.
2282
2282
  *
2283
+ * Note that this set does not include bosses that do not appear in Boss Rooms (e.g. Krampus, Uriel,
2284
+ * and Gabriel.).
2285
+ *
2283
2286
  * Also see the `getBossSet` and `getCombinedBossSet` functions.
2284
2287
  *
2285
2288
  * @param includeStoryBosses Optional. Whether to include "story" bosses like Mom and It Lives!
@@ -2592,8 +2595,12 @@ export declare function getCollectibleDevilCoinPrice(collectibleType: Collectibl
2592
2595
  export declare function getCollectibleDevilHeartPrice(collectibleType: CollectibleType, player: EntityPlayer): PickupPrice;
2593
2596
 
2594
2597
  /**
2595
- * Helper function to get the path to a collectible's sprite. Returns the path to the question mark
2598
+ * Helper function to get the path to a collectible PNG file. Returns the path to the question mark
2596
2599
  * sprite (i.e. from Curse of the Blind) if the provided collectible type was not valid.
2600
+ *
2601
+ * Note that this does not return the file name, but the full path to the collectible's PNG file.
2602
+ * The function is named "GfxFilename" to correspond to the associated `ItemConfigItem.GfxFileName`
2603
+ * field.
2597
2604
  */
2598
2605
  export declare function getCollectibleGfxFilename(collectibleType: CollectibleType): string;
2599
2606
 
@@ -2798,6 +2805,16 @@ export declare function getCombinedBossSet(stage: int): ReadonlySet<string> | un
2798
2805
  */
2799
2806
  export declare function getCrawlSpaces(crawlSpaceVariant?: CrawlSpaceVariant): GridEntity[];
2800
2807
 
2808
+ /**
2809
+ * Helper function to get the actual bit flag for modded curses.
2810
+ *
2811
+ * Will throw a runtime error if the provided curse does not exist.
2812
+ *
2813
+ * Use this over the `Isaac.GetCurseIdByName` method because that will return an integer instead of
2814
+ * a bit flag.
2815
+ */
2816
+ export declare function getCurseIDByName(name: string): LevelCurse;
2817
+
2801
2818
  /**
2802
2819
  * Helper function to get the custom grid entities in the current room. Returns an array of tuples
2803
2820
  * containing the raw decoration grid entity and the associated entity data.
@@ -4022,9 +4039,6 @@ export declare function getPlayerIndexVanilla(playerToFind: EntityPlayer): int |
4022
4039
  * Helper function to get all of the collectibles that the player has gotten so far on this run, in
4023
4040
  * order.
4024
4041
  *
4025
- * Note that this does not include active collectibles that have since been dropped for other
4026
- * collectibles.
4027
- *
4028
4042
  * In the case of inventory initialization or the case where the player rerolls their build in the
4029
4043
  * middle of the run (e.g. with D4), the order of the inventory will not correspond to the order
4030
4044
  * that the items were actually given to the player. In this case, the inventory will be in the
@@ -4036,6 +4050,10 @@ export declare function getPlayerIndexVanilla(playerToFind: EntityPlayer): int |
4036
4050
  * would not be updated. In vanilla, this situation would never happen, but another mod might do
4037
4051
  * this for some reason. (With that said, the next time that a collectible is normally added or
4038
4052
  * removed, it would trigger a re-scan, and the previous changes would be picked up.)
4053
+ *
4054
+ * @param player The player to get the inventory for.
4055
+ * @param includeActiveCollectibles Optional. If true, will include all active collectibles. Default
4056
+ * is true.
4039
4057
  */
4040
4058
  export declare function getPlayerInventory(player: EntityPlayer, includeActiveCollectibles?: boolean): CollectibleType[];
4041
4059
 
@@ -4045,6 +4063,14 @@ export declare function getPlayerInventory(player: EntityPlayer, includeActiveCo
4045
4063
  */
4046
4064
  export declare function getPlayerLastHeart(player: EntityPlayer): HealthType;
4047
4065
 
4066
+ /**
4067
+ * Helper function to get the last passive collectible that the player picked up. In most cases,
4068
+ * this will be the passive that is removed when the player would use Clicker.
4069
+ *
4070
+ * Returns undefined if the player does not have any passive collectibles.
4071
+ */
4072
+ export declare function getPlayerLastPassiveCollectible(player: EntityPlayer): CollectibleType | undefined;
4073
+
4048
4074
  /**
4049
4075
  * Returns the maximum heart containers that the provided player can have. Normally, this is 12, but
4050
4076
  * it can change depending on the character (e.g. Keeper) and other things (e.g. Mother's Kiss).
@@ -5016,6 +5042,16 @@ export declare function getTrinketArray(): readonly TrinketType[];
5016
5042
  */
5017
5043
  export declare function getTrinketDescription(trinketType: TrinketType): string;
5018
5044
 
5045
+ /**
5046
+ * Helper function to get the path to a trinket PNG file. Returns the path to the question mark
5047
+ * sprite (i.e. from Curse of the Blind) if the provided trinket type was not valid.
5048
+ *
5049
+ * Note that this does not return the file name, but the full path to the trinket's PNG file. The
5050
+ * function is named "GfxFilename" to correspond to the associated `ItemConfigItem.GfxFileName`
5051
+ * field.
5052
+ */
5053
+ export declare function getTrinketGfxFilename(trinketType: TrinketType): string;
5054
+
5019
5055
  /**
5020
5056
  * Helper function to get the name of a trinket. Returns "Unknown" if the provided trinket type is
5021
5057
  * not valid.
@@ -7548,7 +7584,7 @@ export declare enum ModCallbackCustom {
7548
7584
  POST_PLAYER_CHANGE_TYPE = 57,
7549
7585
  /**
7550
7586
  * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is higher than
7551
- * what it was on the previous frame.
7587
+ * what it was on the previous frame or when a new active collectible is acquired.
7552
7588
  *
7553
7589
  * When registering the callback, takes an optional second argument that will make the callback
7554
7590
  * only fire if the collectible matches the `CollectibleType` provided.
@@ -7563,7 +7599,7 @@ export declare enum ModCallbackCustom {
7563
7599
  POST_PLAYER_COLLECTIBLE_ADDED = 58,
7564
7600
  /**
7565
7601
  * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is lower than
7566
- * what it was on the previous frame.
7602
+ * what it was on the previous frame or when an active collectible is no longer present.
7567
7603
  *
7568
7604
  * When registering the callback, takes an optional second argument that will make the callback
7569
7605
  * only fire if the collectible matches the `CollectibleType` provided.
@@ -8119,6 +8155,12 @@ export declare const NEW_RUN_PLAYER_STARTING_POSITION: Vector;
8119
8155
  */
8120
8156
  export declare function newChargeBarSprites(maxCharges: int): ChargeBarSprites;
8121
8157
 
8158
+ /**
8159
+ * Helper function to generate a new sprite based on a collectible. If the provided collectible type
8160
+ * is invalid, a sprite with a Curse of the Blind question mark will be returned.
8161
+ */
8162
+ export declare function newCollectibleSprite(collectibleType: CollectibleType): Sprite;
8163
+
8122
8164
  export declare function newPickingUpItem(): PickingUpItem;
8123
8165
 
8124
8166
  /** Returns a `PlayerHealth` object with all zeros. */
@@ -8145,6 +8187,12 @@ export declare function newRNG(seed?: Seed): RNG;
8145
8187
  */
8146
8188
  export declare function newRoom(): int | undefined;
8147
8189
 
8190
+ /**
8191
+ * Helper function to generate a new sprite based on a collectible. If the provided collectible type
8192
+ * is invalid, a sprite with a Curse of the Blind question mark will be returned.
8193
+ */
8194
+ export declare function newTrinketSprite(trinketType: TrinketType): Sprite;
8195
+
8148
8196
  /**
8149
8197
  * Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
8150
8198
  * it is. This function requires that you provide an instantiated class of the same type, as it will
@@ -1 +1 @@
1
- {"version":3,"file":"bossSets.d.ts","sourceRoot":"","sources":["../../src/sets/bossSets.ts"],"names":[],"mappings":";AAibA,eAAO,MAAM,mCAAmC,EAAE,WAAW,CAC3D,GAAG,EACH,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAarC,CAAC;AAEH,eAAO,MAAM,8BAA8B,EAAE,WAAW,CACtD,GAAG,EACH,WAAW,CAAC,MAAM,CAAC,CAanB,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAQ7C,CAAC;AAiBH,eAAO,MAAM,qCAAqC,EAAE,WAAW,CAAC,MAAM,CACpC,CAAC"}
1
+ {"version":3,"file":"bossSets.d.ts","sourceRoot":"","sources":["../../src/sets/bossSets.ts"],"names":[],"mappings":";AAibA,eAAO,MAAM,mCAAmC,EAAE,WAAW,CAC3D,GAAG,EACH,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAarC,CAAC;AAEH,eAAO,MAAM,8BAA8B,EAAE,WAAW,CACtD,GAAG,EACH,WAAW,CAAC,MAAM,CAAC,CAanB,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAQ7C,CAAC;AAEH,eAAO,MAAM,qCAAqC,qBACX,CAAC"}
@@ -7,6 +7,7 @@ local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
7
7
  local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
8
8
  local Map = ____lualib.Map
9
9
  local ____exports = {}
10
+ local getAllBossesExcludingStoryBossesSet
10
11
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
11
12
  local BigHornVariant = ____isaac_2Dtypescript_2Ddefinitions.BigHornVariant
12
13
  local ChubVariant = ____isaac_2Dtypescript_2Ddefinitions.ChubVariant
@@ -43,6 +44,21 @@ local ____set = require("functions.set")
43
44
  local copySet = ____set.copySet
44
45
  local ____storyBossesSet = require("sets.storyBossesSet")
45
46
  local STORY_BOSSES_SET = ____storyBossesSet.STORY_BOSSES_SET
47
+ function getAllBossesExcludingStoryBossesSet(self)
48
+ local allBossesExcludingStoryBossesSet = copySet(nil, ____exports.ALL_BOSSES_SET)
49
+ local allBosses = {__TS__Spread(____exports.ALL_BOSSES_SET:values())}
50
+ for ____, entityTypeVariantString in ipairs(allBosses) do
51
+ local tuple = parseEntityTypeVariantString(nil, entityTypeVariantString)
52
+ if tuple == nil then
53
+ error("Failed to parse a boss tuple when constructing the story boss set.")
54
+ end
55
+ local entityType, _variant = table.unpack(tuple)
56
+ if STORY_BOSSES_SET:has(entityType) then
57
+ allBossesExcludingStoryBossesSet:delete(entityTypeVariantString)
58
+ end
59
+ end
60
+ return allBossesExcludingStoryBossesSet
61
+ end
46
62
  --- Contains just the bosses in Basement (not e.g. Burning Basement).
47
63
  local BASEMENT_BOSSES_SET = __TS__New(
48
64
  Set,
@@ -557,17 +573,5 @@ ____exports.ALL_BOSSES_SET = __TS__New(
557
573
  ____Set_13,
558
574
  {__TS__SparseArraySpread(____array_12)}
559
575
  )
560
- local allBossesExcludingStoryBossesSet = copySet(nil, ____exports.ALL_BOSSES_SET)
561
- local allBosses = {__TS__Spread(____exports.ALL_BOSSES_SET:values())}
562
- for ____, entityTypeVariantString in ipairs(allBosses) do
563
- local tuple = parseEntityTypeVariantString(nil, entityTypeVariantString)
564
- if tuple == nil then
565
- error("Failed to parse a boss tuple when constructing the story boss set.")
566
- end
567
- local entityType, _variant = table.unpack(tuple)
568
- if STORY_BOSSES_SET:has(entityType) then
569
- allBossesExcludingStoryBossesSet:delete(entityTypeVariantString)
570
- end
571
- end
572
- ____exports.ALL_BOSSES_EXCLUDING_STORY_BOSSES_SET = allBossesExcludingStoryBossesSet
576
+ ____exports.ALL_BOSSES_EXCLUDING_STORY_BOSSES_SET = getAllBossesExcludingStoryBossesSet(nil)
573
577
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "8.5.0",
3
+ "version": "8.8.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -959,7 +959,7 @@ export enum ModCallbackCustom {
959
959
 
960
960
  /**
961
961
  * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is higher than
962
- * what it was on the previous frame.
962
+ * what it was on the previous frame or when a new active collectible is acquired.
963
963
  *
964
964
  * When registering the callback, takes an optional second argument that will make the callback
965
965
  * only fire if the collectible matches the `CollectibleType` provided.
@@ -975,7 +975,7 @@ export enum ModCallbackCustom {
975
975
 
976
976
  /**
977
977
  * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is lower than
978
- * what it was on the previous frame.
978
+ * what it was on the previous frame or when an active collectible is no longer present.
979
979
  *
980
980
  * When registering the callback, takes an optional second argument that will make the callback
981
981
  * only fire if the collectible matches the `CollectibleType` provided.
@@ -3,7 +3,11 @@ import { DefaultMap } from "../classes/DefaultMap";
3
3
  import { ModUpgraded } from "../classes/ModUpgraded";
4
4
  import { ModCallbackCustom } from "../enums/ModCallbackCustom";
5
5
  import { errorIfFeaturesNotInitialized } from "../featuresInitialized";
6
- import { arrayRemoveInPlace, copyArray } from "../functions/array";
6
+ import {
7
+ arrayRemoveInPlace,
8
+ copyArray,
9
+ getLastElement,
10
+ } from "../functions/array";
7
11
  import { isActiveCollectible } from "../functions/collectibles";
8
12
  import { getCollectibleArray } from "../functions/collectibleSet";
9
13
  import {
@@ -31,10 +35,16 @@ function newPlayerInventory(player: EntityPlayer) {
31
35
  const inventory: CollectibleType[] = [];
32
36
 
33
37
  for (const collectibleType of getCollectibleArray()) {
34
- const numCollectibles = player.GetCollectibleNum(collectibleType, true);
35
- repeat(numCollectibles, () => {
36
- inventory.push(collectibleType);
37
- });
38
+ // We have to use the `EntityPlayer.HasCollectible` method in addition to the
39
+ // `EntityPlayer.GetCollectibleNum` method in order to mitigate situations like Lilith's Incubus
40
+ // counting as a collectible. (The former method will return false for her innate Incubus, but
41
+ // the latter method will return 1.)
42
+ if (player.HasCollectible(collectibleType)) {
43
+ const numCollectibles = player.GetCollectibleNum(collectibleType, true);
44
+ repeat(numCollectibles, () => {
45
+ inventory.push(collectibleType);
46
+ });
47
+ }
38
48
  }
39
49
 
40
50
  return inventory;
@@ -68,6 +78,9 @@ function useItemD4(
68
78
  _rng: RNG,
69
79
  player: EntityPlayer,
70
80
  ): boolean | undefined {
81
+ // This function is also triggered when the player uses D100, D Infinity, a 1-pip dice room, or a
82
+ // 6-pip dice room. (Genesis should be automatically handled by the
83
+ // `POST_PLAYER_COLLECTIBLE_REMOVED` callback.)
71
84
  resetInventory(player);
72
85
 
73
86
  return undefined;
@@ -107,9 +120,6 @@ function postCollectibleRemoved(
107
120
  * Helper function to get all of the collectibles that the player has gotten so far on this run, in
108
121
  * order.
109
122
  *
110
- * Note that this does not include active collectibles that have since been dropped for other
111
- * collectibles.
112
- *
113
123
  * In the case of inventory initialization or the case where the player rerolls their build in the
114
124
  * middle of the run (e.g. with D4), the order of the inventory will not correspond to the order
115
125
  * that the items were actually given to the player. In this case, the inventory will be in the
@@ -121,6 +131,10 @@ function postCollectibleRemoved(
121
131
  * would not be updated. In vanilla, this situation would never happen, but another mod might do
122
132
  * this for some reason. (With that said, the next time that a collectible is normally added or
123
133
  * removed, it would trigger a re-scan, and the previous changes would be picked up.)
134
+ *
135
+ * @param player The player to get the inventory for.
136
+ * @param includeActiveCollectibles Optional. If true, will include all active collectibles. Default
137
+ * is true.
124
138
  */
125
139
  export function getPlayerInventory(
126
140
  player: EntityPlayer,
@@ -139,3 +153,18 @@ export function getPlayerInventory(
139
153
  (collectibleType) => !isActiveCollectible(collectibleType),
140
154
  );
141
155
  }
156
+
157
+ /**
158
+ * Helper function to get the last passive collectible that the player picked up. In most cases,
159
+ * this will be the passive that is removed when the player would use Clicker.
160
+ *
161
+ * Returns undefined if the player does not have any passive collectibles.
162
+ */
163
+ export function getPlayerLastPassiveCollectible(
164
+ player: EntityPlayer,
165
+ ): CollectibleType | undefined {
166
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
167
+
168
+ const inventory = getPlayerInventory(player, false);
169
+ return getLastElement(inventory);
170
+ }
@@ -56,6 +56,9 @@ export function getAliveBosses(
56
56
  *
57
57
  * The set contains strings with the entity type and variant, separated by a period.
58
58
  *
59
+ * Note that this set does not include bosses that do not appear in Boss Rooms (e.g. Krampus, Uriel,
60
+ * and Gabriel.).
61
+ *
59
62
  * Also see the `getBossSet` and `getCombinedBossSet` functions.
60
63
  *
61
64
  * @param includeStoryBosses Optional. Whether to include "story" bosses like Mom and It Lives!
@@ -31,6 +31,7 @@ import { getRoomListIndex } from "./roomData";
31
31
  import { clearSprite, spriteEquals } from "./sprites";
32
32
  import { irange } from "./utils";
33
33
 
34
+ const COLLECTIBLE_ANM2_PATH = "gfx/005.100_collectible.anm2";
34
35
  const COLLECTIBLE_SPRITE_LAYER = 1;
35
36
  const COLLECTIBLE_SHADOW_LAYER = 4;
36
37
 
@@ -159,8 +160,12 @@ export function getCollectibleDevilHeartPrice(
159
160
  }
160
161
 
161
162
  /**
162
- * Helper function to get the path to a collectible's sprite. Returns the path to the question mark
163
+ * Helper function to get the path to a collectible PNG file. Returns the path to the question mark
163
164
  * sprite (i.e. from Curse of the Blind) if the provided collectible type was not valid.
165
+ *
166
+ * Note that this does not return the file name, but the full path to the collectible's PNG file.
167
+ * The function is named "GfxFilename" to correspond to the associated `ItemConfigItem.GfxFileName`
168
+ * field.
164
169
  */
165
170
  export function getCollectibleGfxFilename(
166
171
  collectibleType: CollectibleType,
@@ -469,6 +474,25 @@ export function isVanillaCollectibleType(
469
474
  return collectibleType <= LAST_VANILLA_COLLECTIBLE_TYPE;
470
475
  }
471
476
 
477
+ /**
478
+ * Helper function to generate a new sprite based on a collectible. If the provided collectible type
479
+ * is invalid, a sprite with a Curse of the Blind question mark will be returned.
480
+ */
481
+ export function newCollectibleSprite(collectibleType: CollectibleType): Sprite {
482
+ const sprite = Sprite();
483
+ sprite.Load(COLLECTIBLE_ANM2_PATH, false);
484
+
485
+ // We want to clear the pedestal layers so that the returned sprite only has the collectible
486
+ // image.
487
+ clearSprite(sprite);
488
+
489
+ const gfxFileName = getCollectibleGfxFilename(collectibleType);
490
+ sprite.ReplaceSpritesheet(COLLECTIBLE_SPRITE_LAYER, gfxFileName);
491
+ sprite.LoadGraphics();
492
+
493
+ return sprite;
494
+ }
495
+
472
496
  /**
473
497
  * Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that it
474
498
  * should remove an item.
@@ -2,6 +2,27 @@ import { LevelCurse } from "isaac-typescript-definitions";
2
2
  import { game } from "../core/cachedClasses";
3
3
  import { hasFlag } from "./flag";
4
4
 
5
+ /**
6
+ * Helper function to get the actual bit flag for modded curses.
7
+ *
8
+ * Will throw a runtime error if the provided curse does not exist.
9
+ *
10
+ * Use this over the `Isaac.GetCurseIdByName` method because that will return an integer instead of
11
+ * a bit flag.
12
+ */
13
+ export function getCurseIDByName(name: string): LevelCurse {
14
+ const curseID = Isaac.GetCurseIdByName(name);
15
+ if (curseID === -1) {
16
+ error(
17
+ `Failed to get the curse ID corresponding to the curse name of "${curseID}". Does this name match what you put in the "content/curses.xml" file?`,
18
+ );
19
+ }
20
+
21
+ // For example, the final vanilla curse is "Curse of the Giant", which has an ID of 8. This
22
+ // corresponds to `LevelCurse.GIANT`, which has a value of `1 << 7`.
23
+ return (1 << (curseID - 1)) as LevelCurse;
24
+ }
25
+
5
26
  export function hasCurse(curse: LevelCurse): boolean {
6
27
  const level = game.GetLevel();
7
28
  const curses = level.GetCurses();
@@ -4,6 +4,7 @@ import {
4
4
  TrinketType,
5
5
  } from "isaac-typescript-definitions";
6
6
  import { itemConfig } from "../core/cachedClasses";
7
+ import { BLIND_ITEM_PNG_PATH } from "../core/constants";
7
8
  import {
8
9
  FIRST_TRINKET_TYPE,
9
10
  LAST_VANILLA_TRINKET_TYPE,
@@ -29,6 +30,7 @@ import { irange } from "./utils";
29
30
  */
30
31
  const GOLDEN_TRINKET_ADJUSTMENT = 32768;
31
32
 
33
+ const TRINKET_ANM2_PATH = "gfx/005.350_trinket.anm2";
32
34
  const TRINKET_SPRITE_LAYER = 0;
33
35
 
34
36
  /**
@@ -95,6 +97,23 @@ export function getTrinketDescription(trinketType: TrinketType): string {
95
97
  return DEFAULT_TRINKET_DESCRIPTION;
96
98
  }
97
99
 
100
+ /**
101
+ * Helper function to get the path to a trinket PNG file. Returns the path to the question mark
102
+ * sprite (i.e. from Curse of the Blind) if the provided trinket type was not valid.
103
+ *
104
+ * Note that this does not return the file name, but the full path to the trinket's PNG file. The
105
+ * function is named "GfxFilename" to correspond to the associated `ItemConfigItem.GfxFileName`
106
+ * field.
107
+ */
108
+ export function getTrinketGfxFilename(trinketType: TrinketType): string {
109
+ const itemConfigItem = itemConfig.GetTrinket(trinketType);
110
+ if (itemConfigItem === undefined) {
111
+ return BLIND_ITEM_PNG_PATH;
112
+ }
113
+
114
+ return itemConfigItem.GfxFileName;
115
+ }
116
+
98
117
  /**
99
118
  * Helper function to get the name of a trinket. Returns "Unknown" if the provided trinket type is
100
119
  * not valid.
@@ -155,6 +174,21 @@ export function isVanillaTrinketType(trinketType: TrinketType): boolean {
155
174
  return trinketType <= LAST_VANILLA_TRINKET_TYPE;
156
175
  }
157
176
 
177
+ /**
178
+ * Helper function to generate a new sprite based on a collectible. If the provided collectible type
179
+ * is invalid, a sprite with a Curse of the Blind question mark will be returned.
180
+ */
181
+ export function newTrinketSprite(trinketType: TrinketType): Sprite {
182
+ const sprite = Sprite();
183
+ sprite.Load(TRINKET_ANM2_PATH, false);
184
+
185
+ const gfxFileName = getTrinketGfxFilename(trinketType);
186
+ sprite.ReplaceSpritesheet(TRINKET_SPRITE_LAYER, gfxFileName);
187
+ sprite.LoadGraphics();
188
+
189
+ return sprite;
190
+ }
191
+
158
192
  /**
159
193
  * Helper function to change the sprite of a trinket entity.
160
194
  *
@@ -475,20 +475,29 @@ export const ALL_BOSSES_SET: ReadonlySet<string> = new Set([
475
475
  ...ALL_STAGE_11_BOSSES_SET.values(),
476
476
  ]);
477
477
 
478
- // Since story bosses are stored by entity type, we copy the existing bosses and filter them (to
479
- // avoid having to hard-code story boss variants).
480
- const allBossesExcludingStoryBossesSet = copySet(ALL_BOSSES_SET);
481
- const allBosses = [...ALL_BOSSES_SET.values()];
482
- for (const entityTypeVariantString of allBosses) {
483
- const tuple = parseEntityTypeVariantString(entityTypeVariantString);
484
- if (tuple === undefined) {
485
- error("Failed to parse a boss tuple when constructing the story boss set.");
478
+ export const ALL_BOSSES_EXCLUDING_STORY_BOSSES_SET =
479
+ getAllBossesExcludingStoryBossesSet();
480
+
481
+ /**
482
+ * Since story bosses are stored by entity type, we copy the existing bosses and filter them (to
483
+ * avoid having to hard-code story boss variants).
484
+ */
485
+ function getAllBossesExcludingStoryBossesSet(): ReadonlySet<string> {
486
+ const allBossesExcludingStoryBossesSet = copySet(ALL_BOSSES_SET);
487
+ const allBosses = [...ALL_BOSSES_SET.values()];
488
+ for (const entityTypeVariantString of allBosses) {
489
+ const tuple = parseEntityTypeVariantString(entityTypeVariantString);
490
+ if (tuple === undefined) {
491
+ error(
492
+ "Failed to parse a boss tuple when constructing the story boss set.",
493
+ );
494
+ }
495
+
496
+ const [entityType, _variant] = tuple;
497
+ if (STORY_BOSSES_SET.has(entityType)) {
498
+ allBossesExcludingStoryBossesSet.delete(entityTypeVariantString);
499
+ }
486
500
  }
487
501
 
488
- const [entityType, _variant] = tuple;
489
- if (STORY_BOSSES_SET.has(entityType)) {
490
- allBossesExcludingStoryBossesSet.delete(entityTypeVariantString);
491
- }
502
+ return allBossesExcludingStoryBossesSet;
492
503
  }
493
- export const ALL_BOSSES_EXCLUDING_STORY_BOSSES_SET: ReadonlySet<string> =
494
- allBossesExcludingStoryBossesSet;