isaacscript-common 8.4.6 → 8.7.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.
Files changed (77) hide show
  1. package/dist/enums/ModCallbackCustom.d.ts +2 -2
  2. package/dist/features/characterStats.d.ts.map +1 -1
  3. package/dist/features/characterStats.lua +1 -2
  4. package/dist/features/firstLast.d.ts +6 -3
  5. package/dist/features/firstLast.d.ts.map +1 -1
  6. package/dist/features/firstLast.lua +6 -3
  7. package/dist/features/playerInventory.d.ts +11 -3
  8. package/dist/features/playerInventory.d.ts.map +1 -1
  9. package/dist/features/playerInventory.lua +24 -11
  10. package/dist/functions/bosses.d.ts +8 -2
  11. package/dist/functions/bosses.d.ts.map +1 -1
  12. package/dist/functions/bosses.lua +14 -6
  13. package/dist/functions/collectibleCacheFlag.d.ts +1 -1
  14. package/dist/functions/collectibleCacheFlag.d.ts.map +1 -1
  15. package/dist/functions/collectibleCacheFlag.lua +1 -2
  16. package/dist/functions/collectibleSet.lua +32 -32
  17. package/dist/functions/collectibleTag.d.ts +1 -1
  18. package/dist/functions/collectibleTag.d.ts.map +1 -1
  19. package/dist/functions/collectibleTag.lua +1 -3
  20. package/dist/functions/collectibles.d.ts +10 -1
  21. package/dist/functions/collectibles.d.ts.map +1 -1
  22. package/dist/functions/collectibles.lua +17 -1
  23. package/dist/functions/eden.d.ts +1 -1
  24. package/dist/functions/eden.d.ts.map +1 -1
  25. package/dist/functions/eden.lua +1 -2
  26. package/dist/functions/flying.d.ts +1 -1
  27. package/dist/functions/flying.d.ts.map +1 -1
  28. package/dist/functions/flying.lua +5 -2
  29. package/dist/functions/input.d.ts +2 -2
  30. package/dist/functions/input.d.ts.map +1 -1
  31. package/dist/functions/input.lua +2 -4
  32. package/dist/functions/playerHealth.d.ts +93 -0
  33. package/dist/functions/playerHealth.d.ts.map +1 -1
  34. package/dist/functions/playerHealth.lua +216 -33
  35. package/dist/functions/players.d.ts +1 -111
  36. package/dist/functions/players.d.ts.map +1 -1
  37. package/dist/functions/players.lua +20 -279
  38. package/dist/functions/revive.d.ts.map +1 -1
  39. package/dist/functions/revive.lua +2 -1
  40. package/dist/functions/stats.d.ts +16 -0
  41. package/dist/functions/stats.d.ts.map +1 -1
  42. package/dist/functions/stats.lua +78 -0
  43. package/dist/functions/transformations.d.ts +1 -1
  44. package/dist/functions/transformations.d.ts.map +1 -1
  45. package/dist/functions/trinketCacheFlag.d.ts +1 -1
  46. package/dist/functions/trinketCacheFlag.d.ts.map +1 -1
  47. package/dist/functions/trinketCacheFlag.lua +1 -3
  48. package/dist/functions/trinketSet.lua +32 -32
  49. package/dist/functions/trinkets.d.ts +14 -0
  50. package/dist/functions/trinkets.d.ts.map +1 -1
  51. package/dist/functions/trinkets.lua +26 -0
  52. package/dist/index.d.ts +63 -36
  53. package/dist/sets/bossSets.d.ts +1 -0
  54. package/dist/sets/bossSets.d.ts.map +1 -1
  55. package/dist/sets/bossSets.lua +23 -0
  56. package/package.json +1 -1
  57. package/src/enums/ModCallbackCustom.ts +2 -2
  58. package/src/features/characterStats.ts +1 -2
  59. package/src/features/firstLast.ts +6 -3
  60. package/src/features/playerInventory.ts +37 -8
  61. package/src/functions/bosses.ts +18 -6
  62. package/src/functions/collectibleCacheFlag.ts +3 -3
  63. package/src/functions/collectibleSet.ts +32 -32
  64. package/src/functions/collectibleTag.ts +2 -3
  65. package/src/functions/collectibles.ts +25 -1
  66. package/src/functions/eden.ts +3 -3
  67. package/src/functions/flying.ts +4 -4
  68. package/src/functions/input.ts +4 -5
  69. package/src/functions/playerHealth.ts +269 -7
  70. package/src/functions/players.ts +1 -348
  71. package/src/functions/revive.ts +2 -6
  72. package/src/functions/stats.ts +75 -0
  73. package/src/functions/transformations.ts +1 -1
  74. package/src/functions/trinketCacheFlag.ts +2 -3
  75. package/src/functions/trinketSet.ts +32 -32
  76. package/src/functions/trinkets.ts +34 -0
  77. package/src/sets/bossSets.ts +33 -0
@@ -34,7 +34,10 @@ local CONDITIONAL_FLYING_COLLECTIBLE_TYPES = {CollectibleType.BIBLE, Collectible
34
34
  -- @param pruneConditionalItems Whether or not collectibles that only grant flight conditionally
35
35
  -- should be included in the set (like Empty Vessel).
36
36
  function ____exports.getFlyingCollectibles(self, pruneConditionalItems)
37
- local collectiblesWithFlyingCacheFlag = getCollectiblesForCacheFlag(nil, CacheFlag.FLYING)
37
+ local collectiblesWithFlyingCacheFlag = copySet(
38
+ nil,
39
+ getCollectiblesForCacheFlag(nil, CacheFlag.FLYING)
40
+ )
38
41
  local collectiblesWithAllCacheFlag = getCollectiblesForCacheFlag(nil, CacheFlag.ALL)
39
42
  deleteSetsFromSet(nil, collectiblesWithFlyingCacheFlag, collectiblesWithAllCacheFlag)
40
43
  if pruneConditionalItems then
@@ -47,7 +50,7 @@ end
47
50
  --- Returns a set of all of the trinkets that grant flight. (All trinkets that grant flight do so
48
51
  -- conditionally, like Bat Wing.)
49
52
  function ____exports.getFlyingTrinkets(self)
50
- return copySet(nil, FLYING_TRINKETS)
53
+ return FLYING_TRINKETS
51
54
  end
52
55
  function ____exports.hasFlyingTemporaryEffect(self, player)
53
56
  local effects = player:GetEffects()
@@ -1,8 +1,8 @@
1
1
  import { ButtonAction, Controller, Keyboard } from "isaac-typescript-definitions";
2
2
  /** Helper function to get the enum name for the specified `Controller` value. */
3
3
  export declare function controllerToString(controller: Controller): string | undefined;
4
- export declare function getMoveActions(): Set<ButtonAction>;
5
- export declare function getShootActions(): Set<ButtonAction>;
4
+ export declare function getMoveActions(): ReadonlySet<ButtonAction>;
5
+ export declare function getShootActions(): ReadonlySet<ButtonAction>;
6
6
  /** Iterates over all inputs to determine if a particular button is pressed (i.e. held down). */
7
7
  export declare function isActionPressedOnAnyInput(buttonAction: ButtonAction): boolean;
8
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/functions/input.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,UAAU,EAEV,QAAQ,EAC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AE1D;AAED,wBAAgB,eAAe,IAAI,WAAW,CAAC,YAAY,CAAC,CAE3D;AAED,gGAAgG;AAChG,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAK7E;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,YAAY,GACzB,OAAO,CAKT;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAI9D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAEhE;AAED,wBAAgB,6BAA6B,IAAI,OAAO,CAIvD;AAED,wBAAgB,+BAA+B,IAAI,OAAO,CAIzD;AAED,wBAAgB,aAAa,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAEjE;AAED,wBAAgB,8BAA8B,IAAI,OAAO,CAIxD;AAED,wBAAgB,gCAAgC,IAAI,OAAO,CAI1D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,OAAO,GACjB,MAAM,GAAG,SAAS,CAQpB"}
@@ -12,8 +12,6 @@ local ____keyboardToString = require("maps.keyboardToString")
12
12
  local KEYBOARD_TO_STRING = ____keyboardToString.KEYBOARD_TO_STRING
13
13
  local ____enums = require("functions.enums")
14
14
  local getEnumValues = ____enums.getEnumValues
15
- local ____set = require("functions.set")
16
- local copySet = ____set.copySet
17
15
  local ____string = require("functions.string")
18
16
  local trimPrefix = ____string.trimPrefix
19
17
  local MODIFIER_KEYS = {
@@ -39,10 +37,10 @@ function ____exports.controllerToString(self, controller)
39
37
  return trimPrefix(nil, key, "BUTTON_")
40
38
  end
41
39
  function ____exports.getMoveActions(self)
42
- return copySet(nil, MOVEMENT_ACTIONS_SET)
40
+ return MOVEMENT_ACTIONS_SET
43
41
  end
44
42
  function ____exports.getShootActions(self)
45
- return copySet(nil, SHOOTING_ACTIONS_SET)
43
+ return SHOOTING_ACTIONS_SET
46
44
  end
47
45
  --- Iterates over all inputs to determine if a particular button is pressed (i.e. held down).
48
46
  function ____exports.isActionPressedOnAnyInput(self, buttonAction)
@@ -3,6 +3,47 @@
3
3
  import { HealthType } from "../enums/HealthType";
4
4
  import { PlayerHealth } from "../interfaces/PlayerHealth";
5
5
  export declare function addPlayerHealthType(player: EntityPlayer, healthType: HealthType, numHearts: int): void;
6
+ /**
7
+ * Returns whether or not all of the player's soul-heart-type hearts are black hearts.
8
+ *
9
+ * Note that this function does not consider red heart containers.
10
+ *
11
+ * For example:
12
+ *
13
+ * - If the player has one black heart, this function would return true.
14
+ * - If the player has one soul heart and two black hearts, this function would return false.
15
+ * - If the player has no black hearts, this function will return false.
16
+ * - If the player has one red heart container and three black hearts, this function would return
17
+ * true.
18
+ */
19
+ export declare function doesPlayerHaveAllBlackHearts(player: EntityPlayer): boolean;
20
+ /**
21
+ * Returns whether or not all of the player's soul-heart-type hearts are soul hearts.
22
+ *
23
+ * Note that this function does not consider red heart containers.
24
+ *
25
+ * For example:
26
+ *
27
+ * - If the player has two soul hearts and one black heart, this function would return false.
28
+ * - If the player has no soul hearts, this function will return false.
29
+ * - If the player has one red heart container and three soul hearts, this function would return
30
+ * true.
31
+ */
32
+ export declare function doesPlayerHaveAllSoulHearts(player: EntityPlayer): boolean;
33
+ /**
34
+ * Returns the number of slots that the player has remaining for new heart containers, accounting
35
+ * for broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full
36
+ * soul hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
37
+ */
38
+ export declare function getPlayerAvailableHeartSlots(player: EntityPlayer): int;
39
+ /**
40
+ * Returns the number of black hearts that the player has, excluding any soul hearts. For example,
41
+ * if the player has one full black heart, one full soul heart, and one half black heart, this
42
+ * function returns 3.
43
+ *
44
+ * This is different from the `EntityPlayer.GetBlackHearts` method, since that returns a bitmask.
45
+ */
46
+ export declare function getPlayerBlackHearts(player: EntityPlayer): int;
6
47
  /**
7
48
  * Helper function to get an object representing the player's health. You can use this in
8
49
  * combination with the `setPlayerHealth` function to restore the player's health back to a certain
@@ -12,6 +53,47 @@ export declare function addPlayerHealthType(player: EntityPlayer, healthType: He
12
53
  */
13
54
  export declare function getPlayerHealth(player: EntityPlayer): PlayerHealth;
14
55
  export declare function getPlayerHealthType(player: EntityPlayer, healthType: HealthType): int;
56
+ /**
57
+ * Returns the number of red hearts that the player has, excluding any rotten hearts. For example,
58
+ * if the player has one full black heart, one full soul heart, and one half black heart, this
59
+ * function returns 3.
60
+ *
61
+ * This is different from the `EntityPlayer.GetHearts` method, since that returns a value that
62
+ * includes rotten hearts.
63
+ */
64
+ export declare function getPlayerHearts(player: EntityPlayer): int;
65
+ /**
66
+ * Helper function that returns the type of the rightmost heart. This does not including golden
67
+ * hearts or broken hearts, since they cannot be damaged directly.
68
+ */
69
+ export declare function getPlayerLastHeart(player: EntityPlayer): HealthType;
70
+ /**
71
+ * Returns the maximum heart containers that the provided player can have. Normally, this is 12, but
72
+ * it can change depending on the character (e.g. Keeper) and other things (e.g. Mother's Kiss).
73
+ * This function does not account for Broken Hearts; use the `getPlayerAvailableHeartSlots` helper
74
+ * function for that.
75
+ */
76
+ export declare function getPlayerMaxHeartContainers(player: EntityPlayer): int;
77
+ /**
78
+ * Returns the number of soul hearts that the player has, excluding any black hearts. For example,
79
+ * if the player has one full black heart, one full soul heart, and one half black heart, this
80
+ * function returns 2.
81
+ *
82
+ * This is different from the `EntityPlayer.GetSoulHearts` method, since that returns the combined
83
+ * number of soul hearts and black hearts.
84
+ */
85
+ export declare function getPlayerSoulHearts(player: EntityPlayer): int;
86
+ /**
87
+ * Helper function to determine how many heart containers that Tainted Magdalene has that will not
88
+ * be automatically depleted over time. By default, this is 2, but this function will return 4 so
89
+ * that it is consistent with the `player.GetHearts` and `player.GetMaxHearts` methods.
90
+ *
91
+ * If Tainted Magdalene has Birthright, she will gained an additional non-temporary heart container.
92
+ *
93
+ * This function does not validate whether or not the provided player is Tainted Magdalene; that
94
+ * should be accomplished before invoking this function.
95
+ */
96
+ export declare function getTaintedMagdaleneNonTemporaryMaxHearts(player: EntityPlayer): int;
15
97
  /** Returns a `PlayerHealth` object with all zeros. */
16
98
  export declare function newPlayerHealth(): PlayerHealth;
17
99
  export declare function playerConvertBlackHeartsToSoulHearts(player: EntityPlayer): void;
@@ -32,4 +114,15 @@ export declare function removeAllPlayerHealth(player: EntityPlayer): void;
32
114
  * Based on the `REVEL.LoadHealth` function in the Revelations mod.
33
115
  */
34
116
  export declare function setPlayerHealth(player: EntityPlayer, playerHealth: PlayerHealth): void;
117
+ /**
118
+ * Helper function to see if a certain damage amount would deal "permanent" damage to Tainted
119
+ * Magdalene.
120
+ *
121
+ * Tainted Magdalene has "permanent" health and "temporary" health. When standing still and doing
122
+ * nothing, all of Tainted Magdalene's temporary health will eventually go away.
123
+ *
124
+ * Before using this function, it is expected that you check to see if the player is Tainted
125
+ * Magdalene first, or else it will give a nonsensical result.
126
+ */
127
+ export declare function wouldDamageTaintedMagdaleneNonTemporaryHeartContainers(player: EntityPlayer, damageAmount: float): boolean;
35
128
  //# sourceMappingURL=playerHealth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"playerHealth.d.ts","sourceRoot":"","sources":["../../src/functions/playerHealth.ts"],"names":[],"mappings":";;AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAiB,MAAM,4BAA4B,CAAC;AAYzE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,GAAG,GACb,IAAI,CA+CN;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CA2ElE;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,EACpB,UAAU,E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UAAU,EAAE,UAAU,GACrB,GAAG,CAmDL;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,GAAG,CAKzD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAoDnE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,YAAY,GAAG,GAAG,CAqCrE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,GAAG,CAK7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,wCAAwC,CACtD,MAAM,EAAE,YAAY,GACnB,GAAG,CAML;AAED,sDAAsD;AACtD,wBAAgB,eAAe,IAAI,YAAY,CAc9C;AAED,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,YAAY,GACnB,IAAI,CAQN;AAED,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,YAAY,GACnB,IAAI,CAQN;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAMjE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAwBhE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,YAAY,GACzB,IAAI,CAsHN;AAED;;;;;;;;;GASG;AACH,wBAAgB,sDAAsD,CACpE,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,KAAK,GAClB,OAAO,CAyBT"}
@@ -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 ____switch52 = soulHeartType
82
- local ____cond52 = ____switch52 == HeartSubType.SOUL
83
- if ____cond52 then
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
- ____cond52 = ____cond52 or ____switch52 == HeartSubType.BLACK
91
- if ____cond52 then
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
- ____cond52 = ____cond52 or ____switch52 == HeartSubType.BONE
99
- if ____cond52 then
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 ____switch24 = healthType
287
- local ____cond24 = ____switch24 == HealthType.RED
288
- if ____cond24 then
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
- ____cond24 = ____cond24 or ____switch24 == HealthType.SOUL
294
- if ____cond24 then
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
- ____cond24 = ____cond24 or ____switch24 == HealthType.ETERNAL
300
- if ____cond24 then
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
- ____cond24 = ____cond24 or ____switch24 == HealthType.BLACK
306
- if ____cond24 then
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
- ____cond24 = ____cond24 or ____switch24 == HealthType.GOLDEN
312
- if ____cond24 then
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
- ____cond24 = ____cond24 or ____switch24 == HealthType.BONE
318
- if ____cond24 then
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
- ____cond24 = ____cond24 or ____switch24 == HealthType.ROTTEN
324
- if ____cond24 then
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
- ____cond24 = ____cond24 or ____switch24 == HealthType.BROKEN
330
- if ____cond24 then
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
- ____cond24 = ____cond24 or ____switch24 == HealthType.MAX_HEARTS
336
- if ____cond24 then
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