isaacscript-common 1.2.71 → 1.2.72
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/array.lua +7 -5
- package/dist/functions/collectibleCacheFlag.lua +6 -5
- package/dist/functions/entity.lua +12 -15
- package/dist/functions/familiars.lua +7 -5
- package/dist/functions/log.lua +16 -21
- package/dist/functions/player.d.ts +5 -0
- package/dist/functions/player.lua +51 -33
- package/dist/functions/position.lua +2 -1
- package/dist/functions/trinketCacheFlag.lua +2 -2
- package/dist/functions/trinketGive.lua +7 -5
- package/dist/functions/trinketSet.lua +8 -9
- package/dist/functions/trinkets.d.ts +1 -1
- package/dist/functions/trinkets.lua +8 -6
- package/dist/functions/utils.d.ts +16 -0
- package/package.json +1 -1
package/dist/functions/array.lua
CHANGED
|
@@ -11,6 +11,8 @@ local ____exports = {}
|
|
|
11
11
|
local ____random = require("functions.random")
|
|
12
12
|
local getRandomInt = ____random.getRandomInt
|
|
13
13
|
local nextSeed = ____random.nextSeed
|
|
14
|
+
local ____utils = require("functions.utils")
|
|
15
|
+
local ____repeat = ____utils["repeat"]
|
|
14
16
|
function ____exports.shuffleArrayInPlace(self, array, seed)
|
|
15
17
|
if seed == nil then
|
|
16
18
|
seed = Random()
|
|
@@ -66,13 +68,13 @@ function ____exports.arrayEquals(self, array1, array2)
|
|
|
66
68
|
end
|
|
67
69
|
function ____exports.initArray(self, defaultValue, size)
|
|
68
70
|
local array = {}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
____repeat(
|
|
72
|
+
nil,
|
|
73
|
+
size,
|
|
74
|
+
function()
|
|
72
75
|
__TS__ArrayPush(array, defaultValue)
|
|
73
|
-
i = i + 1
|
|
74
76
|
end
|
|
75
|
-
|
|
77
|
+
)
|
|
76
78
|
return array
|
|
77
79
|
end
|
|
78
80
|
function ____exports.isArrayInArray(self, arrayToMatch, parentArray)
|
|
@@ -15,6 +15,7 @@ local ____set = require("functions.set")
|
|
|
15
15
|
local copySet = ____set.copySet
|
|
16
16
|
local ____utils = require("functions.utils")
|
|
17
17
|
local getEnumValues = ____utils.getEnumValues
|
|
18
|
+
local ____repeat = ____utils["repeat"]
|
|
18
19
|
local CACHE_FLAG_TO_COLLECTIBLES_MAP = __TS__New(Map)
|
|
19
20
|
local function initCacheFlagMap(self)
|
|
20
21
|
local maxCollectibleType = getMaxCollectibleType(nil)
|
|
@@ -43,13 +44,13 @@ function ____exports.getPlayerCollectiblesForCacheFlag(self, player, cacheFlag)
|
|
|
43
44
|
local playerCollectibles = {}
|
|
44
45
|
for ____, collectibleType in __TS__Iterator(collectiblesForCacheFlag:values()) do
|
|
45
46
|
local numCollectibles = player:GetCollectibleNum(collectibleType)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
____repeat(
|
|
48
|
+
nil,
|
|
49
|
+
numCollectibles,
|
|
50
|
+
function()
|
|
49
51
|
__TS__ArrayPush(playerCollectibles, collectibleType)
|
|
50
|
-
i = i + 1
|
|
51
52
|
end
|
|
52
|
-
|
|
53
|
+
)
|
|
53
54
|
end
|
|
54
55
|
return playerCollectibles
|
|
55
56
|
end
|
|
@@ -12,6 +12,8 @@ local STORY_BOSSES = ____constants.STORY_BOSSES
|
|
|
12
12
|
local ____random = require("functions.random")
|
|
13
13
|
local getRandom = ____random.getRandom
|
|
14
14
|
local nextSeed = ____random.nextSeed
|
|
15
|
+
local ____utils = require("functions.utils")
|
|
16
|
+
local ____repeat = ____utils["repeat"]
|
|
15
17
|
function ____exports.getEntities(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
|
|
16
18
|
if matchingVariant == nil then
|
|
17
19
|
matchingVariant = -1
|
|
@@ -227,16 +229,11 @@ function ____exports.removeEntities(self, entities, cap)
|
|
|
227
229
|
return false
|
|
228
230
|
end
|
|
229
231
|
local numEntitiesRemoved = 0
|
|
230
|
-
do
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
numEntitiesRemoved = numEntitiesRemoved + 1
|
|
236
|
-
if cap ~= nil and numEntitiesRemoved >= cap then
|
|
237
|
-
return true
|
|
238
|
-
end
|
|
239
|
-
i = i + 1
|
|
232
|
+
for ____, entity in ipairs(entities) do
|
|
233
|
+
entity:Remove()
|
|
234
|
+
numEntitiesRemoved = numEntitiesRemoved + 1
|
|
235
|
+
if cap ~= nil and numEntitiesRemoved >= cap then
|
|
236
|
+
return true
|
|
240
237
|
end
|
|
241
238
|
end
|
|
242
239
|
return true
|
|
@@ -311,15 +308,15 @@ end
|
|
|
311
308
|
function ____exports.setEntityRandomColor(self, entity)
|
|
312
309
|
local colorValues = {}
|
|
313
310
|
local seed = entity.InitSeed
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
311
|
+
____repeat(
|
|
312
|
+
nil,
|
|
313
|
+
3,
|
|
314
|
+
function()
|
|
317
315
|
seed = nextSeed(nil, seed)
|
|
318
316
|
local randomColorValue = getRandom(nil, seed)
|
|
319
317
|
__TS__ArrayPush(colorValues, randomColorValue)
|
|
320
|
-
i = i + 1
|
|
321
318
|
end
|
|
322
|
-
|
|
319
|
+
)
|
|
323
320
|
local color = Color(colorValues[1], colorValues[2], colorValues[3])
|
|
324
321
|
entity:SetColor(
|
|
325
322
|
color,
|
|
@@ -8,6 +8,8 @@ local FAMILIARS_THAT_SHOOT_PLAYER_TEARS = ____constants.FAMILIARS_THAT_SHOOT_PLA
|
|
|
8
8
|
local ____entity = require("functions.entity")
|
|
9
9
|
local getEntities = ____entity.getEntities
|
|
10
10
|
local removeEntities = ____entity.removeEntities
|
|
11
|
+
local ____utils = require("functions.utils")
|
|
12
|
+
local ____repeat = ____utils["repeat"]
|
|
11
13
|
function ____exports.getFamiliars(self, matchingVariant, matchingSubType)
|
|
12
14
|
if matchingVariant == nil then
|
|
13
15
|
matchingVariant = -1
|
|
@@ -52,9 +54,10 @@ function ____exports.checkFamiliar(self, player, collectibleType, numTargetFamil
|
|
|
52
54
|
local numFamiliarsToSpawn = numTargetFamiliars - #familiarsForThisPlayer
|
|
53
55
|
local collectibleRNG = player:GetCollectibleRNG(collectibleType)
|
|
54
56
|
local familiarSubTypeToUse = familiarSubType == nil and 0 or familiarSubType
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
____repeat(
|
|
58
|
+
nil,
|
|
59
|
+
numFamiliarsToSpawn,
|
|
60
|
+
function()
|
|
58
61
|
collectibleRNG:Next()
|
|
59
62
|
local familiar = game:Spawn(
|
|
60
63
|
EntityType.ENTITY_FAMILIAR,
|
|
@@ -68,9 +71,8 @@ function ____exports.checkFamiliar(self, player, collectibleType, numTargetFamil
|
|
|
68
71
|
if familiar ~= nil then
|
|
69
72
|
familiar.Player = player
|
|
70
73
|
end
|
|
71
|
-
i = i + 1
|
|
72
74
|
end
|
|
73
|
-
|
|
75
|
+
)
|
|
74
76
|
return numFamiliarsToSpawn
|
|
75
77
|
end
|
|
76
78
|
function ____exports.checkFamiliarFromCollectibles(self, player, collectibleType, familiarVariant, familiarSubType)
|
package/dist/functions/log.lua
CHANGED
|
@@ -10,6 +10,8 @@ local ____collectibles = require("functions.collectibles")
|
|
|
10
10
|
local getCollectibleName = ____collectibles.getCollectibleName
|
|
11
11
|
local ____flag = require("functions.flag")
|
|
12
12
|
local hasFlag = ____flag.hasFlag
|
|
13
|
+
local ____player = require("functions.player")
|
|
14
|
+
local getEffectsList = ____player.getEffectsList
|
|
13
15
|
local ____trinkets = require("functions.trinkets")
|
|
14
16
|
local getTrinketName = ____trinkets.getTrinketName
|
|
15
17
|
function ____exports.getDebugPrependString(self, msg, numParentFunctions)
|
|
@@ -146,34 +148,27 @@ function ____exports.logTable(____table, parentTables)
|
|
|
146
148
|
end
|
|
147
149
|
end
|
|
148
150
|
function ____exports.logTemporaryEffects(player)
|
|
149
|
-
local effects = player
|
|
150
|
-
local effectsList = effects:GetEffectsList()
|
|
151
|
+
local effects = getEffectsList(nil, player)
|
|
151
152
|
____exports.log("Logging all player temporary effects:")
|
|
152
|
-
if
|
|
153
|
+
if #effects == 0 then
|
|
153
154
|
____exports.log(" n/a (no temporary effects)")
|
|
154
155
|
return
|
|
155
156
|
end
|
|
156
157
|
do
|
|
157
158
|
local i = 0
|
|
158
|
-
while i <
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
elseif effect.Item:IsNull() then
|
|
171
|
-
____exports.log(((" " .. tostring(i + 1)) .. ") Null item: ") .. tostring(effect.Item.ID))
|
|
172
|
-
else
|
|
173
|
-
____exports.log(((" " .. tostring(i + 1)) .. ") Unknown type of temporary effect: ") .. tostring(effect.Item.ID))
|
|
174
|
-
end
|
|
159
|
+
while i < #effects do
|
|
160
|
+
local effect = effects[i + 1]
|
|
161
|
+
if effect.Item:IsCollectible() then
|
|
162
|
+
local collectibleName = getCollectibleName(nil, effect.Item.ID)
|
|
163
|
+
____exports.log(((" " .. tostring(i + 1)) .. ") ") .. collectibleName)
|
|
164
|
+
elseif effect.Item:IsTrinket() then
|
|
165
|
+
local trinketName = getTrinketName(nil, effect.Item.ID)
|
|
166
|
+
____exports.log(((" " .. tostring(i + 1)) .. ") ") .. trinketName)
|
|
167
|
+
elseif effect.Item:IsNull() then
|
|
168
|
+
____exports.log(((" " .. tostring(i + 1)) .. ") Null item: ") .. tostring(effect.Item.ID))
|
|
169
|
+
else
|
|
170
|
+
____exports.log(((" " .. tostring(i + 1)) .. ") Unknown type of temporary effect: ") .. tostring(effect.Item.ID))
|
|
175
171
|
end
|
|
176
|
-
::__continue38::
|
|
177
172
|
i = i + 1
|
|
178
173
|
end
|
|
179
174
|
end
|
|
@@ -67,6 +67,11 @@ export declare function getClosestPlayer(position: Vector): EntityPlayer;
|
|
|
67
67
|
* Tainted Forgotten have a 20 frame death animation (i.e. the "ForgottenDeath" animation).
|
|
68
68
|
*/
|
|
69
69
|
export declare function getDeathAnimationName(player: EntityPlayer): string;
|
|
70
|
+
/**
|
|
71
|
+
* Helper function to get an array of temporary effects for a player. This is helpful so that you
|
|
72
|
+
* don't have to manually create an array from an `EffectsList` object.
|
|
73
|
+
*/
|
|
74
|
+
export declare function getEffectsList(player: EntityPlayer): TemporaryEffect[];
|
|
70
75
|
/**
|
|
71
76
|
* Helper function to return the player with the highest ID, according to the `Isaac.GetPlayer()`
|
|
72
77
|
* method.
|
|
@@ -4,10 +4,10 @@ local Set = ____lualib.Set
|
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
5
|
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
6
6
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
7
|
+
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
7
8
|
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
|
|
8
9
|
local Map = ____lualib.Map
|
|
9
10
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
10
|
-
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
11
11
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
12
12
|
local ____exports = {}
|
|
13
13
|
local getPlayerIndexCollectibleType, getAdjustedPlayerName, isTaintedModded, DEFAULT_COLLECTIBLE_TYPE, EXCLUDED_CHARACTERS
|
|
@@ -74,15 +74,15 @@ end
|
|
|
74
74
|
function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSoul)
|
|
75
75
|
local character = player:GetPlayerType()
|
|
76
76
|
repeat
|
|
77
|
-
local
|
|
78
|
-
local
|
|
79
|
-
if
|
|
77
|
+
local ____switch62 = character
|
|
78
|
+
local ____cond62 = ____switch62 == PlayerType.PLAYER_THESOUL
|
|
79
|
+
if ____cond62 then
|
|
80
80
|
do
|
|
81
81
|
return differentiateForgottenAndSoul and CollectibleType.COLLECTIBLE_SPOON_BENDER or DEFAULT_COLLECTIBLE_TYPE
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
|
-
|
|
85
|
-
if
|
|
84
|
+
____cond62 = ____cond62 or ____switch62 == PlayerType.PLAYER_LAZARUS2_B
|
|
85
|
+
if ____cond62 then
|
|
86
86
|
do
|
|
87
87
|
return CollectibleType.COLLECTIBLE_INNER_EYE
|
|
88
88
|
end
|
|
@@ -110,39 +110,39 @@ end
|
|
|
110
110
|
function getAdjustedPlayerName(self, player)
|
|
111
111
|
local character = player:GetPlayerType()
|
|
112
112
|
repeat
|
|
113
|
-
local
|
|
114
|
-
local
|
|
115
|
-
if
|
|
113
|
+
local ____switch75 = character
|
|
114
|
+
local ____cond75 = ____switch75 == PlayerType.PLAYER_BLUEBABY or ____switch75 == PlayerType.PLAYER_BLUEBABY_B
|
|
115
|
+
if ____cond75 then
|
|
116
116
|
do
|
|
117
117
|
return "Blue Baby"
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
|
-
|
|
121
|
-
if
|
|
120
|
+
____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2
|
|
121
|
+
if ____cond75 then
|
|
122
122
|
do
|
|
123
123
|
return "Lazarus II"
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
|
-
|
|
127
|
-
if
|
|
126
|
+
____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_BLACKJUDAS
|
|
127
|
+
if ____cond75 then
|
|
128
128
|
do
|
|
129
129
|
return "Dark Judas"
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
|
-
|
|
133
|
-
if
|
|
132
|
+
____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB
|
|
133
|
+
if ____cond75 then
|
|
134
134
|
do
|
|
135
135
|
return "Jacob & Esau"
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
|
-
|
|
139
|
-
if
|
|
138
|
+
____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2_B
|
|
139
|
+
if ____cond75 then
|
|
140
140
|
do
|
|
141
141
|
return "Dead Tainted Lazarus"
|
|
142
142
|
end
|
|
143
143
|
end
|
|
144
|
-
|
|
145
|
-
if
|
|
144
|
+
____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB2_B
|
|
145
|
+
if ____cond75 then
|
|
146
146
|
do
|
|
147
147
|
return "Dead Tainted Jacob"
|
|
148
148
|
end
|
|
@@ -159,22 +159,23 @@ function ____exports.getPlayers(self, performExclusions)
|
|
|
159
159
|
performExclusions = false
|
|
160
160
|
end
|
|
161
161
|
local game = Game()
|
|
162
|
+
local numPlayers = game:GetNumPlayers()
|
|
162
163
|
local players = {}
|
|
163
164
|
do
|
|
164
165
|
local i = 0
|
|
165
|
-
while i <
|
|
166
|
+
while i < numPlayers do
|
|
166
167
|
do
|
|
167
168
|
local player = Isaac.GetPlayer(i)
|
|
168
169
|
if ____exports.isChildPlayer(nil, player) then
|
|
169
|
-
goto
|
|
170
|
+
goto __continue85
|
|
170
171
|
end
|
|
171
172
|
local character = player:GetPlayerType()
|
|
172
173
|
if performExclusions and EXCLUDED_CHARACTERS:has(character) then
|
|
173
|
-
goto
|
|
174
|
+
goto __continue85
|
|
174
175
|
end
|
|
175
176
|
__TS__ArrayPush(players, player)
|
|
176
177
|
end
|
|
177
|
-
::
|
|
178
|
+
::__continue85::
|
|
178
179
|
i = i + 1
|
|
179
180
|
end
|
|
180
181
|
end
|
|
@@ -311,6 +312,22 @@ function ____exports.getDeathAnimationName(self, player)
|
|
|
311
312
|
end
|
|
312
313
|
return "Death"
|
|
313
314
|
end
|
|
315
|
+
function ____exports.getEffectsList(self, player)
|
|
316
|
+
local effects = player:GetEffects()
|
|
317
|
+
local effectsList = effects:GetEffectsList()
|
|
318
|
+
local effectArray = {}
|
|
319
|
+
do
|
|
320
|
+
local i = 0
|
|
321
|
+
while i < effectsList.Size do
|
|
322
|
+
local effect = effectsList:Get(i)
|
|
323
|
+
if effect ~= nil then
|
|
324
|
+
__TS__ArrayPush(effectArray, effect)
|
|
325
|
+
end
|
|
326
|
+
i = i + 1
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
return effectArray
|
|
330
|
+
end
|
|
314
331
|
function ____exports.getFinalPlayer(self)
|
|
315
332
|
local players = ____exports.getPlayers(nil)
|
|
316
333
|
return players[#players]
|
|
@@ -408,10 +425,11 @@ function ____exports.getPlayerFromIndex(self, playerIndex)
|
|
|
408
425
|
end
|
|
409
426
|
function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
410
427
|
local game = Game()
|
|
428
|
+
local numPlayers = game:GetNumPlayers()
|
|
411
429
|
local playerToFindHash = GetPtrHash(playerToFind)
|
|
412
430
|
do
|
|
413
431
|
local i = 0
|
|
414
|
-
while i <
|
|
432
|
+
while i < numPlayers do
|
|
415
433
|
local player = Isaac.GetPlayer(i)
|
|
416
434
|
local playerHash = GetPtrHash(player)
|
|
417
435
|
if playerHash == playerToFindHash then
|
|
@@ -548,9 +566,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
548
566
|
itemPool:RemoveCollectible(collectibleType)
|
|
549
567
|
end
|
|
550
568
|
repeat
|
|
551
|
-
local
|
|
552
|
-
local
|
|
553
|
-
if
|
|
569
|
+
local ____switch121 = activeSlot
|
|
570
|
+
local ____cond121 = ____switch121 == ActiveSlot.SLOT_PRIMARY
|
|
571
|
+
if ____cond121 then
|
|
554
572
|
do
|
|
555
573
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
556
574
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -559,8 +577,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
559
577
|
break
|
|
560
578
|
end
|
|
561
579
|
end
|
|
562
|
-
|
|
563
|
-
if
|
|
580
|
+
____cond121 = ____cond121 or ____switch121 == ActiveSlot.SLOT_SECONDARY
|
|
581
|
+
if ____cond121 then
|
|
564
582
|
do
|
|
565
583
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
566
584
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -575,16 +593,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
575
593
|
break
|
|
576
594
|
end
|
|
577
595
|
end
|
|
578
|
-
|
|
579
|
-
if
|
|
596
|
+
____cond121 = ____cond121 or ____switch121 == ActiveSlot.SLOT_POCKET
|
|
597
|
+
if ____cond121 then
|
|
580
598
|
do
|
|
581
599
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
582
600
|
player:SetActiveCharge(charge, activeSlot)
|
|
583
601
|
break
|
|
584
602
|
end
|
|
585
603
|
end
|
|
586
|
-
|
|
587
|
-
if
|
|
604
|
+
____cond121 = ____cond121 or ____switch121 == ActiveSlot.SLOT_POCKET2
|
|
605
|
+
if ____cond121 then
|
|
588
606
|
do
|
|
589
607
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
590
608
|
break
|
|
@@ -7,6 +7,7 @@ local anyEntityCloserThan = ____entity.anyEntityCloserThan
|
|
|
7
7
|
local getEffects = ____entity.getEffects
|
|
8
8
|
local ____player = require("functions.player")
|
|
9
9
|
local getPlayerCloserThan = ____player.getPlayerCloserThan
|
|
10
|
+
local MAX_FIND_FREE_POSITION_ATTEMPTS = 100
|
|
10
11
|
function ____exports.findFreePosition(self, startingPosition, avoidActiveEntities)
|
|
11
12
|
if avoidActiveEntities == nil then
|
|
12
13
|
avoidActiveEntities = false
|
|
@@ -16,7 +17,7 @@ function ____exports.findFreePosition(self, startingPosition, avoidActiveEntitie
|
|
|
16
17
|
local heavenDoors = getEffects(nil, EffectVariant.HEAVEN_LIGHT_DOOR, 0)
|
|
17
18
|
do
|
|
18
19
|
local i = 0
|
|
19
|
-
while i <
|
|
20
|
+
while i < MAX_FIND_FREE_POSITION_ATTEMPTS do
|
|
20
21
|
do
|
|
21
22
|
local position = room:FindFreePickupSpawnPosition(startingPosition, i, avoidActiveEntities)
|
|
22
23
|
local closePlayer = getPlayerCloserThan(nil, position, DISTANCE_OF_GRID_TILE)
|
|
@@ -10,13 +10,13 @@ local range = ____math.range
|
|
|
10
10
|
local ____set = require("functions.set")
|
|
11
11
|
local copySet = ____set.copySet
|
|
12
12
|
local ____trinkets = require("functions.trinkets")
|
|
13
|
-
local
|
|
13
|
+
local getMaxTrinketType = ____trinkets.getMaxTrinketType
|
|
14
14
|
local trinketHasCacheFlag = ____trinkets.trinketHasCacheFlag
|
|
15
15
|
local ____utils = require("functions.utils")
|
|
16
16
|
local getEnumValues = ____utils.getEnumValues
|
|
17
17
|
local CACHE_FLAG_TO_TRINKETS_MAP = __TS__New(Map)
|
|
18
18
|
local function initCacheFlagMap(self)
|
|
19
|
-
local maxTrinketID =
|
|
19
|
+
local maxTrinketID = getMaxTrinketType(nil)
|
|
20
20
|
for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
|
|
21
21
|
local trinketsSet = __TS__New(Set)
|
|
22
22
|
for ____, trinketType in ipairs(range(nil, 1, maxTrinketID)) do
|
|
@@ -4,6 +4,8 @@ local ____constants = require("constants")
|
|
|
4
4
|
local GOLDEN_TRINKET_SHIFT = ____constants.GOLDEN_TRINKET_SHIFT
|
|
5
5
|
local ____player = require("functions.player")
|
|
6
6
|
local useActiveItemTemp = ____player.useActiveItemTemp
|
|
7
|
+
local ____utils = require("functions.utils")
|
|
8
|
+
local ____repeat = ____utils["repeat"]
|
|
7
9
|
function ____exports.temporarilyRemoveTrinket(self, player, trinketType)
|
|
8
10
|
if not player:HasTrinket(trinketType) then
|
|
9
11
|
return nil
|
|
@@ -52,14 +54,14 @@ function ____exports.giveTrinketsBack(self, player, trinketSituation)
|
|
|
52
54
|
if trinket2 ~= TrinketType.TRINKET_NULL then
|
|
53
55
|
player:TryRemoveTrinket(trinket2)
|
|
54
56
|
end
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
____repeat(
|
|
58
|
+
nil,
|
|
59
|
+
trinketSituation.numSmeltedTrinkets,
|
|
60
|
+
function()
|
|
58
61
|
player:AddTrinket(trinketSituation.trinketTypeRemoved, false)
|
|
59
62
|
useActiveItemTemp(nil, player, CollectibleType.COLLECTIBLE_SMELTER)
|
|
60
|
-
i = i + 1
|
|
61
63
|
end
|
|
62
|
-
|
|
64
|
+
)
|
|
63
65
|
if trinketSituation.trinket1 ~= TrinketType.TRINKET_NULL then
|
|
64
66
|
player:AddTrinket(trinketSituation.trinket1, false)
|
|
65
67
|
end
|
|
@@ -3,21 +3,20 @@ local ____lualib = require("lualib_bundle")
|
|
|
3
3
|
local Set = ____lualib.Set
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
5
|
local ____exports = {}
|
|
6
|
+
local ____math = require("functions.math")
|
|
7
|
+
local range = ____math.range
|
|
6
8
|
local ____set = require("functions.set")
|
|
7
9
|
local copySet = ____set.copySet
|
|
8
10
|
local ____trinkets = require("functions.trinkets")
|
|
9
|
-
local
|
|
11
|
+
local getMaxTrinketType = ____trinkets.getMaxTrinketType
|
|
10
12
|
local TRINKET_SET = __TS__New(Set)
|
|
11
13
|
local function initTrinketSet(self)
|
|
12
14
|
local itemConfig = Isaac.GetItemConfig()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
TRINKET_SET:add(trinketType)
|
|
19
|
-
end
|
|
20
|
-
trinketType = trinketType + 1
|
|
15
|
+
local maxTrinketID = getMaxTrinketType(nil)
|
|
16
|
+
for ____, trinketType in ipairs(range(nil, 1, maxTrinketID)) do
|
|
17
|
+
local itemConfigTrinket = itemConfig:GetTrinket(trinketType)
|
|
18
|
+
if itemConfigTrinket ~= nil then
|
|
19
|
+
TRINKET_SET:add(trinketType)
|
|
21
20
|
end
|
|
22
21
|
end
|
|
23
22
|
end
|
|
@@ -15,7 +15,9 @@ local useActiveItemTemp = ____player.useActiveItemTemp
|
|
|
15
15
|
local ____trinketGive = require("functions.trinketGive")
|
|
16
16
|
local giveTrinketsBack = ____trinketGive.giveTrinketsBack
|
|
17
17
|
local temporarilyRemoveTrinkets = ____trinketGive.temporarilyRemoveTrinkets
|
|
18
|
-
|
|
18
|
+
local ____utils = require("functions.utils")
|
|
19
|
+
local ____repeat = ____utils["repeat"]
|
|
20
|
+
function ____exports.getMaxTrinketType(self)
|
|
19
21
|
local itemConfig = Isaac.GetItemConfig()
|
|
20
22
|
return itemConfig:GetTrinkets().Size - 1
|
|
21
23
|
end
|
|
@@ -88,14 +90,14 @@ function ____exports.smeltTrinket(self, player, trinketType, numTrinkets)
|
|
|
88
90
|
numTrinkets = 1
|
|
89
91
|
end
|
|
90
92
|
local trinketSituation = temporarilyRemoveTrinkets(nil, player)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
____repeat(
|
|
94
|
+
nil,
|
|
95
|
+
numTrinkets,
|
|
96
|
+
function()
|
|
94
97
|
player:AddTrinket(trinketType)
|
|
95
98
|
useActiveItemTemp(nil, player, CollectibleType.COLLECTIBLE_SMELTER)
|
|
96
|
-
i = i + 1
|
|
97
99
|
end
|
|
98
|
-
|
|
100
|
+
)
|
|
99
101
|
giveTrinketsBack(nil, player, trinketSituation)
|
|
100
102
|
end
|
|
101
103
|
function ____exports.trinketHasCacheFlag(self, trinketType, cacheFlag)
|
|
@@ -82,5 +82,21 @@ export declare function onSetSeed(): boolean;
|
|
|
82
82
|
export declare function printConsole(msg: string): void;
|
|
83
83
|
/**
|
|
84
84
|
* Helper function to repeat code N times. This is faster to type and cleaner than using a for loop.
|
|
85
|
+
*
|
|
86
|
+
* Example:
|
|
87
|
+
* ```ts
|
|
88
|
+
* const player = Isaac.GetPlayer();
|
|
89
|
+
* repeat(10, () => {
|
|
90
|
+
* player.AddCollectible(CollectibleType.COLLECTIBLE_STEVEN);
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* The repeated function is passed the index of the iteration, if needed:
|
|
95
|
+
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* repeat(3, (i) => {
|
|
98
|
+
* print(i); // Prints "0", "1", "2"
|
|
99
|
+
* });
|
|
100
|
+
* ```
|
|
85
101
|
*/
|
|
86
102
|
export declare function repeat(n: int, func: (i: int) => void): void;
|