Charge
Functions
Section titled “Functions”addCharge()
Section titled “addCharge()”addCharge(
player,activeSlot?,numCharges?,playSoundEffect?):int
Defined in: packages/isaacscript-common/src/functions/charge.ts:36
Helper function to add a charge to the player’s active item. Will flash the HUD and play the appropriate sound effect, depending on whether the charge is partially full or completely full.
If the player’s active item is already fully charged, then this function will return 0 and not flash the HUD or play a sound effect.
This function will take the following things into account:
- The Battery
- AAA Battery
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
The player to grant the charges to.
activeSlot?
Section titled “activeSlot?”ActiveSlot = ActiveSlot.PRIMARY
Optional. The slot to grant the charges to. Default is ActiveSlot.PRIMARY.
numCharges?
Section titled “numCharges?”number = 1
Optional. The amount of charges to grant. Default is 1.
playSoundEffect?
Section titled “playSoundEffect?”boolean = true
Optional. Whether to play a charge-related sound effect. Default is true.
Returns
Section titled “Returns”int
The amount of charges that were actually granted. For example, if the active item was
only one away from a full charge, but the numCharges provided to this function was 2,
then this function would return 1.
addRoomClearCharge()
Section titled “addRoomClearCharge()”addRoomClearCharge(
player,bigRoomDoubleCharge?,playSoundEffect?):void
Defined in: packages/isaacscript-common/src/functions/charge.ts:89
Helper function to add a charge to a player’s active item(s), emulating what happens when a room is cleared.
This function will take the following things into account:
- 2x2 rooms and L rooms granting a double charge
- The Battery
- AAA Battery
- Not charging active items with
chargetype="special"
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
The player to grant the charges to.
bigRoomDoubleCharge?
Section titled “bigRoomDoubleCharge?”boolean = true
Optional. If set to false, it will treat the current room as a 1x1 room for the purposes of calculating how much charge to grant. Default is true.
playSoundEffect?
Section titled “playSoundEffect?”boolean = true
Optional. Whether to play a charge-related sound effect. Default is true.
Returns
Section titled “Returns”void
addRoomClearCharges()
Section titled “addRoomClearCharges()”addRoomClearCharges(
bigRoomDoubleCharge?):void
Defined in: packages/isaacscript-common/src/functions/charge.ts:121
Helper function to add a charge to every player’s active item, emulating what happens when a room is cleared.
This function will take the following things into account:
- L rooms and 2x2 rooms granting a double charge
- The Battery
- AAA Battery
Parameters
Section titled “Parameters”bigRoomDoubleCharge?
Section titled “bigRoomDoubleCharge?”boolean = true
Optional. If set to false, it will treat the current room as a 1x1 room for the purposes of calculating how much charge to grant. Default is true.
Returns
Section titled “Returns”void
addRoomClearChargeToSlot()
Section titled “addRoomClearChargeToSlot()”addRoomClearChargeToSlot(
player,activeSlot?,bigRoomDoubleCharge?,playSoundEffect?):void
Defined in: packages/isaacscript-common/src/functions/charge.ts:145
Helper function to add a charge to one of a player’s active items, emulating what happens when a room is cleared.
This function will take the following things into account:
- L rooms and 2x2 rooms granting a double charge
- The Battery
- AAA Battery
- Not charging active items with
chargetype="special"
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
The player to grant the charges to.
activeSlot?
Section titled “activeSlot?”ActiveSlot = ActiveSlot.PRIMARY
Optional. The active item slot to grant the charges to. Default is
ActiveSlot.PRIMARY.
bigRoomDoubleCharge?
Section titled “bigRoomDoubleCharge?”boolean = true
Optional. If set to false, it will treat the current room as a 1x1 room for the purposes of calculating how much charge to grant. Default is true.
playSoundEffect?
Section titled “playSoundEffect?”boolean = true
Optional. Whether to play a charge-related sound effect. Default is true.
Returns
Section titled “Returns”void
getChargesAwayFromMax()
Section titled “getChargesAwayFromMax()”getChargesAwayFromMax(
player,activeSlot?):int
Defined in: packages/isaacscript-common/src/functions/charge.ts:191
Helper function to get the amount of charges away from the maximum charge that a particular player is.
This function accounts for The Battery. For example, if the player has 2/6 charges on a D6, this function will return 10 (because there are 4 charges remaining on the base charge and 6 charges remaining on The Battery charge).
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
The player to get the charges from.
activeSlot?
Section titled “activeSlot?”ActiveSlot = ActiveSlot.PRIMARY
Optional. The slot to get the charges from. Default is ActiveSlot.PRIMARY.
Returns
Section titled “Returns”int
getTotalCharge()
Section titled “getTotalCharge()”getTotalCharge(
player,activeSlot?):int
Defined in: packages/isaacscript-common/src/functions/charge.ts:212
Helper function to get the combined normal charge and the battery charge for the player’s active item. This is useful because you have to add these two values together when setting the active charge.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
The player to get the charges from.
activeSlot?
Section titled “activeSlot?”ActiveSlot = ActiveSlot.PRIMARY
Optional. The slot to get the charges from. Default is ActiveSlot.PRIMARY.
Returns
Section titled “Returns”int
getUsableActiveItemSlots()
Section titled “getUsableActiveItemSlots()”getUsableActiveItemSlots(
player,collectibleType): readonlyActiveSlot[]
Defined in: packages/isaacscript-common/src/functions/charge.ts:227
Helper function to find the active slots that the player has the corresponding collectible type in and have enough charge to be used. Returns an empty array if the player does not have the collectible in any active slot or does not have enough charges.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
collectibleType
Section titled “collectibleType”CollectibleType
Returns
Section titled “Returns”readonly ActiveSlot[]
isActiveSlotDoubleCharged()
Section titled “isActiveSlotDoubleCharged()”isActiveSlotDoubleCharged(
player,activeSlot?):boolean
Defined in: packages/isaacscript-common/src/functions/charge.ts:246
Helper function to check if a player’s active item is “double charged”, meaning that it has both a full normal charge and a full charge from The Battery.
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
The player to check.
activeSlot?
Section titled “activeSlot?”ActiveSlot = ActiveSlot.PRIMARY
Optional. The slot to check. Default is ActiveSlot.PRIMARY.
Returns
Section titled “Returns”boolean
playChargeSoundEffect()
Section titled “playChargeSoundEffect()”playChargeSoundEffect(
player,activeSlot?):void
Defined in: packages/isaacscript-common/src/functions/charge.ts:265
Helper function to play the appropriate sound effect for a player after getting one or more charges on their active item. (There is a different sound depending on whether the item is fully charged.)
Parameters
Section titled “Parameters”player
Section titled “player”EntityPlayer
The player to play the sound effect for.
activeSlot?
Section titled “activeSlot?”ActiveSlot = ActiveSlot.PRIMARY
Optional. The slot that was just charged. Default is ActiveSlot.PRIMARY.
Returns
Section titled “Returns”void
