isaacscript-common 1.2.193 → 1.2.196

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.
Files changed (58) hide show
  1. package/dist/callbacks/customRevive.lua +3 -3
  2. package/dist/callbacks/postEsauJr.lua +2 -2
  3. package/dist/callbacks/postPlayerChangeHealth.lua +2 -2
  4. package/dist/callbacks/postPlayerFatalDamage.lua +2 -2
  5. package/dist/callbacks/postPlayerReordered.lua +3 -3
  6. package/dist/callbacks/preBerserkDeath.lua +2 -1
  7. package/dist/constants.d.ts +2 -38
  8. package/dist/constants.lua +3 -103
  9. package/dist/features/extraConsoleCommands/commands.lua +5 -3
  10. package/dist/features/playerInventory.lua +3 -3
  11. package/dist/functions/character.d.ts +46 -0
  12. package/dist/functions/character.lua +64 -0
  13. package/dist/functions/charge.lua +2 -2
  14. package/dist/functions/collectibles.lua +7 -6
  15. package/dist/functions/entity.lua +3 -3
  16. package/dist/functions/familiars.lua +3 -3
  17. package/dist/functions/flying.lua +1 -1
  18. package/dist/functions/pickups.d.ts +5 -0
  19. package/dist/functions/pickups.lua +33 -2
  20. package/dist/functions/player.d.ts +23 -127
  21. package/dist/functions/player.lua +86 -247
  22. package/dist/functions/playerDataStructures.lua +2 -2
  23. package/dist/functions/playerHealth.lua +7 -7
  24. package/dist/functions/playerIndex.d.ts +67 -0
  25. package/dist/functions/playerIndex.lua +125 -0
  26. package/dist/functions/pocketItems.d.ts +5 -0
  27. package/dist/functions/pocketItems.lua +5 -0
  28. package/dist/functions/positionVelocity.lua +2 -1
  29. package/dist/functions/revive.lua +6 -4
  30. package/dist/functions/utils.d.ts +2 -1
  31. package/dist/functions/utils.lua +5 -0
  32. package/dist/index.d.ts +3 -1
  33. package/dist/index.lua +17 -1
  34. package/dist/objects/colors.d.ts +17 -0
  35. package/dist/objects/colors.lua +13 -0
  36. package/dist/sets/charactersThatStartWithAnActiveItemSet.d.ts +2 -0
  37. package/dist/sets/charactersThatStartWithAnActiveItemSet.lua +18 -0
  38. package/dist/sets/charactersWithBlackHeartFromEternalHeartSet.d.ts +2 -0
  39. package/dist/sets/charactersWithBlackHeartFromEternalHeartSet.lua +6 -0
  40. package/dist/sets/charactersWithFreeDevilDealsSet.d.ts +2 -0
  41. package/dist/sets/charactersWithFreeDevilDealsSet.lua +6 -0
  42. package/dist/sets/charactersWithNoRedHeartsSet.d.ts +6 -0
  43. package/dist/sets/charactersWithNoRedHeartsSet.lua +15 -0
  44. package/dist/sets/charactersWithNoSoulHeartsSet.d.ts +6 -0
  45. package/dist/sets/charactersWithNoSoulHeartsSet.lua +12 -0
  46. package/dist/sets/chestPickupVariantsSet.d.ts +2 -0
  47. package/dist/sets/chestPickupVariantsSet.lua +19 -0
  48. package/dist/sets/familiarsThatShootPlayerTearsSet.d.ts +2 -0
  49. package/dist/sets/familiarsThatShootPlayerTearsSet.lua +15 -0
  50. package/dist/sets/lostStyleCharactersSet.d.ts +6 -0
  51. package/dist/sets/lostStyleCharactersSet.lua +12 -0
  52. package/dist/sets/redHeartSubTypesSet.d.ts +2 -0
  53. package/dist/sets/redHeartSubTypesSet.lua +6 -0
  54. package/dist/sets/singleUseActiveCollectibleTypesSet.d.ts +2 -0
  55. package/dist/sets/singleUseActiveCollectibleTypesSet.lua +15 -0
  56. package/dist/sets/storyBossesSet.d.ts +2 -0
  57. package/dist/sets/storyBossesSet.lua +20 -0
  58. package/package.json +2 -2
@@ -1,31 +1,23 @@
1
1
  local ____lualib = require("lualib_bundle")
2
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
2
3
  local Set = ____lualib.Set
3
4
  local __TS__New = ____lualib.__TS__New
4
- local __TS__ArraySome = ____lualib.__TS__ArraySome
5
5
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
6
- local __TS__ArrayPush = ____lualib.__TS__ArrayPush
7
6
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
7
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
8
8
  local Map = ____lualib.Map
9
9
  local __TS__Iterator = ____lualib.__TS__Iterator
10
10
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
11
11
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
12
12
  local ____exports = {}
13
- local getPlayerIndexCollectibleType, isTaintedModded, DEFAULT_COLLECTIBLE_TYPE, EXCLUDED_CHARACTERS
13
+ local isTaintedModded
14
14
  local ____cachedClasses = require("cachedClasses")
15
15
  local game = ____cachedClasses.game
16
16
  local itemConfig = ____cachedClasses.itemConfig
17
17
  local ____constants = require("constants")
18
- local CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART = ____constants.CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART
19
- local CHARACTERS_WITH_FREE_DEVIL_DEALS = ____constants.CHARACTERS_WITH_FREE_DEVIL_DEALS
20
- local CHARACTERS_WITH_NO_RED_HEARTS = ____constants.CHARACTERS_WITH_NO_RED_HEARTS
21
- local CHARACTERS_WITH_NO_SOUL_HEARTS = ____constants.CHARACTERS_WITH_NO_SOUL_HEARTS
22
- local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
23
18
  local MAX_VANILLA_CHARACTER = ____constants.MAX_VANILLA_CHARACTER
24
19
  local ____HealthType = require("enums.HealthType")
25
20
  local HealthType = ____HealthType.HealthType
26
- local ____characterNames = require("objects.characterNames")
27
- local CHARACTER_NAMES = ____characterNames.CHARACTER_NAMES
28
- local DEFAULT_CHARACTER_NAME = ____characterNames.DEFAULT_CHARACTER_NAME
29
21
  local ____array = require("functions.array")
30
22
  local getLastElement = ____array.getLastElement
31
23
  local sumArray = ____array.sumArray
@@ -33,92 +25,30 @@ local ____bitwise = require("functions.bitwise")
33
25
  local countSetBits = ____bitwise.countSetBits
34
26
  local getKBitOfN = ____bitwise.getKBitOfN
35
27
  local getNumBitsOfN = ____bitwise.getNumBitsOfN
28
+ local ____character = require("functions.character")
29
+ local getCharacterMaxHeartContainers = ____character.getCharacterMaxHeartContainers
30
+ local getCharacterName = ____character.getCharacterName
36
31
  local ____collectibles = require("functions.collectibles")
37
32
  local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
38
33
  local ____collectibleSet = require("functions.collectibleSet")
39
34
  local getCollectibleSet = ____collectibleSet.getCollectibleSet
35
+ local ____playerIndex = require("functions.playerIndex")
36
+ local getPlayerIndexVanilla = ____playerIndex.getPlayerIndexVanilla
37
+ local getPlayers = ____playerIndex.getPlayers
40
38
  local ____utils = require("functions.utils")
41
39
  local ensureAllCases = ____utils.ensureAllCases
42
40
  local getEnumValues = ____utils.getEnumValues
43
41
  local ____repeat = ____utils["repeat"]
44
- function ____exports.getAllPlayers(self)
45
- local numPlayers = game:GetNumPlayers()
46
- local players = {}
47
- do
48
- local i = 0
49
- while i < numPlayers do
50
- local player = Isaac.GetPlayer(i)
51
- __TS__ArrayPush(players, player)
52
- i = i + 1
53
- end
54
- end
55
- return players
56
- end
57
- function ____exports.getCharacterMaxHeartContainers(self, character)
58
- if character == PlayerType.PLAYER_KEEPER then
59
- return 3
60
- end
61
- if character == PlayerType.PLAYER_THEFORGOTTEN then
62
- return 6
63
- end
64
- if character == PlayerType.PLAYER_THESOUL then
65
- return 6
66
- end
67
- if character == PlayerType.PLAYER_KEEPER_B then
68
- return 2
69
- end
70
- return 12
71
- end
72
42
  function ____exports.getCharacters(self)
73
- local players = ____exports.getPlayers(nil)
43
+ local players = getPlayers(nil)
74
44
  return __TS__ArrayMap(
75
45
  players,
76
46
  function(____, player) return player:GetPlayerType() end
77
47
  )
78
48
  end
79
- function ____exports.getPlayerIndex(self, player, differentiateForgottenAndSoul)
80
- if differentiateForgottenAndSoul == nil then
81
- differentiateForgottenAndSoul = false
82
- end
83
- local playerToUse = player
84
- local isSubPlayer = player:IsSubPlayer()
85
- if isSubPlayer then
86
- local playerParent = ____exports.getSubPlayerParent(nil, player)
87
- if playerParent ~= nil then
88
- playerToUse = playerParent
89
- end
90
- end
91
- local collectibleType = getPlayerIndexCollectibleType(nil, player, differentiateForgottenAndSoul)
92
- local collectibleRNG = playerToUse:GetCollectibleRNG(collectibleType)
93
- local seed = collectibleRNG:GetSeed()
94
- return seed
95
- end
96
- function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSoul)
97
- local character = player:GetPlayerType()
98
- repeat
99
- local ____switch73 = character
100
- local ____cond73 = ____switch73 == PlayerType.PLAYER_THESOUL
101
- if ____cond73 then
102
- do
103
- return differentiateForgottenAndSoul and CollectibleType.COLLECTIBLE_SPOON_BENDER or DEFAULT_COLLECTIBLE_TYPE
104
- end
105
- end
106
- ____cond73 = ____cond73 or ____switch73 == PlayerType.PLAYER_LAZARUS2_B
107
- if ____cond73 then
108
- do
109
- return CollectibleType.COLLECTIBLE_INNER_EYE
110
- end
111
- end
112
- do
113
- do
114
- return DEFAULT_COLLECTIBLE_TYPE
115
- end
116
- end
117
- until true
118
- end
119
49
  function ____exports.getPlayerMaxHeartContainers(self, player)
120
50
  local character = player:GetPlayerType()
121
- local characterMaxHeartContainers = ____exports.getCharacterMaxHeartContainers(nil, character)
51
+ local characterMaxHeartContainers = getCharacterMaxHeartContainers(nil, character)
122
52
  if character == PlayerType.PLAYER_MAGDALENE and player:HasCollectible(CollectibleType.COLLECTIBLE_BIRTHRIGHT) then
123
53
  local extraMaxHeartContainersFromBirthright = 6
124
54
  return characterMaxHeartContainers + extraMaxHeartContainersFromBirthright
@@ -132,42 +62,6 @@ function ____exports.getPlayerMaxHeartContainers(self, player)
132
62
  end
133
63
  return characterMaxHeartContainers
134
64
  end
135
- function ____exports.getPlayers(self, performCharacterExclusions)
136
- if performCharacterExclusions == nil then
137
- performCharacterExclusions = false
138
- end
139
- local players = ____exports.getAllPlayers(nil)
140
- local nonChildPlayers = __TS__ArrayFilter(
141
- players,
142
- function(____, player) return not ____exports.isChildPlayer(nil, player) end
143
- )
144
- local nonChildPlayersFiltered = __TS__ArrayFilter(
145
- nonChildPlayers,
146
- function(____, player)
147
- local character = player:GetPlayerType()
148
- return not EXCLUDED_CHARACTERS:has(character)
149
- end
150
- )
151
- return performCharacterExclusions and nonChildPlayersFiltered or nonChildPlayers
152
- end
153
- function ____exports.getSubPlayerParent(self, subPlayer)
154
- local subPlayerPtrHash = GetPtrHash(subPlayer)
155
- local players = ____exports.getPlayers(nil)
156
- return __TS__ArrayFind(
157
- players,
158
- function(____, player)
159
- local thisPlayerSubPlayer = player:GetSubPlayer()
160
- if thisPlayerSubPlayer == nil then
161
- return false
162
- end
163
- local thisPlayerSubPlayerPtrHash = GetPtrHash(thisPlayerSubPlayer)
164
- return thisPlayerSubPlayerPtrHash == subPlayerPtrHash
165
- end
166
- )
167
- end
168
- function ____exports.isChildPlayer(self, player)
169
- return player.Parent ~= nil
170
- end
171
65
  function ____exports.isKeeper(self, player)
172
66
  local character = player:GetPlayerType()
173
67
  return character == PlayerType.PLAYER_KEEPER or character == PlayerType.PLAYER_KEEPER_B
@@ -185,8 +79,6 @@ end
185
79
  function ____exports.isVanillaCharacter(self, player)
186
80
  return not ____exports.isModdedCharacter(nil, player)
187
81
  end
188
- DEFAULT_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_SAD_ONION
189
- EXCLUDED_CHARACTERS = __TS__New(Set, {PlayerType.PLAYER_ESAU, PlayerType.PLAYER_THESOUL_B})
190
82
  function ____exports.addCollectibleCostume(self, player, collectibleType)
191
83
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
192
84
  if itemConfigItem == nil then
@@ -202,14 +94,14 @@ function ____exports.addTrinketCostume(self, player, trinketType)
202
94
  player:AddCostume(itemConfigTrinket, false)
203
95
  end
204
96
  function ____exports.anyPlayerHasCollectible(self, collectibleType)
205
- local players = ____exports.getPlayers(nil)
97
+ local players = getPlayers(nil)
206
98
  return __TS__ArraySome(
207
99
  players,
208
100
  function(____, player) return player:HasCollectible(collectibleType) end
209
101
  )
210
102
  end
211
103
  function ____exports.anyPlayerHasTrinket(self, trinketType)
212
- local players = ____exports.getPlayers(nil)
104
+ local players = getPlayers(nil)
213
105
  return __TS__ArraySome(
214
106
  players,
215
107
  function(____, player) return player:HasTrinket(trinketType) end
@@ -228,19 +120,6 @@ function ____exports.canPlayerCrushRocks(self, player)
228
120
  local effects = player:GetEffects()
229
121
  return player:HasCollectible(CollectibleType.COLLECTIBLE_LEO) or player:HasCollectible(CollectibleType.COLLECTIBLE_THUNDER_THIGHS) or effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_MEGA_MUSH) or player:HasPlayerForm(PlayerForm.PLAYERFORM_STOMPY)
230
122
  end
231
- function ____exports.canTakeFreeDevilDeals(self, player)
232
- local character = player:GetPlayerType()
233
- return CHARACTERS_WITH_FREE_DEVIL_DEALS:has(character)
234
- end
235
- function ____exports.characterCanHaveRedHearts(self, character)
236
- return not CHARACTERS_WITH_NO_RED_HEARTS:has(character)
237
- end
238
- function ____exports.characterCanHaveSoulHearts(self, character)
239
- return not CHARACTERS_WITH_NO_SOUL_HEARTS:has(character)
240
- end
241
- function ____exports.characterGetsBlackHeartFromEternalHeart(self, character)
242
- return CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART:has(character)
243
- end
244
123
  function ____exports.getActiveItemSlot(self, player, collectibleType)
245
124
  local activeSlots = getEnumValues(nil, ActiveSlot)
246
125
  return __TS__ArrayFind(
@@ -259,22 +138,10 @@ function ____exports.getAzazelBrimstoneDistance(self, playerOrTearHeight)
259
138
  end
260
139
  return 32 - 2.5 * tearHeight
261
140
  end
262
- function ____exports.getBlackHearts(self, player)
263
- local blackHeartsBitmask = player:GetBlackHearts()
264
- local blackHeartBits = countSetBits(nil, blackHeartsBitmask)
265
- return blackHeartBits * 2
266
- end
267
- function ____exports.getCharacterName(self, character)
268
- if character >= PlayerType.NUM_PLAYER_TYPES then
269
- return "unknown"
270
- end
271
- local characterName = CHARACTER_NAMES[character]
272
- return characterName == nil and DEFAULT_CHARACTER_NAME or characterName
273
- end
274
141
  function ____exports.getClosestPlayer(self, position)
275
142
  local closestPlayer = nil
276
143
  local closestDistance = math.huge
277
- for ____, player in ipairs(____exports.getPlayers(nil)) do
144
+ for ____, player in ipairs(getPlayers(nil)) do
278
145
  local distance = position:Distance(player.Position)
279
146
  if distance < closestDistance then
280
147
  closestPlayer = player
@@ -286,16 +153,6 @@ function ____exports.getClosestPlayer(self, position)
286
153
  end
287
154
  return closestPlayer
288
155
  end
289
- function ____exports.getDeathAnimationName(self, player)
290
- local character = player:GetPlayerType()
291
- if LOST_STYLE_PLAYER_TYPES:has(character) then
292
- return "LostDeath"
293
- end
294
- if character == PlayerType.PLAYER_THEFORGOTTEN_B then
295
- return "ForgottenDeath"
296
- end
297
- return "Death"
298
- end
299
156
  function ____exports.getEffectsList(self, player)
300
157
  local effects = player:GetEffects()
301
158
  local effectsList = effects:GetEffectsList()
@@ -313,59 +170,13 @@ function ____exports.getEffectsList(self, player)
313
170
  return effectArray
314
171
  end
315
172
  function ____exports.getFinalPlayer(self)
316
- local players = ____exports.getPlayers(nil)
173
+ local players = getPlayers(nil)
317
174
  return getLastElement(nil, players)
318
175
  end
319
- function ____exports.getHearts(self, player)
320
- local rottenHearts = player:GetRottenHearts()
321
- local hearts = player:GetHearts()
322
- return hearts - rottenHearts * 2
323
- end
324
- function ____exports.getLastHeart(self, player)
325
- local hearts = player:GetHearts()
326
- local effectiveMaxHearts = player:GetEffectiveMaxHearts()
327
- local soulHearts = player:GetSoulHearts()
328
- local blackHearts = player:GetBlackHearts()
329
- local eternalHearts = player:GetEternalHearts()
330
- local boneHearts = player:GetBoneHearts()
331
- local rottenHearts = player:GetRottenHearts()
332
- local soulHeartSlots = soulHearts / 2
333
- local lastHeartIndex = boneHearts + soulHeartSlots - 1
334
- local isLastHeartBone = player:IsBoneHeart(lastHeartIndex)
335
- if isLastHeartBone then
336
- local isLastContainerEmpty = hearts <= effectiveMaxHearts - 2
337
- if isLastContainerEmpty then
338
- return HealthType.BONE
339
- end
340
- if rottenHearts > 0 then
341
- return HealthType.ROTTEN
342
- end
343
- if eternalHearts > 0 then
344
- return HealthType.ETERNAL
345
- end
346
- return HealthType.RED
347
- end
348
- if soulHearts > 0 then
349
- local numBits = getNumBitsOfN(nil, blackHearts)
350
- local finalBit = getKBitOfN(nil, numBits - 1, blackHearts)
351
- local isBlack = finalBit == 1
352
- if isBlack then
353
- return HealthType.BLACK
354
- end
355
- return HealthType.SOUL
356
- end
357
- if eternalHearts > 0 then
358
- return HealthType.ETERNAL
359
- end
360
- if rottenHearts > 0 then
361
- return HealthType.ROTTEN
362
- end
363
- return HealthType.RED
364
- end
365
176
  function ____exports.getNewestPlayer(self)
366
177
  local newestPlayer = nil
367
178
  local lowestFrame = math.huge
368
- for ____, player in ipairs(____exports.getPlayers(nil)) do
179
+ for ____, player in ipairs(getPlayers(nil)) do
369
180
  if player.FrameCount < lowestFrame then
370
181
  newestPlayer = player
371
182
  lowestFrame = player.FrameCount
@@ -387,8 +198,13 @@ function ____exports.getPlayerAvailableHeartSlots(self, player)
387
198
  local totalOccupiedHeartSlots = totalHeartContainers + brokenHearts
388
199
  return maxHeartContainers - totalOccupiedHeartSlots
389
200
  end
201
+ function ____exports.getPlayerBlackHearts(self, player)
202
+ local blackHeartsBitmask = player:GetBlackHearts()
203
+ local blackHeartBits = countSetBits(nil, blackHeartsBitmask)
204
+ return blackHeartBits * 2
205
+ end
390
206
  function ____exports.getPlayerCloserThan(self, position, distance)
391
- local players = ____exports.getPlayers(nil)
207
+ local players = getPlayers(nil)
392
208
  return __TS__ArrayFind(
393
209
  players,
394
210
  function(____, player) return player.Position:Distance(position) <= distance end
@@ -405,32 +221,55 @@ function ____exports.getPlayerCollectibleMap(self, player)
405
221
  end
406
222
  return collectibleMap
407
223
  end
408
- function ____exports.getPlayerFromIndex(self, playerIndex)
409
- local players = ____exports.getPlayers(nil)
410
- return __TS__ArrayFind(
411
- players,
412
- function(____, player) return ____exports.getPlayerIndex(nil, player) == playerIndex end
413
- )
224
+ function ____exports.getPlayerHearts(self, player)
225
+ local rottenHearts = player:GetRottenHearts()
226
+ local hearts = player:GetHearts()
227
+ return hearts - rottenHearts * 2
414
228
  end
415
- function ____exports.getPlayerIndexVanilla(self, playerToFind)
416
- local numPlayers = game:GetNumPlayers()
417
- local playerToFindHash = GetPtrHash(playerToFind)
418
- do
419
- local i = 0
420
- while i < numPlayers do
421
- local player = Isaac.GetPlayer(i)
422
- local playerHash = GetPtrHash(player)
423
- if playerHash == playerToFindHash then
424
- return i
425
- end
426
- i = i + 1
229
+ function ____exports.getPlayerLastHeart(self, player)
230
+ local hearts = player:GetHearts()
231
+ local effectiveMaxHearts = player:GetEffectiveMaxHearts()
232
+ local soulHearts = player:GetSoulHearts()
233
+ local blackHearts = player:GetBlackHearts()
234
+ local eternalHearts = player:GetEternalHearts()
235
+ local boneHearts = player:GetBoneHearts()
236
+ local rottenHearts = player:GetRottenHearts()
237
+ local soulHeartSlots = soulHearts / 2
238
+ local lastHeartIndex = boneHearts + soulHeartSlots - 1
239
+ local isLastHeartBone = player:IsBoneHeart(lastHeartIndex)
240
+ if isLastHeartBone then
241
+ local isLastContainerEmpty = hearts <= effectiveMaxHearts - 2
242
+ if isLastContainerEmpty then
243
+ return HealthType.BONE
244
+ end
245
+ if rottenHearts > 0 then
246
+ return HealthType.ROTTEN
247
+ end
248
+ if eternalHearts > 0 then
249
+ return HealthType.ETERNAL
427
250
  end
251
+ return HealthType.RED
428
252
  end
429
- return nil
253
+ if soulHearts > 0 then
254
+ local numBits = getNumBitsOfN(nil, blackHearts)
255
+ local finalBit = getKBitOfN(nil, numBits - 1, blackHearts)
256
+ local isBlack = finalBit == 1
257
+ if isBlack then
258
+ return HealthType.BLACK
259
+ end
260
+ return HealthType.SOUL
261
+ end
262
+ if eternalHearts > 0 then
263
+ return HealthType.ETERNAL
264
+ end
265
+ if rottenHearts > 0 then
266
+ return HealthType.ROTTEN
267
+ end
268
+ return HealthType.RED
430
269
  end
431
270
  function ____exports.getPlayerName(self, player)
432
271
  local character = player:GetPlayerType()
433
- return character >= PlayerType.NUM_PLAYER_TYPES and player:GetName() or ____exports.getCharacterName(nil, character)
272
+ return character >= PlayerType.NUM_PLAYER_TYPES and player:GetName() or getCharacterName(nil, character)
434
273
  end
435
274
  function ____exports.getPlayerNumHitsRemaining(self, player)
436
275
  local hearts = player:GetHearts()
@@ -440,10 +279,15 @@ function ____exports.getPlayerNumHitsRemaining(self, player)
440
279
  local rottenHearts = player:GetRottenHearts()
441
280
  return hearts + soulHearts + boneHearts + eternalHearts - rottenHearts
442
281
  end
282
+ function ____exports.getPlayerSoulHearts(self, player)
283
+ local soulHearts = player:GetSoulHearts()
284
+ local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
285
+ return soulHearts - blackHearts
286
+ end
443
287
  function ____exports.getPlayersOfType(self, ...)
444
288
  local characters = {...}
445
289
  local charactersSet = __TS__New(Set, characters)
446
- local players = ____exports.getPlayers(nil)
290
+ local players = getPlayers(nil)
447
291
  return __TS__ArrayFilter(
448
292
  players,
449
293
  function(____, player)
@@ -454,7 +298,7 @@ function ____exports.getPlayersOfType(self, ...)
454
298
  end
455
299
  function ____exports.getPlayersWithCollectible(self, ...)
456
300
  local collectibleTypes = {...}
457
- local players = ____exports.getPlayers(nil)
301
+ local players = getPlayers(nil)
458
302
  return __TS__ArrayFilter(
459
303
  players,
460
304
  function(____, player) return __TS__ArrayEvery(
@@ -463,11 +307,6 @@ function ____exports.getPlayersWithCollectible(self, ...)
463
307
  ) end
464
308
  )
465
309
  end
466
- function ____exports.getSoulHearts(self, player)
467
- local soulHearts = player:GetSoulHearts()
468
- local blackHearts = ____exports.getBlackHearts(nil, player)
469
- return soulHearts - blackHearts
470
- end
471
310
  function ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(self, player)
472
311
  local maxHearts = player:GetMaxHearts()
473
312
  local hasBirthright = player:HasCollectible(CollectibleType.COLLECTIBLE_BIRTHRIGHT)
@@ -475,7 +314,7 @@ function ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(self, player)
475
314
  return math.min(maxHearts, maxNonTemporaryMaxHearts)
476
315
  end
477
316
  function ____exports.getTotalPlayerCollectibles(self, collectibleType)
478
- local players = ____exports.getPlayers(nil)
317
+ local players = getPlayers(nil)
479
318
  local numCollectiblesArray = __TS__ArrayMap(
480
319
  players,
481
320
  function(____, player) return player:GetCollectibleNum(collectibleType) end
@@ -484,7 +323,7 @@ function ____exports.getTotalPlayerCollectibles(self, collectibleType)
484
323
  end
485
324
  function ____exports.hasLostCurse(self, player)
486
325
  local effects = player:GetEffects()
487
- return effects:HasNullEffect(NullItemID.ID_LOST_CURSE)
326
+ return effects:HasNullEffect(112)
488
327
  end
489
328
  function ____exports.hasOpenActiveItemSlot(self, player)
490
329
  local character = player:GetPlayerType()
@@ -512,7 +351,7 @@ function ____exports.isEden(self, player)
512
351
  return character == PlayerType.PLAYER_EDEN or character == PlayerType.PLAYER_EDEN_B
513
352
  end
514
353
  function ____exports.isFirstPlayer(self, player)
515
- return ____exports.getPlayerIndexVanilla(nil, player) == 0
354
+ return getPlayerIndexVanilla(nil, player) == 0
516
355
  end
517
356
  function ____exports.isJacobOrEsau(self, player)
518
357
  local character = player:GetPlayerType()
@@ -574,9 +413,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
574
413
  itemPool:RemoveCollectible(collectibleType)
575
414
  end
576
415
  repeat
577
- local ____switch126 = activeSlot
578
- local ____cond126 = ____switch126 == ActiveSlot.SLOT_PRIMARY
579
- if ____cond126 then
416
+ local ____switch90 = activeSlot
417
+ local ____cond90 = ____switch90 == ActiveSlot.SLOT_PRIMARY
418
+ if ____cond90 then
580
419
  do
581
420
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
582
421
  player:RemoveCollectible(primaryCollectibleType)
@@ -585,8 +424,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
585
424
  break
586
425
  end
587
426
  end
588
- ____cond126 = ____cond126 or ____switch126 == ActiveSlot.SLOT_SECONDARY
589
- if ____cond126 then
427
+ ____cond90 = ____cond90 or ____switch90 == ActiveSlot.SLOT_SECONDARY
428
+ if ____cond90 then
590
429
  do
591
430
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
592
431
  player:RemoveCollectible(primaryCollectibleType)
@@ -601,16 +440,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
601
440
  break
602
441
  end
603
442
  end
604
- ____cond126 = ____cond126 or ____switch126 == ActiveSlot.SLOT_POCKET
605
- if ____cond126 then
443
+ ____cond90 = ____cond90 or ____switch90 == ActiveSlot.SLOT_POCKET
444
+ if ____cond90 then
606
445
  do
607
446
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
608
447
  player:SetActiveCharge(charge, activeSlot)
609
448
  break
610
449
  end
611
450
  end
612
- ____cond126 = ____cond126 or ____switch126 == ActiveSlot.SLOT_POCKET2
613
- if ____cond126 then
451
+ ____cond90 = ____cond90 or ____switch90 == ActiveSlot.SLOT_POCKET2
452
+ if ____cond90 then
614
453
  do
615
454
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
616
455
  break
@@ -634,14 +473,14 @@ function ____exports.setBlindfold(self, player, enabled, modifyCostume)
634
473
  player:ChangePlayerType(character)
635
474
  game.Challenge = challenge
636
475
  if not modifyCostume then
637
- player:TryRemoveNullCostume(NullItemID.ID_BLINDFOLD)
476
+ player:TryRemoveNullCostume(14)
638
477
  end
639
478
  else
640
479
  game.Challenge = Challenge.CHALLENGE_NULL
641
480
  player:ChangePlayerType(character)
642
481
  game.Challenge = challenge
643
482
  if modifyCostume then
644
- player:TryRemoveNullCostume(NullItemID.ID_BLINDFOLD)
483
+ player:TryRemoveNullCostume(14)
645
484
  end
646
485
  end
647
486
  end
@@ -2,8 +2,8 @@ local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
3
  local Set = ____lualib.Set
4
4
  local ____exports = {}
5
- local ____player = require("functions.player")
6
- local getPlayerIndex = ____player.getPlayerIndex
5
+ local ____playerIndex = require("functions.playerIndex")
6
+ local getPlayerIndex = ____playerIndex.getPlayerIndex
7
7
  function ____exports.defaultMapGetPlayer(self, map, player, ...)
8
8
  local playerIndex = getPlayerIndex(nil, player)
9
9
  return map:getAndSetDefault(playerIndex, ...)
@@ -7,9 +7,9 @@ local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
7
7
  local ____HealthType = require("enums.HealthType")
8
8
  local HealthType = ____HealthType.HealthType
9
9
  local ____player = require("functions.player")
10
- local getBlackHearts = ____player.getBlackHearts
11
- local getHearts = ____player.getHearts
12
- local getSoulHearts = ____player.getSoulHearts
10
+ local getPlayerBlackHearts = ____player.getPlayerBlackHearts
11
+ local getPlayerHearts = ____player.getPlayerHearts
12
+ local getPlayerSoulHearts = ____player.getPlayerSoulHearts
13
13
  local ____utils = require("functions.utils")
14
14
  local ensureAllCases = ____utils.ensureAllCases
15
15
  local ____repeat = ____utils["repeat"]
@@ -90,7 +90,7 @@ function ____exports.getPlayerHealth(self, player)
90
90
  local character = player:GetPlayerType()
91
91
  local soulHeartTypes = {}
92
92
  local maxHearts = player:GetMaxHearts()
93
- local hearts = getHearts(nil, player)
93
+ local hearts = getPlayerHearts(nil, player)
94
94
  local soulHearts = player:GetSoulHearts()
95
95
  local boneHearts = player:GetBoneHearts()
96
96
  local goldenHearts = player:GetGoldenHearts()
@@ -154,13 +154,13 @@ function ____exports.getPlayerHealthType(self, player, healthType)
154
154
  local ____cond25 = ____switch25 == HealthType.RED
155
155
  if ____cond25 then
156
156
  do
157
- return getHearts(nil, player)
157
+ return getPlayerHearts(nil, player)
158
158
  end
159
159
  end
160
160
  ____cond25 = ____cond25 or ____switch25 == HealthType.SOUL
161
161
  if ____cond25 then
162
162
  do
163
- return getSoulHearts(nil, player)
163
+ return getPlayerSoulHearts(nil, player)
164
164
  end
165
165
  end
166
166
  ____cond25 = ____cond25 or ____switch25 == HealthType.ETERNAL
@@ -172,7 +172,7 @@ function ____exports.getPlayerHealthType(self, player, healthType)
172
172
  ____cond25 = ____cond25 or ____switch25 == HealthType.BLACK
173
173
  if ____cond25 then
174
174
  do
175
- return getBlackHearts(nil, player)
175
+ return getPlayerBlackHearts(nil, player)
176
176
  end
177
177
  end
178
178
  ____cond25 = ____cond25 or ____switch25 == HealthType.GOLDEN
@@ -0,0 +1,67 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ import { PlayerIndex } from "../types/PlayerIndex";
3
+ /**
4
+ * Helper function to get every player with no restrictions, by using `Game.GetNumPlayers` and
5
+ * `Isaac.GetPlayer`.
6
+ *
7
+ * This function is almost never what you want to use. For most purposes, use the `getPlayers`
8
+ * helper function instead to get a filtered list of players.
9
+ */
10
+ export declare function getAllPlayers(): EntityPlayer[];
11
+ export declare function getPlayerFromIndex(playerIndex: PlayerIndex): EntityPlayer | undefined;
12
+ /**
13
+ * Mods often have to track variables relating to the player. In naive mods, information will only
14
+ * be stored about the first player. However, in order to be robust, mods must handle up to 4
15
+ * players playing at the same time. This means that information must be stored on a map data
16
+ * structure. Finding a good index for these types of map data structures is difficult:
17
+ *
18
+ * - We cannot use the index from `Isaac.GetPlayer(i)` since this fails in the case where there are
19
+ * two players and the first player leaves the run.
20
+ * - We cannot use `EntityPlayer.ControllerIndex` as an index because it fails in the case of Jacob
21
+ * & Esau or Tainted Forgotten. It also fails in the case of a player changing their controls
22
+ * mid-run.
23
+ * - We cannot use `EntityPlayer.GetData().index` because it does not persist across saving and
24
+ * continuing.
25
+ * - We cannot use `GetPtrHash()` as an index because it does not persist across exiting and
26
+ * relaunching the game.
27
+ * - We cannot use `EntityPlayer.InitSeed` because it is not consistent with additional players
28
+ * beyond the first.
29
+ *
30
+ * Instead, we use the `EntityPlayer.GetCollectibleRNG` method with an arbitrary value of Sad Onion
31
+ * (1). This works even if the player does not have any Sad Onions.
32
+ *
33
+ * Since the RNG value is the same for both Tainted Lazarus and Dead Tainted Lazarus, we revert to
34
+ * using the RNG of The Inner Eye (2) for Dead Tainted Lazarus.
35
+ *
36
+ * Note that by default, this returns the same index for both The Forgotten and The Soul. (Even
37
+ * though they are technically different characters, they share the same inventory and InitSeed.) If
38
+ * this is not desired, pass true for the `differentiateForgottenAndSoul` argument, and the RNG of
39
+ * Spoon Bender (3) will be used for The Soul.
40
+ */
41
+ export declare function getPlayerIndex(player: EntityPlayer, differentiateForgottenAndSoul?: boolean): PlayerIndex;
42
+ /**
43
+ * Helper function to return the index of this player with respect to the output of the
44
+ * `Isaac.GetPlayer` method.
45
+ */
46
+ export declare function getPlayerIndexVanilla(playerToFind: EntityPlayer): int | undefined;
47
+ /**
48
+ * This function always excludes players with a non-undefined parent, since they are not real
49
+ * players. (e.g. the Strawman Keeper)
50
+ *
51
+ * If this is not desired, use the `getAllPlayers` helper function instead.
52
+ *
53
+ * @param performCharacterExclusions Whether or not to exclude characters that are not directly
54
+ * controlled by the player (i.e. Esau & Tainted Soul). Default is false.
55
+ */
56
+ export declare function getPlayers(performCharacterExclusions?: boolean): EntityPlayer[];
57
+ /**
58
+ * Helper function to get a parent `EntityPlayer` object for a given `EntitySubPlayer` object. This
59
+ * is useful because calling the `EntityPlayer.GetSubPlayer` method on a sub-player object will
60
+ * return undefined.
61
+ */
62
+ export declare function getSubPlayerParent(subPlayer: EntitySubPlayer): EntityPlayer | undefined;
63
+ /**
64
+ * Some players are "child" players, meaning that they have a non-undefined Parent property.
65
+ * (For example, the Strawman Keeper.)
66
+ */
67
+ export declare function isChildPlayer(player: EntityPlayer): boolean;