isaacscript-common 3.15.6 → 3.17.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.
package/constants.d.ts CHANGED
@@ -14,6 +14,8 @@ export declare const AZAZEL_DEFAULT_BRIMSTONE_DISTANCE = 75.125;
14
14
  export declare const BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png";
15
15
  /** Bombs explode when their frame count is equal to this value. */
16
16
  export declare const BOMB_EXPLODE_FRAME = 45;
17
+ /** This is the initial value of the `EntityPickup.Wait` property after a collectible is spawned. */
18
+ export declare const COLLECTIBLE_INITIAL_WAIT = 20;
17
19
  export declare const DEFAULT_ITEM_POOL_TYPE = ItemPoolType.TREASURE;
18
20
  /** This is also the distance that a player spawns from the door that they enter a room from. */
19
21
  export declare const DISTANCE_OF_GRID_TILE = 40;
package/constants.lua CHANGED
@@ -18,6 +18,8 @@ ____exports.AZAZEL_DEFAULT_BRIMSTONE_DISTANCE = 75.125
18
18
  ____exports.BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png"
19
19
  --- Bombs explode when their frame count is equal to this value.
20
20
  ____exports.BOMB_EXPLODE_FRAME = 45
21
+ --- This is the initial value of the `EntityPickup.Wait` property after a collectible is spawned.
22
+ ____exports.COLLECTIBLE_INITIAL_WAIT = 20
21
23
  ____exports.DEFAULT_ITEM_POOL_TYPE = ItemPoolType.TREASURE
22
24
  --- This is also the distance that a player spawns from the door that they enter a room from.
23
25
  ____exports.DISTANCE_OF_GRID_TILE = 40
@@ -12,6 +12,8 @@ export declare function addPlayerHealthType(player: EntityPlayer, healthType: He
12
12
  */
13
13
  export declare function getPlayerHealth(player: EntityPlayer): PlayerHealth;
14
14
  export declare function getPlayerHealthType(player: EntityPlayer, healthType: HealthType): int;
15
+ /** Returns a `PlayerHealth` object with all 0s. */
16
+ export declare function newPlayerHealth(): PlayerHealth;
15
17
  export declare function playerConvertBlackHeartsToSoulHearts(player: EntityPlayer): void;
16
18
  export declare function playerConvertSoulHeartsToBlackHearts(player: EntityPlayer): void;
17
19
  export declare function removeAllPlayerHealth(player: EntityPlayer): void;
@@ -3,17 +3,24 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
3
3
  local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
4
4
  local ____exports = {}
5
5
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
+ local ActiveSlot = ____isaac_2Dtypescript_2Ddefinitions.ActiveSlot
7
+ local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
6
8
  local HeartSubType = ____isaac_2Dtypescript_2Ddefinitions.HeartSubType
7
9
  local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
8
10
  local ____constants = require("constants")
9
11
  local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
10
12
  local ____HealthType = require("enums.HealthType")
11
13
  local HealthType = ____HealthType.HealthType
14
+ local ____charge = require("functions.charge")
15
+ local getTotalCharge = ____charge.getTotalCharge
16
+ local ____enums = require("functions.enums")
17
+ local getEnumValues = ____enums.getEnumValues
12
18
  local ____player = require("functions.player")
13
19
  local getPlayerBlackHearts = ____player.getPlayerBlackHearts
14
20
  local getPlayerHearts = ____player.getPlayerHearts
15
21
  local getPlayerSoulHearts = ____player.getPlayerSoulHearts
16
22
  local isCharacter = ____player.isCharacter
23
+ local setActiveItem = ____player.setActiveItem
17
24
  local ____utils = require("functions.utils")
18
25
  local ensureAllCases = ____utils.ensureAllCases
19
26
  local ____repeat = ____utils["repeat"]
@@ -45,6 +52,17 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
45
52
  local character = player:GetPlayerType()
46
53
  local subPlayer = player:GetSubPlayer()
47
54
  ____exports.removeAllPlayerHealth(nil, player)
55
+ local alabasterBoxes = {}
56
+ if player:HasCollectible(CollectibleType.ALABASTER_BOX) then
57
+ for ____, activeSlot in ipairs(getEnumValues(nil, ActiveSlot)) do
58
+ local activeItem = player:GetActiveItem()
59
+ if activeItem == CollectibleType.ALABASTER_BOX then
60
+ local totalCharge = getTotalCharge(nil, player, activeSlot)
61
+ setActiveItem(nil, player, CollectibleType.NULL, activeSlot)
62
+ alabasterBoxes[#alabasterBoxes + 1] = {activeSlot, totalCharge}
63
+ end
64
+ end
65
+ end
48
66
  if character == PlayerType.THE_SOUL and subPlayer ~= nil then
49
67
  subPlayer:AddMaxHearts(playerHealth.maxHearts, false)
50
68
  else
@@ -89,6 +107,17 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
89
107
  elseif character == PlayerType.BETHANY_B then
90
108
  player:SetBloodCharge(playerHealth.bloodCharges)
91
109
  end
110
+ for ____, ____value in ipairs(alabasterBoxes) do
111
+ local activeSlot = ____value[1]
112
+ local totalCharge = ____value[2]
113
+ setActiveItem(
114
+ nil,
115
+ player,
116
+ CollectibleType.ALABASTER_BOX,
117
+ activeSlot,
118
+ totalCharge
119
+ )
120
+ end
92
121
  end
93
122
  function ____exports.addPlayerHealthType(self, player, healthType, numHearts)
94
123
  repeat
@@ -294,6 +323,22 @@ function ____exports.getPlayerHealthType(self, player, healthType)
294
323
  end
295
324
  until true
296
325
  end
326
+ --- Returns a `PlayerHealth` object with all 0s.
327
+ function ____exports.newPlayerHealth(self)
328
+ return {
329
+ maxHearts = 0,
330
+ hearts = 0,
331
+ eternalHearts = 0,
332
+ soulHearts = 0,
333
+ boneHearts = 0,
334
+ goldenHearts = 0,
335
+ rottenHearts = 0,
336
+ brokenHearts = 0,
337
+ soulCharges = 0,
338
+ bloodCharges = 0,
339
+ soulHeartTypes = {}
340
+ }
341
+ end
297
342
  function ____exports.playerConvertBlackHeartsToSoulHearts(self, player)
298
343
  local playerHealth = ____exports.getPlayerHealth(nil, player)
299
344
  ____exports.removeAllPlayerHealth(nil, player)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "3.15.6",
3
+ "version": "3.17.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",