isaacscript-common 1.2.101 → 1.2.102

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.
@@ -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,8 +15,8 @@ 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 getRoomGridIndex = ____rooms.getRoomGridIndex
18
19
  local getRoomListIndex = ____rooms.getRoomListIndex
19
- local getRoomSafeGridIndex = ____rooms.getRoomSafeGridIndex
20
20
  local getRoomSubType = ____rooms.getRoomSubType
21
21
  local getRoomVariant = ____rooms.getRoomVariant
22
22
  local ____trinkets = require("functions.trinkets")
@@ -135,10 +135,10 @@ function ____exports.logRoom()
135
135
  local roomType = room:GetType()
136
136
  local roomVariant = getRoomVariant(nil)
137
137
  local roomSubType = getRoomSubType(nil)
138
- local roomSafeGridIndex = getRoomSafeGridIndex(nil)
138
+ local roomGridIndex = getRoomGridIndex(nil)
139
139
  local roomListIndex = getRoomListIndex(nil)
140
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))
141
+ ____exports.log("Current room grid index: " .. tostring(roomGridIndex))
142
142
  ____exports.log("Current room list index: " .. tostring(roomListIndex))
143
143
  end
144
144
  function ____exports.logTable(____table, parentTables)
@@ -34,6 +34,23 @@ export declare function getRoomType(roomGridIndex: int): RoomType;
34
34
  * @param roomGridIndex Optional. Equal to the current room index by default.
35
35
  */
36
36
  export declare function getRoomDescriptor(roomGridIndex?: int): RoomDescriptor;
37
+ /**
38
+ * Helper function to get the grid index of the current room.
39
+ *
40
+ * - If the current room is inside of the grid, this function will return the `SafeGridIndex` from
41
+ * the room descriptor. (The safe grid index is defined as the top-left 1x1 section that the room
42
+ * overlaps with, or the top-right 1x1 section of a `RoomType.ROOMSHAPE_LTL` room.)
43
+ * - If the current room is outside of the grid, it will return the index from the
44
+ * `Level.GetCurrentRoomIndex` method (since `SafeGridIndex` is bugged for these cases).
45
+ *
46
+ * Use this function instead of the `Level.GetCurrentRoomIndex` method directly because the latter
47
+ * will return the specific 1x1 quadrant that the player entered the room at. For most situations,
48
+ * using the safe grid index is more reliable than this.
49
+ *
50
+ * Data structures that store data per room should use the room's `ListIndex` instead of
51
+ * `SafeGridIndex`, since the former is unique across different dimensions.
52
+ */
53
+ export declare function getRoomGridIndex(): int;
37
54
  /**
38
55
  * Helper function to get an array of all of the safe grid indexes for rooms that match the
39
56
  * specified room type.
@@ -67,22 +84,6 @@ export declare function getRoomListIndex(roomGridIndex?: int): int;
67
84
  * @returns The room name. Returns "Unknown" if the type was not found.
68
85
  */
69
86
  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
87
  /**
87
88
  * Helper function to get the stage ID for a room from the XML/STB data. The room stage ID will
88
89
  * correspond to the first number in the filename of the XML/STB file. For example, a Depths room
@@ -133,6 +133,16 @@ function ____exports.getRoomType(self, roomGridIndex)
133
133
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
134
134
  return roomData == nil and -1 or roomData.Type
135
135
  end
136
+ function ____exports.getRoomGridIndex(self)
137
+ local game = Game()
138
+ local level = game:GetLevel()
139
+ local currentRoomIndex = level:GetCurrentRoomIndex()
140
+ if currentRoomIndex < 0 then
141
+ return currentRoomIndex
142
+ end
143
+ local roomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
144
+ return roomDescriptor.SafeGridIndex
145
+ end
136
146
  function ____exports.getRoomGridIndexesForType(self, ...)
137
147
  local roomTypes = {...}
138
148
  local rooms = ____exports.getRooms(nil)
@@ -161,10 +171,6 @@ function ____exports.getRoomName(self, roomGridIndex)
161
171
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
162
172
  return roomData == nil and "Unknown" or roomData.Name
163
173
  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
174
  function ____exports.getRoomVariant(self, roomGridIndex)
169
175
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
170
176
  return roomData == nil and -1 or roomData.Variant
@@ -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 __continue58
309
315
  end
310
316
  openDoorFast(nil, door)
311
317
  door.ExtraVisible = false
312
318
  end
313
- ::__continue57::
319
+ ::__continue58::
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.102",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",