Skip to main content

Player Health

Functions

addPlayerHealthType

addPlayerHealthType(player, healthType, numHearts): void

Parameters

NameType
playerEntityPlayer
healthTypeHealthType
numHeartsint

Returns

void

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:18


canPickEternalHearts

canPickEternalHearts(player): boolean

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

NameType
playerEntityPlayer

Returns

boolean

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:78


doesPlayerHaveAllBlackHearts

doesPlayerHaveAllBlackHearts(player): boolean

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

NameType
playerEntityPlayer

Returns

boolean

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:99


doesPlayerHaveAllSoulHearts

doesPlayerHaveAllSoulHearts(player): boolean

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

NameType
playerEntityPlayer

Returns

boolean

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:118


getPlayerAvailableHeartSlots

getPlayerAvailableHeartSlots(player): int

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

NameType
playerEntityPlayer

Returns

int

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:130


getPlayerBlackHearts

getPlayerBlackHearts(player): int

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

NameType
playerEntityPlayer

Returns

int

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:151


getPlayerHealth

getPlayerHealth(player): Readonly<PlayerHealth>

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

NameType
playerEntityPlayer

Returns

Readonly<PlayerHealth>

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:165


getPlayerHealthType

getPlayerHealthType(player, healthType): int

Parameters

NameType
playerEntityPlayer
healthTypeHealthType

Returns

int

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:242


getPlayerHearts

getPlayerHearts(player): int

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

NameType
playerEntityPlayer

Returns

int

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:306


getPlayerLastHeart

getPlayerLastHeart(player): HealthType

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

NameType
playerEntityPlayer

Returns

HealthType

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:317


getPlayerMaxHeartContainers

getPlayerMaxHeartContainers(player): int

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

NameType
playerEntityPlayer

Returns

int

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:377


getPlayerSoulHearts

getPlayerSoulHearts(player): int

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

NameType
playerEntityPlayer

Returns

int

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:424


getTaintedMagdaleneNonTemporaryMaxHearts

getTaintedMagdaleneNonTemporaryMaxHearts(player): int

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

NameType
playerEntityPlayer

Returns

int

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:441


newPlayerHealth

newPlayerHealth(): PlayerHealth

Returns a PlayerHealth object with all zeros.

Returns

PlayerHealth

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:452


playerConvertBlackHeartsToSoulHearts

playerConvertBlackHeartsToSoulHearts(player): void

Helper function to remove all of a player's black hearts and add the corresponding amount of soul hearts.

Parameters

NameType
playerEntityPlayer

Returns

void

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:472


playerConvertSoulHeartsToBlackHearts

playerConvertSoulHeartsToBlackHearts(player): void

Helper function to remove all of a player's soul hearts and add the corresponding amount of black hearts.

Parameters

NameType
playerEntityPlayer

Returns

void

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:494


playerHasHealthLeft

playerHasHealthLeft(player): boolean

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

NameType
playerEntityPlayer

Returns

boolean

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:518


removeAllPlayerHealth

removeAllPlayerHealth(player): void

Parameters

NameType
playerEntityPlayer

Returns

void

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:526


setPlayerHealth

setPlayerHealth(player, playerHealth): void

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

NameType
playerEntityPlayer
playerHealthPlayerHealth

Returns

void

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:559


wouldDamageTaintedMagdaleneNonTemporaryHeartContainers

wouldDamageTaintedMagdaleneNonTemporaryHeartContainers(player, damageAmount): boolean

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

NameType
playerEntityPlayer
damageAmountfloat

Returns

boolean

Defined in

packages/isaacscript-common/src/functions/playerHealth.ts:695