isaacscript-common 3.13.0 → 3.14.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.
package/constants.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module Constants
3
3
  */
4
- import { ItemPoolType, LevelStage, RoomType } from "isaac-typescript-definitions";
4
+ import { CollectibleType, ItemPoolType, LevelStage, RoomType } from "isaac-typescript-definitions";
5
5
  /**
6
6
  * The distance of the laser when Azazel does not have any range up items yet. For more info, see
7
7
  * the documentation for the `getAzazelBrimstoneDistance` function.
@@ -34,7 +34,7 @@ export declare const EMPTY_PNG_PATH = "gfx/none.png";
34
34
  * encountered by the player. The first TMTRAINER item takes the final possible 32 bit number. The
35
35
  * second TMTRAINER item subtracts one from that, and so on.
36
36
  */
37
- export declare const FIRST_GLITCHED_COLLECTIBLE_TYPE: number;
37
+ export declare const FIRST_GLITCHED_COLLECTIBLE_TYPE: CollectibleType;
38
38
  export declare const GAME_FRAMES_PER_SECOND = 30;
39
39
  export declare const GRID_INDEX_CENTER_OF_1X1_ROOM = 67;
40
40
  export declare const ISAAC_FRAMES_PER_SECOND = 60;
@@ -191,6 +191,11 @@ export declare function setCollectibleBlind(collectible: EntityPickup): void;
191
191
  * For more information, see the documentation for the "clearSprite" helper function.
192
192
  */
193
193
  export declare function setCollectibleEmpty(collectible: EntityPickup): void;
194
+ /**
195
+ * Helper function to change a collectible into a "glitched" item (like the ones that appear when
196
+ * the player has TMTRAINER).
197
+ */
198
+ export declare function setCollectibleGlitched(collectible: EntityPickup): void;
194
199
  /**
195
200
  * Helper function to change the sprite of a collectible pedestal entity.
196
201
  *
@@ -13,6 +13,7 @@ local game = ____cachedClasses.game
13
13
  local itemConfig = ____cachedClasses.itemConfig
14
14
  local ____constants = require("constants")
15
15
  local BLIND_ITEM_PNG_PATH = ____constants.BLIND_ITEM_PNG_PATH
16
+ local DEFAULT_ITEM_POOL_TYPE = ____constants.DEFAULT_ITEM_POOL_TYPE
16
17
  local ____constantsFirstLast = require("constantsFirstLast")
17
18
  local FIRST_COLLECTIBLE_TYPE = ____constantsFirstLast.FIRST_COLLECTIBLE_TYPE
18
19
  local FIRST_MODDED_COLLECTIBLE_TYPE = ____constantsFirstLast.FIRST_MODDED_COLLECTIBLE_TYPE
@@ -44,6 +45,22 @@ function initQuestionMarkSprite(self)
44
45
  sprite:LoadGraphics()
45
46
  return sprite
46
47
  end
48
+ function ____exports.clearCollectibleSprite(self, collectible)
49
+ ____exports.setCollectibleSprite(nil, collectible, nil)
50
+ end
51
+ --- Helper function to remove the collectible from a collectible pedestal and make it appear as if a
52
+ -- player has already taken the item. This is accomplished by changing the sub-type to
53
+ -- `CollectibleType.NULL` and then setting the sprite to an empty/missing PNG file.
54
+ --
55
+ -- For more information, see the documentation for the "clearSprite" helper function.
56
+ function ____exports.setCollectibleEmpty(self, collectible)
57
+ if not isCollectible(nil, collectible) then
58
+ local entityID = getEntityID(nil, collectible)
59
+ error("The \"setCollectibleEmpty\" function was given a non-collectible: " .. entityID)
60
+ end
61
+ collectible.SubType = CollectibleType.NULL
62
+ ____exports.clearCollectibleSprite(nil, collectible)
63
+ end
47
64
  --- Helper function to change the sprite of a collectible pedestal entity.
48
65
  --
49
66
  -- For more information about removing the collectible sprite, see the documentation for the
@@ -67,13 +84,30 @@ function ____exports.setCollectibleSprite(self, collectible, pngPath)
67
84
  sprite:LoadGraphics()
68
85
  end
69
86
  end
87
+ --- Helper function to change the collectible on a pedestal. Simply updating the `SubType` property
88
+ -- is not sufficient because the sprite will not change.
89
+ function ____exports.setCollectibleSubType(self, collectible, newCollectibleType)
90
+ if not isCollectible(nil, collectible) then
91
+ local entityID = getEntityID(nil, collectible)
92
+ error("The \"setCollectibleSubType\" function was given a non-collectible: " .. entityID)
93
+ end
94
+ if newCollectibleType == CollectibleType.NULL then
95
+ ____exports.setCollectibleEmpty(nil, collectible)
96
+ return
97
+ end
98
+ collectible:Morph(
99
+ EntityType.PICKUP,
100
+ PickupVariant.COLLECTIBLE,
101
+ newCollectibleType,
102
+ true,
103
+ true,
104
+ true
105
+ )
106
+ end
70
107
  COLLECTIBLE_SPRITE_LAYER = 1
71
108
  COLLECTIBLE_SHADOW_LAYER = 4
72
109
  local GLITCHED_ITEM_THRESHOLD = 4000000000
73
110
  local questionMarkSprite = initQuestionMarkSprite(nil)
74
- function ____exports.clearCollectibleSprite(self, collectible)
75
- ____exports.setCollectibleSprite(nil, collectible, nil)
76
- end
77
111
  --- Helper function to check if two collectible sprites have the same sprite sheet loaded.
78
112
  function ____exports.collectibleSpriteEquals(self, sprite1, sprite2)
79
113
  local xStart = -1
@@ -384,38 +418,24 @@ function ____exports.setCollectibleBlind(self, collectible)
384
418
  end
385
419
  ____exports.setCollectibleSprite(nil, collectible, BLIND_ITEM_PNG_PATH)
386
420
  end
387
- --- Helper function to remove the collectible from a collectible pedestal and make it appear as if a
388
- -- player has already taken the item. This is accomplished by changing the sub-type to
389
- -- `CollectibleType.NULL` and then setting the sprite to an empty/missing PNG file.
390
- --
391
- -- For more information, see the documentation for the "clearSprite" helper function.
392
- function ____exports.setCollectibleEmpty(self, collectible)
421
+ --- Helper function to change a collectible into a "glitched" item (like the ones that appear when
422
+ -- the player has TMTRAINER).
423
+ function ____exports.setCollectibleGlitched(self, collectible)
393
424
  if not isCollectible(nil, collectible) then
394
425
  local entityID = getEntityID(nil, collectible)
395
- error("The \"setCollectibleEmpty\" function was given a non-collectible: " .. entityID)
426
+ error("The \"setCollectibleGlitched\" function was given a non-collectible: " .. entityID)
396
427
  end
397
- collectible.SubType = CollectibleType.NULL
398
- ____exports.clearCollectibleSprite(nil, collectible)
399
- end
400
- --- Helper function to change the collectible on a pedestal. Simply updating the `SubType` property
401
- -- is not sufficient because the sprite will not change.
402
- function ____exports.setCollectibleSubType(self, collectible, newCollectibleType)
403
- if not isCollectible(nil, collectible) then
404
- local entityID = getEntityID(nil, collectible)
405
- error("The \"setCollectibleSubType\" function was given a non-collectible: " .. entityID)
428
+ local player = Isaac.GetPlayer()
429
+ local hasTMTRAINER = player:HasCollectible(CollectibleType.TMTRAINER)
430
+ if not hasTMTRAINER then
431
+ player:AddCollectible(CollectibleType.TMTRAINER, 0, false)
406
432
  end
407
- if newCollectibleType == CollectibleType.NULL then
408
- ____exports.setCollectibleEmpty(nil, collectible)
409
- return
433
+ local itemPool = game:GetItemPool()
434
+ local collectibleType = itemPool:GetCollectible(DEFAULT_ITEM_POOL_TYPE)
435
+ ____exports.setCollectibleSubType(nil, collectible, collectibleType)
436
+ if not hasTMTRAINER then
437
+ player:RemoveCollectible(CollectibleType.TMTRAINER)
410
438
  end
411
- collectible:Morph(
412
- EntityType.PICKUP,
413
- PickupVariant.COLLECTIBLE,
414
- newCollectibleType,
415
- true,
416
- true,
417
- true
418
- )
419
439
  end
420
440
  --- Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that
421
441
  -- the build has been rerolled.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "3.13.0",
3
+ "version": "3.14.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",