isaacscript-common 8.6.0 → 8.8.1

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.
@@ -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;AA6G5E;;;;;;;;;;;;;;;;;;;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"}
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"}
@@ -33,14 +33,16 @@ local saveDataManager = ____exports.saveDataManager
33
33
  function newPlayerInventory(self, player)
34
34
  local inventory = {}
35
35
  for ____, collectibleType in ipairs(getCollectibleArray(nil)) do
36
- local numCollectibles = player:GetCollectibleNum(collectibleType, true)
37
- ____repeat(
38
- nil,
39
- numCollectibles,
40
- function()
41
- inventory[#inventory + 1] = collectibleType
42
- end
43
- )
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
44
46
  end
45
47
  return inventory
46
48
  end
@@ -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,CAC1C,eAAe,EAAE,eAAe,GAC/B,GAAG,CAYL;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,YAAY,GACnB,WAAW,CAyBb;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,GAC/B,MAAM,CAOR;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,YAAY,GACxB,gBAAgB,CAsBlB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,GAC/B,GAAG,CAOL;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,eAAe,GAC/B,QAAQ,CAOV;AAED;;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G7E;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;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,CAa7E;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"}
@@ -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,wBAA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AMG;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
@@ -2595,8 +2595,12 @@ export declare function getCollectibleDevilCoinPrice(collectibleType: Collectibl
2595
2595
  export declare function getCollectibleDevilHeartPrice(collectibleType: CollectibleType, player: EntityPlayer): PickupPrice;
2596
2596
 
2597
2597
  /**
2598
- * 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
2599
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.
2600
2604
  */
2601
2605
  export declare function getCollectibleGfxFilename(collectibleType: CollectibleType): string;
2602
2606
 
@@ -2801,6 +2805,16 @@ export declare function getCombinedBossSet(stage: int): ReadonlySet<string> | un
2801
2805
  */
2802
2806
  export declare function getCrawlSpaces(crawlSpaceVariant?: CrawlSpaceVariant): GridEntity[];
2803
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
+
2804
2818
  /**
2805
2819
  * Helper function to get the custom grid entities in the current room. Returns an array of tuples
2806
2820
  * containing the raw decoration grid entity and the associated entity data.
@@ -5028,6 +5042,16 @@ export declare function getTrinketArray(): readonly TrinketType[];
5028
5042
  */
5029
5043
  export declare function getTrinketDescription(trinketType: TrinketType): string;
5030
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
+
5031
5055
  /**
5032
5056
  * Helper function to get the name of a trinket. Returns "Unknown" if the provided trinket type is
5033
5057
  * not valid.
@@ -7560,7 +7584,7 @@ export declare enum ModCallbackCustom {
7560
7584
  POST_PLAYER_CHANGE_TYPE = 57,
7561
7585
  /**
7562
7586
  * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is higher than
7563
- * what it was on the previous frame.
7587
+ * what it was on the previous frame or when a new active collectible is acquired.
7564
7588
  *
7565
7589
  * When registering the callback, takes an optional second argument that will make the callback
7566
7590
  * only fire if the collectible matches the `CollectibleType` provided.
@@ -7575,7 +7599,7 @@ export declare enum ModCallbackCustom {
7575
7599
  POST_PLAYER_COLLECTIBLE_ADDED = 58,
7576
7600
  /**
7577
7601
  * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is lower than
7578
- * what it was on the previous frame.
7602
+ * what it was on the previous frame or when an active collectible is no longer present.
7579
7603
  *
7580
7604
  * When registering the callback, takes an optional second argument that will make the callback
7581
7605
  * only fire if the collectible matches the `CollectibleType` provided.
@@ -8131,6 +8155,12 @@ export declare const NEW_RUN_PLAYER_STARTING_POSITION: Vector;
8131
8155
  */
8132
8156
  export declare function newChargeBarSprites(maxCharges: int): ChargeBarSprites;
8133
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
+
8134
8164
  export declare function newPickingUpItem(): PickingUpItem;
8135
8165
 
8136
8166
  /** Returns a `PlayerHealth` object with all zeros. */
@@ -8157,6 +8187,12 @@ export declare function newRNG(seed?: Seed): RNG;
8157
8187
  */
8158
8188
  export declare function newRoom(): int | undefined;
8159
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
+
8160
8196
  /**
8161
8197
  * Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
8162
8198
  * it is. This function requires that you provide an instantiated class of the same type, as it will
@@ -241,7 +241,7 @@ local MINES_BOSSES_SET = __TS__New(
241
241
  (tostring(EntityType.LARRY_JR) .. ".") .. tostring(LarryJrVariant.TUFF_TWIN),
242
242
  tostring(EntityType.REAP_CREEP) .. ".0",
243
243
  tostring(EntityType.HORNFEL) .. ".0",
244
- tostring(EntityType.GIDEON) .. ".0"
244
+ tostring(EntityType.GREAT_GIDEON) .. ".0"
245
245
  }
246
246
  )
247
247
  --- Contains just the bosses in Ashpit (not e.g. Flooded Caves).
@@ -250,7 +250,7 @@ local ASHPIT_BOSSES_SET = __TS__New(
250
250
  {
251
251
  (tostring(EntityType.LARRY_JR) .. ".") .. tostring(LarryJrVariant.THE_SHELL),
252
252
  (tostring(EntityType.POLYCEPHALUS) .. ".") .. tostring(PolycephalusVariant.THE_PILE),
253
- tostring(EntityType.GIDEON) .. ".0",
253
+ tostring(EntityType.GREAT_GIDEON) .. ".0",
254
254
  tostring(EntityType.SINGE) .. ".0",
255
255
  tostring(EntityType.CLUTCH) .. ".0"
256
256
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "8.6.0",
3
+ "version": "8.8.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "dist/index",
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^3.5.2"
25
+ "isaac-typescript-definitions": "^3.6.1"
26
26
  }
27
27
  }
@@ -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.
@@ -35,10 +35,16 @@ function newPlayerInventory(player: EntityPlayer) {
35
35
  const inventory: CollectibleType[] = [];
36
36
 
37
37
  for (const collectibleType of getCollectibleArray()) {
38
- const numCollectibles = player.GetCollectibleNum(collectibleType, true);
39
- repeat(numCollectibles, () => {
40
- inventory.push(collectibleType);
41
- });
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
+ }
42
48
  }
43
49
 
44
50
  return inventory;
@@ -72,6 +78,9 @@ function useItemD4(
72
78
  _rng: RNG,
73
79
  player: EntityPlayer,
74
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.)
75
84
  resetInventory(player);
76
85
 
77
86
  return undefined;
@@ -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
  *
@@ -193,14 +193,14 @@ const MINES_BOSSES_SET: ReadonlySet<string> = new Set([
193
193
  `${EntityType.LARRY_JR}.${LarryJrVariant.TUFF_TWIN}`, // 19.2
194
194
  `${EntityType.REAP_CREEP}.0`, // 900.0
195
195
  `${EntityType.HORNFEL}.0`, // 906.0
196
- `${EntityType.GIDEON}.0`, // 907.0
196
+ `${EntityType.GREAT_GIDEON}.0`, // 907.0
197
197
  ]);
198
198
 
199
199
  /** Contains just the bosses in Ashpit (not e.g. Flooded Caves). */
200
200
  const ASHPIT_BOSSES_SET: ReadonlySet<string> = new Set([
201
201
  `${EntityType.LARRY_JR}.${LarryJrVariant.THE_SHELL}`, // 19.3
202
202
  `${EntityType.POLYCEPHALUS}.${PolycephalusVariant.THE_PILE}`, // 269.1
203
- `${EntityType.GIDEON}.0`, // 907.0
203
+ `${EntityType.GREAT_GIDEON}.0`, // 907.0
204
204
  `${EntityType.SINGE}.0`, // 915.0
205
205
  `${EntityType.CLUTCH}.0`, // 921.0
206
206
  ]);