isaacscript-common 1.2.275 → 1.2.278
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/log.lua +61 -49
- 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/log.lua
CHANGED
|
@@ -82,14 +82,14 @@ function ____exports.logFlags(flags, flagEnum, description)
|
|
|
82
82
|
for key, value in pairs(flagEnum) do
|
|
83
83
|
do
|
|
84
84
|
if type(value) ~= "number" then
|
|
85
|
-
goto
|
|
85
|
+
goto __continue43
|
|
86
86
|
end
|
|
87
87
|
if hasFlag(nil, flags, value) then
|
|
88
88
|
____exports.log((((" Has flag: " .. tostring(key)) .. " (") .. tostring(value)) .. ")")
|
|
89
89
|
hasNoFlags = false
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
|
-
::
|
|
92
|
+
::__continue43::
|
|
93
93
|
end
|
|
94
94
|
if hasNoFlags then
|
|
95
95
|
____exports.log(" n/a (no flags)")
|
|
@@ -143,15 +143,13 @@ function ____exports.logEffects(player)
|
|
|
143
143
|
)
|
|
144
144
|
end
|
|
145
145
|
function ____exports.logEntities(includeBackgroundEffects, entityTypeFilter)
|
|
146
|
-
local
|
|
146
|
+
local msg = "Entities in the room"
|
|
147
147
|
if entityTypeFilter ~= nil then
|
|
148
|
-
|
|
148
|
+
msg = msg .. (" (filtered to entity type " .. tostring(entityTypeFilter)) .. ")"
|
|
149
|
+
elseif not includeBackgroundEffects then
|
|
150
|
+
msg = msg .. " (not including background effects)"
|
|
149
151
|
end
|
|
150
|
-
|
|
151
|
-
headerMsg = headerMsg .. " (not excluding background effects)"
|
|
152
|
-
end
|
|
153
|
-
headerMsg = headerMsg .. ":"
|
|
154
|
-
____exports.log(headerMsg)
|
|
152
|
+
msg = msg .. ":\n"
|
|
155
153
|
local entities = getEntities(nil)
|
|
156
154
|
local numMatchedEntities = 0
|
|
157
155
|
__TS__ArrayForEach(
|
|
@@ -164,62 +162,70 @@ function ____exports.logEntities(includeBackgroundEffects, entityTypeFilter)
|
|
|
164
162
|
return
|
|
165
163
|
end
|
|
166
164
|
local entityID = getEntityID(nil, entity)
|
|
167
|
-
|
|
165
|
+
msg = msg .. (tostring(i + 1) .. ") ") .. entityID
|
|
168
166
|
local bomb = entity:ToBomb()
|
|
169
167
|
if bomb ~= nil then
|
|
170
|
-
|
|
168
|
+
msg = msg .. " (bomb)"
|
|
171
169
|
end
|
|
172
170
|
local effect = entity:ToEffect()
|
|
173
171
|
if effect ~= nil then
|
|
174
|
-
|
|
172
|
+
msg = msg .. (" (effect) (State: " .. tostring(effect.State)) .. ")"
|
|
175
173
|
end
|
|
176
174
|
local familiar = entity:ToFamiliar()
|
|
177
175
|
if familiar ~= nil then
|
|
178
|
-
|
|
176
|
+
msg = msg .. (" (familiar) (State: " .. tostring(familiar.State)) .. ")"
|
|
179
177
|
end
|
|
180
178
|
local knife = entity:ToKnife()
|
|
181
179
|
if knife ~= nil then
|
|
182
|
-
|
|
180
|
+
msg = msg .. " (knife)"
|
|
183
181
|
end
|
|
184
182
|
local laser = entity:ToLaser()
|
|
185
183
|
if laser ~= nil then
|
|
186
|
-
|
|
184
|
+
msg = msg .. " (laser)"
|
|
187
185
|
end
|
|
188
186
|
local npc = entity:ToNPC()
|
|
189
187
|
if npc ~= nil then
|
|
190
|
-
|
|
188
|
+
msg = msg .. (" (NPC) (State: " .. tostring(npc.State)) .. ")"
|
|
191
189
|
end
|
|
192
190
|
local pickup = entity:ToPickup()
|
|
193
191
|
if pickup ~= nil then
|
|
194
|
-
|
|
192
|
+
msg = msg .. (" (pickup) (State: " .. tostring(pickup.State)) .. ")"
|
|
195
193
|
end
|
|
196
194
|
local player = entity:ToPlayer()
|
|
197
195
|
if player ~= nil then
|
|
198
|
-
|
|
196
|
+
msg = msg .. " (player)"
|
|
199
197
|
end
|
|
200
198
|
local projectile = entity:ToProjectile()
|
|
201
199
|
if projectile ~= nil then
|
|
202
|
-
|
|
200
|
+
msg = msg .. " (projectile)"
|
|
203
201
|
end
|
|
204
202
|
local tear = entity:ToTear()
|
|
205
203
|
if tear ~= nil then
|
|
206
|
-
|
|
204
|
+
msg = msg .. " (tear)"
|
|
205
|
+
end
|
|
206
|
+
msg = msg .. "\n"
|
|
207
|
+
msg = msg .. (" - Index: " .. tostring(entity.Index)) .. "\n"
|
|
208
|
+
msg = msg .. (" - InitSeed: " .. tostring(entity.InitSeed)) .. "\n"
|
|
209
|
+
msg = msg .. (" - DropSeed: " .. tostring(entity.DropSeed)) .. "\n"
|
|
210
|
+
msg = msg .. (((" - Position: (" .. tostring(entity.Position.X)) .. ", ") .. tostring(entity.Position.Y)) .. ")\n"
|
|
211
|
+
msg = msg .. (((" - Velocity: (" .. tostring(entity.Velocity.X)) .. ", ") .. tostring(entity.Velocity.Y)) .. ")\n"
|
|
212
|
+
msg = msg .. (((" - HP: " .. tostring(entity.HitPoints)) .. " / ") .. tostring(entity.MaxHitPoints)) .. "\n"
|
|
213
|
+
msg = msg .. (" - Parent: " .. tostring(entity.Parent)) .. "\n"
|
|
214
|
+
msg = msg .. (" - Child: " .. tostring(entity.Child)) .. "\n"
|
|
215
|
+
msg = msg .. (" - SpawnerEntity: " .. tostring(entity.SpawnerEntity)) .. "\n"
|
|
216
|
+
msg = msg .. (((" - SpawnerType / SpawnerVariant: " .. tostring(entity.SpawnerType)) .. ".") .. tostring(entity.SpawnerVariant)) .. "\n"
|
|
217
|
+
if npc ~= nil then
|
|
218
|
+
msg = msg .. (" - CanShutDoors: " .. tostring(npc.CanShutDoors)) .. "\n"
|
|
207
219
|
end
|
|
208
|
-
debugString = debugString .. (" (Index: " .. tostring(entity.Index)) .. ")"
|
|
209
|
-
debugString = debugString .. (" (InitSeed: " .. tostring(entity.InitSeed)) .. ")"
|
|
210
|
-
debugString = debugString .. (" (DropSeed: " .. tostring(entity.DropSeed)) .. ")"
|
|
211
|
-
debugString = debugString .. (((" (Position: " .. tostring(entity.Position.X)) .. ", ") .. tostring(entity.Position.Y)) .. ")"
|
|
212
|
-
debugString = debugString .. (((" (Velocity: " .. tostring(entity.Velocity.X)) .. ", ") .. tostring(entity.Velocity.Y)) .. ")"
|
|
213
|
-
debugString = debugString .. (((" (HP: " .. tostring(entity.HitPoints)) .. " / ") .. tostring(entity.MaxHitPoints)) .. ")"
|
|
214
|
-
____exports.log(debugString)
|
|
215
220
|
numMatchedEntities = numMatchedEntities + 1
|
|
216
221
|
end
|
|
217
222
|
)
|
|
218
223
|
if numMatchedEntities == 0 then
|
|
219
|
-
|
|
224
|
+
msg = msg .. "(no entities matched)\n"
|
|
220
225
|
else
|
|
221
|
-
|
|
226
|
+
msg = msg .. ("(" .. tostring(numMatchedEntities)) .. " total entities)\n"
|
|
222
227
|
end
|
|
228
|
+
____exports.log(msg)
|
|
223
229
|
end
|
|
224
230
|
function ____exports.logEntityFlags(flags)
|
|
225
231
|
____exports.logFlags(flags, EntityFlag, "entity")
|
|
@@ -248,14 +254,13 @@ function ____exports.logGameStateFlags()
|
|
|
248
254
|
end
|
|
249
255
|
end
|
|
250
256
|
function ____exports.logGridEntities(includeWalls, gridEntityTypeFilter)
|
|
251
|
-
local
|
|
257
|
+
local msg = "Grid entities in the room"
|
|
252
258
|
if gridEntityTypeFilter ~= nil then
|
|
253
|
-
|
|
259
|
+
msg = msg .. (" (filtered to grid entity type " .. tostring(gridEntityTypeFilter)) .. ")"
|
|
260
|
+
elseif not includeWalls then
|
|
261
|
+
msg = msg .. " (not including walls)"
|
|
254
262
|
end
|
|
255
|
-
|
|
256
|
-
headerMsg = headerMsg .. " (not including walls)"
|
|
257
|
-
end
|
|
258
|
-
____exports.log(headerMsg)
|
|
263
|
+
msg = msg .. ":\n"
|
|
259
264
|
local gridEntities = getGridEntities(nil)
|
|
260
265
|
local numMatchedEntities = 0
|
|
261
266
|
__TS__ArrayForEach(
|
|
@@ -271,47 +276,54 @@ function ____exports.logGridEntities(includeWalls, gridEntityTypeFilter)
|
|
|
271
276
|
if not includeWalls and gridEntityType == GridEntityType.GRID_WALL and gridEntityTypeFilter ~= GridEntityType.GRID_WALL then
|
|
272
277
|
return
|
|
273
278
|
end
|
|
274
|
-
|
|
279
|
+
msg = msg .. (((((tostring(gridEntityIndex) .. ") ") .. tostring(gridEntityType)) .. ".") .. tostring(gridEntityVariant)) .. ".") .. tostring(gridEntity.State)
|
|
275
280
|
local door = gridEntity:ToDoor()
|
|
276
281
|
if door ~= nil then
|
|
277
|
-
|
|
282
|
+
msg = msg .. " (door)"
|
|
278
283
|
end
|
|
279
284
|
local pit = gridEntity:ToPit()
|
|
280
285
|
if pit ~= nil then
|
|
281
|
-
|
|
286
|
+
msg = msg .. " (pit)"
|
|
282
287
|
end
|
|
283
288
|
local poop = gridEntity:ToPoop()
|
|
284
289
|
if poop ~= nil then
|
|
285
|
-
|
|
290
|
+
msg = msg .. " (poop)"
|
|
286
291
|
end
|
|
287
292
|
local pressurePlate = gridEntity:ToPressurePlate()
|
|
288
293
|
if pressurePlate ~= nil then
|
|
289
|
-
|
|
294
|
+
msg = msg .. " (pressurePlate)"
|
|
290
295
|
end
|
|
291
296
|
local rock = gridEntity:ToRock()
|
|
292
297
|
if rock ~= nil then
|
|
293
|
-
|
|
298
|
+
msg = msg .. " (rock)"
|
|
294
299
|
end
|
|
295
300
|
local spikes = gridEntity:ToSpikes()
|
|
296
301
|
if spikes ~= nil then
|
|
297
|
-
|
|
302
|
+
msg = msg .. " (spikes)"
|
|
298
303
|
end
|
|
299
304
|
local tnt = gridEntity:ToTNT()
|
|
300
305
|
if tnt ~= nil then
|
|
301
|
-
|
|
306
|
+
msg = msg .. " (TNT)"
|
|
307
|
+
end
|
|
308
|
+
msg = msg .. (" - VarData: " .. tostring(gridEntity.VarData)) .. "\n"
|
|
309
|
+
msg = msg .. (((" - Position: (" .. tostring(gridEntity.Position.X)) .. ", ") .. tostring(gridEntity.Position.Y)) .. ")\n"
|
|
310
|
+
msg = msg .. (" - SpawnSeed: " .. tostring(gridEntityDesc.SpawnSeed)) .. "\n"
|
|
311
|
+
msg = msg .. (" - VariableSeed: " .. tostring(gridEntityDesc.VariableSeed)) .. ")\n"
|
|
312
|
+
if door ~= nil then
|
|
313
|
+
msg = msg .. (" - Slot: " .. tostring(door.Slot)) .. "\n"
|
|
314
|
+
msg = msg .. (" - Direction: " .. tostring(door.Direction)) .. "\n"
|
|
315
|
+
msg = msg .. (" - TargetRoomIndex: " .. tostring(door.TargetRoomIndex)) .. "\n"
|
|
316
|
+
msg = msg .. (" - TargetRoomType: " .. tostring(door.TargetRoomType)) .. "\n"
|
|
302
317
|
end
|
|
303
|
-
debugString = debugString .. (" (VarData: " .. tostring(gridEntity.VarData)) .. ")"
|
|
304
|
-
debugString = debugString .. (((" (Position: " .. tostring(gridEntity.Position.X)) .. ", ") .. tostring(gridEntity.Position.Y)) .. ")"
|
|
305
|
-
debugString = debugString .. (((" (SpawnSeed: " .. tostring(gridEntityDesc.SpawnSeed)) .. ", VariableSeed: ") .. tostring(gridEntityDesc.VariableSeed)) .. ")"
|
|
306
|
-
____exports.log(debugString)
|
|
307
318
|
numMatchedEntities = numMatchedEntities + 1
|
|
308
319
|
end
|
|
309
320
|
)
|
|
310
321
|
if numMatchedEntities == 0 then
|
|
311
|
-
|
|
322
|
+
msg = msg .. "(no grid entities matched)\n"
|
|
312
323
|
else
|
|
313
|
-
|
|
324
|
+
msg = msg .. ("(" .. tostring(numMatchedEntities)) .. " total grid entities)\n"
|
|
314
325
|
end
|
|
326
|
+
____exports.log(msg)
|
|
315
327
|
end
|
|
316
328
|
function ____exports.logKColor(kColor)
|
|
317
329
|
____exports.log((((((("Color: R" .. tostring(kColor.Red)) .. ", G") .. tostring(kColor.Green)) .. ", B") .. tostring(kColor.Blue)) .. ", A") .. tostring(kColor.Alpha))
|
|
@@ -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
|
}
|