isaacscript-common 1.2.274 → 1.2.277
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/functions/boss.d.ts +3 -2
- package/dist/functions/boss.lua +42 -4
- package/dist/functions/doors.d.ts +2 -0
- package/dist/functions/doors.lua +10 -0
- package/dist/functions/rooms.lua +4 -5
- package/dist/functions/trinketGive.lua +23 -23
- package/dist/functions/trinkets.lua +5 -5
- package/dist/types/TrinketSituation.d.ts +2 -2
- package/package.json +1 -1
package/dist/functions/boss.d.ts
CHANGED
|
@@ -44,8 +44,9 @@ export declare function isSin(npc: EntityNPC): boolean;
|
|
|
44
44
|
* Use this function instead of `spawnNPC` since it handles automatically spawning multiple segments
|
|
45
45
|
* for multi-segment bosses.
|
|
46
46
|
*
|
|
47
|
-
* By default, this will spawn Chub (and his variants) with 3 segments
|
|
48
|
-
* bosses with 4 segments. You can
|
|
47
|
+
* By default, this will spawn Chub (and his variants) with 3 segments, Lokii with 2 copies,
|
|
48
|
+
* Gurglings/Turdlings with 2 copies, and other multi-segment bosses with 4 segments. You can
|
|
49
|
+
* customize this via the "numSegments" argument.
|
|
49
50
|
*/
|
|
50
51
|
export declare function spawnBoss<T extends number>(entityType: T extends EntityTypeNonNPC ? never : T, variant: int, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined, numSegments?: int): EntityNPC;
|
|
51
52
|
/**
|
package/dist/functions/boss.lua
CHANGED
|
@@ -3,6 +3,7 @@ local Set = ____lualib.Set
|
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
4
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
5
5
|
local ____exports = {}
|
|
6
|
+
local getNumBossSegments, DEFAULT_BOSS_MULTI_SEGMENTS
|
|
6
7
|
local ____constants = require("constants")
|
|
7
8
|
local VectorZero = ____constants.VectorZero
|
|
8
9
|
local ____bossSets = require("sets.bossSets")
|
|
@@ -20,7 +21,45 @@ local ____set = require("functions.set")
|
|
|
20
21
|
local copySet = ____set.copySet
|
|
21
22
|
local ____utils = require("functions.utils")
|
|
22
23
|
local ____repeat = ____utils["repeat"]
|
|
23
|
-
|
|
24
|
+
function getNumBossSegments(self, entityType, variant, numSegments)
|
|
25
|
+
if numSegments ~= nil then
|
|
26
|
+
return numSegments
|
|
27
|
+
end
|
|
28
|
+
repeat
|
|
29
|
+
local ____switch18 = entityType
|
|
30
|
+
local ____cond18 = ____switch18 == EntityType.ENTITY_CHUB
|
|
31
|
+
if ____cond18 then
|
|
32
|
+
do
|
|
33
|
+
return 3
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
____cond18 = ____cond18 or ____switch18 == EntityType.ENTITY_LOKI
|
|
37
|
+
if ____cond18 then
|
|
38
|
+
do
|
|
39
|
+
return variant == 1 and 2 or 1
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
____cond18 = ____cond18 or ____switch18 == EntityType.ENTITY_GURGLING
|
|
43
|
+
if ____cond18 then
|
|
44
|
+
do
|
|
45
|
+
return 2
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
do
|
|
49
|
+
do
|
|
50
|
+
return DEFAULT_BOSS_MULTI_SEGMENTS
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
until true
|
|
54
|
+
end
|
|
55
|
+
local BOSSES_THAT_REQUIRE_MULTIPLE_SPAWNS = __TS__New(Set, {
|
|
56
|
+
EntityType.ENTITY_LARRYJR,
|
|
57
|
+
EntityType.ENTITY_CHUB,
|
|
58
|
+
EntityType.ENTITY_LOKI,
|
|
59
|
+
EntityType.ENTITY_GURGLING,
|
|
60
|
+
EntityType.ENTITY_TURDLET
|
|
61
|
+
})
|
|
62
|
+
DEFAULT_BOSS_MULTI_SEGMENTS = 4
|
|
24
63
|
function ____exports.getAliveBosses(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
|
|
25
64
|
if ignoreFriendly == nil then
|
|
26
65
|
ignoreFriendly = false
|
|
@@ -98,9 +137,8 @@ function ____exports.spawnBoss(self, entityType, variant, subType, position, vel
|
|
|
98
137
|
seed
|
|
99
138
|
)
|
|
100
139
|
if BOSSES_THAT_REQUIRE_MULTIPLE_SPAWNS:has(entityType) then
|
|
101
|
-
local
|
|
102
|
-
local
|
|
103
|
-
local remainingSegmentsToSpawn = numSegmentsToUse - 1
|
|
140
|
+
local numBossSegments = getNumBossSegments(nil, entityType, variant, numSegments)
|
|
141
|
+
local remainingSegmentsToSpawn = numBossSegments - 1
|
|
104
142
|
____repeat(
|
|
105
143
|
nil,
|
|
106
144
|
remainingSegmentsToSpawn,
|
|
@@ -29,6 +29,8 @@ export declare function getDoors(...roomTypes: RoomType[]): GridEntityDoor[];
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function getDoorsToRoomIndex(...roomGridIndex: int[]): GridEntityDoor[];
|
|
31
31
|
export declare function getRepentanceDoor(): GridEntityDoor | undefined;
|
|
32
|
+
/** Helper function to find unused door slots in the room that can be used to make custom doors. */
|
|
33
|
+
export declare function getUnusedDoorSlots(): DoorSlot[];
|
|
32
34
|
export declare function isAngelRoomDoor(door: GridEntityDoor): boolean;
|
|
33
35
|
export declare function isDevilRoomDoor(door: GridEntityDoor): boolean;
|
|
34
36
|
/** Helper function to see if a door slot could exist for a given room shape. */
|
package/dist/functions/doors.lua
CHANGED
|
@@ -12,6 +12,8 @@ local ____doorSlotToDirection = require("objects.doorSlotToDirection")
|
|
|
12
12
|
local DOOR_SLOT_TO_DIRECTION = ____doorSlotToDirection.DOOR_SLOT_TO_DIRECTION
|
|
13
13
|
local ____roomShapeToDoorSlots = require("objects.roomShapeToDoorSlots")
|
|
14
14
|
local ROOM_SHAPE_TO_DOOR_SLOTS = ____roomShapeToDoorSlots.ROOM_SHAPE_TO_DOOR_SLOTS
|
|
15
|
+
local ____utils = require("functions.utils")
|
|
16
|
+
local getEnumValues = ____utils.getEnumValues
|
|
15
17
|
function ____exports.getDoors(self, ...)
|
|
16
18
|
local roomTypes = {...}
|
|
17
19
|
local room = game:GetRoom()
|
|
@@ -116,6 +118,14 @@ function ____exports.getRepentanceDoor(self)
|
|
|
116
118
|
function(____, door) return ____exports.isRepentanceDoor(nil, door) end
|
|
117
119
|
)
|
|
118
120
|
end
|
|
121
|
+
function ____exports.getUnusedDoorSlots(self)
|
|
122
|
+
local room = game:GetRoom()
|
|
123
|
+
local doorSlots = getEnumValues(nil, DoorSlot)
|
|
124
|
+
return __TS__ArrayFilter(
|
|
125
|
+
doorSlots,
|
|
126
|
+
function(____, doorSlot) return room:IsDoorSlotAllowed(doorSlot) and room:GetDoor(doorSlot) == nil end
|
|
127
|
+
)
|
|
128
|
+
end
|
|
119
129
|
function ____exports.isAngelRoomDoor(self, door)
|
|
120
130
|
return door.TargetRoomType == RoomType.ROOM_ANGEL
|
|
121
131
|
end
|
package/dist/functions/rooms.lua
CHANGED
|
@@ -3,6 +3,7 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
|
3
3
|
local Set = ____lualib.Set
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
5
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
6
|
+
local __TS__StringIncludes = ____lualib.__TS__StringIncludes
|
|
6
7
|
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
|
|
7
8
|
local Map = ____lualib.Map
|
|
8
9
|
local ____exports = {}
|
|
@@ -12,8 +13,6 @@ local sfxManager = ____cachedClasses.sfxManager
|
|
|
12
13
|
local ____constants = require("constants")
|
|
13
14
|
local MAX_ROOM_INDEX = ____constants.MAX_ROOM_INDEX
|
|
14
15
|
local NUM_DIMENSIONS = ____constants.NUM_DIMENSIONS
|
|
15
|
-
local ____doubleTroubleRoomVariants = require("sets.doubleTroubleRoomVariants")
|
|
16
|
-
local DOUBLE_TROUBLE_ROOM_VARIANTS = ____doubleTroubleRoomVariants.DOUBLE_TROUBLE_ROOM_VARIANTS
|
|
17
16
|
local ____doors = require("functions.doors")
|
|
18
17
|
local closeAllDoors = ____doors.closeAllDoors
|
|
19
18
|
local getDoors = ____doors.getDoors
|
|
@@ -36,10 +35,10 @@ local getRoomAllowedDoors = ____roomData.getRoomAllowedDoors
|
|
|
36
35
|
local getRoomData = ____roomData.getRoomData
|
|
37
36
|
local getRoomDescriptor = ____roomData.getRoomDescriptor
|
|
38
37
|
local getRoomGridIndex = ____roomData.getRoomGridIndex
|
|
38
|
+
local getRoomName = ____roomData.getRoomName
|
|
39
39
|
local getRoomShape = ____roomData.getRoomShape
|
|
40
40
|
local getRoomStageID = ____roomData.getRoomStageID
|
|
41
41
|
local getRoomSubType = ____roomData.getRoomSubType
|
|
42
|
-
local getRoomVariant = ____roomData.getRoomVariant
|
|
43
42
|
local ____roomShape = require("functions.roomShape")
|
|
44
43
|
local getGridIndexDelta = ____roomShape.getGridIndexDelta
|
|
45
44
|
function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
@@ -175,8 +174,8 @@ end
|
|
|
175
174
|
function ____exports.inDoubleTrouble(self)
|
|
176
175
|
local room = game:GetRoom()
|
|
177
176
|
local roomType = room:GetType()
|
|
178
|
-
local
|
|
179
|
-
return roomType == RoomType.ROOM_BOSS and
|
|
177
|
+
local roomName = getRoomName(nil)
|
|
178
|
+
return roomType == RoomType.ROOM_BOSS and __TS__StringIncludes(roomName, "Double Trouble")
|
|
180
179
|
end
|
|
181
180
|
function ____exports.inGenesisRoom(self)
|
|
182
181
|
local roomGridIndex = getRoomGridIndex(nil)
|
|
@@ -10,13 +10,13 @@ function ____exports.giveTrinketsBack(self, player, trinketSituation)
|
|
|
10
10
|
if trinketSituation == nil then
|
|
11
11
|
return
|
|
12
12
|
end
|
|
13
|
-
local
|
|
14
|
-
local
|
|
15
|
-
if
|
|
16
|
-
player:TryRemoveTrinket(
|
|
13
|
+
local trinketType1 = player:GetTrinket(0)
|
|
14
|
+
local trinketType2 = player:GetTrinket(1)
|
|
15
|
+
if trinketType1 ~= TrinketType.TRINKET_NULL then
|
|
16
|
+
player:TryRemoveTrinket(trinketType1)
|
|
17
17
|
end
|
|
18
|
-
if
|
|
19
|
-
player:TryRemoveTrinket(
|
|
18
|
+
if trinketType2 ~= TrinketType.TRINKET_NULL then
|
|
19
|
+
player:TryRemoveTrinket(trinketType2)
|
|
20
20
|
end
|
|
21
21
|
____repeat(
|
|
22
22
|
nil,
|
|
@@ -26,47 +26,47 @@ function ____exports.giveTrinketsBack(self, player, trinketSituation)
|
|
|
26
26
|
useActiveItemTemp(nil, player, CollectibleType.COLLECTIBLE_SMELTER)
|
|
27
27
|
end
|
|
28
28
|
)
|
|
29
|
-
if trinketSituation.
|
|
30
|
-
player:AddTrinket(trinketSituation.
|
|
29
|
+
if trinketSituation.trinketType1 ~= TrinketType.TRINKET_NULL then
|
|
30
|
+
player:AddTrinket(trinketSituation.trinketType1, false)
|
|
31
31
|
end
|
|
32
|
-
if trinketSituation.
|
|
33
|
-
player:AddTrinket(trinketSituation.
|
|
32
|
+
if trinketSituation.trinketType2 ~= TrinketType.TRINKET_NULL then
|
|
33
|
+
player:AddTrinket(trinketSituation.trinketType2, false)
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
function ____exports.temporarilyRemoveTrinket(self, player, trinketType)
|
|
37
37
|
if not player:HasTrinket(trinketType) then
|
|
38
38
|
return nil
|
|
39
39
|
end
|
|
40
|
-
local
|
|
41
|
-
local
|
|
40
|
+
local trinketType1 = player:GetTrinket(0)
|
|
41
|
+
local trinketType2 = player:GetTrinket(1)
|
|
42
42
|
local numTrinkets = 0
|
|
43
43
|
while player:HasTrinket(trinketType) do
|
|
44
44
|
player:TryRemoveTrinket(trinketType)
|
|
45
45
|
numTrinkets = numTrinkets + 1
|
|
46
46
|
end
|
|
47
47
|
local numSmeltedTrinkets = numTrinkets
|
|
48
|
-
local trinketWasInSlot1 =
|
|
48
|
+
local trinketWasInSlot1 = trinketType1 == trinketType or trinketType1 + TRINKET_GOLDEN_FLAG == trinketType
|
|
49
49
|
if trinketWasInSlot1 then
|
|
50
50
|
numSmeltedTrinkets = numSmeltedTrinkets - 1
|
|
51
51
|
end
|
|
52
|
-
local trinketWasInSlot2 =
|
|
52
|
+
local trinketWasInSlot2 = trinketType2 == trinketType or trinketType2 + TRINKET_GOLDEN_FLAG == trinketType
|
|
53
53
|
if trinketWasInSlot2 then
|
|
54
54
|
numSmeltedTrinkets = numSmeltedTrinkets - 1
|
|
55
55
|
end
|
|
56
|
-
return {trinketTypeRemoved = trinketType,
|
|
56
|
+
return {trinketTypeRemoved = trinketType, trinketType1 = trinketType1, trinketType2 = trinketType2, numSmeltedTrinkets = numSmeltedTrinkets}
|
|
57
57
|
end
|
|
58
58
|
function ____exports.temporarilyRemoveTrinkets(self, player)
|
|
59
|
-
local
|
|
60
|
-
local
|
|
61
|
-
if
|
|
59
|
+
local trinketType1 = player:GetTrinket(0)
|
|
60
|
+
local trinketType2 = player:GetTrinket(1)
|
|
61
|
+
if trinketType1 == TrinketType.TRINKET_NULL and trinketType2 == TrinketType.TRINKET_NULL then
|
|
62
62
|
return nil
|
|
63
63
|
end
|
|
64
|
-
if
|
|
65
|
-
player:TryRemoveTrinket(
|
|
64
|
+
if trinketType1 ~= TrinketType.TRINKET_NULL then
|
|
65
|
+
player:TryRemoveTrinket(trinketType1)
|
|
66
66
|
end
|
|
67
|
-
if
|
|
68
|
-
player:TryRemoveTrinket(
|
|
67
|
+
if trinketType2 ~= TrinketType.TRINKET_NULL then
|
|
68
|
+
player:TryRemoveTrinket(trinketType2)
|
|
69
69
|
end
|
|
70
|
-
return {trinketTypeRemoved = TrinketType.TRINKET_NULL,
|
|
70
|
+
return {trinketTypeRemoved = TrinketType.TRINKET_NULL, trinketType1 = trinketType1, trinketType2 = trinketType2, numSmeltedTrinkets = 0}
|
|
71
71
|
end
|
|
72
72
|
return ____exports
|
|
@@ -28,16 +28,16 @@ function ____exports.getMaxTrinketType(self)
|
|
|
28
28
|
end
|
|
29
29
|
function ____exports.getOpenTrinketSlot(self, player)
|
|
30
30
|
local maxTrinkets = player:GetMaxTrinkets()
|
|
31
|
-
local
|
|
32
|
-
local
|
|
31
|
+
local trinketType1 = player:GetTrinket(0)
|
|
32
|
+
local trinketType2 = player:GetTrinket(1)
|
|
33
33
|
if maxTrinkets == 1 then
|
|
34
|
-
return
|
|
34
|
+
return trinketType1 == TrinketType.TRINKET_NULL and 0 or nil
|
|
35
35
|
end
|
|
36
36
|
if maxTrinkets == 2 then
|
|
37
|
-
if
|
|
37
|
+
if trinketType1 == TrinketType.TRINKET_NULL then
|
|
38
38
|
return 0
|
|
39
39
|
end
|
|
40
|
-
return
|
|
40
|
+
return trinketType2 == TrinketType.TRINKET_NULL and 1 or nil
|
|
41
41
|
end
|
|
42
42
|
return error("The player has an unknown number of trinket slots: " .. tostring(maxTrinkets))
|
|
43
43
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
export interface TrinketSituation {
|
|
3
3
|
trinketTypeRemoved: TrinketType | int;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
trinketType1: TrinketType | int;
|
|
5
|
+
trinketType2: TrinketType | int;
|
|
6
6
|
numSmeltedTrinkets: int;
|
|
7
7
|
}
|