Player Health
Functions
Section titled “Functions”addPlayerHealthType()
Section titled “addPlayerHealthType()”addPlayerHealthType(
player,healthType,numHearts):void
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:18
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
healthType
Section titled “healthType”numHearts
Section titled “numHearts”int
Returns
Section titled “Returns”void
canPickEternalHearts()
Section titled “canPickEternalHearts()”canPickEternalHearts(
player):boolean
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:78
Helper function to see if the provided player can pick up an eternal heart. (If a player already has an eternal heart and full heart containers, they are not able to pick up any additional eternal hearts.)
This function’s name matches the existing EntityPlayer methods.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”boolean
doesPlayerHaveAllBlackHearts()
Section titled “doesPlayerHaveAllBlackHearts()”doesPlayerHaveAllBlackHearts(
player):boolean
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:99
Returns whether all of the player’s soul-heart-type hearts are black hearts.
Note that this function does not consider red heart containers.
For example:
- If the player has one black heart, this function would return true.
- If the player has one soul heart and two black hearts, this function would return false.
- If the player has no black hearts, this function will return false.
- If the player has one red heart container and three black hearts, this function would return true.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”boolean
doesPlayerHaveAllSoulHearts()
Section titled “doesPlayerHaveAllSoulHearts()”doesPlayerHaveAllSoulHearts(
player):boolean
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:118
Returns whether all of the player’s soul-heart-type hearts are soul hearts.
Note that this function does not consider red heart containers.
For example:
- If the player has two soul hearts and one black heart, this function would return false.
- If the player has no soul hearts, this function will return false.
- If the player has one red heart container and three soul hearts, this function would return true.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”boolean
getPlayerAvailableHeartSlots()
Section titled “getPlayerAvailableHeartSlots()”getPlayerAvailableHeartSlots(
player):int
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:130
Returns the number of slots that the player has remaining for new heart containers, accounting for broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full soul hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”int
getPlayerBlackHearts()
Section titled “getPlayerBlackHearts()”getPlayerBlackHearts(
player):int
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:151
Returns the number of black hearts that the player has, excluding any soul hearts. For example, if the player has one full black heart, one full soul heart, and one half black heart, this function returns 3.
This is different from the EntityPlayer.GetBlackHearts method, since that returns a bitmask.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”int
getPlayerHealth()
Section titled “getPlayerHealth()”getPlayerHealth(
player):Readonly<PlayerHealth>
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:165
Helper function to get an object representing the player’s health. You can use this in
combination with the setPlayerHealth function to restore the player’s health back to a certain
configuration at a later time.
This is based on the REVEL.StoreHealth function in the Revelations mod.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”Readonly<PlayerHealth>
getPlayerHealthType()
Section titled “getPlayerHealthType()”getPlayerHealthType(
player,healthType):int
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:242
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
healthType
Section titled “healthType”Returns
Section titled “Returns”int
getPlayerHearts()
Section titled “getPlayerHearts()”getPlayerHearts(
player):int
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:306
Returns the number of red hearts that the player has, excluding any rotten hearts. For example, if the player has one full black heart, one full soul heart, and one half black heart, this function returns 3.
This is different from the EntityPlayer.GetHearts method, since that returns a value that
includes rotten hearts.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”int
getPlayerLastHeart()
Section titled “getPlayerLastHeart()”getPlayerLastHeart(
player):HealthType
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:317
Helper function that returns the type of the rightmost heart. This does not including golden hearts or broken hearts, since they cannot be damaged directly.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”getPlayerMaxHeartContainers()
Section titled “getPlayerMaxHeartContainers()”getPlayerMaxHeartContainers(
player):int
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:377
Returns the maximum heart containers that the provided player can have. Normally, this is 12, but
it can change depending on the character (e.g. Keeper) and other things (e.g. Mother’s Kiss).
This function does not account for Broken Hearts; use the getPlayerAvailableHeartSlots helper
function for that.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”int
getPlayerSoulHearts()
Section titled “getPlayerSoulHearts()”getPlayerSoulHearts(
player):int
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:424
Returns the number of soul hearts that the player has, excluding any black hearts. For example, if the player has one full black heart, one full soul heart, and one half black heart, this function returns 2.
This is different from the EntityPlayer.GetSoulHearts method, since that returns the combined
number of soul hearts and black hearts.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”int
getTaintedMagdaleneNonTemporaryMaxHearts()
Section titled “getTaintedMagdaleneNonTemporaryMaxHearts()”getTaintedMagdaleneNonTemporaryMaxHearts(
player):int
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:441
Helper function to determine how many heart containers that Tainted Magdalene has that will not
be automatically depleted over time. By default, this is 2, but this function will return 4 so
that it is consistent with the player.GetHearts and player.GetMaxHearts methods.
If Tainted Magdalene has Birthright, she will gained an additional non-temporary heart container.
This function does not validate whether the provided player is Tainted Magdalene; that should be accomplished before invoking this function.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”int
newPlayerHealth()
Section titled “newPlayerHealth()”newPlayerHealth():
PlayerHealth
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:452
Returns a PlayerHealth object with all zeros.
Returns
Section titled “Returns”playerConvertBlackHeartsToSoulHearts()
Section titled “playerConvertBlackHeartsToSoulHearts()”playerConvertBlackHeartsToSoulHearts(
player):void
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:472
Helper function to remove all of a player’s black hearts and add the corresponding amount of soul hearts.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”void
playerConvertSoulHeartsToBlackHearts()
Section titled “playerConvertSoulHeartsToBlackHearts()”playerConvertSoulHeartsToBlackHearts(
player):void
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:494
Helper function to remove all of a player’s soul hearts and add the corresponding amount of black hearts.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”void
playerHasHealthLeft()
Section titled “playerHasHealthLeft()”playerHasHealthLeft(
player):boolean
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:518
Helper function to see if the player is out of health.
Specifically, this function will return false if the player has 0 red hearts, 0 soul/black hearts, and 0 bone hearts.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”boolean
removeAllPlayerHealth()
Section titled “removeAllPlayerHealth()”removeAllPlayerHealth(
player):void
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:526
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
Returns
Section titled “Returns”void
setPlayerHealth()
Section titled “setPlayerHealth()”setPlayerHealth(
player,playerHealth):void
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:559
Helper function to set a player’s health to a specific state. You can use this in combination
with the getPlayerHealth function to restore the player’s health back to a certain
configuration at a later time.
Based on the REVEL.LoadHealth function in the Revelations mod.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
playerHealth
Section titled “playerHealth”Returns
Section titled “Returns”void
wouldDamageTaintedMagdaleneNonTemporaryHeartContainers()
Section titled “wouldDamageTaintedMagdaleneNonTemporaryHeartContainers()”wouldDamageTaintedMagdaleneNonTemporaryHeartContainers(
player,damageAmount):boolean
Defined in: packages/isaacscript-common/src/functions/playerHealth.ts:697
Helper function to see if a certain damage amount would deal “permanent” damage to Tainted Magdalene.
Tainted Magdalene has “permanent” health and “temporary” health. When standing still and doing nothing, all of Tainted Magdalene’s temporary health will eventually go away.
Before using this function, it is expected that you check to see if the player is Tainted Magdalene first, or else it will give a nonsensical result.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
damageAmount
Section titled “damageAmount”float
Returns
Section titled “Returns”boolean
