isaacscript-common 1.2.81 → 1.2.82

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.
@@ -97,9 +97,9 @@ export declare function getLastHeart(player: EntityPlayer): HealthType;
97
97
  */
98
98
  export declare function getNewestPlayer(): EntityPlayer;
99
99
  /**
100
- * Returns the number of slots that the player has remaining for heart containers, accounting for
101
- * broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full soul
102
- * hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
100
+ * Returns the number of slots that the player has remaining for new heart containers, accounting
101
+ * for broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full
102
+ * soul hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
103
103
  */
104
104
  export declare function getPlayerAvailableHeartSlots(player: EntityPlayer): int;
105
105
  /**
@@ -5,8 +5,8 @@
5
5
  */
6
6
  export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageGameFrame: int): boolean;
7
7
  /**
8
- * The `EntityPlayer.WillPlayerRevive()` function does not properly account for Mysterious Paper,
9
- * so use this helper function instead for more robust revival detection.
8
+ * The `EntityPlayer.WillPlayerRevive()` function does not properly account for Mysterious Paper, so
9
+ * use this helper function instead for more robust revival detection.
10
10
  */
11
11
  export declare function willPlayerRevive(player: EntityPlayer): boolean;
12
12
  /**
@@ -18,6 +18,12 @@ export declare function willPlayerRevive(player: EntityPlayer): boolean;
18
18
  * Mysterious Paper be Missing Power is: `gameFrameCount % 4 === 3`
19
19
  */
20
20
  export declare function willMysteriousPaperRevive(player: EntityPlayer): boolean;
21
+ /**
22
+ * Helper function to determine if the player will be revived by the Heartbreak collectible if they
23
+ * take fatal damage. This is contingent on the character that they are playing as and the amount of
24
+ * broken hearts that they already have.
25
+ */
26
+ export declare function willReviveFromHeartbreak(player: EntityPlayer): boolean;
21
27
  /**
22
28
  * Helper function to determine if the Spirit Shackles item is in an enabled state. (It can be
23
29
  * either enabled or disabled.)
@@ -2,9 +2,10 @@
2
2
  local ____exports = {}
3
3
  local ____player = require("functions.player")
4
4
  local getDeathAnimationName = ____player.getDeathAnimationName
5
- local getPlayerAvailableHeartSlots = ____player.getPlayerAvailableHeartSlots
5
+ local getPlayerMaxHeartContainers = ____player.getPlayerMaxHeartContainers
6
6
  local getPlayerNumHitsRemaining = ____player.getPlayerNumHitsRemaining
7
7
  local hasLostCurse = ____player.hasLostCurse
8
+ local isKeeper = ____player.isKeeper
8
9
  local ____sprite = require("functions.sprite")
9
10
  local getFinalFrameOfAnimation = ____sprite.getFinalFrameOfAnimation
10
11
  local ____trinketGive = require("functions.trinketGive")
@@ -19,6 +20,16 @@ function ____exports.willMysteriousPaperRevive(self, player)
19
20
  local frameOfDeath = gameFrameCount + deathAnimationFrames + 1
20
21
  return frameOfDeath % 4 == 3
21
22
  end
23
+ function ____exports.willReviveFromHeartbreak(self, player)
24
+ if player:HasCollectible(CollectibleType.COLLECTIBLE_HEARTBREAK) then
25
+ return false
26
+ end
27
+ local numBrokenHeartsThatWillBeAdded = isKeeper(nil, player) and 1 or 2
28
+ local brokenHearts = player:GetBrokenHearts()
29
+ local numBrokenHeartsAfterRevival = numBrokenHeartsThatWillBeAdded + brokenHearts
30
+ local maxHeartContainers = getPlayerMaxHeartContainers(nil, player)
31
+ return numBrokenHeartsAfterRevival < maxHeartContainers
32
+ end
22
33
  function ____exports.willReviveFromSpiritShackles(self, player)
23
34
  if not player:HasCollectible(CollectibleType.COLLECTIBLE_SPIRIT_SHACKLES) then
24
35
  return false
@@ -53,8 +64,7 @@ function ____exports.isDamageToPlayerFatal(self, player, damageAmount, damageSou
53
64
  if damageAmount < playerNumAllHearts then
54
65
  return false
55
66
  end
56
- local playerAvailableHeartSlots = getPlayerAvailableHeartSlots(nil, player)
57
- if player:HasCollectible(CollectibleType.COLLECTIBLE_HEARTBREAK) and playerAvailableHeartSlots >= 2 then
67
+ if ____exports.willReviveFromHeartbreak(nil, player) then
58
68
  return false
59
69
  end
60
70
  if player:HasCollectible(CollectibleType.COLLECTIBLE_BROKEN_GLASS_CANNON) and gameFrameCount == lastDamageGameFrame then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.81",
3
+ "version": "1.2.82",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",