isaacscript-common 1.2.101 → 1.2.104

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.
@@ -63,8 +63,6 @@ export declare const FINAL_STAGE: number;
63
63
  * second TMTRAINER item subtracts one from that, and so on.
64
64
  */
65
65
  export declare const FIRST_GLITCHED_COLLECTIBLE_TYPE: number;
66
- export declare const GENESIS_ROOM_VARIANT = -1;
67
- export declare const GENESIS_ROOM_SUBTYPE = -1;
68
66
  export declare const GOLDEN_TRINKET_SHIFT: number;
69
67
  export declare const GRID_INDEX_CENTER_OF_1X1_ROOM = 67;
70
68
  export declare const GAME_FRAMES_PER_SECOND = 30;
@@ -79,8 +79,6 @@ ____exports.FAMILIARS_THAT_SHOOT_PLAYER_TEARS = __TS__New(Set, {
79
79
  })
80
80
  ____exports.FINAL_STAGE = LevelStage.NUM_STAGES - 1
81
81
  ____exports.FIRST_GLITCHED_COLLECTIBLE_TYPE = (1 << 32) - 1
82
- ____exports.GENESIS_ROOM_VARIANT = -1
83
- ____exports.GENESIS_ROOM_SUBTYPE = -1
84
82
  ____exports.GOLDEN_TRINKET_SHIFT = 1 << 15
85
83
  ____exports.GRID_INDEX_CENTER_OF_1X1_ROOM = 67
86
84
  ____exports.GAME_FRAMES_PER_SECOND = 30
@@ -3,7 +3,7 @@
3
3
  * Helper function to add and remove familiars based on a target amount that you specify. Use this
4
4
  * instead of the `EntityPlayer.CheckFamiliar` method so that the InitSeed of the spawned familiar
5
5
  * will be set properly. Note that when using this function, you need to manually account for Box of
6
- * Friends (by looking at the number of collectible effects on the player for Box of Friends).
6
+ * Friends and Monster Manual (by looking at the number of collectible effects for the familiar).
7
7
  *
8
8
  * This function is meant to be called in the EvaluateCache callback (when the cache flag is equal
9
9
  * to `CacheFlag.CACHE_FAMILIARS`).
@@ -33,8 +33,9 @@ export declare function checkFamiliar(player: EntityPlayer, collectibleType: int
33
33
  * to `CacheFlag.CACHE_FAMILIARS`).
34
34
  *
35
35
  * Use this function when the amount of familiars should be equal to the amount of associated
36
- * collectibles that the player has (plus any extras from having used Box of Friends). If you
37
- * instead need to have a custom amount of familiars, use the `checkFamiliars` function instead.
36
+ * collectibles that the player has (plus any extras from having used Box of Friends or Monster
37
+ * Manual). If you instead need to have a custom amount of familiars, use the `checkFamiliars`
38
+ * function instead.
38
39
  *
39
40
  * @param player The player that owns the familiars and collectibles.
40
41
  * @param collectibleType The collectible type of the collectible associated with this familiar.
@@ -74,8 +74,8 @@ end
74
74
  function ____exports.checkFamiliarFromCollectibles(self, player, collectibleType, familiarVariant, familiarSubType)
75
75
  local numCollectibles = player:GetCollectibleNum(collectibleType)
76
76
  local effects = player:GetEffects()
77
- local numBoxOfFriendsUses = effects:GetCollectibleEffectNum(CollectibleType.COLLECTIBLE_BOX_OF_FRIENDS)
78
- local numTargetFamiliars = numCollectibles * (numBoxOfFriendsUses + 1)
77
+ local numCollectibleEffects = effects:GetCollectibleEffectNum(collectibleType)
78
+ local numTargetFamiliars = numCollectibles + numCollectibleEffects
79
79
  return ____exports.checkFamiliar(
80
80
  nil,
81
81
  player,
@@ -15,10 +15,9 @@ local hasFlag = ____flag.hasFlag
15
15
  local ____player = require("functions.player")
16
16
  local getEffectsList = ____player.getEffectsList
17
17
  local ____rooms = require("functions.rooms")
18
+ local getRoomData = ____rooms.getRoomData
19
+ local getRoomGridIndex = ____rooms.getRoomGridIndex
18
20
  local getRoomListIndex = ____rooms.getRoomListIndex
19
- local getRoomSafeGridIndex = ____rooms.getRoomSafeGridIndex
20
- local getRoomSubType = ____rooms.getRoomSubType
21
- local getRoomVariant = ____rooms.getRoomVariant
22
21
  local ____trinkets = require("functions.trinkets")
23
22
  local getTrinketName = ____trinkets.getTrinketName
24
23
  function ____exports.getDebugPrependString(self, msg, numParentFunctions)
@@ -130,15 +129,15 @@ function ____exports.logMap(map)
130
129
  ____exports.log("The size of the map was: " .. tostring(map.size))
131
130
  end
132
131
  function ____exports.logRoom()
133
- local game = Game()
134
- local room = game:GetRoom()
135
- local roomType = room:GetType()
136
- local roomVariant = getRoomVariant(nil)
137
- local roomSubType = getRoomSubType(nil)
138
- local roomSafeGridIndex = getRoomSafeGridIndex(nil)
132
+ local roomGridIndex = getRoomGridIndex(nil)
139
133
  local roomListIndex = getRoomListIndex(nil)
140
- ____exports.log((((("Current room type/variant/sub-type: " .. tostring(roomType)) .. ".") .. tostring(roomVariant)) .. ".") .. tostring(roomSubType))
141
- ____exports.log("Current room safe grid index: " .. tostring(roomSafeGridIndex))
134
+ local roomData = getRoomData(nil)
135
+ if roomData == nil then
136
+ ____exports.log("Current room data is undefined.")
137
+ else
138
+ ____exports.log((((("Current room type/variant/sub-type: " .. tostring(roomData.Type)) .. ".") .. tostring(roomData.Variant)) .. ".") .. tostring(roomData.Subtype))
139
+ end
140
+ ____exports.log("Current room grid index: " .. tostring(roomGridIndex))
142
141
  ____exports.log("Current room list index: " .. tostring(roomListIndex))
143
142
  end
144
143
  function ____exports.logTable(____table, parentTables)
@@ -14,7 +14,10 @@ export declare function getAllRoomGridIndexes(): int[];
14
14
  * tricky to properly detect.
15
15
  */
16
16
  export declare function getCurrentDimension(): Dimension;
17
- /** Alias for the `Level.GetCurrentRoomDesc()` method. */
17
+ /**
18
+ * Alias for the `Level.GetCurrentRoomDesc()` method. Use this to make it more clear what type of
19
+ * `RoomDescriptor` object that you are retrieving.
20
+ */
18
21
  export declare function getCurrentRoomDescriptorReadOnly(): RoomDescriptorReadOnly;
19
22
  /**
20
23
  * Helper function to get the room data for the provided room.
@@ -25,15 +28,33 @@ export declare function getRoomData(roomGridIndex?: int): RoomConfig | undefined
25
28
  /**
26
29
  * Helper function for getting the type of the room with the given grid index.
27
30
  *
31
+ * @param roomGridIndex Optional. Equal to the current room index by default.
28
32
  * @returns The room data type. Returns -1 if the type was not found.
29
33
  */
30
- export declare function getRoomType(roomGridIndex: int): RoomType;
34
+ export declare function getRoomType(roomGridIndex?: int): RoomType;
31
35
  /**
32
36
  * Helper function to get the descriptor for a room.
33
37
  *
34
38
  * @param roomGridIndex Optional. Equal to the current room index by default.
35
39
  */
36
40
  export declare function getRoomDescriptor(roomGridIndex?: int): RoomDescriptor;
41
+ /**
42
+ * Helper function to get the grid index of the current room.
43
+ *
44
+ * - If the current room is inside of the grid, this function will return the `SafeGridIndex` from
45
+ * the room descriptor. (The safe grid index is defined as the top-left 1x1 section that the room
46
+ * overlaps with, or the top-right 1x1 section of a `RoomType.ROOMSHAPE_LTL` room.)
47
+ * - If the current room is outside of the grid, it will return the index from the
48
+ * `Level.GetCurrentRoomIndex` method (since `SafeGridIndex` is bugged for these cases).
49
+ *
50
+ * Use this function instead of the `Level.GetCurrentRoomIndex` method directly because the latter
51
+ * will return the specific 1x1 quadrant that the player entered the room at. For most situations,
52
+ * using the safe grid index is more reliable than this.
53
+ *
54
+ * Data structures that store data per room should use the room's `ListIndex` instead of
55
+ * `SafeGridIndex`, since the former is unique across different dimensions.
56
+ */
57
+ export declare function getRoomGridIndex(): int;
37
58
  /**
38
59
  * Helper function to get an array of all of the safe grid indexes for rooms that match the
39
60
  * specified room type.
@@ -67,22 +88,6 @@ export declare function getRoomListIndex(roomGridIndex?: int): int;
67
88
  * @returns The room name. Returns "Unknown" if the type was not found.
68
89
  */
69
90
  export declare function getRoomName(roomGridIndex?: int): string;
70
- /**
71
- * Helper function to get the safe grid index of the provided room. The safe grid index is defined as
72
- * the top-left 1x1 section that the room overlaps with (or the top-right 1x1 section of a
73
- * `RoomType.ROOMSHAPE_LTL` room).
74
- *
75
- * In most situations, using the safe grid index is more reliable than using the `GridIndex` or the
76
- * `Level.GetCurrentRoomIndex()` method directly. `GridIndex` can return quadrants that are not on
77
- * the map, and `Level.GetCurrentRoomIndex()` returns the specific 1x1 quadrant that the player
78
- * entered the room at.
79
- *
80
- * Data structures that store data per room should use the room's `ListIndex` instead of
81
- * `SafeGridIndex`, since the former is unique across different dimensions.
82
- *
83
- * @param roomGridIndex Optional. Equal to the current room index by default.
84
- */
85
- export declare function getRoomSafeGridIndex(roomGridIndex?: int): int;
86
91
  /**
87
92
  * Helper function to get the stage ID for a room from the XML/STB data. The room stage ID will
88
93
  * correspond to the first number in the filename of the XML/STB file. For example, a Depths room
@@ -166,6 +171,7 @@ export declare function inDimension(dimension: Dimension): boolean;
166
171
  /** Helper function to determine if the current room shape is one of the four L room shapes. */
167
172
  export declare function inLRoom(): boolean;
168
173
  export declare function inGenesisRoom(): boolean;
174
+ export declare function inMegaSatanRoom(): boolean;
169
175
  /**
170
176
  * Helper function to check if the current room is a miniboss room for a particular miniboss. This
171
177
  * will only work for minibosses that have dedicated boss rooms in the "00.special rooms.stb" file.
@@ -10,8 +10,6 @@ local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
10
10
  local Map = ____lualib.Map
11
11
  local ____exports = {}
12
12
  local ____constants = require("constants")
13
- local GENESIS_ROOM_SUBTYPE = ____constants.GENESIS_ROOM_SUBTYPE
14
- local GENESIS_ROOM_VARIANT = ____constants.GENESIS_ROOM_VARIANT
15
13
  local MAX_ROOM_INDEX = ____constants.MAX_ROOM_INDEX
16
14
  local NUM_DIMENSIONS = ____constants.NUM_DIMENSIONS
17
15
  local ____doors = require("functions.doors")
@@ -43,11 +41,20 @@ function ____exports.getRoomDescriptor(self, roomGridIndex)
43
41
  local game = Game()
44
42
  local level = game:GetLevel()
45
43
  if roomGridIndex == nil then
46
- local currentRoomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
47
- roomGridIndex = currentRoomDescriptor.SafeGridIndex
44
+ roomGridIndex = ____exports.getRoomGridIndex(nil)
48
45
  end
49
46
  return level:GetRoomByIdx(roomGridIndex)
50
47
  end
48
+ function ____exports.getRoomGridIndex(self)
49
+ local game = Game()
50
+ local level = game:GetLevel()
51
+ local currentRoomIndex = level:GetCurrentRoomIndex()
52
+ if currentRoomIndex < 0 then
53
+ return currentRoomIndex
54
+ end
55
+ local roomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
56
+ return roomDescriptor.SafeGridIndex
57
+ end
51
58
  function ____exports.getRoomStageID(self, roomGridIndex)
52
59
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
53
60
  return roomData == nil and -1 or roomData.StageID
@@ -161,10 +168,6 @@ function ____exports.getRoomName(self, roomGridIndex)
161
168
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
162
169
  return roomData == nil and "Unknown" or roomData.Name
163
170
  end
164
- function ____exports.getRoomSafeGridIndex(self, roomGridIndex)
165
- local roomDescriptor = roomGridIndex == nil and ____exports.getCurrentRoomDescriptorReadOnly(nil) or ____exports.getRoomDescriptor(nil, roomGridIndex)
166
- return roomDescriptor.SafeGridIndex
167
- end
168
171
  function ____exports.getRoomVariant(self, roomGridIndex)
169
172
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
170
173
  return roomData == nil and -1 or roomData.Variant
@@ -233,9 +236,12 @@ function ____exports.inGenesisRoom(self)
233
236
  local game = Game()
234
237
  local room = game:GetRoom()
235
238
  local roomType = room:GetType()
236
- local roomVariant = ____exports.getRoomVariant(nil)
237
239
  local roomSubType = ____exports.getRoomSubType(nil)
238
- return roomType == RoomType.ROOM_ISAACS and roomVariant == GENESIS_ROOM_VARIANT and roomSubType == GENESIS_ROOM_SUBTYPE
240
+ return roomType == RoomType.ROOM_ISAACS and roomSubType == 99
241
+ end
242
+ function ____exports.inMegaSatanRoom(self)
243
+ local roomGridIndex = ____exports.getRoomGridIndex(nil)
244
+ return roomGridIndex == GridRooms.ROOM_MEGA_SATAN_IDX
239
245
  end
240
246
  function ____exports.inMinibossRoomOf(self, minibossID)
241
247
  local game = Game()
@@ -246,14 +252,14 @@ function ____exports.inMinibossRoomOf(self, minibossID)
246
252
  return roomType == RoomType.ROOM_MINIBOSS and roomStageID == 0 and roomSubType == minibossID
247
253
  end
248
254
  function ____exports.inSecretShop(self)
249
- return ____exports.getRoomSafeGridIndex(nil) == GridRooms.ROOM_SECRET_SHOP_IDX
255
+ return ____exports.getRoomGridIndex(nil) == GridRooms.ROOM_SECRET_SHOP_IDX
250
256
  end
251
257
  function ____exports.inStartingRoom(self)
252
258
  local game = Game()
253
259
  local level = game:GetLevel()
254
260
  local startingRoomGridIndex = level:GetStartingRoomIndex()
255
- local roomSafeGridIndex = ____exports.getRoomSafeGridIndex(nil)
256
- return roomSafeGridIndex == startingRoomGridIndex and ____exports.inDimension(nil, 0)
261
+ local roomGridIndex = ____exports.getRoomGridIndex(nil)
262
+ return roomGridIndex == startingRoomGridIndex and ____exports.inDimension(nil, 0)
257
263
  end
258
264
  function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes)
259
265
  local ____temp_0
@@ -279,7 +285,7 @@ function ____exports.isRedKeyRoom(self, roomGridIndex)
279
285
  end
280
286
  function ____exports.isRoomInsideMap(self, roomGridIndex)
281
287
  if roomGridIndex == nil then
282
- roomGridIndex = ____exports.getRoomSafeGridIndex(nil)
288
+ roomGridIndex = ____exports.getRoomGridIndex(nil)
283
289
  end
284
290
  return roomGridIndex >= 0
285
291
  end
@@ -305,12 +311,12 @@ function ____exports.setRoomCleared(self)
305
311
  for ____, door in ipairs(getDoors(nil)) do
306
312
  do
307
313
  if isHiddenSecretRoomDoor(nil, door) then
308
- goto __continue57
314
+ goto __continue59
309
315
  end
310
316
  openDoorFast(nil, door)
311
317
  door.ExtraVisible = false
312
318
  end
313
- ::__continue57::
319
+ ::__continue59::
314
320
  end
315
321
  sfx:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
316
322
  game:ShakeScreen(0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.101",
3
+ "version": "1.2.104",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",