isaacscript-common 1.0.569 → 1.0.573
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/dist/constants.d.ts +1 -0
- package/dist/constants.lua +1 -0
- package/dist/functions/doors.lua +3 -5
- package/dist/functions/entity.d.ts +15 -0
- package/dist/functions/entity.lua +28 -0
- package/dist/functions/npc.d.ts +14 -0
- package/dist/functions/npc.lua +14 -0
- package/dist/functions/player.d.ts +6 -0
- package/dist/functions/player.lua +19 -15
- package/dist/functions/rooms.d.ts +68 -42
- package/dist/functions/rooms.lua +67 -76
- package/dist/index.d.ts +1 -0
- package/dist/types/AnyEntity.d.ts +2 -0
- package/dist/types/AnyEntity.lua +3 -0
- package/package.json +2 -2
package/dist/constants.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare const BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.
|
|
|
12
12
|
/** Bombs explode when their frame count is equal to this value. */
|
|
13
13
|
export declare const BOMB_EXPLODE_FRAME = 45;
|
|
14
14
|
export declare const CHARACTERS_WITH_AN_ACTIVE_ITEM: Set<PlayerType>;
|
|
15
|
+
export declare const CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART: Set<PlayerType>;
|
|
15
16
|
/**
|
|
16
17
|
* The set of characters where red heart containers will be turned into soul hearts (e.g. Blue
|
|
17
18
|
* Baby). This includes The Lost and Tainted Lost. This does not include Keeper or Tainted Keeper.
|
package/dist/constants.lua
CHANGED
|
@@ -5,6 +5,7 @@ ____exports.AZAZEL_DEFAULT_BRIMSTONE_DISTANCE = 75.125
|
|
|
5
5
|
____exports.BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png"
|
|
6
6
|
____exports.BOMB_EXPLODE_FRAME = 45
|
|
7
7
|
____exports.CHARACTERS_WITH_AN_ACTIVE_ITEM = __TS__New(Set, {PlayerType.PLAYER_ISAAC, PlayerType.PLAYER_MAGDALENE, PlayerType.PLAYER_JUDAS, PlayerType.PLAYER_BLUEBABY, PlayerType.PLAYER_EVE, PlayerType.PLAYER_EDEN, PlayerType.PLAYER_THELOST, PlayerType.PLAYER_LILITH, PlayerType.PLAYER_KEEPER, PlayerType.PLAYER_APOLLYON, PlayerType.PLAYER_EDEN_B})
|
|
8
|
+
____exports.CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART = __TS__New(Set, {PlayerType.PLAYER_BLACKJUDAS, PlayerType.PLAYER_JUDAS_B})
|
|
8
9
|
____exports.CHARACTERS_WITH_NO_RED_HEARTS = __TS__New(Set, {PlayerType.PLAYER_BLUEBABY, PlayerType.PLAYER_THELOST, PlayerType.PLAYER_BLACKJUDAS, PlayerType.PLAYER_JUDAS_B, PlayerType.PLAYER_BLUEBABY_B, PlayerType.PLAYER_THELOST_B, PlayerType.PLAYER_THEFORGOTTEN_B, PlayerType.PLAYER_BETHANY_B})
|
|
9
10
|
____exports.CHARACTERS_WITH_NO_SOUL_HEARTS = __TS__New(Set, {PlayerType.PLAYER_THELOST, PlayerType.PLAYER_KEEPER, PlayerType.PLAYER_BETHANY, PlayerType.PLAYER_THELOST_B, PlayerType.PLAYER_KEEPER_B})
|
|
10
11
|
____exports.COLORS = {
|
package/dist/functions/doors.lua
CHANGED
|
@@ -47,9 +47,7 @@ function ____exports.closeAllDoors(self)
|
|
|
47
47
|
for ____, door in ipairs(
|
|
48
48
|
____exports.getDoors(nil)
|
|
49
49
|
) do
|
|
50
|
-
door
|
|
51
|
-
local sprite = door:GetSprite()
|
|
52
|
-
sprite:Play("Close", true)
|
|
50
|
+
door:Close(true)
|
|
53
51
|
end
|
|
54
52
|
end
|
|
55
53
|
function ____exports.getAngelRoomDoor(self)
|
|
@@ -140,8 +138,8 @@ end
|
|
|
140
138
|
function ____exports.lockDoor(self, door)
|
|
141
139
|
local game = Game()
|
|
142
140
|
local level = game:GetLevel()
|
|
143
|
-
local
|
|
144
|
-
|
|
141
|
+
local roomDescriptor = level:GetRoomByIdx(door.TargetRoomIndex)
|
|
142
|
+
roomDescriptor.VisitedCount = 0
|
|
145
143
|
door:SetVariant(DoorVariant.DOOR_LOCKED)
|
|
146
144
|
door:SetLocked(true)
|
|
147
145
|
door:Close(true)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
import { AnyEntity } from "../types/AnyEntity";
|
|
2
3
|
export declare function anyEntityCloserThan(entities: Entity[], position: Vector, distance: int): boolean;
|
|
3
4
|
/**
|
|
4
5
|
* Helper function to get all of the bombs in the room.
|
|
@@ -24,6 +25,11 @@ export declare function getBombs(matchingVariant?: number, matchingSubType?: num
|
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
27
|
export declare function getClosestEntityTo(referenceEntity: Entity, entities: Entity[]): Entity;
|
|
28
|
+
/**
|
|
29
|
+
* Helper function to compare two different arrays of entities. Returns the entities that are in the
|
|
30
|
+
* second array but not in the first array.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getFilteredNewEntities<T extends AnyEntity>(oldEntities: T[], newEntities: T[]): T[];
|
|
27
33
|
/**
|
|
28
34
|
* Helper function to get all of the effects in the room.
|
|
29
35
|
*
|
|
@@ -251,6 +257,15 @@ export declare function removeAllProjectiles(variant?: ProjectileVariant | int,
|
|
|
251
257
|
* @returns True if one or more tears was removed, false otherwise.
|
|
252
258
|
*/
|
|
253
259
|
export declare function removeAllTears(variant?: TearVariant | int, subType?: int, cap?: int): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Game().RerollEnemy rerolls a boolean of whether or not the enemy was rerolled. However, you
|
|
262
|
+
* cannot use the same entity object after a reroll. This function calls game.RerollEnemy and
|
|
263
|
+
* returns the new entity object.
|
|
264
|
+
*
|
|
265
|
+
* @param entity The entity to reroll
|
|
266
|
+
* @returns If the entity was not rerolled, returns the original entity. otherwise, returns the resulting entity from the reroll
|
|
267
|
+
*/
|
|
268
|
+
export declare function rerollEnemy(entity: Entity): Entity;
|
|
254
269
|
/**
|
|
255
270
|
* Helper function to set the position of every entity in the room based on a map of positions. If
|
|
256
271
|
* an entity is found that does not have matching element in the provided map, then that entity will
|
|
@@ -44,6 +44,20 @@ function ____exports.getClosestEntityTo(self, referenceEntity, entities)
|
|
|
44
44
|
end
|
|
45
45
|
return closestEntity
|
|
46
46
|
end
|
|
47
|
+
function ____exports.getFilteredNewEntities(self, oldEntities, newEntities)
|
|
48
|
+
local oldEntitiesSet = __TS__New(Set)
|
|
49
|
+
for ____, entity in ipairs(oldEntities) do
|
|
50
|
+
local ptrHash = GetPtrHash(entity)
|
|
51
|
+
oldEntitiesSet:add(ptrHash)
|
|
52
|
+
end
|
|
53
|
+
return __TS__ArrayFilter(
|
|
54
|
+
newEntities,
|
|
55
|
+
function(____, entity)
|
|
56
|
+
local ptrHash = GetPtrHash(entity)
|
|
57
|
+
return not oldEntitiesSet:has(ptrHash)
|
|
58
|
+
end
|
|
59
|
+
)
|
|
60
|
+
end
|
|
47
61
|
function ____exports.getEffects(self, matchingVariant, matchingSubType)
|
|
48
62
|
if matchingVariant == nil then
|
|
49
63
|
matchingVariant = -1
|
|
@@ -280,6 +294,20 @@ function ____exports.removeAllTears(self, variant, subType, cap)
|
|
|
280
294
|
local tears = ____exports.getTears(nil, variant, subType)
|
|
281
295
|
return ____exports.removeEntities(nil, tears, cap)
|
|
282
296
|
end
|
|
297
|
+
function ____exports.rerollEnemy(self, entity)
|
|
298
|
+
local game = Game()
|
|
299
|
+
local oldEntities = ____exports.getEntities(nil)
|
|
300
|
+
local wasRerolled = game:RerollEnemy(entity)
|
|
301
|
+
if not wasRerolled then
|
|
302
|
+
return entity
|
|
303
|
+
end
|
|
304
|
+
local newEntities = ____exports.getEntities(nil)
|
|
305
|
+
local filteredNewEntities = ____exports.getFilteredNewEntities(nil, oldEntities, newEntities)
|
|
306
|
+
if #filteredNewEntities ~= 0 then
|
|
307
|
+
error("Failed to find the new entity generated by the \"RerollEnemy\" method.")
|
|
308
|
+
end
|
|
309
|
+
return filteredNewEntities[1]
|
|
310
|
+
end
|
|
283
311
|
function ____exports.setEntityPositions(self, entityPositions, entities)
|
|
284
312
|
if entities == nil then
|
|
285
313
|
entities = ____exports.getEntities(nil)
|
package/dist/functions/npc.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to make an NPC fire a projectile. Returns the fired projectile. Use this function
|
|
4
|
+
* instead of `EntityNPC.FireProjectiles()`, since that returns void.
|
|
5
|
+
*
|
|
6
|
+
* @param npc The NPC to fire the projectile from.
|
|
7
|
+
* @param position The staring position of the projectile.
|
|
8
|
+
* @param velocity The starting velocity of the projectile.
|
|
9
|
+
* @param projectilesMode The mode of the projectile. Optional. Equal to
|
|
10
|
+
* `ProjectilesMode.ONE_PROJECTILE` by default.
|
|
11
|
+
* @param projectileParams The parameters of the projectile. Optional. Equal to `ProjectileParams()`
|
|
12
|
+
* by default.
|
|
13
|
+
* @returns The fired projectile.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fireProjectiles(npc: EntityNPC, position: Vector, velocity: Vector, projectilesMode?: ProjectilesMode, projectileParams?: ProjectileParams): EntityProjectile[];
|
|
2
16
|
/**
|
|
3
17
|
* Helper function to get all of the non-dead bosses in the room.
|
|
4
18
|
*
|
package/dist/functions/npc.lua
CHANGED
|
@@ -6,6 +6,8 @@ local ____constants = require("constants")
|
|
|
6
6
|
local EGGY_STATE_FRAME_OF_FINAL_SPIDER = ____constants.EGGY_STATE_FRAME_OF_FINAL_SPIDER
|
|
7
7
|
local ____entity = require("functions.entity")
|
|
8
8
|
local getEntities = ____entity.getEntities
|
|
9
|
+
local getFilteredNewEntities = ____entity.getFilteredNewEntities
|
|
10
|
+
local getProjectiles = ____entity.getProjectiles
|
|
9
11
|
local removeEntities = ____entity.removeEntities
|
|
10
12
|
function ____exports.getBosses(self)
|
|
11
13
|
local bosses = {}
|
|
@@ -75,6 +77,18 @@ NON_ALIVE_NPCS_TYPE_VARIANT_SUBTYPE = __TS__New(
|
|
|
75
77
|
(((tostring(EntityType.ENTITY_CHARGER) .. ".") .. 0) .. ".") .. 1
|
|
76
78
|
}
|
|
77
79
|
)
|
|
80
|
+
function ____exports.fireProjectiles(self, npc, position, velocity, projectilesMode, projectileParams)
|
|
81
|
+
if projectilesMode == nil then
|
|
82
|
+
projectilesMode = 0
|
|
83
|
+
end
|
|
84
|
+
if projectileParams == nil then
|
|
85
|
+
projectileParams = ProjectileParams()
|
|
86
|
+
end
|
|
87
|
+
local oldProjectiles = getProjectiles(nil, projectileParams.Variant)
|
|
88
|
+
npc:FireProjectiles(position, velocity, projectilesMode, projectileParams)
|
|
89
|
+
local newProjectiles = getProjectiles(nil, projectileParams.Variant)
|
|
90
|
+
return getFilteredNewEntities(nil, oldProjectiles, newProjectiles)
|
|
91
|
+
end
|
|
78
92
|
function ____exports.getAliveBosses(self)
|
|
79
93
|
local aliveBosses = {}
|
|
80
94
|
for ____, boss in ipairs(
|
|
@@ -39,6 +39,12 @@ export declare function characterCanHaveRedHearts(character: PlayerType): boolea
|
|
|
39
39
|
* false for The Lost and Tainted Lost.
|
|
40
40
|
*/
|
|
41
41
|
export declare function characterCanHaveSoulHearts(character: PlayerType): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Normally, characters get a red heart container upon reaching a new floor with an eternal heart,
|
|
44
|
+
* but some characters grant a black heart instead. Returns true for Dark Judas and Tainted Judas.
|
|
45
|
+
* Otherwise, returns false.
|
|
46
|
+
*/
|
|
47
|
+
export declare function characterGetsBlackHeartFromEternalHeart(character: PlayerType): boolean;
|
|
42
48
|
/**
|
|
43
49
|
* Helper function to get how long Azazel's Brimstone laser should be. You can pass either an
|
|
44
50
|
* `EntityPlayer` object or a tear height stat.
|
|
@@ -3,6 +3,7 @@ require("lualib_bundle");
|
|
|
3
3
|
local ____exports = {}
|
|
4
4
|
local EXCLUDED_CHARACTERS
|
|
5
5
|
local ____constants = require("constants")
|
|
6
|
+
local CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART = ____constants.CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART
|
|
6
7
|
local CHARACTERS_WITH_NO_RED_HEARTS = ____constants.CHARACTERS_WITH_NO_RED_HEARTS
|
|
7
8
|
local CHARACTERS_WITH_NO_SOUL_HEARTS = ____constants.CHARACTERS_WITH_NO_SOUL_HEARTS
|
|
8
9
|
local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
|
|
@@ -59,18 +60,18 @@ function ____exports.getPlayers(self, performExclusions)
|
|
|
59
60
|
do
|
|
60
61
|
local player = Isaac.GetPlayer(i)
|
|
61
62
|
if player == nil then
|
|
62
|
-
goto
|
|
63
|
+
goto __continue67
|
|
63
64
|
end
|
|
64
65
|
if ____exports.isChildPlayer(nil, player) then
|
|
65
|
-
goto
|
|
66
|
+
goto __continue67
|
|
66
67
|
end
|
|
67
68
|
local character = player:GetPlayerType()
|
|
68
69
|
if performExclusions and EXCLUDED_CHARACTERS:has(character) then
|
|
69
|
-
goto
|
|
70
|
+
goto __continue67
|
|
70
71
|
end
|
|
71
72
|
__TS__ArrayPush(players, player)
|
|
72
73
|
end
|
|
73
|
-
::
|
|
74
|
+
::__continue67::
|
|
74
75
|
i = i + 1
|
|
75
76
|
end
|
|
76
77
|
end
|
|
@@ -145,6 +146,9 @@ end
|
|
|
145
146
|
function ____exports.characterCanHaveSoulHearts(self, character)
|
|
146
147
|
return not CHARACTERS_WITH_NO_SOUL_HEARTS:has(character)
|
|
147
148
|
end
|
|
149
|
+
function ____exports.characterGetsBlackHeartFromEternalHeart(self, character)
|
|
150
|
+
return CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART:has(character)
|
|
151
|
+
end
|
|
148
152
|
function ____exports.getAzazelBrimstoneDistance(self, playerOrTearHeight)
|
|
149
153
|
local tearHeight = tonumber(playerOrTearHeight)
|
|
150
154
|
if tearHeight == nil then
|
|
@@ -295,14 +299,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
|
295
299
|
do
|
|
296
300
|
local player = Isaac.GetPlayer(i)
|
|
297
301
|
if player == nil then
|
|
298
|
-
goto
|
|
302
|
+
goto __continue59
|
|
299
303
|
end
|
|
300
304
|
local playerHash = GetPtrHash(player)
|
|
301
305
|
if playerHash == playerToFindHash then
|
|
302
306
|
return i
|
|
303
307
|
end
|
|
304
308
|
end
|
|
305
|
-
::
|
|
309
|
+
::__continue59::
|
|
306
310
|
i = i + 1
|
|
307
311
|
end
|
|
308
312
|
end
|
|
@@ -423,9 +427,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
423
427
|
itemPool:RemoveCollectible(collectibleType)
|
|
424
428
|
end
|
|
425
429
|
repeat
|
|
426
|
-
local
|
|
427
|
-
local
|
|
428
|
-
if
|
|
430
|
+
local ____switch97 = activeSlot
|
|
431
|
+
local ____cond97 = ____switch97 == ActiveSlot.SLOT_PRIMARY
|
|
432
|
+
if ____cond97 then
|
|
429
433
|
do
|
|
430
434
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
431
435
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -434,8 +438,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
434
438
|
break
|
|
435
439
|
end
|
|
436
440
|
end
|
|
437
|
-
|
|
438
|
-
if
|
|
441
|
+
____cond97 = ____cond97 or (____switch97 == ActiveSlot.SLOT_SECONDARY)
|
|
442
|
+
if ____cond97 then
|
|
439
443
|
do
|
|
440
444
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
441
445
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -450,16 +454,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
450
454
|
break
|
|
451
455
|
end
|
|
452
456
|
end
|
|
453
|
-
|
|
454
|
-
if
|
|
457
|
+
____cond97 = ____cond97 or (____switch97 == ActiveSlot.SLOT_POCKET)
|
|
458
|
+
if ____cond97 then
|
|
455
459
|
do
|
|
456
460
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
457
461
|
player:SetActiveCharge(charge, activeSlot)
|
|
458
462
|
break
|
|
459
463
|
end
|
|
460
464
|
end
|
|
461
|
-
|
|
462
|
-
if
|
|
465
|
+
____cond97 = ____cond97 or (____switch97 == ActiveSlot.SLOT_POCKET2)
|
|
466
|
+
if ____cond97 then
|
|
463
467
|
do
|
|
464
468
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
465
469
|
break
|
|
@@ -10,45 +10,34 @@ export declare function getAllRoomGridIndexes(): int[];
|
|
|
10
10
|
* Helper function to get the current dimension. Most of the time, this will be `Dimension.MAIN`,
|
|
11
11
|
* but it can change if e.g. the player is in the mirror world of Downpour/Dross.
|
|
12
12
|
*
|
|
13
|
-
* Note that this function
|
|
13
|
+
* Note that this function correctly handles detecting the Death Certificate dimension, which is
|
|
14
14
|
* tricky to properly detect.
|
|
15
15
|
*/
|
|
16
16
|
export declare function getCurrentDimension(): Dimension;
|
|
17
|
-
/**
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function getRoomData(): RoomConfig | undefined;
|
|
17
|
+
/** Alias for the `Level.GetCurrentRoomDesc()` method. */
|
|
18
|
+
export declare function getCurrentRoomDescriptorReadOnly(): RoomDescriptorReadOnly;
|
|
20
19
|
/**
|
|
21
|
-
* Helper function to get the
|
|
20
|
+
* Helper function to get the room data for the provided room.
|
|
21
|
+
*
|
|
22
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getRoomData(roomGridIndex?: int): RoomConfig | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Helper function to get the type of a room from the XML/STB data. The room data type will
|
|
22
27
|
* correspond to different things depending on what XML/STB file it draws from. For example, in the
|
|
23
28
|
* "00.special rooms.stb" file, a room type of 2 corresponds to a shop, a room type of 3 corresponds
|
|
24
29
|
* to an I AM ERROR room, and so on.
|
|
25
30
|
*
|
|
31
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
26
32
|
* @returns The room data type. Returns -1 if the type was not found.
|
|
27
33
|
*/
|
|
28
|
-
export declare function getRoomDataType(): int;
|
|
34
|
+
export declare function getRoomDataType(roomGridIndex?: int): int;
|
|
29
35
|
/**
|
|
30
|
-
* Helper function to get the
|
|
31
|
-
* the `Level.GetRooms().Get()` method. In other words, this is equal to the order that the room was
|
|
32
|
-
* created by the floor generation algorithm.
|
|
33
|
-
*
|
|
34
|
-
* Use this as an index for data structures that store data per room, since it is unique across
|
|
35
|
-
* different dimensions.
|
|
36
|
-
*/
|
|
37
|
-
export declare function getRoomListIndex(): int;
|
|
38
|
-
/**
|
|
39
|
-
* Helper function to get the safe grid index of the current room. The safe grid index is defined as
|
|
40
|
-
* the top-left 1x1 section that the room overlaps with (or the top-right 1x1 section of a
|
|
41
|
-
* `RoomType.ROOMSHAPE_LTL` room).
|
|
42
|
-
*
|
|
43
|
-
* In most situations, using the safe grid index is more reliable than using the `GridIndex` or the
|
|
44
|
-
* `Level.GetCurrentRoomIndex()` method directly. `GridIndex` can return quadrants that are not on
|
|
45
|
-
* the map, and `Level.GetCurrentRoomIndex()` returns the specific 1x1 quadrant that the player
|
|
46
|
-
* entered the room at.
|
|
36
|
+
* Helper function to get the descriptor for a room.
|
|
47
37
|
*
|
|
48
|
-
*
|
|
49
|
-
* `SafeGridIndex`, since the former is unique across different dimensions.
|
|
38
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
50
39
|
*/
|
|
51
|
-
export declare function
|
|
40
|
+
export declare function getRoomDescriptor(roomGridIndex?: int): RoomDescriptor;
|
|
52
41
|
/**
|
|
53
42
|
* Helper function to get an array of all of the safe grid indexes for rooms that match the
|
|
54
43
|
* specified room type.
|
|
@@ -61,43 +50,76 @@ export declare function getRoomGridIndexesForType(roomType: RoomType): int[];
|
|
|
61
50
|
* `ItemPoolType.ItemPoolType.POOL_ANGEL` if you are in an Angel Room.
|
|
62
51
|
*/
|
|
63
52
|
export declare function getRoomItemPoolType(): ItemPoolType;
|
|
53
|
+
/**
|
|
54
|
+
* Helper function to get the list grid index of the provided room, which is equal to the index in
|
|
55
|
+
* the `Level.GetRooms().Get()` method. In other words, this is equal to the order that the room was
|
|
56
|
+
* created by the floor generation algorithm.
|
|
57
|
+
*
|
|
58
|
+
* Use this as an index for data structures that store data per room, since it is unique across
|
|
59
|
+
* different dimensions.
|
|
60
|
+
*
|
|
61
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
62
|
+
*/
|
|
63
|
+
export declare function getRoomListIndex(roomGridIndex?: int): int;
|
|
64
64
|
/**
|
|
65
65
|
* Helper function to get the name of the room as it appears in the STB/XML data.
|
|
66
66
|
*
|
|
67
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
67
68
|
* @returns The room name. Returns "Unknown" if the type was not found.
|
|
68
69
|
*/
|
|
69
|
-
export declare function getRoomName(): string;
|
|
70
|
+
export declare function getRoomName(roomGridIndex?: int): string;
|
|
70
71
|
/**
|
|
71
|
-
* Helper function to get the
|
|
72
|
+
* Helper function to get the safe grid index of the provided room. The safe grid index is defined as
|
|
73
|
+
* the top-left 1x1 section that the room overlaps with (or the top-right 1x1 section of a
|
|
74
|
+
* `RoomType.ROOMSHAPE_LTL` room).
|
|
75
|
+
*
|
|
76
|
+
* In most situations, using the safe grid index is more reliable than using the `GridIndex` or the
|
|
77
|
+
* `Level.GetCurrentRoomIndex()` method directly. `GridIndex` can return quadrants that are not on
|
|
78
|
+
* the map, and `Level.GetCurrentRoomIndex()` returns the specific 1x1 quadrant that the player
|
|
79
|
+
* entered the room at.
|
|
80
|
+
*
|
|
81
|
+
* Data structures that store data per room should use the room's `ListIndex` instead of
|
|
82
|
+
* `SafeGridIndex`, since the former is unique across different dimensions.
|
|
83
|
+
*
|
|
84
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
85
|
+
*/
|
|
86
|
+
export declare function getRoomSafeGridIndex(roomGridIndex?: int): int;
|
|
87
|
+
/**
|
|
88
|
+
* Helper function to get the stage ID for a room from the XML/STB data. The room stage ID will
|
|
72
89
|
* correspond to the first number in the filename of the XML/STB file. For example, a Depths room
|
|
73
90
|
* would have a stage ID of 7.
|
|
74
91
|
*
|
|
92
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
75
93
|
* @returns The room stage ID. Returns -1 if the stage ID was not found.
|
|
76
94
|
*/
|
|
77
|
-
export declare function getRoomStageID(): StageID;
|
|
95
|
+
export declare function getRoomStageID(roomGridIndex?: int): StageID;
|
|
78
96
|
/**
|
|
79
|
-
* Helper function to get the subtype for
|
|
97
|
+
* Helper function to get the subtype for a room from the XML/STB data. The room subtype will
|
|
80
98
|
* correspond to different things depending on what XML/STB file it draws from. For example, in the
|
|
81
99
|
* "00.special rooms.stb" file, an Angel Room with a subtype of 0 will correspond to a normal Angel
|
|
82
100
|
* Room and a subtype of 1 will correspond to an Angel Room shop for The Stairway.
|
|
83
101
|
*
|
|
102
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
84
103
|
* @returns The room subtype. Returns -1 if the subtype was not found.
|
|
85
104
|
*/
|
|
86
|
-
export declare function getRoomSubType(): int;
|
|
105
|
+
export declare function getRoomSubType(roomGridIndex?: int): int;
|
|
87
106
|
/**
|
|
88
|
-
* Helper function to get the variant for
|
|
89
|
-
*
|
|
107
|
+
* Helper function to get the variant for a room from the XML/STB data. You can think of a room
|
|
108
|
+
* variant as its identifier. For example, to go to Basement room #123, you would use a console
|
|
90
109
|
* command of `goto d.123` while on the Basement.
|
|
91
110
|
*
|
|
111
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
92
112
|
* @returns The room variant. Returns -1 if the variant was not found.
|
|
93
113
|
*/
|
|
94
|
-
export declare function getRoomVariant(): int;
|
|
114
|
+
export declare function getRoomVariant(roomGridIndex?: int): int;
|
|
95
115
|
/**
|
|
96
|
-
*
|
|
97
|
-
* fired (i.e. when entities are initializing and performing their first update). This
|
|
98
|
-
* the variable is only incremented immediately before the PostNewRoom callback fires.
|
|
116
|
+
* Note that the room visited count will be inaccurate during the period before the PostNewRoom
|
|
117
|
+
* callback has fired (i.e. when entities are initializing and performing their first update). This
|
|
118
|
+
* is because the variable is only incremented immediately before the PostNewRoom callback fires.
|
|
119
|
+
*
|
|
120
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
99
121
|
*/
|
|
100
|
-
export declare function getRoomVisitedCount(): int;
|
|
122
|
+
export declare function getRoomVisitedCount(roomGridIndex?: int): int;
|
|
101
123
|
/**
|
|
102
124
|
* Helper function to get the room descriptor for every room on the level. Uses the
|
|
103
125
|
* `Level.GetRooms()` method to accomplish this.
|
|
@@ -167,15 +189,19 @@ export declare function inStartingRoom(): boolean;
|
|
|
167
189
|
*/
|
|
168
190
|
export declare function isAllRoomsClear(onlyCheckRoomTypes?: RoomType[]): boolean;
|
|
169
191
|
/**
|
|
170
|
-
* Helper function to detect if the
|
|
192
|
+
* Helper function to detect if the provided room was created by the Red Key item. Under the hood,
|
|
171
193
|
* this checks for the `RoomDescriptorFlag.FLAG_RED_ROOM` flag.
|
|
194
|
+
*
|
|
195
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
172
196
|
*/
|
|
173
|
-
export declare function isRedKeyRoom(): boolean;
|
|
197
|
+
export declare function isRedKeyRoom(roomGridIndex?: int): boolean;
|
|
174
198
|
/**
|
|
175
|
-
* Helper function to determine
|
|
199
|
+
* Helper function to determine if the provided room is part of the floor layout. For
|
|
176
200
|
* example, Devil Rooms and the Mega Satan room are not considered to be inside the map.
|
|
201
|
+
*
|
|
202
|
+
* @param roomGridIndex Optional. Equal to the current room index by default.
|
|
177
203
|
*/
|
|
178
|
-
export declare function isRoomInsideMap(): boolean;
|
|
204
|
+
export declare function isRoomInsideMap(roomGridIndex?: int): boolean;
|
|
179
205
|
/**
|
|
180
206
|
* If `Room.Update()` is called in a PostNewRoom callback, then some entities will slide around
|
|
181
207
|
* (such as the player). Since those entity velocities are already at zero, setting them to zero
|
package/dist/functions/rooms.lua
CHANGED
|
@@ -17,35 +17,31 @@ local setEntityPositions = ____entity.setEntityPositions
|
|
|
17
17
|
local setEntityVelocities = ____entity.setEntityVelocities
|
|
18
18
|
local ____flag = require("functions.flag")
|
|
19
19
|
local hasFlag = ____flag.hasFlag
|
|
20
|
-
function ____exports.
|
|
20
|
+
function ____exports.getCurrentRoomDescriptorReadOnly(self)
|
|
21
21
|
local game = Game()
|
|
22
22
|
local level = game:GetLevel()
|
|
23
23
|
return level:GetCurrentRoomDesc()
|
|
24
24
|
end
|
|
25
|
-
function ____exports.getRoomData(self)
|
|
25
|
+
function ____exports.getRoomData(self, roomGridIndex)
|
|
26
|
+
local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
|
|
27
|
+
return roomDescriptor.Data
|
|
28
|
+
end
|
|
29
|
+
function ____exports.getRoomDescriptor(self, roomGridIndex)
|
|
26
30
|
local game = Game()
|
|
27
31
|
local level = game:GetLevel()
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
function ____exports.getRoomSafeGridIndex(self)
|
|
33
|
-
local roomDesc = ____exports.getCurrentRoomDescReadOnly(nil)
|
|
34
|
-
return roomDesc.SafeGridIndex
|
|
35
|
-
end
|
|
36
|
-
function ____exports.getRoomStageID(self)
|
|
37
|
-
local roomData = ____exports.getRoomData(nil)
|
|
38
|
-
if roomData == nil then
|
|
39
|
-
return -1
|
|
32
|
+
if roomGridIndex == nil then
|
|
33
|
+
local currentRoomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
|
|
34
|
+
roomGridIndex = currentRoomDescriptor.SafeGridIndex
|
|
40
35
|
end
|
|
41
|
-
return
|
|
36
|
+
return level:GetRoomByIdx(roomGridIndex)
|
|
42
37
|
end
|
|
43
|
-
function ____exports.
|
|
44
|
-
local roomData = ____exports.getRoomData(nil)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
function ____exports.getRoomStageID(self, roomGridIndex)
|
|
39
|
+
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
40
|
+
return ((roomData == nil) and -1) or roomData.StageID
|
|
41
|
+
end
|
|
42
|
+
function ____exports.getRoomSubType(self, roomGridIndex)
|
|
43
|
+
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
44
|
+
return ((roomData == nil) and -1) or roomData.Subtype
|
|
49
45
|
end
|
|
50
46
|
function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
51
47
|
if includeExtraDimensionalRooms == nil then
|
|
@@ -59,9 +55,9 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
|
59
55
|
do
|
|
60
56
|
local i = 0
|
|
61
57
|
while i < roomList.Size do
|
|
62
|
-
local
|
|
63
|
-
if
|
|
64
|
-
__TS__ArrayPush(rooms,
|
|
58
|
+
local roomDescriptor = roomList:Get(i)
|
|
59
|
+
if roomDescriptor ~= nil then
|
|
60
|
+
__TS__ArrayPush(rooms, roomDescriptor)
|
|
65
61
|
end
|
|
66
62
|
i = i + 1
|
|
67
63
|
end
|
|
@@ -70,9 +66,9 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
|
70
66
|
do
|
|
71
67
|
local i = 0
|
|
72
68
|
while i <= MAX_ROOM_INDEX do
|
|
73
|
-
local
|
|
74
|
-
if
|
|
75
|
-
__TS__ArrayPush(rooms,
|
|
69
|
+
local roomDescriptor = level:GetRoomByIdx(i)
|
|
70
|
+
if roomDescriptor ~= nil then
|
|
71
|
+
__TS__ArrayPush(rooms, roomDescriptor)
|
|
76
72
|
end
|
|
77
73
|
i = i + 1
|
|
78
74
|
end
|
|
@@ -93,10 +89,10 @@ function ____exports.changeRoom(self, roomGridIndex)
|
|
|
93
89
|
end
|
|
94
90
|
function ____exports.getAllRoomGridIndexes(self)
|
|
95
91
|
local allRoomGridIndexes = {}
|
|
96
|
-
for ____,
|
|
92
|
+
for ____, roomDescriptor in ipairs(
|
|
97
93
|
____exports.getRooms(nil)
|
|
98
94
|
) do
|
|
99
|
-
__TS__ArrayPush(allRoomGridIndexes,
|
|
95
|
+
__TS__ArrayPush(allRoomGridIndexes, roomDescriptor.SafeGridIndex)
|
|
100
96
|
end
|
|
101
97
|
return allRoomGridIndexes
|
|
102
98
|
end
|
|
@@ -125,24 +121,17 @@ function ____exports.getCurrentDimension(self)
|
|
|
125
121
|
)
|
|
126
122
|
return 0
|
|
127
123
|
end
|
|
128
|
-
function ____exports.getRoomDataType(self)
|
|
129
|
-
local roomData = ____exports.getRoomData(nil)
|
|
130
|
-
|
|
131
|
-
return -1
|
|
132
|
-
end
|
|
133
|
-
return roomData.Type
|
|
134
|
-
end
|
|
135
|
-
function ____exports.getRoomListIndex(self)
|
|
136
|
-
local roomDesc = ____exports.getCurrentRoomDescReadOnly(nil)
|
|
137
|
-
return roomDesc.ListIndex
|
|
124
|
+
function ____exports.getRoomDataType(self, roomGridIndex)
|
|
125
|
+
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
126
|
+
return ((roomData == nil) and -1) or roomData.Type
|
|
138
127
|
end
|
|
139
128
|
function ____exports.getRoomGridIndexesForType(self, roomType)
|
|
140
129
|
local roomGridIndexes = {}
|
|
141
|
-
for ____,
|
|
130
|
+
for ____, roomDescriptor in ipairs(
|
|
142
131
|
____exports.getRooms(nil)
|
|
143
132
|
) do
|
|
144
|
-
if (
|
|
145
|
-
__TS__ArrayPush(roomGridIndexes,
|
|
133
|
+
if (roomDescriptor.Data ~= nil) and (roomDescriptor.Data.Type == roomType) then
|
|
134
|
+
__TS__ArrayPush(roomGridIndexes, roomDescriptor.SafeGridIndex)
|
|
146
135
|
end
|
|
147
136
|
end
|
|
148
137
|
return roomGridIndexes
|
|
@@ -155,23 +144,25 @@ function ____exports.getRoomItemPoolType(self)
|
|
|
155
144
|
local roomSeed = room:GetSpawnSeed()
|
|
156
145
|
return itemPool:GetPoolForRoom(roomType, roomSeed)
|
|
157
146
|
end
|
|
158
|
-
function ____exports.
|
|
159
|
-
local
|
|
160
|
-
|
|
161
|
-
return "Unknown"
|
|
162
|
-
end
|
|
163
|
-
return roomData.Name
|
|
147
|
+
function ____exports.getRoomListIndex(self, roomGridIndex)
|
|
148
|
+
local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
|
|
149
|
+
return roomDescriptor.ListIndex
|
|
164
150
|
end
|
|
165
|
-
function ____exports.
|
|
166
|
-
local roomData = ____exports.getRoomData(nil)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
151
|
+
function ____exports.getRoomName(self, roomGridIndex)
|
|
152
|
+
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
153
|
+
return ((roomData == nil) and "Unknown") or roomData.Name
|
|
154
|
+
end
|
|
155
|
+
function ____exports.getRoomSafeGridIndex(self, roomGridIndex)
|
|
156
|
+
local roomDescriptor = ((roomGridIndex == nil) and ____exports.getCurrentRoomDescriptorReadOnly(nil)) or ____exports.getRoomDescriptor(nil, roomGridIndex)
|
|
157
|
+
return roomDescriptor.SafeGridIndex
|
|
171
158
|
end
|
|
172
|
-
function ____exports.
|
|
173
|
-
local
|
|
174
|
-
return
|
|
159
|
+
function ____exports.getRoomVariant(self, roomGridIndex)
|
|
160
|
+
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
161
|
+
return ((roomData == nil) and -1) or roomData.Variant
|
|
162
|
+
end
|
|
163
|
+
function ____exports.getRoomVisitedCount(self, roomGridIndex)
|
|
164
|
+
local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
|
|
165
|
+
return roomDescriptor.VisitedCount
|
|
175
166
|
end
|
|
176
167
|
function ____exports.gridToPos(self, x, y)
|
|
177
168
|
local game = Game()
|
|
@@ -213,8 +204,8 @@ function ____exports.inCrawlspace(self)
|
|
|
213
204
|
return (roomSafeGridIndex == GridRooms.ROOM_DUNGEON_IDX) and (roomSubType ~= 4)
|
|
214
205
|
end
|
|
215
206
|
function ____exports.inDevilsCrownTreasureRoom(self)
|
|
216
|
-
local
|
|
217
|
-
return hasFlag(nil,
|
|
207
|
+
local roomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
|
|
208
|
+
return hasFlag(nil, roomDescriptor.Flags, 2048)
|
|
218
209
|
end
|
|
219
210
|
function ____exports.inDimension(self, dimension)
|
|
220
211
|
return dimension == ____exports.getCurrentDimension(nil)
|
|
@@ -250,33 +241,35 @@ function ____exports.inStartingRoom(self)
|
|
|
250
241
|
end
|
|
251
242
|
function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes)
|
|
252
243
|
local roomTypeWhitelist = (((onlyCheckRoomTypes == nil) and (function() return nil end)) or (function() return __TS__New(Set, onlyCheckRoomTypes) end))()
|
|
253
|
-
for ____,
|
|
244
|
+
for ____, roomDescriptor in ipairs(
|
|
254
245
|
____exports.getRooms(nil)
|
|
255
246
|
) do
|
|
256
247
|
do
|
|
257
|
-
local roomData =
|
|
248
|
+
local roomData = roomDescriptor.Data
|
|
258
249
|
if roomData == nil then
|
|
259
|
-
goto
|
|
250
|
+
goto __continue46
|
|
260
251
|
end
|
|
261
252
|
local roomType = roomData.Type
|
|
262
253
|
if (roomTypeWhitelist ~= nil) and (not roomTypeWhitelist:has(roomType)) then
|
|
263
|
-
goto
|
|
254
|
+
goto __continue46
|
|
264
255
|
end
|
|
265
|
-
if not
|
|
256
|
+
if not roomDescriptor.Clear then
|
|
266
257
|
return false
|
|
267
258
|
end
|
|
268
259
|
end
|
|
269
|
-
::
|
|
260
|
+
::__continue46::
|
|
270
261
|
end
|
|
271
262
|
return true
|
|
272
263
|
end
|
|
273
|
-
function ____exports.isRedKeyRoom(self)
|
|
274
|
-
local
|
|
275
|
-
return hasFlag(nil,
|
|
264
|
+
function ____exports.isRedKeyRoom(self, roomGridIndex)
|
|
265
|
+
local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
|
|
266
|
+
return hasFlag(nil, roomDescriptor.Flags, 1024)
|
|
276
267
|
end
|
|
277
|
-
function ____exports.isRoomInsideMap(self)
|
|
278
|
-
|
|
279
|
-
|
|
268
|
+
function ____exports.isRoomInsideMap(self, roomGridIndex)
|
|
269
|
+
if roomGridIndex == nil then
|
|
270
|
+
roomGridIndex = ____exports.getRoomSafeGridIndex(nil)
|
|
271
|
+
end
|
|
272
|
+
return roomGridIndex >= 0
|
|
280
273
|
end
|
|
281
274
|
function ____exports.roomUpdateSafe(self)
|
|
282
275
|
local game = Game()
|
|
@@ -302,14 +295,12 @@ function ____exports.setRoomCleared(self)
|
|
|
302
295
|
) do
|
|
303
296
|
do
|
|
304
297
|
if isHiddenSecretRoomDoor(nil, door) then
|
|
305
|
-
goto
|
|
298
|
+
goto __continue56
|
|
306
299
|
end
|
|
307
|
-
door
|
|
308
|
-
local sprite = door:GetSprite()
|
|
309
|
-
sprite:Play("Opened", true)
|
|
300
|
+
door:Open()
|
|
310
301
|
door.ExtraVisible = false
|
|
311
302
|
end
|
|
312
|
-
::
|
|
303
|
+
::__continue56::
|
|
313
304
|
end
|
|
314
305
|
sfx:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
|
|
315
306
|
game:ShakeScreen(0)
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export * from "./maps/transformationMaps";
|
|
|
61
61
|
export * from "./maps/transformationNameMap";
|
|
62
62
|
export * from "./maps/trinketNameMap";
|
|
63
63
|
export * from "./sets/cards";
|
|
64
|
+
export * from "./types/AnyEntity";
|
|
64
65
|
export * from "./types/CallbackParametersCustom";
|
|
65
66
|
export * from "./types/HealthType";
|
|
66
67
|
export * from "./types/JSONDoor";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.573",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist/**/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^1.0.
|
|
28
|
+
"isaac-typescript-definitions": "^1.0.315",
|
|
29
29
|
"isaacscript-lint": "^1.0.74",
|
|
30
30
|
"typedoc": "^0.22.10",
|
|
31
31
|
"typescript": "4.4.4",
|