isaacscript-common 8.4.5 → 8.6.0
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/postCursedTeleport.lua +4 -4
- package/dist/callbacks/postPlayerFatalDamage.lua +7 -7
- package/dist/callbacks/postSacrifice.lua +2 -2
- package/dist/callbacks/postTrinketBreak.lua +2 -2
- package/dist/callbacks/subscriptions/postPlayerFatalDamage.d.ts +2 -2
- package/dist/callbacks/subscriptions/postPlayerFatalDamage.d.ts.map +1 -1
- package/dist/callbacks/subscriptions/postPlayerFatalDamage.lua +4 -4
- package/dist/features/characterStats.d.ts.map +1 -1
- package/dist/features/characterStats.lua +1 -2
- package/dist/features/customGridEntity.d.ts.map +1 -1
- package/dist/features/customGridEntity.lua +3 -36
- package/dist/features/extraConsoleCommands/init.d.ts.map +1 -1
- package/dist/features/extraConsoleCommands/init.lua +1 -1
- package/dist/features/firstLast.d.ts +6 -3
- package/dist/features/firstLast.d.ts.map +1 -1
- package/dist/features/firstLast.lua +6 -3
- package/dist/features/playerInventory.d.ts +11 -3
- package/dist/features/playerInventory.d.ts.map +1 -1
- package/dist/features/playerInventory.lua +14 -3
- package/dist/functions/bosses.d.ts +8 -2
- package/dist/functions/bosses.d.ts.map +1 -1
- package/dist/functions/bosses.lua +14 -6
- package/dist/functions/collectibleCacheFlag.d.ts +1 -1
- package/dist/functions/collectibleCacheFlag.d.ts.map +1 -1
- package/dist/functions/collectibleCacheFlag.lua +1 -2
- package/dist/functions/collectibleSet.lua +32 -32
- package/dist/functions/collectibleTag.d.ts +1 -1
- package/dist/functions/collectibleTag.d.ts.map +1 -1
- package/dist/functions/collectibleTag.lua +1 -3
- package/dist/functions/eden.d.ts +1 -1
- package/dist/functions/eden.d.ts.map +1 -1
- package/dist/functions/eden.lua +1 -2
- package/dist/functions/flag.d.ts +1 -1
- package/dist/functions/flag.lua +1 -1
- package/dist/functions/flying.d.ts +1 -1
- package/dist/functions/flying.d.ts.map +1 -1
- package/dist/functions/flying.lua +5 -2
- package/dist/functions/input.d.ts +2 -2
- package/dist/functions/input.d.ts.map +1 -1
- package/dist/functions/input.lua +2 -4
- package/dist/functions/playerHealth.d.ts +93 -0
- package/dist/functions/playerHealth.d.ts.map +1 -1
- package/dist/functions/playerHealth.lua +216 -33
- package/dist/functions/players.d.ts +1 -111
- package/dist/functions/players.d.ts.map +1 -1
- package/dist/functions/players.lua +20 -279
- package/dist/functions/revive.d.ts +1 -1
- package/dist/functions/revive.d.ts.map +1 -1
- package/dist/functions/revive.lua +5 -4
- package/dist/functions/stats.d.ts +16 -0
- package/dist/functions/stats.d.ts.map +1 -1
- package/dist/functions/stats.lua +78 -0
- package/dist/functions/transformations.d.ts +1 -1
- package/dist/functions/transformations.d.ts.map +1 -1
- package/dist/functions/trinketCacheFlag.d.ts +1 -1
- package/dist/functions/trinketCacheFlag.d.ts.map +1 -1
- package/dist/functions/trinketCacheFlag.lua +1 -3
- package/dist/functions/trinketSet.lua +32 -32
- package/dist/index.d.ts +37 -36
- package/dist/sets/bossSets.d.ts +1 -0
- package/dist/sets/bossSets.d.ts.map +1 -1
- package/dist/sets/bossSets.lua +23 -0
- package/package.json +2 -2
- package/src/callbacks/postCursedTeleport.ts +7 -7
- package/src/callbacks/postPlayerFatalDamage.ts +9 -16
- package/src/callbacks/postSacrifice.ts +5 -5
- package/src/callbacks/postTrinketBreak.ts +5 -5
- package/src/callbacks/subscriptions/postPlayerFatalDamage.ts +9 -9
- package/src/features/characterStats.ts +1 -2
- package/src/features/customGridEntity.ts +0 -55
- package/src/features/extraConsoleCommands/init.ts +8 -1
- package/src/features/firstLast.ts +6 -3
- package/src/features/playerInventory.ts +24 -4
- package/src/functions/bosses.ts +18 -6
- package/src/functions/collectibleCacheFlag.ts +3 -3
- package/src/functions/collectibleSet.ts +32 -32
- package/src/functions/collectibleTag.ts +2 -3
- package/src/functions/eden.ts +3 -3
- package/src/functions/flag.ts +1 -1
- package/src/functions/flying.ts +4 -4
- package/src/functions/input.ts +4 -5
- package/src/functions/playerHealth.ts +269 -7
- package/src/functions/players.ts +1 -348
- package/src/functions/revive.ts +6 -10
- package/src/functions/stats.ts +75 -0
- package/src/functions/transformations.ts +1 -1
- package/src/functions/trinketCacheFlag.ts +2 -3
- package/src/functions/trinketSet.ts +32 -32
- package/src/sets/bossSets.ts +33 -0
|
@@ -7,22 +7,79 @@ local ActiveSlot = ____isaac_2Dtypescript_2Ddefinitions.ActiveSlot
|
|
|
7
7
|
local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
|
|
8
8
|
local HeartSubType = ____isaac_2Dtypescript_2Ddefinitions.HeartSubType
|
|
9
9
|
local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
|
|
10
|
+
local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
|
|
10
11
|
local ____constants = require("core.constants")
|
|
11
12
|
local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
|
|
12
13
|
local ____HealthType = require("enums.HealthType")
|
|
13
14
|
local HealthType = ____HealthType.HealthType
|
|
15
|
+
local ____bitwise = require("functions.bitwise")
|
|
16
|
+
local countSetBits = ____bitwise.countSetBits
|
|
17
|
+
local getKBitOfN = ____bitwise.getKBitOfN
|
|
18
|
+
local getNumBitsOfN = ____bitwise.getNumBitsOfN
|
|
19
|
+
local ____characters = require("functions.characters")
|
|
20
|
+
local getCharacterMaxHeartContainers = ____characters.getCharacterMaxHeartContainers
|
|
14
21
|
local ____charge = require("functions.charge")
|
|
15
22
|
local getTotalCharge = ____charge.getTotalCharge
|
|
16
23
|
local ____enums = require("functions.enums")
|
|
17
24
|
local getEnumValues = ____enums.getEnumValues
|
|
18
25
|
local ____players = require("functions.players")
|
|
19
|
-
local getPlayerBlackHearts = ____players.getPlayerBlackHearts
|
|
20
|
-
local getPlayerHearts = ____players.getPlayerHearts
|
|
21
|
-
local getPlayerSoulHearts = ____players.getPlayerSoulHearts
|
|
22
26
|
local isCharacter = ____players.isCharacter
|
|
27
|
+
local isKeeper = ____players.isKeeper
|
|
23
28
|
local setActiveItem = ____players.setActiveItem
|
|
24
29
|
local ____utils = require("functions.utils")
|
|
25
30
|
local ____repeat = ____utils["repeat"]
|
|
31
|
+
--- Returns the number of black hearts that the player has, excluding any soul hearts. For example,
|
|
32
|
+
-- if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
33
|
+
-- function returns 3.
|
|
34
|
+
--
|
|
35
|
+
-- This is different from the `EntityPlayer.GetBlackHearts` method, since that returns a bitmask.
|
|
36
|
+
function ____exports.getPlayerBlackHearts(self, player)
|
|
37
|
+
local blackHeartsBitmask = player:GetBlackHearts()
|
|
38
|
+
local blackHeartBits = countSetBits(nil, blackHeartsBitmask)
|
|
39
|
+
return blackHeartBits * 2
|
|
40
|
+
end
|
|
41
|
+
--- Returns the number of red hearts that the player has, excluding any rotten hearts. For example,
|
|
42
|
+
-- if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
43
|
+
-- function returns 3.
|
|
44
|
+
--
|
|
45
|
+
-- This is different from the `EntityPlayer.GetHearts` method, since that returns a value that
|
|
46
|
+
-- includes rotten hearts.
|
|
47
|
+
function ____exports.getPlayerHearts(self, player)
|
|
48
|
+
local rottenHearts = player:GetRottenHearts()
|
|
49
|
+
local hearts = player:GetHearts()
|
|
50
|
+
return hearts - rottenHearts * 2
|
|
51
|
+
end
|
|
52
|
+
--- Returns the maximum heart containers that the provided player can have. Normally, this is 12, but
|
|
53
|
+
-- it can change depending on the character (e.g. Keeper) and other things (e.g. Mother's Kiss).
|
|
54
|
+
-- This function does not account for Broken Hearts; use the `getPlayerAvailableHeartSlots` helper
|
|
55
|
+
-- function for that.
|
|
56
|
+
function ____exports.getPlayerMaxHeartContainers(self, player)
|
|
57
|
+
local character = player:GetPlayerType()
|
|
58
|
+
local characterMaxHeartContainers = getCharacterMaxHeartContainers(nil, character)
|
|
59
|
+
if character == PlayerType.MAGDALENE and player:HasCollectible(CollectibleType.BIRTHRIGHT) then
|
|
60
|
+
local extraMaxHeartContainersFromBirthright = 6
|
|
61
|
+
return characterMaxHeartContainers + extraMaxHeartContainersFromBirthright
|
|
62
|
+
end
|
|
63
|
+
if isKeeper(nil, player) then
|
|
64
|
+
local numMothersKisses = player:GetTrinketMultiplier(TrinketType.MOTHERS_KISS)
|
|
65
|
+
local hasGreedsGullet = player:HasCollectible(CollectibleType.GREEDS_GULLET)
|
|
66
|
+
local coins = player:GetNumCoins()
|
|
67
|
+
local greedsGulletCoinContainers = hasGreedsGullet and math.floor(coins / 25) or 0
|
|
68
|
+
return characterMaxHeartContainers + numMothersKisses + greedsGulletCoinContainers
|
|
69
|
+
end
|
|
70
|
+
return characterMaxHeartContainers
|
|
71
|
+
end
|
|
72
|
+
--- Returns the number of soul hearts that the player has, excluding any black hearts. For example,
|
|
73
|
+
-- if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
74
|
+
-- function returns 2.
|
|
75
|
+
--
|
|
76
|
+
-- This is different from the `EntityPlayer.GetSoulHearts` method, since that returns the combined
|
|
77
|
+
-- number of soul hearts and black hearts.
|
|
78
|
+
function ____exports.getPlayerSoulHearts(self, player)
|
|
79
|
+
local soulHearts = player:GetSoulHearts()
|
|
80
|
+
local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
|
|
81
|
+
return soulHearts - blackHearts
|
|
82
|
+
end
|
|
26
83
|
function ____exports.removeAllPlayerHealth(self, player)
|
|
27
84
|
local goldenHearts = player:GetGoldenHearts()
|
|
28
85
|
local eternalHearts = player:GetEternalHearts()
|
|
@@ -78,25 +135,25 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
|
|
|
78
135
|
addAmount = 1
|
|
79
136
|
end
|
|
80
137
|
repeat
|
|
81
|
-
local
|
|
82
|
-
local
|
|
83
|
-
if
|
|
138
|
+
local ____switch71 = soulHeartType
|
|
139
|
+
local ____cond71 = ____switch71 == HeartSubType.SOUL
|
|
140
|
+
if ____cond71 then
|
|
84
141
|
do
|
|
85
142
|
player:AddSoulHearts(addAmount)
|
|
86
143
|
soulHeartsRemaining = soulHeartsRemaining - addAmount
|
|
87
144
|
break
|
|
88
145
|
end
|
|
89
146
|
end
|
|
90
|
-
|
|
91
|
-
if
|
|
147
|
+
____cond71 = ____cond71 or ____switch71 == HeartSubType.BLACK
|
|
148
|
+
if ____cond71 then
|
|
92
149
|
do
|
|
93
150
|
player:AddBlackHearts(addAmount)
|
|
94
151
|
soulHeartsRemaining = soulHeartsRemaining - addAmount
|
|
95
152
|
break
|
|
96
153
|
end
|
|
97
154
|
end
|
|
98
|
-
|
|
99
|
-
if
|
|
155
|
+
____cond71 = ____cond71 or ____switch71 == HeartSubType.BONE
|
|
156
|
+
if ____cond71 then
|
|
100
157
|
do
|
|
101
158
|
player:AddBoneHearts(addAmount)
|
|
102
159
|
break
|
|
@@ -214,6 +271,51 @@ function ____exports.addPlayerHealthType(self, player, healthType, numHearts)
|
|
|
214
271
|
end
|
|
215
272
|
until true
|
|
216
273
|
end
|
|
274
|
+
--- Returns whether or not all of the player's soul-heart-type hearts are black hearts.
|
|
275
|
+
--
|
|
276
|
+
-- Note that this function does not consider red heart containers.
|
|
277
|
+
--
|
|
278
|
+
-- For example:
|
|
279
|
+
--
|
|
280
|
+
-- - If the player has one black heart, this function would return true.
|
|
281
|
+
-- - If the player has one soul heart and two black hearts, this function would return false.
|
|
282
|
+
-- - If the player has no black hearts, this function will return false.
|
|
283
|
+
-- - If the player has one red heart container and three black hearts, this function would return
|
|
284
|
+
-- true.
|
|
285
|
+
function ____exports.doesPlayerHaveAllBlackHearts(self, player)
|
|
286
|
+
local soulHearts = ____exports.getPlayerSoulHearts(nil, player)
|
|
287
|
+
local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
|
|
288
|
+
return blackHearts > 0 and soulHearts == 0
|
|
289
|
+
end
|
|
290
|
+
--- Returns whether or not all of the player's soul-heart-type hearts are soul hearts.
|
|
291
|
+
--
|
|
292
|
+
-- Note that this function does not consider red heart containers.
|
|
293
|
+
--
|
|
294
|
+
-- For example:
|
|
295
|
+
--
|
|
296
|
+
-- - If the player has two soul hearts and one black heart, this function would return false.
|
|
297
|
+
-- - If the player has no soul hearts, this function will return false.
|
|
298
|
+
-- - If the player has one red heart container and three soul hearts, this function would return
|
|
299
|
+
-- true.
|
|
300
|
+
function ____exports.doesPlayerHaveAllSoulHearts(self, player)
|
|
301
|
+
local soulHearts = ____exports.getPlayerSoulHearts(nil, player)
|
|
302
|
+
local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
|
|
303
|
+
return soulHearts > 0 and blackHearts == 0
|
|
304
|
+
end
|
|
305
|
+
--- Returns the number of slots that the player has remaining for new heart containers, accounting
|
|
306
|
+
-- for broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full
|
|
307
|
+
-- soul hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
|
|
308
|
+
function ____exports.getPlayerAvailableHeartSlots(self, player)
|
|
309
|
+
local maxHeartContainers = ____exports.getPlayerMaxHeartContainers(nil, player)
|
|
310
|
+
local effectiveMaxHearts = player:GetEffectiveMaxHearts()
|
|
311
|
+
local normalAndBoneHeartContainers = effectiveMaxHearts / 2
|
|
312
|
+
local soulHearts = player:GetSoulHearts()
|
|
313
|
+
local soulHeartContainers = math.ceil(soulHearts / 2)
|
|
314
|
+
local totalHeartContainers = normalAndBoneHeartContainers + soulHeartContainers
|
|
315
|
+
local brokenHearts = player:GetBrokenHearts()
|
|
316
|
+
local totalOccupiedHeartSlots = totalHeartContainers + brokenHearts
|
|
317
|
+
return maxHeartContainers - totalOccupiedHeartSlots
|
|
318
|
+
end
|
|
217
319
|
--- Helper function to get an object representing the player's health. You can use this in
|
|
218
320
|
-- combination with the `setPlayerHealth` function to restore the player's health back to a certain
|
|
219
321
|
-- configuration at a later time.
|
|
@@ -222,7 +324,7 @@ end
|
|
|
222
324
|
function ____exports.getPlayerHealth(self, player)
|
|
223
325
|
local character = player:GetPlayerType()
|
|
224
326
|
local maxHearts = player:GetMaxHearts()
|
|
225
|
-
local hearts = getPlayerHearts(nil, player)
|
|
327
|
+
local hearts = ____exports.getPlayerHearts(nil, player)
|
|
226
328
|
local soulHearts = player:GetSoulHearts()
|
|
227
329
|
local boneHearts = player:GetBoneHearts()
|
|
228
330
|
local goldenHearts = player:GetGoldenHearts()
|
|
@@ -283,63 +385,120 @@ function ____exports.getPlayerHealth(self, player)
|
|
|
283
385
|
end
|
|
284
386
|
function ____exports.getPlayerHealthType(self, player, healthType)
|
|
285
387
|
repeat
|
|
286
|
-
local
|
|
287
|
-
local
|
|
288
|
-
if
|
|
388
|
+
local ____switch28 = healthType
|
|
389
|
+
local ____cond28 = ____switch28 == HealthType.RED
|
|
390
|
+
if ____cond28 then
|
|
289
391
|
do
|
|
290
|
-
return getPlayerHearts(nil, player)
|
|
392
|
+
return ____exports.getPlayerHearts(nil, player)
|
|
291
393
|
end
|
|
292
394
|
end
|
|
293
|
-
|
|
294
|
-
if
|
|
395
|
+
____cond28 = ____cond28 or ____switch28 == HealthType.SOUL
|
|
396
|
+
if ____cond28 then
|
|
295
397
|
do
|
|
296
|
-
return getPlayerSoulHearts(nil, player)
|
|
398
|
+
return ____exports.getPlayerSoulHearts(nil, player)
|
|
297
399
|
end
|
|
298
400
|
end
|
|
299
|
-
|
|
300
|
-
if
|
|
401
|
+
____cond28 = ____cond28 or ____switch28 == HealthType.ETERNAL
|
|
402
|
+
if ____cond28 then
|
|
301
403
|
do
|
|
302
404
|
return player:GetEternalHearts()
|
|
303
405
|
end
|
|
304
406
|
end
|
|
305
|
-
|
|
306
|
-
if
|
|
407
|
+
____cond28 = ____cond28 or ____switch28 == HealthType.BLACK
|
|
408
|
+
if ____cond28 then
|
|
307
409
|
do
|
|
308
|
-
return getPlayerBlackHearts(nil, player)
|
|
410
|
+
return ____exports.getPlayerBlackHearts(nil, player)
|
|
309
411
|
end
|
|
310
412
|
end
|
|
311
|
-
|
|
312
|
-
if
|
|
413
|
+
____cond28 = ____cond28 or ____switch28 == HealthType.GOLDEN
|
|
414
|
+
if ____cond28 then
|
|
313
415
|
do
|
|
314
416
|
return player:GetGoldenHearts()
|
|
315
417
|
end
|
|
316
418
|
end
|
|
317
|
-
|
|
318
|
-
if
|
|
419
|
+
____cond28 = ____cond28 or ____switch28 == HealthType.BONE
|
|
420
|
+
if ____cond28 then
|
|
319
421
|
do
|
|
320
422
|
return player:GetBoneHearts()
|
|
321
423
|
end
|
|
322
424
|
end
|
|
323
|
-
|
|
324
|
-
if
|
|
425
|
+
____cond28 = ____cond28 or ____switch28 == HealthType.ROTTEN
|
|
426
|
+
if ____cond28 then
|
|
325
427
|
do
|
|
326
428
|
return player:GetRottenHearts()
|
|
327
429
|
end
|
|
328
430
|
end
|
|
329
|
-
|
|
330
|
-
if
|
|
431
|
+
____cond28 = ____cond28 or ____switch28 == HealthType.BROKEN
|
|
432
|
+
if ____cond28 then
|
|
331
433
|
do
|
|
332
434
|
return player:GetBrokenHearts()
|
|
333
435
|
end
|
|
334
436
|
end
|
|
335
|
-
|
|
336
|
-
if
|
|
437
|
+
____cond28 = ____cond28 or ____switch28 == HealthType.MAX_HEARTS
|
|
438
|
+
if ____cond28 then
|
|
337
439
|
do
|
|
338
440
|
return player:GetMaxHearts()
|
|
339
441
|
end
|
|
340
442
|
end
|
|
341
443
|
until true
|
|
342
444
|
end
|
|
445
|
+
--- Helper function that returns the type of the rightmost heart. This does not including golden
|
|
446
|
+
-- hearts or broken hearts, since they cannot be damaged directly.
|
|
447
|
+
function ____exports.getPlayerLastHeart(self, player)
|
|
448
|
+
local hearts = player:GetHearts()
|
|
449
|
+
local effectiveMaxHearts = player:GetEffectiveMaxHearts()
|
|
450
|
+
local soulHearts = player:GetSoulHearts()
|
|
451
|
+
local blackHearts = player:GetBlackHearts()
|
|
452
|
+
local eternalHearts = player:GetEternalHearts()
|
|
453
|
+
local boneHearts = player:GetBoneHearts()
|
|
454
|
+
local rottenHearts = player:GetRottenHearts()
|
|
455
|
+
local soulHeartSlots = soulHearts / 2
|
|
456
|
+
local lastHeartIndex = boneHearts + soulHeartSlots - 1
|
|
457
|
+
local isLastHeartBone = player:IsBoneHeart(lastHeartIndex)
|
|
458
|
+
if isLastHeartBone then
|
|
459
|
+
local isLastContainerEmpty = hearts <= effectiveMaxHearts - 2
|
|
460
|
+
if isLastContainerEmpty then
|
|
461
|
+
return HealthType.BONE
|
|
462
|
+
end
|
|
463
|
+
if rottenHearts > 0 then
|
|
464
|
+
return HealthType.ROTTEN
|
|
465
|
+
end
|
|
466
|
+
if eternalHearts > 0 then
|
|
467
|
+
return HealthType.ETERNAL
|
|
468
|
+
end
|
|
469
|
+
return HealthType.RED
|
|
470
|
+
end
|
|
471
|
+
if soulHearts > 0 then
|
|
472
|
+
local numBits = getNumBitsOfN(nil, blackHearts)
|
|
473
|
+
local finalBit = getKBitOfN(nil, numBits - 1, blackHearts)
|
|
474
|
+
local isBlack = finalBit == 1
|
|
475
|
+
if isBlack then
|
|
476
|
+
return HealthType.BLACK
|
|
477
|
+
end
|
|
478
|
+
return HealthType.SOUL
|
|
479
|
+
end
|
|
480
|
+
if eternalHearts > 0 then
|
|
481
|
+
return HealthType.ETERNAL
|
|
482
|
+
end
|
|
483
|
+
if rottenHearts > 0 then
|
|
484
|
+
return HealthType.ROTTEN
|
|
485
|
+
end
|
|
486
|
+
return HealthType.RED
|
|
487
|
+
end
|
|
488
|
+
--- Helper function to determine how many heart containers that Tainted Magdalene has that will not
|
|
489
|
+
-- be automatically depleted over time. By default, this is 2, but this function will return 4 so
|
|
490
|
+
-- that it is consistent with the `player.GetHearts` and `player.GetMaxHearts` methods.
|
|
491
|
+
--
|
|
492
|
+
-- If Tainted Magdalene has Birthright, she will gained an additional non-temporary heart container.
|
|
493
|
+
--
|
|
494
|
+
-- This function does not validate whether or not the provided player is Tainted Magdalene; that
|
|
495
|
+
-- should be accomplished before invoking this function.
|
|
496
|
+
function ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(self, player)
|
|
497
|
+
local maxHearts = player:GetMaxHearts()
|
|
498
|
+
local hasBirthright = player:HasCollectible(CollectibleType.BIRTHRIGHT)
|
|
499
|
+
local maxNonTemporaryMaxHearts = hasBirthright and 6 or 4
|
|
500
|
+
return math.min(maxHearts, maxNonTemporaryMaxHearts)
|
|
501
|
+
end
|
|
343
502
|
--- Returns a `PlayerHealth` object with all zeros.
|
|
344
503
|
function ____exports.newPlayerHealth(self)
|
|
345
504
|
return {
|
|
@@ -384,4 +543,28 @@ function ____exports.playerHasHealthLeft(self, player)
|
|
|
384
543
|
local boneHearts = player:GetBoneHearts()
|
|
385
544
|
return hearts > 0 or soulHearts > 0 or boneHearts > 0
|
|
386
545
|
end
|
|
546
|
+
--- Helper function to see if a certain damage amount would deal "permanent" damage to Tainted
|
|
547
|
+
-- Magdalene.
|
|
548
|
+
--
|
|
549
|
+
-- Tainted Magdalene has "permanent" health and "temporary" health. When standing still and doing
|
|
550
|
+
-- nothing, all of Tainted Magdalene's temporary health will eventually go away.
|
|
551
|
+
--
|
|
552
|
+
-- Before using this function, it is expected that you check to see if the player is Tainted
|
|
553
|
+
-- Magdalene first, or else it will give a nonsensical result.
|
|
554
|
+
function ____exports.wouldDamageTaintedMagdaleneNonTemporaryHeartContainers(self, player, damageAmount)
|
|
555
|
+
local soulHearts = player:GetSoulHearts()
|
|
556
|
+
if soulHearts > 0 then
|
|
557
|
+
return false
|
|
558
|
+
end
|
|
559
|
+
local boneHearts = player:GetBoneHearts()
|
|
560
|
+
if boneHearts > 0 then
|
|
561
|
+
return false
|
|
562
|
+
end
|
|
563
|
+
local hearts = player:GetHearts()
|
|
564
|
+
local rottenHearts = player:GetRottenHearts()
|
|
565
|
+
local effectiveDamageAmount = damageAmount + math.min(rottenHearts, damageAmount)
|
|
566
|
+
local heartsAfterDamage = hearts - effectiveDamageAmount
|
|
567
|
+
local nonTemporaryMaxHearts = ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(nil, player)
|
|
568
|
+
return heartsAfterDamage < nonTemporaryMaxHearts
|
|
569
|
+
end
|
|
387
570
|
return ____exports
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
import { ActiveSlot,
|
|
2
|
-
import { HealthType } from "../enums/HealthType";
|
|
1
|
+
import { ActiveSlot, CollectibleType, PlayerType, TrinketType } from "isaac-typescript-definitions";
|
|
3
2
|
export declare function addCollectibleCostume(player: EntityPlayer, collectibleType: CollectibleType): void;
|
|
4
|
-
/**
|
|
5
|
-
* Helper function to add a stat to a player based on the `CacheFlag` provided. Call this function
|
|
6
|
-
* from the `EVALUATE_CACHE` callback.
|
|
7
|
-
*
|
|
8
|
-
* Note that for `CacheFlag.FIRE_DELAY`, the "amount" argument will be interpreted as the tear stat
|
|
9
|
-
* to add (and not the amount to mutate `EntityPlayer.MaxFireDelay` by).
|
|
10
|
-
*
|
|
11
|
-
* This function supports the following cache flags:
|
|
12
|
-
* - CacheFlag.DAMAGE (1 << 0)
|
|
13
|
-
* - CacheFlag.FIRE_DELAY (1 << 1)
|
|
14
|
-
* - CacheFlag.SHOT_SPEED (1 << 2)
|
|
15
|
-
* - CacheFlag.RANGE (1 << 3)
|
|
16
|
-
* - CacheFlag.SPEED (1 << 4)
|
|
17
|
-
* - CacheFlag.LUCK (1 << 10)
|
|
18
|
-
*/
|
|
19
|
-
export declare function addStat(player: EntityPlayer, cacheFlag: CacheFlag, amount: number): void;
|
|
20
3
|
export declare function addTrinketCostume(player: EntityPlayer, trinketType: TrinketType): void;
|
|
21
4
|
export declare function anyPlayerHasCollectible(collectibleType: CollectibleType): boolean;
|
|
22
5
|
export declare function anyPlayerHasTrinket(trinketType: TrinketType): boolean;
|
|
@@ -37,33 +20,6 @@ export declare function anyPlayerIs(...matchingCharacters: PlayerType[]): boolea
|
|
|
37
20
|
* - the player has Stompy (transformation 13)
|
|
38
21
|
*/
|
|
39
22
|
export declare function canPlayerCrushRocks(player: EntityPlayer): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Returns whether or not all of the player's soul-heart-type hearts are black hearts.
|
|
42
|
-
*
|
|
43
|
-
* Note that this function does not consider red heart containers.
|
|
44
|
-
*
|
|
45
|
-
* For example:
|
|
46
|
-
*
|
|
47
|
-
* - If the player has one black heart, this function would return true.
|
|
48
|
-
* - If the player has one soul heart and two black hearts, this function would return false.
|
|
49
|
-
* - If the player has no black hearts, this function will return false.
|
|
50
|
-
* - If the player has one red heart container and three black hearts, this function would return
|
|
51
|
-
* true.
|
|
52
|
-
*/
|
|
53
|
-
export declare function doesPlayerHaveAllBlackHearts(player: EntityPlayer): boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Returns whether or not all of the player's soul-heart-type hearts are soul hearts.
|
|
56
|
-
*
|
|
57
|
-
* Note that this function does not consider red heart containers.
|
|
58
|
-
*
|
|
59
|
-
* For example:
|
|
60
|
-
*
|
|
61
|
-
* - If the player has two soul hearts and one black heart, this function would return false.
|
|
62
|
-
* - If the player has no soul hearts, this function will return false.
|
|
63
|
-
* - If the player has one red heart container and three soul hearts, this function would return
|
|
64
|
-
* true.
|
|
65
|
-
*/
|
|
66
|
-
export declare function doesPlayerHaveAllSoulHearts(player: EntityPlayer): boolean;
|
|
67
23
|
/**
|
|
68
24
|
* Helper function to find the active slot that the player has the corresponding collectible type
|
|
69
25
|
* in. Returns undefined if the player does not have the collectible in any active slot.
|
|
@@ -95,20 +51,6 @@ export declare function getFinalPlayer(): EntityPlayer;
|
|
|
95
51
|
* will be spawned on the same frame.
|
|
96
52
|
*/
|
|
97
53
|
export declare function getNewestPlayer(): EntityPlayer;
|
|
98
|
-
/**
|
|
99
|
-
* Returns the number of slots that the player has remaining for new heart containers, accounting
|
|
100
|
-
* for broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full
|
|
101
|
-
* soul hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
|
|
102
|
-
*/
|
|
103
|
-
export declare function getPlayerAvailableHeartSlots(player: EntityPlayer): int;
|
|
104
|
-
/**
|
|
105
|
-
* Returns the number of black hearts that the player has, excluding any soul hearts. For example,
|
|
106
|
-
* if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
107
|
-
* function returns 3.
|
|
108
|
-
*
|
|
109
|
-
* This is different from the `EntityPlayer.GetBlackHearts` method, since that returns a bitmask.
|
|
110
|
-
*/
|
|
111
|
-
export declare function getPlayerBlackHearts(player: EntityPlayer): int;
|
|
112
54
|
/**
|
|
113
55
|
* Iterates over all players and checks if any are close enough to the specified position.
|
|
114
56
|
*
|
|
@@ -129,27 +71,6 @@ export declare function getPlayerCollectibleCount(player: EntityPlayer, ...colle
|
|
|
129
71
|
export declare function getPlayerCollectibleMap(player: EntityPlayer): Map<CollectibleType, int>;
|
|
130
72
|
/** Helper function to get the player from a tear, laser, bomb, etc. */
|
|
131
73
|
export declare function getPlayerFromTear(entity: Entity): EntityPlayer | undefined;
|
|
132
|
-
/**
|
|
133
|
-
* Returns the number of red hearts that the player has, excluding any rotten hearts. For example,
|
|
134
|
-
* if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
135
|
-
* function returns 3.
|
|
136
|
-
*
|
|
137
|
-
* This is different from the `EntityPlayer.GetHearts` method, since that returns a value that
|
|
138
|
-
* includes rotten hearts.
|
|
139
|
-
*/
|
|
140
|
-
export declare function getPlayerHearts(player: EntityPlayer): int;
|
|
141
|
-
/**
|
|
142
|
-
* Helper function that returns the type of the rightmost heart. This does not including golden
|
|
143
|
-
* hearts or broken hearts, since they cannot be damaged directly.
|
|
144
|
-
*/
|
|
145
|
-
export declare function getPlayerLastHeart(player: EntityPlayer): HealthType;
|
|
146
|
-
/**
|
|
147
|
-
* Returns the maximum heart containers that the provided player can have. Normally, this is 12, but
|
|
148
|
-
* it can change depending on the character (e.g. Keeper) and other things (e.g. Mother's Kiss).
|
|
149
|
-
* This function does not account for Broken Hearts; use the `getPlayerAvailableHeartSlots` helper
|
|
150
|
-
* function for that.
|
|
151
|
-
*/
|
|
152
|
-
export declare function getPlayerMaxHeartContainers(player: EntityPlayer): int;
|
|
153
74
|
/**
|
|
154
75
|
* Helper function to get the proper name of the player. Use this instead of the
|
|
155
76
|
* `EntityPlayer.GetName` method because it accounts for Blue Baby, Lazarus II, and Tainted
|
|
@@ -166,15 +87,6 @@ export declare function getPlayerName(player: EntityPlayer): string;
|
|
|
166
87
|
* function would report that they have 2 hits remaining.)
|
|
167
88
|
*/
|
|
168
89
|
export declare function getPlayerNumHitsRemaining(player: EntityPlayer): int;
|
|
169
|
-
/**
|
|
170
|
-
* Returns the number of soul hearts that the player has, excluding any black hearts. For example,
|
|
171
|
-
* if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
172
|
-
* function returns 2.
|
|
173
|
-
*
|
|
174
|
-
* This is different from the `EntityPlayer.GetSoulHearts` method, since that returns the combined
|
|
175
|
-
* number of soul hearts and black hearts.
|
|
176
|
-
*/
|
|
177
|
-
export declare function getPlayerSoulHearts(player: EntityPlayer): int;
|
|
178
90
|
/**
|
|
179
91
|
* Helper function to get all of the players that are a certain character.
|
|
180
92
|
*
|
|
@@ -196,17 +108,6 @@ export declare function getPlayersWithCollectible(...collectibleTypes: Collectib
|
|
|
196
108
|
* for. It only returns the players that have all of the trinkets.
|
|
197
109
|
*/
|
|
198
110
|
export declare function getPlayersWithTrinket(...trinketTypes: TrinketType[]): EntityPlayer[];
|
|
199
|
-
/**
|
|
200
|
-
* Helper function to determine how many heart containers that Tainted Magdalene has that will not
|
|
201
|
-
* be automatically depleted over time. By default, this is 2, but this function will return 4 so
|
|
202
|
-
* that it is consistent with the `player.GetHearts` and `player.GetMaxHearts` methods.
|
|
203
|
-
*
|
|
204
|
-
* If Tainted Magdalene has Birthright, she will gained an additional non-temporary heart container.
|
|
205
|
-
*
|
|
206
|
-
* This function does not validate whether or not the provided player is Tainted Magdalene; that
|
|
207
|
-
* should be accomplished before invoking this function.
|
|
208
|
-
*/
|
|
209
|
-
export declare function getTaintedMagdaleneNonTemporaryMaxHearts(player: EntityPlayer): int;
|
|
210
111
|
/**
|
|
211
112
|
* Returns the total number of collectibles amongst all players. For example, if player 1 has 1 Sad
|
|
212
113
|
* Onion and player 2 has 2 Sad Onions, then this function would return 3.
|
|
@@ -340,15 +241,4 @@ export declare function setBlindfold(player: EntityPlayer, enabled: boolean, mod
|
|
|
340
241
|
* any costumes.
|
|
341
242
|
*/
|
|
342
243
|
export declare function useActiveItemTemp(player: EntityPlayer, collectibleType: CollectibleType): void;
|
|
343
|
-
/**
|
|
344
|
-
* Helper function to see if a certain damage amount would deal "permanent" damage to Tainted
|
|
345
|
-
* Magdalene.
|
|
346
|
-
*
|
|
347
|
-
* Tainted Magdalene has "permanent" health and "temporary" health. When standing still and doing
|
|
348
|
-
* nothing, all of Tainted Magdalene's temporary health will eventually go away.
|
|
349
|
-
*
|
|
350
|
-
* Before using this function, it is expected that you check to see if the player is Tainted
|
|
351
|
-
* Magdalene first, or else it will give a nonsensical result.
|
|
352
|
-
*/
|
|
353
|
-
export declare function wouldDamageTaintedMagdaleneNonTemporaryHeartContainers(player: EntityPlayer, damageAmount: float): boolean;
|
|
354
244
|
//# sourceMappingURL=players.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"players.d.ts","sourceRoot":"","sources":["../../src/functions/players.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,
|
|
1
|
+
{"version":3,"file":"players.d.ts","sourceRoot":"","sources":["../../src/functions/players.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,eAAe,EAIf,UAAU,EAEV,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAetC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAON;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,GACvB,IAAI,CAON;AAED,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAGT;AAED,wBAAgB,mBAAmB,CAAC,W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