isaacscript-common 1.2.63 → 1.2.66
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/callbacks/postPlayerFatalDamage.lua +9 -6
- package/dist/constants.d.ts +1 -0
- package/dist/constants.lua +1 -0
- package/dist/features/deployJSONRoom.lua +14 -16
- package/dist/functions/collectibleCacheFlag.lua +5 -7
- package/dist/functions/collectibleSet.lua +6 -8
- package/dist/functions/doors.d.ts +8 -0
- package/dist/functions/doors.lua +26 -3
- package/dist/functions/gridEntity.lua +13 -16
- package/dist/functions/player.d.ts +0 -2
- package/dist/functions/player.lua +9 -47
- package/dist/functions/pocketItems.lua +22 -24
- package/dist/functions/revive.d.ts +5 -0
- package/dist/functions/revive.lua +50 -6
- package/dist/functions/rooms.lua +10 -11
- package/dist/functions/transformations.lua +21 -23
- package/dist/functions/trinketCacheFlag.lua +5 -7
- package/dist/types/DefaultMap.d.ts +2 -3
- package/dist/types/PocketItemDescription.d.ts +2 -2
- package/package.json +2 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
|
-
local Map = ____lualib.Map
|
|
4
3
|
local __TS__New = ____lualib.__TS__New
|
|
5
4
|
local ____exports = {}
|
|
6
5
|
local hasSubscriptions, entityTakeDmgPlayer, v
|
|
@@ -9,9 +8,11 @@ local saveDataManager = ____exports.saveDataManager
|
|
|
9
8
|
local ____player = require("functions.player")
|
|
10
9
|
local getPlayerIndex = ____player.getPlayerIndex
|
|
11
10
|
local isChildPlayer = ____player.isChildPlayer
|
|
12
|
-
local isDamageToPlayerFatal = ____player.isDamageToPlayerFatal
|
|
13
11
|
local ____revive = require("functions.revive")
|
|
12
|
+
local isDamageToPlayerFatal = ____revive.isDamageToPlayerFatal
|
|
14
13
|
local willPlayerRevive = ____revive.willPlayerRevive
|
|
14
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
15
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
15
16
|
local ____postPlayerFatalDamage = require("callbacks.subscriptions.postPlayerFatalDamage")
|
|
16
17
|
local postPlayerFatalDamageFire = ____postPlayerFatalDamage.postPlayerFatalDamageFire
|
|
17
18
|
local postPlayerFatalDamageHasSubscriptions = ____postPlayerFatalDamage.postPlayerFatalDamageHasSubscriptions
|
|
@@ -32,8 +33,7 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damage
|
|
|
32
33
|
local game = Game()
|
|
33
34
|
local gameFrameCount = game:GetFrameCount()
|
|
34
35
|
local playerIndex = getPlayerIndex(nil, player)
|
|
35
|
-
local
|
|
36
|
-
v.run.playerLastDamageFrame:set(playerIndex, gameFrameCount)
|
|
36
|
+
local lastDamageGameFrame = v.run.playersLastDamageGameFrame:getAndSetDefault(playerIndex, gameFrameCount)
|
|
37
37
|
if willPlayerRevive(nil, player) then
|
|
38
38
|
return nil
|
|
39
39
|
end
|
|
@@ -42,7 +42,7 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damage
|
|
|
42
42
|
player,
|
|
43
43
|
damageAmount,
|
|
44
44
|
damageSource,
|
|
45
|
-
|
|
45
|
+
lastDamageGameFrame
|
|
46
46
|
) then
|
|
47
47
|
return nil
|
|
48
48
|
end
|
|
@@ -59,7 +59,10 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damage
|
|
|
59
59
|
end
|
|
60
60
|
return nil
|
|
61
61
|
end
|
|
62
|
-
v = {run = {
|
|
62
|
+
v = {run = {playersLastDamageGameFrame = __TS__New(
|
|
63
|
+
DefaultMap,
|
|
64
|
+
function(____, _key, gameFrameCount) return gameFrameCount end
|
|
65
|
+
)}}
|
|
63
66
|
function ____exports.postPlayerFatalDamageCallbackInit(self, mod)
|
|
64
67
|
saveDataManager(nil, "postPlayerFatalDamage", v)
|
|
65
68
|
mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, entityTakeDmgPlayer, EntityType.ENTITY_PLAYER)
|
package/dist/constants.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ export declare const MAX_PLAYER_TRINKET_SLOTS = 2;
|
|
|
102
102
|
export declare const MAX_ROOM_INDEX = 168;
|
|
103
103
|
export declare const MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B;
|
|
104
104
|
export declare const MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING;
|
|
105
|
+
export declare const NUM_DIMENSIONS = 3;
|
|
105
106
|
export declare const SECOND_IN_MILLISECONDS = 1000;
|
|
106
107
|
export declare const MINUTE_IN_MILLISECONDS: number;
|
|
107
108
|
export declare const ONE_BY_ONE_ROOM_GRID_SIZE = 135;
|
package/dist/constants.lua
CHANGED
|
@@ -88,6 +88,7 @@ ____exports.MAX_PLAYER_TRINKET_SLOTS = 2
|
|
|
88
88
|
____exports.MAX_ROOM_INDEX = 168
|
|
89
89
|
____exports.MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B
|
|
90
90
|
____exports.MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING
|
|
91
|
+
____exports.NUM_DIMENSIONS = 3
|
|
91
92
|
____exports.SECOND_IN_MILLISECONDS = 1000
|
|
92
93
|
____exports.MINUTE_IN_MILLISECONDS = 60 * ____exports.SECOND_IN_MILLISECONDS
|
|
93
94
|
____exports.ONE_BY_ONE_ROOM_GRID_SIZE = 135
|
|
@@ -23,6 +23,8 @@ local ____jsonRoom = require("functions.jsonRoom")
|
|
|
23
23
|
local getRandomJSONRoom = ____jsonRoom.getRandomJSONRoom
|
|
24
24
|
local ____log = require("functions.log")
|
|
25
25
|
local log = ____log.log
|
|
26
|
+
local ____math = require("functions.math")
|
|
27
|
+
local range = ____math.range
|
|
26
28
|
local ____npc = require("functions.npc")
|
|
27
29
|
local getNPCs = ____npc.getNPCs
|
|
28
30
|
local ____random = require("functions.random")
|
|
@@ -121,24 +123,20 @@ function fillRoomWithDecorations(self)
|
|
|
121
123
|
local gridSize = room:GetGridSize()
|
|
122
124
|
local roomListIndex = getRoomListIndex(nil)
|
|
123
125
|
local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
|
|
124
|
-
do
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if decoration ~= nil then
|
|
135
|
-
setGridEntityInvisible(nil, decoration)
|
|
136
|
-
end
|
|
137
|
-
__TS__ArrayPush(decorationGridIndexes, gridIndex)
|
|
126
|
+
for ____, gridIndex in ipairs(range(nil, 0, gridSize - 1)) do
|
|
127
|
+
do
|
|
128
|
+
local existingGridEntity = room:GetGridEntity(gridIndex)
|
|
129
|
+
if existingGridEntity ~= nil then
|
|
130
|
+
goto __continue33
|
|
131
|
+
end
|
|
132
|
+
local position = room:GetGridPosition(gridIndex)
|
|
133
|
+
local decoration = Isaac.GridSpawn(GridEntityType.GRID_DECORATION, 0, position, true)
|
|
134
|
+
if decoration ~= nil then
|
|
135
|
+
setGridEntityInvisible(nil, decoration)
|
|
138
136
|
end
|
|
139
|
-
|
|
140
|
-
gridIndex = gridIndex + 1
|
|
137
|
+
__TS__ArrayPush(decorationGridIndexes, gridIndex)
|
|
141
138
|
end
|
|
139
|
+
::__continue33::
|
|
142
140
|
end
|
|
143
141
|
end
|
|
144
142
|
function spawnAllEntities(self, jsonRoom, seed, verbose)
|
|
@@ -9,6 +9,8 @@ local ____exports = {}
|
|
|
9
9
|
local ____collectibles = require("functions.collectibles")
|
|
10
10
|
local collectibleHasCacheFlag = ____collectibles.collectibleHasCacheFlag
|
|
11
11
|
local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
|
|
12
|
+
local ____math = require("functions.math")
|
|
13
|
+
local range = ____math.range
|
|
12
14
|
local ____set = require("functions.set")
|
|
13
15
|
local copySet = ____set.copySet
|
|
14
16
|
local ____utils = require("functions.utils")
|
|
@@ -18,13 +20,9 @@ local function initCacheFlagMap(self)
|
|
|
18
20
|
local maxCollectibleID = getMaxCollectibleID(nil)
|
|
19
21
|
for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
|
|
20
22
|
local collectiblesSet = __TS__New(Set)
|
|
21
|
-
do
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
|
|
25
|
-
collectiblesSet:add(collectibleType)
|
|
26
|
-
end
|
|
27
|
-
collectibleType = collectibleType + 1
|
|
23
|
+
for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleID)) do
|
|
24
|
+
if collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
|
|
25
|
+
collectiblesSet:add(collectibleType)
|
|
28
26
|
end
|
|
29
27
|
end
|
|
30
28
|
CACHE_FLAG_TO_COLLECTIBLES_MAP:set(cacheFlag, collectiblesSet)
|
|
@@ -5,20 +5,18 @@ local __TS__New = ____lualib.__TS__New
|
|
|
5
5
|
local ____exports = {}
|
|
6
6
|
local ____collectibles = require("functions.collectibles")
|
|
7
7
|
local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
|
|
8
|
+
local ____math = require("functions.math")
|
|
9
|
+
local range = ____math.range
|
|
8
10
|
local ____set = require("functions.set")
|
|
9
11
|
local copySet = ____set.copySet
|
|
10
12
|
local COLLECTIBLE_SET = __TS__New(Set)
|
|
11
13
|
local function initCollectibleSet(self)
|
|
12
14
|
local itemConfig = Isaac.GetItemConfig()
|
|
13
15
|
local maxCollectibleID = getMaxCollectibleID(nil)
|
|
14
|
-
do
|
|
15
|
-
local
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if itemConfigItem ~= nil then
|
|
19
|
-
COLLECTIBLE_SET:add(collectibleType)
|
|
20
|
-
end
|
|
21
|
-
collectibleType = collectibleType + 1
|
|
16
|
+
for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleID)) do
|
|
17
|
+
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
18
|
+
if itemConfigItem ~= nil then
|
|
19
|
+
COLLECTIBLE_SET:add(collectibleType)
|
|
22
20
|
end
|
|
23
21
|
end
|
|
24
22
|
end
|
|
@@ -73,3 +73,11 @@ export declare function openAllDoors(): void;
|
|
|
73
73
|
* an animation.
|
|
74
74
|
*/
|
|
75
75
|
export declare function openDoorFast(door: GridEntityDoor): void;
|
|
76
|
+
/**
|
|
77
|
+
* Helper function to remove all of the doors in the room. By default, it will remove every door.
|
|
78
|
+
* You can optionally specify one or more room types to remove only the doors that match the
|
|
79
|
+
* specified room types.
|
|
80
|
+
*
|
|
81
|
+
* @returns The number of doors removed.
|
|
82
|
+
*/
|
|
83
|
+
export declare function removeAllDoors(...roomTypes: RoomType[]): int;
|
package/dist/functions/doors.lua
CHANGED
|
@@ -21,9 +21,7 @@ function ____exports.getDoors(self, ...)
|
|
|
21
21
|
if door == nil then
|
|
22
22
|
goto __continue7
|
|
23
23
|
end
|
|
24
|
-
if #roomTypes == 0 then
|
|
25
|
-
__TS__ArrayPush(doors, door)
|
|
26
|
-
elseif roomTypesSet:has(door.TargetRoomType) then
|
|
24
|
+
if #roomTypes == 0 or roomTypesSet:has(door.TargetRoomType) then
|
|
27
25
|
__TS__ArrayPush(doors, door)
|
|
28
26
|
end
|
|
29
27
|
end
|
|
@@ -158,4 +156,29 @@ function ____exports.openDoorFast(self, door)
|
|
|
158
156
|
local sprite = door:GetSprite()
|
|
159
157
|
sprite:Play("Opened", true)
|
|
160
158
|
end
|
|
159
|
+
function ____exports.removeAllDoors(self, ...)
|
|
160
|
+
local roomTypes = {...}
|
|
161
|
+
local game = Game()
|
|
162
|
+
local room = game:GetRoom()
|
|
163
|
+
local roomTypesSet = __TS__New(Set, roomTypes)
|
|
164
|
+
local numDoorsRemoved = 0
|
|
165
|
+
do
|
|
166
|
+
local i = 0
|
|
167
|
+
while i < MAX_NUM_DOORS do
|
|
168
|
+
do
|
|
169
|
+
local door = room:GetDoor(i)
|
|
170
|
+
if door == nil then
|
|
171
|
+
goto __continue36
|
|
172
|
+
end
|
|
173
|
+
if #roomTypes == 0 or roomTypesSet:has(door.TargetRoomType) then
|
|
174
|
+
room:RemoveDoor(i)
|
|
175
|
+
numDoorsRemoved = numDoorsRemoved + 1
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
::__continue36::
|
|
179
|
+
i = i + 1
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
return numDoorsRemoved
|
|
183
|
+
end
|
|
161
184
|
return ____exports
|
|
@@ -15,6 +15,7 @@ local DEFAULT_TOP_LEFT_WALL_GRID_INDEX = ____roomShapeToTopLeftWallGridIndexMap.
|
|
|
15
15
|
local ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP = ____roomShapeToTopLeftWallGridIndexMap.ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP
|
|
16
16
|
local ____math = require("functions.math")
|
|
17
17
|
local isCircleIntersectingRectangle = ____math.isCircleIntersectingRectangle
|
|
18
|
+
local range = ____math.range
|
|
18
19
|
local ____rooms = require("functions.rooms")
|
|
19
20
|
local roomUpdateSafe = ____rooms.roomUpdateSafe
|
|
20
21
|
local ____sprite = require("functions.sprite")
|
|
@@ -101,26 +102,22 @@ function ____exports.getGridEntities(self, ...)
|
|
|
101
102
|
local gridSize = room:GetGridSize()
|
|
102
103
|
local gridEntityTypesSet = __TS__New(Set, gridEntityTypes)
|
|
103
104
|
local gridEntities = {}
|
|
104
|
-
do
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
105
|
+
for ____, gridIndex in ipairs(range(nil, 0, gridSize - 1)) do
|
|
106
|
+
do
|
|
107
|
+
local gridEntity = room:GetGridEntity(gridIndex)
|
|
108
|
+
if gridEntity == nil then
|
|
109
|
+
goto __continue10
|
|
110
|
+
end
|
|
111
|
+
if #gridEntityTypes == 0 then
|
|
112
|
+
__TS__ArrayPush(gridEntities, gridEntity)
|
|
113
|
+
else
|
|
114
|
+
local thisGridEntityType = gridEntity:GetType()
|
|
115
|
+
if gridEntityTypesSet:has(thisGridEntityType) then
|
|
113
116
|
__TS__ArrayPush(gridEntities, gridEntity)
|
|
114
|
-
else
|
|
115
|
-
local thisGridEntityType = gridEntity:GetType()
|
|
116
|
-
if gridEntityTypesSet:has(thisGridEntityType) then
|
|
117
|
-
__TS__ArrayPush(gridEntities, gridEntity)
|
|
118
|
-
end
|
|
119
117
|
end
|
|
120
118
|
end
|
|
121
|
-
::__continue10::
|
|
122
|
-
gridIndex = gridIndex + 1
|
|
123
119
|
end
|
|
120
|
+
::__continue10::
|
|
124
121
|
end
|
|
125
122
|
return gridEntities
|
|
126
123
|
end
|
|
@@ -210,8 +210,6 @@ export declare function isBethany(player: EntityPlayer): boolean;
|
|
|
210
210
|
* (For example, the Strawman Keeper.)
|
|
211
211
|
*/
|
|
212
212
|
export declare function isChildPlayer(player: EntityPlayer): boolean;
|
|
213
|
-
/** Uses the player's current health and character to determine if incoming damage will be fatal. */
|
|
214
|
-
export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageFrame?: int): boolean;
|
|
215
213
|
export declare function isFirstPlayer(player: EntityPlayer): boolean;
|
|
216
214
|
/**
|
|
217
215
|
* Helper function for detecting when a player is Jacob or Esau. This will only match the
|
|
@@ -484,44 +484,6 @@ function ____exports.isBethany(self, player)
|
|
|
484
484
|
local character = player:GetPlayerType()
|
|
485
485
|
return character == PlayerType.PLAYER_BETHANY or character == PlayerType.PLAYER_BETHANY_B
|
|
486
486
|
end
|
|
487
|
-
function ____exports.isDamageToPlayerFatal(self, player, damageAmount, damageSource, lastDamageFrame)
|
|
488
|
-
local game = Game()
|
|
489
|
-
local gameFrameCount = game:GetFrameCount()
|
|
490
|
-
local character = player:GetPlayerType()
|
|
491
|
-
local effects = player:GetEffects()
|
|
492
|
-
local isBerserk = effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_BERSERK)
|
|
493
|
-
if character == PlayerType.PLAYER_JACOB_B and damageSource.Type == EntityType.ENTITY_DARK_ESAU then
|
|
494
|
-
return false
|
|
495
|
-
end
|
|
496
|
-
if isBerserk then
|
|
497
|
-
return false
|
|
498
|
-
end
|
|
499
|
-
if character == PlayerType.PLAYER_JACOB2_B then
|
|
500
|
-
return true
|
|
501
|
-
end
|
|
502
|
-
if ____exports.hasLostCurse(nil, player) then
|
|
503
|
-
return true
|
|
504
|
-
end
|
|
505
|
-
local playerNumAllHearts = ____exports.getPlayerNumHitsRemaining(nil, player)
|
|
506
|
-
if damageAmount < playerNumAllHearts then
|
|
507
|
-
return false
|
|
508
|
-
end
|
|
509
|
-
local playerAvailableHeartSlots = ____exports.getPlayerAvailableHeartSlots(nil, player)
|
|
510
|
-
if player:HasCollectible(CollectibleType.COLLECTIBLE_HEARTBREAK) and playerAvailableHeartSlots >= 2 then
|
|
511
|
-
return false
|
|
512
|
-
end
|
|
513
|
-
if player:HasCollectible(CollectibleType.COLLECTIBLE_BROKEN_GLASS_CANNON) and gameFrameCount == lastDamageFrame then
|
|
514
|
-
return false
|
|
515
|
-
end
|
|
516
|
-
local hearts = player:GetHearts()
|
|
517
|
-
local eternalHearts = player:GetEternalHearts()
|
|
518
|
-
local soulHearts = player:GetSoulHearts()
|
|
519
|
-
local boneHearts = player:GetBoneHearts()
|
|
520
|
-
if hearts > 0 and soulHearts > 0 or hearts > 0 and boneHearts > 0 or soulHearts > 0 and boneHearts > 0 or soulHearts > 0 and eternalHearts > 0 or boneHearts >= 2 then
|
|
521
|
-
return false
|
|
522
|
-
end
|
|
523
|
-
return true
|
|
524
|
-
end
|
|
525
487
|
function ____exports.isFirstPlayer(self, player)
|
|
526
488
|
return ____exports.getPlayerIndexVanilla(nil, player) == 0
|
|
527
489
|
end
|
|
@@ -586,9 +548,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
586
548
|
itemPool:RemoveCollectible(collectibleType)
|
|
587
549
|
end
|
|
588
550
|
repeat
|
|
589
|
-
local
|
|
590
|
-
local
|
|
591
|
-
if
|
|
551
|
+
local ____switch118 = activeSlot
|
|
552
|
+
local ____cond118 = ____switch118 == ActiveSlot.SLOT_PRIMARY
|
|
553
|
+
if ____cond118 then
|
|
592
554
|
do
|
|
593
555
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
594
556
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -597,8 +559,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
597
559
|
break
|
|
598
560
|
end
|
|
599
561
|
end
|
|
600
|
-
|
|
601
|
-
if
|
|
562
|
+
____cond118 = ____cond118 or ____switch118 == ActiveSlot.SLOT_SECONDARY
|
|
563
|
+
if ____cond118 then
|
|
602
564
|
do
|
|
603
565
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
604
566
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -613,16 +575,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
613
575
|
break
|
|
614
576
|
end
|
|
615
577
|
end
|
|
616
|
-
|
|
617
|
-
if
|
|
578
|
+
____cond118 = ____cond118 or ____switch118 == ActiveSlot.SLOT_POCKET
|
|
579
|
+
if ____cond118 then
|
|
618
580
|
do
|
|
619
581
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
620
582
|
player:SetActiveCharge(charge, activeSlot)
|
|
621
583
|
break
|
|
622
584
|
end
|
|
623
585
|
end
|
|
624
|
-
|
|
625
|
-
if
|
|
586
|
+
____cond118 = ____cond118 or ____switch118 == ActiveSlot.SLOT_POCKET2
|
|
587
|
+
if ____cond118 then
|
|
626
588
|
do
|
|
627
589
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
628
590
|
break
|
|
@@ -8,6 +8,8 @@ local ____constants = require("constants")
|
|
|
8
8
|
local MAX_PLAYER_POCKET_ITEM_SLOTS = ____constants.MAX_PLAYER_POCKET_ITEM_SLOTS
|
|
9
9
|
local ____PocketItemType = require("types.PocketItemType")
|
|
10
10
|
local PocketItemType = ____PocketItemType.PocketItemType
|
|
11
|
+
local ____math = require("functions.math")
|
|
12
|
+
local range = ____math.range
|
|
11
13
|
function ____exports.getPocketItems(self, player)
|
|
12
14
|
local pocketItem = player:GetActiveItem(ActiveSlot.SLOT_POCKET)
|
|
13
15
|
local hasPocketItem = pocketItem ~= CollectibleType.COLLECTIBLE_NULL
|
|
@@ -17,30 +19,26 @@ function ____exports.getPocketItems(self, player)
|
|
|
17
19
|
local pocketItems = {}
|
|
18
20
|
local pocketItemIdentified = false
|
|
19
21
|
local pocketItem2Identified = false
|
|
20
|
-
do
|
|
21
|
-
local
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if slot + 1 == maxPocketItems then
|
|
41
|
-
break
|
|
42
|
-
end
|
|
43
|
-
slot = slot + 1
|
|
22
|
+
for ____, slot in ipairs(range(nil, 0, MAX_PLAYER_POCKET_ITEM_SLOTS - 1)) do
|
|
23
|
+
local card = player:GetCard(slot)
|
|
24
|
+
local pillColor = player:GetPill(slot)
|
|
25
|
+
if card ~= Card.CARD_NULL then
|
|
26
|
+
__TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.CARD, subType = card})
|
|
27
|
+
elseif pillColor ~= PillColor.PILL_NULL then
|
|
28
|
+
__TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.PILL, subType = pillColor})
|
|
29
|
+
elseif hasPocketItem and not hasPocketItem2 and not pocketItemIdentified then
|
|
30
|
+
pocketItemIdentified = true
|
|
31
|
+
__TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.ACTIVE_ITEM, subType = pocketItem})
|
|
32
|
+
elseif not hasPocketItem and hasPocketItem2 and not pocketItem2Identified then
|
|
33
|
+
pocketItem2Identified = true
|
|
34
|
+
__TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.DICE_BAG_DICE, subType = pocketItem2})
|
|
35
|
+
elseif hasPocketItem and hasPocketItem2 then
|
|
36
|
+
__TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.UNDETERMINABLE, subType = 0})
|
|
37
|
+
else
|
|
38
|
+
__TS__ArrayPush(pocketItems, {slot = slot, type = PocketItemType.EMPTY, subType = 0})
|
|
39
|
+
end
|
|
40
|
+
if slot + 1 == maxPocketItems then
|
|
41
|
+
break
|
|
44
42
|
end
|
|
45
43
|
end
|
|
46
44
|
return pocketItems
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* Uses the player's current health and other miscellaneous things to determine if incoming damage
|
|
4
|
+
* will be fatal.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageGameFrame: int): boolean;
|
|
2
7
|
/**
|
|
3
8
|
* The `EntityPlayer.WillPlayerRevive()` function does not properly account for Mysterious Paper,
|
|
4
9
|
* so use this helper function instead for more robust revival detection.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
local ____exports = {}
|
|
3
3
|
local ____player = require("functions.player")
|
|
4
4
|
local getDeathAnimationName = ____player.getDeathAnimationName
|
|
5
|
+
local getPlayerAvailableHeartSlots = ____player.getPlayerAvailableHeartSlots
|
|
6
|
+
local getPlayerNumHitsRemaining = ____player.getPlayerNumHitsRemaining
|
|
7
|
+
local hasLostCurse = ____player.hasLostCurse
|
|
5
8
|
local ____sprite = require("functions.sprite")
|
|
6
9
|
local getFinalFrameOfAnimation = ____sprite.getFinalFrameOfAnimation
|
|
7
10
|
local ____trinketGive = require("functions.trinketGive")
|
|
@@ -16,12 +19,6 @@ function ____exports.willMysteriousPaperRevive(self, player)
|
|
|
16
19
|
local frameOfDeath = gameFrameCount + deathAnimationFrames + 1
|
|
17
20
|
return frameOfDeath % 4 == 3
|
|
18
21
|
end
|
|
19
|
-
function ____exports.willPlayerRevive(self, player)
|
|
20
|
-
local trinketSituation = temporarilyRemoveTrinket(nil, player, TrinketType.TRINKET_MYSTERIOUS_PAPER)
|
|
21
|
-
local willRevive = player:WillPlayerRevive() or trinketSituation ~= nil and ____exports.willMysteriousPaperRevive(nil, player)
|
|
22
|
-
giveTrinketsBack(nil, player, trinketSituation)
|
|
23
|
-
return willRevive
|
|
24
|
-
end
|
|
25
22
|
function ____exports.willReviveFromSpiritShackles(self, player)
|
|
26
23
|
if not player:HasCollectible(CollectibleType.COLLECTIBLE_SPIRIT_SHACKLES) then
|
|
27
24
|
return false
|
|
@@ -31,4 +28,51 @@ function ____exports.willReviveFromSpiritShackles(self, player)
|
|
|
31
28
|
local playerInSoulForm = effects:HasNullEffect(NullItemID.ID_SPIRIT_SHACKLES_SOUL)
|
|
32
29
|
return spiritShacklesEnabled and not playerInSoulForm
|
|
33
30
|
end
|
|
31
|
+
function ____exports.isDamageToPlayerFatal(self, player, damageAmount, damageSource, lastDamageGameFrame)
|
|
32
|
+
local game = Game()
|
|
33
|
+
local gameFrameCount = game:GetFrameCount()
|
|
34
|
+
local character = player:GetPlayerType()
|
|
35
|
+
local effects = player:GetEffects()
|
|
36
|
+
local isBerserk = effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_BERSERK)
|
|
37
|
+
if character == PlayerType.PLAYER_JACOB_B and damageSource.Type == EntityType.ENTITY_DARK_ESAU then
|
|
38
|
+
return false
|
|
39
|
+
end
|
|
40
|
+
if isBerserk then
|
|
41
|
+
return false
|
|
42
|
+
end
|
|
43
|
+
if ____exports.willReviveFromSpiritShackles(nil, player) then
|
|
44
|
+
return false
|
|
45
|
+
end
|
|
46
|
+
if character == PlayerType.PLAYER_JACOB2_B then
|
|
47
|
+
return true
|
|
48
|
+
end
|
|
49
|
+
if hasLostCurse(nil, player) then
|
|
50
|
+
return true
|
|
51
|
+
end
|
|
52
|
+
local playerNumAllHearts = getPlayerNumHitsRemaining(nil, player)
|
|
53
|
+
if damageAmount < playerNumAllHearts then
|
|
54
|
+
return false
|
|
55
|
+
end
|
|
56
|
+
local playerAvailableHeartSlots = getPlayerAvailableHeartSlots(nil, player)
|
|
57
|
+
if player:HasCollectible(CollectibleType.COLLECTIBLE_HEARTBREAK) and playerAvailableHeartSlots >= 2 then
|
|
58
|
+
return false
|
|
59
|
+
end
|
|
60
|
+
if player:HasCollectible(CollectibleType.COLLECTIBLE_BROKEN_GLASS_CANNON) and gameFrameCount == lastDamageGameFrame then
|
|
61
|
+
return false
|
|
62
|
+
end
|
|
63
|
+
local hearts = player:GetHearts()
|
|
64
|
+
local eternalHearts = player:GetEternalHearts()
|
|
65
|
+
local soulHearts = player:GetSoulHearts()
|
|
66
|
+
local boneHearts = player:GetBoneHearts()
|
|
67
|
+
if hearts > 0 and soulHearts > 0 or hearts > 0 and boneHearts > 0 or soulHearts > 0 and boneHearts > 0 or soulHearts > 0 and eternalHearts > 0 or boneHearts >= 2 then
|
|
68
|
+
return false
|
|
69
|
+
end
|
|
70
|
+
return true
|
|
71
|
+
end
|
|
72
|
+
function ____exports.willPlayerRevive(self, player)
|
|
73
|
+
local trinketSituation = temporarilyRemoveTrinket(nil, player, TrinketType.TRINKET_MYSTERIOUS_PAPER)
|
|
74
|
+
local willRevive = player:WillPlayerRevive() or trinketSituation ~= nil and ____exports.willMysteriousPaperRevive(nil, player)
|
|
75
|
+
giveTrinketsBack(nil, player, trinketSituation)
|
|
76
|
+
return willRevive
|
|
77
|
+
end
|
|
34
78
|
return ____exports
|
package/dist/functions/rooms.lua
CHANGED
|
@@ -13,6 +13,7 @@ local ____constants = require("constants")
|
|
|
13
13
|
local GENESIS_ROOM_SUBTYPE = ____constants.GENESIS_ROOM_SUBTYPE
|
|
14
14
|
local GENESIS_ROOM_VARIANT = ____constants.GENESIS_ROOM_VARIANT
|
|
15
15
|
local MAX_ROOM_INDEX = ____constants.MAX_ROOM_INDEX
|
|
16
|
+
local NUM_DIMENSIONS = ____constants.NUM_DIMENSIONS
|
|
16
17
|
local ____doors = require("functions.doors")
|
|
17
18
|
local closeAllDoors = ____doors.closeAllDoors
|
|
18
19
|
local getDoors = ____doors.getDoors
|
|
@@ -26,6 +27,8 @@ local setEntityPositions = ____entity.setEntityPositions
|
|
|
26
27
|
local setEntityVelocities = ____entity.setEntityVelocities
|
|
27
28
|
local ____flag = require("functions.flag")
|
|
28
29
|
local hasFlag = ____flag.hasFlag
|
|
30
|
+
local ____math = require("functions.math")
|
|
31
|
+
local range = ____math.range
|
|
29
32
|
function ____exports.getCurrentRoomDescriptorReadOnly(self)
|
|
30
33
|
local game = Game()
|
|
31
34
|
local level = game:GetLevel()
|
|
@@ -116,15 +119,11 @@ function ____exports.getCurrentDimension(self)
|
|
|
116
119
|
local startingRoomGridIndex = level:GetStartingRoomIndex()
|
|
117
120
|
local startingRoomDesc = level:GetRoomByIdx(startingRoomGridIndex, -1)
|
|
118
121
|
local startingRoomHash = GetPtrHash(startingRoomDesc)
|
|
119
|
-
do
|
|
120
|
-
local
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if dimensionRoomHash == startingRoomHash then
|
|
125
|
-
return dimension
|
|
126
|
-
end
|
|
127
|
-
dimension = dimension + 1
|
|
122
|
+
for ____, dimension in ipairs(range(nil, 0, NUM_DIMENSIONS - 1)) do
|
|
123
|
+
local dimensionRoomDesc = level:GetRoomByIdx(startingRoomGridIndex, dimension)
|
|
124
|
+
local dimensionRoomHash = GetPtrHash(dimensionRoomDesc)
|
|
125
|
+
if dimensionRoomHash == startingRoomHash then
|
|
126
|
+
return dimension
|
|
128
127
|
end
|
|
129
128
|
end
|
|
130
129
|
return error("Failed to get the current dimension using the starting room index of: " .. tostring(startingRoomGridIndex))
|
|
@@ -298,12 +297,12 @@ function ____exports.setRoomCleared(self)
|
|
|
298
297
|
for ____, door in ipairs(getDoors(nil)) do
|
|
299
298
|
do
|
|
300
299
|
if isHiddenSecretRoomDoor(nil, door) then
|
|
301
|
-
goto
|
|
300
|
+
goto __continue56
|
|
302
301
|
end
|
|
303
302
|
openDoorFast(nil, door)
|
|
304
303
|
door.ExtraVisible = false
|
|
305
304
|
end
|
|
306
|
-
::
|
|
305
|
+
::__continue56::
|
|
307
306
|
end
|
|
308
307
|
sfx:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
|
|
309
308
|
game:ShakeScreen(0)
|
|
@@ -10,6 +10,8 @@ local TRANSFORMATION_NAME_MAP = ____transformationNameMap.TRANSFORMATION_NAME_MA
|
|
|
10
10
|
local ____collectibles = require("functions.collectibles")
|
|
11
11
|
local collectibleHasTag = ____collectibles.collectibleHasTag
|
|
12
12
|
local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
|
|
13
|
+
local ____math = require("functions.math")
|
|
14
|
+
local range = ____math.range
|
|
13
15
|
local ____set = require("functions.set")
|
|
14
16
|
local copySet = ____set.copySet
|
|
15
17
|
local TRANSFORMATION_TO_TAG_MAP = __TS__New(Map, {
|
|
@@ -38,31 +40,27 @@ local function initMaps(self)
|
|
|
38
40
|
__TS__New(Set)
|
|
39
41
|
)
|
|
40
42
|
end
|
|
41
|
-
do
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if not collectibleHasTag(nil, collectibleType, tag) then
|
|
49
|
-
goto __continue6
|
|
50
|
-
end
|
|
51
|
-
local collectibleTypesSet = TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:get(playerForm)
|
|
52
|
-
if collectibleTypesSet == nil then
|
|
53
|
-
error("Failed to get the collectible types for transformation: " .. tostring(playerForm))
|
|
54
|
-
end
|
|
55
|
-
collectibleTypesSet:add(collectibleType)
|
|
56
|
-
local transformations = COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:get(collectibleType)
|
|
57
|
-
if transformations == nil then
|
|
58
|
-
transformations = __TS__New(Set)
|
|
59
|
-
COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:set(collectibleType, transformations)
|
|
60
|
-
end
|
|
61
|
-
transformations:add(playerForm)
|
|
43
|
+
for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleID)) do
|
|
44
|
+
for ____, ____value in __TS__Iterator(TRANSFORMATION_TO_TAG_MAP:entries()) do
|
|
45
|
+
local playerForm = ____value[1]
|
|
46
|
+
local tag = ____value[2]
|
|
47
|
+
do
|
|
48
|
+
if not collectibleHasTag(nil, collectibleType, tag) then
|
|
49
|
+
goto __continue6
|
|
62
50
|
end
|
|
63
|
-
|
|
51
|
+
local collectibleTypesSet = TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:get(playerForm)
|
|
52
|
+
if collectibleTypesSet == nil then
|
|
53
|
+
error("Failed to get the collectible types for transformation: " .. tostring(playerForm))
|
|
54
|
+
end
|
|
55
|
+
collectibleTypesSet:add(collectibleType)
|
|
56
|
+
local transformations = COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:get(collectibleType)
|
|
57
|
+
if transformations == nil then
|
|
58
|
+
transformations = __TS__New(Set)
|
|
59
|
+
COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:set(collectibleType, transformations)
|
|
60
|
+
end
|
|
61
|
+
transformations:add(playerForm)
|
|
64
62
|
end
|
|
65
|
-
|
|
63
|
+
::__continue6::
|
|
66
64
|
end
|
|
67
65
|
end
|
|
68
66
|
end
|
|
@@ -5,6 +5,8 @@ local __TS__New = ____lualib.__TS__New
|
|
|
5
5
|
local Set = ____lualib.Set
|
|
6
6
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
7
7
|
local ____exports = {}
|
|
8
|
+
local ____math = require("functions.math")
|
|
9
|
+
local range = ____math.range
|
|
8
10
|
local ____set = require("functions.set")
|
|
9
11
|
local copySet = ____set.copySet
|
|
10
12
|
local ____trinkets = require("functions.trinkets")
|
|
@@ -17,13 +19,9 @@ local function initCacheFlagMap(self)
|
|
|
17
19
|
local maxTrinketID = getMaxTrinketID(nil)
|
|
18
20
|
for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
|
|
19
21
|
local trinketsSet = __TS__New(Set)
|
|
20
|
-
do
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if trinketHasCacheFlag(nil, trinketType, cacheFlag) then
|
|
24
|
-
trinketsSet:add(trinketType)
|
|
25
|
-
end
|
|
26
|
-
trinketType = trinketType + 1
|
|
22
|
+
for ____, trinketType in ipairs(range(nil, 1, maxTrinketID)) do
|
|
23
|
+
if trinketHasCacheFlag(nil, trinketType, cacheFlag) then
|
|
24
|
+
trinketsSet:add(trinketType)
|
|
27
25
|
end
|
|
28
26
|
end
|
|
29
27
|
CACHE_FLAG_TO_TRINKETS_MAP:set(cacheFlag, trinketsSet)
|
|
@@ -43,9 +43,8 @@ declare type SecondArg<K, V, A extends unknown[]> = V | FactoryFunction<K, V, A>
|
|
|
43
43
|
* first:
|
|
44
44
|
*
|
|
45
45
|
* ```ts
|
|
46
|
-
* const
|
|
47
|
-
*
|
|
48
|
-
* })
|
|
46
|
+
* const factoryFunction = (_key: string, arg2: boolean) => arg2 ? 0 : 1;
|
|
47
|
+
* const defaultMapWithExtraArgs = new DefaultMap<string, string, [arg2: boolean]>(factoryFunction);
|
|
49
48
|
* ```
|
|
50
49
|
*/
|
|
51
50
|
export declare class DefaultMap<K, V, A extends unknown[] = []> extends Map<K, V> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.66",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@zamiell/typescript-to-lua": "^1.4.0",
|
|
29
29
|
"isaac-typescript-definitions": "^1.0.349",
|
|
30
|
-
"isaacscript-lint": "^1.0.
|
|
30
|
+
"isaacscript-lint": "^1.0.81",
|
|
31
31
|
"isaacscript-tsconfig": "^1.1.8",
|
|
32
32
|
"typedoc": "^0.22.12",
|
|
33
33
|
"typescript": "^4.5.5"
|