isaacscript-common 1.2.192 → 1.2.195
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/callbacks/customRevive.lua +3 -3
- package/dist/callbacks/postEsauJr.lua +2 -2
- package/dist/callbacks/postPlayerChangeHealth.lua +2 -2
- package/dist/callbacks/postPlayerFatalDamage.lua +2 -2
- package/dist/callbacks/postPlayerReordered.lua +3 -3
- package/dist/callbacks/preBerserkDeath.lua +2 -1
- package/dist/constants.d.ts +2 -38
- package/dist/constants.lua +3 -103
- package/dist/features/extraConsoleCommands/commands.lua +4 -2
- package/dist/features/playerInventory.lua +3 -3
- package/dist/functions/character.d.ts +46 -0
- package/dist/functions/character.lua +64 -0
- package/dist/functions/charge.lua +2 -2
- package/dist/functions/collectibles.lua +7 -6
- package/dist/functions/entity.lua +3 -3
- package/dist/functions/familiars.lua +3 -3
- package/dist/functions/flying.lua +1 -1
- package/dist/functions/pickups.d.ts +5 -0
- package/dist/functions/pickups.lua +33 -2
- package/dist/functions/player.d.ts +26 -125
- package/dist/functions/player.lua +97 -247
- package/dist/functions/playerDataStructures.lua +2 -2
- package/dist/functions/playerHealth.lua +7 -7
- package/dist/functions/playerIndex.d.ts +67 -0
- package/dist/functions/playerIndex.lua +125 -0
- package/dist/functions/pocketItems.d.ts +5 -0
- package/dist/functions/pocketItems.lua +5 -0
- package/dist/functions/positionVelocity.lua +2 -1
- package/dist/functions/revive.lua +6 -4
- package/dist/functions/utils.d.ts +2 -1
- package/dist/functions/utils.lua +5 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.lua +17 -1
- package/dist/objects/colors.d.ts +17 -0
- package/dist/objects/colors.lua +13 -0
- package/dist/sets/charactersThatStartWithAnActiveItemSet.d.ts +2 -0
- package/dist/sets/charactersThatStartWithAnActiveItemSet.lua +18 -0
- package/dist/sets/charactersWithBlackHeartFromEternalHeartSet.d.ts +2 -0
- package/dist/sets/charactersWithBlackHeartFromEternalHeartSet.lua +6 -0
- package/dist/sets/charactersWithFreeDevilDealsSet.d.ts +2 -0
- package/dist/sets/charactersWithFreeDevilDealsSet.lua +6 -0
- package/dist/sets/charactersWithNoRedHeartsSet.d.ts +6 -0
- package/dist/sets/charactersWithNoRedHeartsSet.lua +15 -0
- package/dist/sets/charactersWithNoSoulHeartsSet.d.ts +6 -0
- package/dist/sets/charactersWithNoSoulHeartsSet.lua +12 -0
- package/dist/sets/chestPickupVariantsSet.d.ts +2 -0
- package/dist/sets/chestPickupVariantsSet.lua +19 -0
- package/dist/sets/familiarsThatShootPlayerTearsSet.d.ts +2 -0
- package/dist/sets/familiarsThatShootPlayerTearsSet.lua +15 -0
- package/dist/sets/lostStyleCharactersSet.d.ts +6 -0
- package/dist/sets/lostStyleCharactersSet.lua +12 -0
- package/dist/sets/redHeartSubTypesSet.d.ts +2 -0
- package/dist/sets/redHeartSubTypesSet.lua +6 -0
- package/dist/sets/singleUseActiveCollectibleTypesSet.d.ts +2 -0
- package/dist/sets/singleUseActiveCollectibleTypesSet.lua +15 -0
- package/dist/sets/storyBossesSet.d.ts +2 -0
- package/dist/sets/storyBossesSet.lua +20 -0
- package/package.json +3 -3
|
@@ -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
|
-
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
6
|
-
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
7
5
|
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
|
|
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
|
|
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,91 +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
|
|
40
|
+
local getEnumValues = ____utils.getEnumValues
|
|
42
41
|
local ____repeat = ____utils["repeat"]
|
|
43
|
-
function ____exports.getAllPlayers(self)
|
|
44
|
-
local numPlayers = game:GetNumPlayers()
|
|
45
|
-
local players = {}
|
|
46
|
-
do
|
|
47
|
-
local i = 0
|
|
48
|
-
while i < numPlayers do
|
|
49
|
-
local player = Isaac.GetPlayer(i)
|
|
50
|
-
__TS__ArrayPush(players, player)
|
|
51
|
-
i = i + 1
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
return players
|
|
55
|
-
end
|
|
56
|
-
function ____exports.getCharacterMaxHeartContainers(self, character)
|
|
57
|
-
if character == PlayerType.PLAYER_KEEPER then
|
|
58
|
-
return 3
|
|
59
|
-
end
|
|
60
|
-
if character == PlayerType.PLAYER_THEFORGOTTEN then
|
|
61
|
-
return 6
|
|
62
|
-
end
|
|
63
|
-
if character == PlayerType.PLAYER_THESOUL then
|
|
64
|
-
return 6
|
|
65
|
-
end
|
|
66
|
-
if character == PlayerType.PLAYER_KEEPER_B then
|
|
67
|
-
return 2
|
|
68
|
-
end
|
|
69
|
-
return 12
|
|
70
|
-
end
|
|
71
42
|
function ____exports.getCharacters(self)
|
|
72
|
-
local players =
|
|
43
|
+
local players = getPlayers(nil)
|
|
73
44
|
return __TS__ArrayMap(
|
|
74
45
|
players,
|
|
75
46
|
function(____, player) return player:GetPlayerType() end
|
|
76
47
|
)
|
|
77
48
|
end
|
|
78
|
-
function ____exports.getPlayerIndex(self, player, differentiateForgottenAndSoul)
|
|
79
|
-
if differentiateForgottenAndSoul == nil then
|
|
80
|
-
differentiateForgottenAndSoul = false
|
|
81
|
-
end
|
|
82
|
-
local playerToUse = player
|
|
83
|
-
local isSubPlayer = player:IsSubPlayer()
|
|
84
|
-
if isSubPlayer then
|
|
85
|
-
local playerParent = ____exports.getSubPlayerParent(nil, player)
|
|
86
|
-
if playerParent ~= nil then
|
|
87
|
-
playerToUse = playerParent
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
local collectibleType = getPlayerIndexCollectibleType(nil, player, differentiateForgottenAndSoul)
|
|
91
|
-
local collectibleRNG = playerToUse:GetCollectibleRNG(collectibleType)
|
|
92
|
-
local seed = collectibleRNG:GetSeed()
|
|
93
|
-
return seed
|
|
94
|
-
end
|
|
95
|
-
function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSoul)
|
|
96
|
-
local character = player:GetPlayerType()
|
|
97
|
-
repeat
|
|
98
|
-
local ____switch71 = character
|
|
99
|
-
local ____cond71 = ____switch71 == PlayerType.PLAYER_THESOUL
|
|
100
|
-
if ____cond71 then
|
|
101
|
-
do
|
|
102
|
-
return differentiateForgottenAndSoul and CollectibleType.COLLECTIBLE_SPOON_BENDER or DEFAULT_COLLECTIBLE_TYPE
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_LAZARUS2_B
|
|
106
|
-
if ____cond71 then
|
|
107
|
-
do
|
|
108
|
-
return CollectibleType.COLLECTIBLE_INNER_EYE
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
do
|
|
112
|
-
do
|
|
113
|
-
return DEFAULT_COLLECTIBLE_TYPE
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
until true
|
|
117
|
-
end
|
|
118
49
|
function ____exports.getPlayerMaxHeartContainers(self, player)
|
|
119
50
|
local character = player:GetPlayerType()
|
|
120
|
-
local characterMaxHeartContainers =
|
|
51
|
+
local characterMaxHeartContainers = getCharacterMaxHeartContainers(nil, character)
|
|
121
52
|
if character == PlayerType.PLAYER_MAGDALENE and player:HasCollectible(CollectibleType.COLLECTIBLE_BIRTHRIGHT) then
|
|
122
53
|
local extraMaxHeartContainersFromBirthright = 6
|
|
123
54
|
return characterMaxHeartContainers + extraMaxHeartContainersFromBirthright
|
|
@@ -131,42 +62,6 @@ function ____exports.getPlayerMaxHeartContainers(self, player)
|
|
|
131
62
|
end
|
|
132
63
|
return characterMaxHeartContainers
|
|
133
64
|
end
|
|
134
|
-
function ____exports.getPlayers(self, performCharacterExclusions)
|
|
135
|
-
if performCharacterExclusions == nil then
|
|
136
|
-
performCharacterExclusions = false
|
|
137
|
-
end
|
|
138
|
-
local players = ____exports.getAllPlayers(nil)
|
|
139
|
-
local nonChildPlayers = __TS__ArrayFilter(
|
|
140
|
-
players,
|
|
141
|
-
function(____, player) return not ____exports.isChildPlayer(nil, player) end
|
|
142
|
-
)
|
|
143
|
-
local nonChildPlayersFiltered = __TS__ArrayFilter(
|
|
144
|
-
nonChildPlayers,
|
|
145
|
-
function(____, player)
|
|
146
|
-
local character = player:GetPlayerType()
|
|
147
|
-
return not EXCLUDED_CHARACTERS:has(character)
|
|
148
|
-
end
|
|
149
|
-
)
|
|
150
|
-
return performCharacterExclusions and nonChildPlayersFiltered or nonChildPlayers
|
|
151
|
-
end
|
|
152
|
-
function ____exports.getSubPlayerParent(self, subPlayer)
|
|
153
|
-
local subPlayerPtrHash = GetPtrHash(subPlayer)
|
|
154
|
-
local players = ____exports.getPlayers(nil)
|
|
155
|
-
return __TS__ArrayFind(
|
|
156
|
-
players,
|
|
157
|
-
function(____, player)
|
|
158
|
-
local thisPlayerSubPlayer = player:GetSubPlayer()
|
|
159
|
-
if thisPlayerSubPlayer == nil then
|
|
160
|
-
return false
|
|
161
|
-
end
|
|
162
|
-
local thisPlayerSubPlayerPtrHash = GetPtrHash(thisPlayerSubPlayer)
|
|
163
|
-
return thisPlayerSubPlayerPtrHash == subPlayerPtrHash
|
|
164
|
-
end
|
|
165
|
-
)
|
|
166
|
-
end
|
|
167
|
-
function ____exports.isChildPlayer(self, player)
|
|
168
|
-
return player.Parent ~= nil
|
|
169
|
-
end
|
|
170
65
|
function ____exports.isKeeper(self, player)
|
|
171
66
|
local character = player:GetPlayerType()
|
|
172
67
|
return character == PlayerType.PLAYER_KEEPER or character == PlayerType.PLAYER_KEEPER_B
|
|
@@ -184,8 +79,6 @@ end
|
|
|
184
79
|
function ____exports.isVanillaCharacter(self, player)
|
|
185
80
|
return not ____exports.isModdedCharacter(nil, player)
|
|
186
81
|
end
|
|
187
|
-
DEFAULT_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_SAD_ONION
|
|
188
|
-
EXCLUDED_CHARACTERS = __TS__New(Set, {PlayerType.PLAYER_ESAU, PlayerType.PLAYER_THESOUL_B})
|
|
189
82
|
function ____exports.addCollectibleCostume(self, player, collectibleType)
|
|
190
83
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
191
84
|
if itemConfigItem == nil then
|
|
@@ -201,14 +94,14 @@ function ____exports.addTrinketCostume(self, player, trinketType)
|
|
|
201
94
|
player:AddCostume(itemConfigTrinket, false)
|
|
202
95
|
end
|
|
203
96
|
function ____exports.anyPlayerHasCollectible(self, collectibleType)
|
|
204
|
-
local players =
|
|
97
|
+
local players = getPlayers(nil)
|
|
205
98
|
return __TS__ArraySome(
|
|
206
99
|
players,
|
|
207
100
|
function(____, player) return player:HasCollectible(collectibleType) end
|
|
208
101
|
)
|
|
209
102
|
end
|
|
210
103
|
function ____exports.anyPlayerHasTrinket(self, trinketType)
|
|
211
|
-
local players =
|
|
104
|
+
local players = getPlayers(nil)
|
|
212
105
|
return __TS__ArraySome(
|
|
213
106
|
players,
|
|
214
107
|
function(____, player) return player:HasTrinket(trinketType) end
|
|
@@ -227,18 +120,15 @@ function ____exports.canPlayerCrushRocks(self, player)
|
|
|
227
120
|
local effects = player:GetEffects()
|
|
228
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)
|
|
229
122
|
end
|
|
230
|
-
function ____exports.
|
|
231
|
-
local
|
|
232
|
-
return
|
|
233
|
-
|
|
234
|
-
function
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
end
|
|
240
|
-
function ____exports.characterGetsBlackHeartFromEternalHeart(self, character)
|
|
241
|
-
return CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART:has(character)
|
|
123
|
+
function ____exports.getActiveItemSlot(self, player, collectibleType)
|
|
124
|
+
local activeSlots = getEnumValues(nil, ActiveSlot)
|
|
125
|
+
return __TS__ArrayFind(
|
|
126
|
+
activeSlots,
|
|
127
|
+
function(____, activeSlot)
|
|
128
|
+
local activeItem = player:GetActiveItem(activeSlot)
|
|
129
|
+
return activeItem == collectibleType
|
|
130
|
+
end
|
|
131
|
+
)
|
|
242
132
|
end
|
|
243
133
|
function ____exports.getAzazelBrimstoneDistance(self, playerOrTearHeight)
|
|
244
134
|
local tearHeight = tonumber(playerOrTearHeight)
|
|
@@ -248,22 +138,10 @@ function ____exports.getAzazelBrimstoneDistance(self, playerOrTearHeight)
|
|
|
248
138
|
end
|
|
249
139
|
return 32 - 2.5 * tearHeight
|
|
250
140
|
end
|
|
251
|
-
function ____exports.getBlackHearts(self, player)
|
|
252
|
-
local blackHeartsBitmask = player:GetBlackHearts()
|
|
253
|
-
local blackHeartBits = countSetBits(nil, blackHeartsBitmask)
|
|
254
|
-
return blackHeartBits * 2
|
|
255
|
-
end
|
|
256
|
-
function ____exports.getCharacterName(self, character)
|
|
257
|
-
if character >= PlayerType.NUM_PLAYER_TYPES then
|
|
258
|
-
return "unknown"
|
|
259
|
-
end
|
|
260
|
-
local characterName = CHARACTER_NAMES[character]
|
|
261
|
-
return characterName == nil and DEFAULT_CHARACTER_NAME or characterName
|
|
262
|
-
end
|
|
263
141
|
function ____exports.getClosestPlayer(self, position)
|
|
264
142
|
local closestPlayer = nil
|
|
265
143
|
local closestDistance = math.huge
|
|
266
|
-
for ____, player in ipairs(
|
|
144
|
+
for ____, player in ipairs(getPlayers(nil)) do
|
|
267
145
|
local distance = position:Distance(player.Position)
|
|
268
146
|
if distance < closestDistance then
|
|
269
147
|
closestPlayer = player
|
|
@@ -275,16 +153,6 @@ function ____exports.getClosestPlayer(self, position)
|
|
|
275
153
|
end
|
|
276
154
|
return closestPlayer
|
|
277
155
|
end
|
|
278
|
-
function ____exports.getDeathAnimationName(self, player)
|
|
279
|
-
local character = player:GetPlayerType()
|
|
280
|
-
if LOST_STYLE_PLAYER_TYPES:has(character) then
|
|
281
|
-
return "LostDeath"
|
|
282
|
-
end
|
|
283
|
-
if character == PlayerType.PLAYER_THEFORGOTTEN_B then
|
|
284
|
-
return "ForgottenDeath"
|
|
285
|
-
end
|
|
286
|
-
return "Death"
|
|
287
|
-
end
|
|
288
156
|
function ____exports.getEffectsList(self, player)
|
|
289
157
|
local effects = player:GetEffects()
|
|
290
158
|
local effectsList = effects:GetEffectsList()
|
|
@@ -302,59 +170,13 @@ function ____exports.getEffectsList(self, player)
|
|
|
302
170
|
return effectArray
|
|
303
171
|
end
|
|
304
172
|
function ____exports.getFinalPlayer(self)
|
|
305
|
-
local players =
|
|
173
|
+
local players = getPlayers(nil)
|
|
306
174
|
return getLastElement(nil, players)
|
|
307
175
|
end
|
|
308
|
-
function ____exports.getHearts(self, player)
|
|
309
|
-
local rottenHearts = player:GetRottenHearts()
|
|
310
|
-
local hearts = player:GetHearts()
|
|
311
|
-
return hearts - rottenHearts * 2
|
|
312
|
-
end
|
|
313
|
-
function ____exports.getLastHeart(self, player)
|
|
314
|
-
local hearts = player:GetHearts()
|
|
315
|
-
local effectiveMaxHearts = player:GetEffectiveMaxHearts()
|
|
316
|
-
local soulHearts = player:GetSoulHearts()
|
|
317
|
-
local blackHearts = player:GetBlackHearts()
|
|
318
|
-
local eternalHearts = player:GetEternalHearts()
|
|
319
|
-
local boneHearts = player:GetBoneHearts()
|
|
320
|
-
local rottenHearts = player:GetRottenHearts()
|
|
321
|
-
local soulHeartSlots = soulHearts / 2
|
|
322
|
-
local lastHeartIndex = boneHearts + soulHeartSlots - 1
|
|
323
|
-
local isLastHeartBone = player:IsBoneHeart(lastHeartIndex)
|
|
324
|
-
if isLastHeartBone then
|
|
325
|
-
local isLastContainerEmpty = hearts <= effectiveMaxHearts - 2
|
|
326
|
-
if isLastContainerEmpty then
|
|
327
|
-
return HealthType.BONE
|
|
328
|
-
end
|
|
329
|
-
if rottenHearts > 0 then
|
|
330
|
-
return HealthType.ROTTEN
|
|
331
|
-
end
|
|
332
|
-
if eternalHearts > 0 then
|
|
333
|
-
return HealthType.ETERNAL
|
|
334
|
-
end
|
|
335
|
-
return HealthType.RED
|
|
336
|
-
end
|
|
337
|
-
if soulHearts > 0 then
|
|
338
|
-
local numBits = getNumBitsOfN(nil, blackHearts)
|
|
339
|
-
local finalBit = getKBitOfN(nil, numBits - 1, blackHearts)
|
|
340
|
-
local isBlack = finalBit == 1
|
|
341
|
-
if isBlack then
|
|
342
|
-
return HealthType.BLACK
|
|
343
|
-
end
|
|
344
|
-
return HealthType.SOUL
|
|
345
|
-
end
|
|
346
|
-
if eternalHearts > 0 then
|
|
347
|
-
return HealthType.ETERNAL
|
|
348
|
-
end
|
|
349
|
-
if rottenHearts > 0 then
|
|
350
|
-
return HealthType.ROTTEN
|
|
351
|
-
end
|
|
352
|
-
return HealthType.RED
|
|
353
|
-
end
|
|
354
176
|
function ____exports.getNewestPlayer(self)
|
|
355
177
|
local newestPlayer = nil
|
|
356
178
|
local lowestFrame = math.huge
|
|
357
|
-
for ____, player in ipairs(
|
|
179
|
+
for ____, player in ipairs(getPlayers(nil)) do
|
|
358
180
|
if player.FrameCount < lowestFrame then
|
|
359
181
|
newestPlayer = player
|
|
360
182
|
lowestFrame = player.FrameCount
|
|
@@ -376,8 +198,13 @@ function ____exports.getPlayerAvailableHeartSlots(self, player)
|
|
|
376
198
|
local totalOccupiedHeartSlots = totalHeartContainers + brokenHearts
|
|
377
199
|
return maxHeartContainers - totalOccupiedHeartSlots
|
|
378
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
|
|
379
206
|
function ____exports.getPlayerCloserThan(self, position, distance)
|
|
380
|
-
local players =
|
|
207
|
+
local players = getPlayers(nil)
|
|
381
208
|
return __TS__ArrayFind(
|
|
382
209
|
players,
|
|
383
210
|
function(____, player) return player.Position:Distance(position) <= distance end
|
|
@@ -394,32 +221,55 @@ function ____exports.getPlayerCollectibleMap(self, player)
|
|
|
394
221
|
end
|
|
395
222
|
return collectibleMap
|
|
396
223
|
end
|
|
397
|
-
function ____exports.
|
|
398
|
-
local
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
function(____, player) return ____exports.getPlayerIndex(nil, player) == playerIndex end
|
|
402
|
-
)
|
|
224
|
+
function ____exports.getPlayerHearts(self, player)
|
|
225
|
+
local rottenHearts = player:GetRottenHearts()
|
|
226
|
+
local hearts = player:GetHearts()
|
|
227
|
+
return hearts - rottenHearts * 2
|
|
403
228
|
end
|
|
404
|
-
function ____exports.
|
|
405
|
-
local
|
|
406
|
-
local
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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
|
|
250
|
+
end
|
|
251
|
+
return HealthType.RED
|
|
252
|
+
end
|
|
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
|
|
416
259
|
end
|
|
260
|
+
return HealthType.SOUL
|
|
261
|
+
end
|
|
262
|
+
if eternalHearts > 0 then
|
|
263
|
+
return HealthType.ETERNAL
|
|
417
264
|
end
|
|
418
|
-
|
|
265
|
+
if rottenHearts > 0 then
|
|
266
|
+
return HealthType.ROTTEN
|
|
267
|
+
end
|
|
268
|
+
return HealthType.RED
|
|
419
269
|
end
|
|
420
270
|
function ____exports.getPlayerName(self, player)
|
|
421
271
|
local character = player:GetPlayerType()
|
|
422
|
-
return character >= PlayerType.NUM_PLAYER_TYPES and player:GetName() or
|
|
272
|
+
return character >= PlayerType.NUM_PLAYER_TYPES and player:GetName() or getCharacterName(nil, character)
|
|
423
273
|
end
|
|
424
274
|
function ____exports.getPlayerNumHitsRemaining(self, player)
|
|
425
275
|
local hearts = player:GetHearts()
|
|
@@ -429,10 +279,15 @@ function ____exports.getPlayerNumHitsRemaining(self, player)
|
|
|
429
279
|
local rottenHearts = player:GetRottenHearts()
|
|
430
280
|
return hearts + soulHearts + boneHearts + eternalHearts - rottenHearts
|
|
431
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
|
|
432
287
|
function ____exports.getPlayersOfType(self, ...)
|
|
433
288
|
local characters = {...}
|
|
434
289
|
local charactersSet = __TS__New(Set, characters)
|
|
435
|
-
local players =
|
|
290
|
+
local players = getPlayers(nil)
|
|
436
291
|
return __TS__ArrayFilter(
|
|
437
292
|
players,
|
|
438
293
|
function(____, player)
|
|
@@ -443,7 +298,7 @@ function ____exports.getPlayersOfType(self, ...)
|
|
|
443
298
|
end
|
|
444
299
|
function ____exports.getPlayersWithCollectible(self, ...)
|
|
445
300
|
local collectibleTypes = {...}
|
|
446
|
-
local players =
|
|
301
|
+
local players = getPlayers(nil)
|
|
447
302
|
return __TS__ArrayFilter(
|
|
448
303
|
players,
|
|
449
304
|
function(____, player) return __TS__ArrayEvery(
|
|
@@ -452,11 +307,6 @@ function ____exports.getPlayersWithCollectible(self, ...)
|
|
|
452
307
|
) end
|
|
453
308
|
)
|
|
454
309
|
end
|
|
455
|
-
function ____exports.getSoulHearts(self, player)
|
|
456
|
-
local soulHearts = player:GetSoulHearts()
|
|
457
|
-
local blackHearts = ____exports.getBlackHearts(nil, player)
|
|
458
|
-
return soulHearts - blackHearts
|
|
459
|
-
end
|
|
460
310
|
function ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(self, player)
|
|
461
311
|
local maxHearts = player:GetMaxHearts()
|
|
462
312
|
local hasBirthright = player:HasCollectible(CollectibleType.COLLECTIBLE_BIRTHRIGHT)
|
|
@@ -464,7 +314,7 @@ function ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(self, player)
|
|
|
464
314
|
return math.min(maxHearts, maxNonTemporaryMaxHearts)
|
|
465
315
|
end
|
|
466
316
|
function ____exports.getTotalPlayerCollectibles(self, collectibleType)
|
|
467
|
-
local players =
|
|
317
|
+
local players = getPlayers(nil)
|
|
468
318
|
local numCollectiblesArray = __TS__ArrayMap(
|
|
469
319
|
players,
|
|
470
320
|
function(____, player) return player:GetCollectibleNum(collectibleType) end
|
|
@@ -473,7 +323,7 @@ function ____exports.getTotalPlayerCollectibles(self, collectibleType)
|
|
|
473
323
|
end
|
|
474
324
|
function ____exports.hasLostCurse(self, player)
|
|
475
325
|
local effects = player:GetEffects()
|
|
476
|
-
return effects:HasNullEffect(
|
|
326
|
+
return effects:HasNullEffect(112)
|
|
477
327
|
end
|
|
478
328
|
function ____exports.hasOpenActiveItemSlot(self, player)
|
|
479
329
|
local character = player:GetPlayerType()
|
|
@@ -501,7 +351,7 @@ function ____exports.isEden(self, player)
|
|
|
501
351
|
return character == PlayerType.PLAYER_EDEN or character == PlayerType.PLAYER_EDEN_B
|
|
502
352
|
end
|
|
503
353
|
function ____exports.isFirstPlayer(self, player)
|
|
504
|
-
return
|
|
354
|
+
return getPlayerIndexVanilla(nil, player) == 0
|
|
505
355
|
end
|
|
506
356
|
function ____exports.isJacobOrEsau(self, player)
|
|
507
357
|
local character = player:GetPlayerType()
|
|
@@ -563,9 +413,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
563
413
|
itemPool:RemoveCollectible(collectibleType)
|
|
564
414
|
end
|
|
565
415
|
repeat
|
|
566
|
-
local
|
|
567
|
-
local
|
|
568
|
-
if
|
|
416
|
+
local ____switch90 = activeSlot
|
|
417
|
+
local ____cond90 = ____switch90 == ActiveSlot.SLOT_PRIMARY
|
|
418
|
+
if ____cond90 then
|
|
569
419
|
do
|
|
570
420
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
571
421
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -574,8 +424,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
574
424
|
break
|
|
575
425
|
end
|
|
576
426
|
end
|
|
577
|
-
|
|
578
|
-
if
|
|
427
|
+
____cond90 = ____cond90 or ____switch90 == ActiveSlot.SLOT_SECONDARY
|
|
428
|
+
if ____cond90 then
|
|
579
429
|
do
|
|
580
430
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
581
431
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -590,16 +440,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
590
440
|
break
|
|
591
441
|
end
|
|
592
442
|
end
|
|
593
|
-
|
|
594
|
-
if
|
|
443
|
+
____cond90 = ____cond90 or ____switch90 == ActiveSlot.SLOT_POCKET
|
|
444
|
+
if ____cond90 then
|
|
595
445
|
do
|
|
596
446
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
597
447
|
player:SetActiveCharge(charge, activeSlot)
|
|
598
448
|
break
|
|
599
449
|
end
|
|
600
450
|
end
|
|
601
|
-
|
|
602
|
-
if
|
|
451
|
+
____cond90 = ____cond90 or ____switch90 == ActiveSlot.SLOT_POCKET2
|
|
452
|
+
if ____cond90 then
|
|
603
453
|
do
|
|
604
454
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
605
455
|
break
|
|
@@ -623,14 +473,14 @@ function ____exports.setBlindfold(self, player, enabled, modifyCostume)
|
|
|
623
473
|
player:ChangePlayerType(character)
|
|
624
474
|
game.Challenge = challenge
|
|
625
475
|
if not modifyCostume then
|
|
626
|
-
player:TryRemoveNullCostume(
|
|
476
|
+
player:TryRemoveNullCostume(14)
|
|
627
477
|
end
|
|
628
478
|
else
|
|
629
479
|
game.Challenge = Challenge.CHALLENGE_NULL
|
|
630
480
|
player:ChangePlayerType(character)
|
|
631
481
|
game.Challenge = challenge
|
|
632
482
|
if modifyCostume then
|
|
633
|
-
player:TryRemoveNullCostume(
|
|
483
|
+
player:TryRemoveNullCostume(14)
|
|
634
484
|
end
|
|
635
485
|
end
|
|
636
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
|
|
6
|
-
local 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
|
|
11
|
-
local
|
|
12
|
-
local
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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;
|