isaacscript-common 1.2.94 → 1.2.95

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.
@@ -6,6 +6,8 @@ local ____exports = {}
6
6
  local hasSubscriptions, postPEffectUpdateReordered, getCurrentHealthValue, v
7
7
  local ____exports = require("features.saveDataManager.exports")
8
8
  local saveDataManager = ____exports.saveDataManager
9
+ local ____math = require("functions.math")
10
+ local countSetBits = ____math.countSetBits
9
11
  local ____player = require("functions.player")
10
12
  local getPlayerIndex = ____player.getPlayerIndex
11
13
  local ____utils = require("functions.utils")
@@ -63,7 +65,8 @@ function getCurrentHealthValue(self, player, healthType)
63
65
  ____cond11 = ____cond11 or ____switch11 == HealthType.BLACK
64
66
  if ____cond11 then
65
67
  do
66
- return player:GetBlackHearts()
68
+ local blackHearts = player:GetBlackHearts()
69
+ return countSetBits(nil, blackHearts)
67
70
  end
68
71
  end
69
72
  ____cond11 = ____cond11 or ____switch11 == HealthType.GOLDEN
@@ -48,6 +48,14 @@ export declare function getAllPlayers(): EntityPlayer[];
48
48
  * The formula for calculating it is: 32 - 2.5 * player.TearHeight
49
49
  */
50
50
  export declare function getAzazelBrimstoneDistance(playerOrTearHeight: EntityPlayer | float): number;
51
+ /**
52
+ * Returns the number of black hearts that the player has, excluding any soul hearts. For example,
53
+ * if the player has one full black heart, one full soul heart, and one half black heart, this
54
+ * function returns 3.
55
+ *
56
+ * This is different from the `EntityPlayer.GetBlackHearts` method, since that returns a bitmask.
57
+ */
58
+ export declare function getBlackHearts(player: EntityPlayer): int;
51
59
  /**
52
60
  * Returns the maximum heart containers that the provided character can have. Normally, this is 12,
53
61
  * but with Keeper it is 3, with Tainted Keeper it is 2. Does not account for Birthright or Mother's
@@ -176,6 +184,15 @@ export declare function getPlayers(performCharacterExclusions?: boolean): Entity
176
184
  * for. Returns true if any of the characters supplied are present.
177
185
  */
178
186
  export declare function getPlayersOfType(...characters: Array<PlayerType | int>): EntityPlayer[];
187
+ /**
188
+ * Returns the number of soul hearts that the player has, excluding any black hearts. For example,
189
+ * if the player has one full black heart, one full soul heart, and one half black heart, this
190
+ * function returns 2.
191
+ *
192
+ * This is different from the `EntityPlayer.GetSoulHearts` method, since that returns the combined
193
+ * number of soul hearts and black hearts.
194
+ */
195
+ export declare function getSoulHearts(player: EntityPlayer): int;
179
196
  /**
180
197
  * Helper function to get a parent `EntityPlayer` object for a given `EntitySubPlayer` object. This
181
198
  * is useful because calling the `EntityPlayer.GetSubPlayer` method on a sub-player object will
@@ -31,6 +31,8 @@ local ____collectibles = require("functions.collectibles")
31
31
  local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
32
32
  local ____collectibleSet = require("functions.collectibleSet")
33
33
  local getCollectibleSet = ____collectibleSet.getCollectibleSet
34
+ local ____math = require("functions.math")
35
+ local countSetBits = ____math.countSetBits
34
36
  local ____string = require("functions.string")
35
37
  local stringContains = ____string.stringContains
36
38
  local trimPrefix = ____string.trimPrefix
@@ -90,15 +92,15 @@ end
90
92
  function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSoul)
91
93
  local character = player:GetPlayerType()
92
94
  repeat
93
- local ____switch64 = character
94
- local ____cond64 = ____switch64 == PlayerType.PLAYER_THESOUL
95
- if ____cond64 then
95
+ local ____switch65 = character
96
+ local ____cond65 = ____switch65 == PlayerType.PLAYER_THESOUL
97
+ if ____cond65 then
96
98
  do
97
99
  return differentiateForgottenAndSoul and CollectibleType.COLLECTIBLE_SPOON_BENDER or DEFAULT_COLLECTIBLE_TYPE
98
100
  end
99
101
  end
100
- ____cond64 = ____cond64 or ____switch64 == PlayerType.PLAYER_LAZARUS2_B
101
- if ____cond64 then
102
+ ____cond65 = ____cond65 or ____switch65 == PlayerType.PLAYER_LAZARUS2_B
103
+ if ____cond65 then
102
104
  do
103
105
  return CollectibleType.COLLECTIBLE_INNER_EYE
104
106
  end
@@ -126,39 +128,39 @@ end
126
128
  function getAdjustedPlayerName(self, player)
127
129
  local character = player:GetPlayerType()
128
130
  repeat
129
- local ____switch77 = character
130
- local ____cond77 = ____switch77 == PlayerType.PLAYER_BLUEBABY or ____switch77 == PlayerType.PLAYER_BLUEBABY_B
131
- if ____cond77 then
131
+ local ____switch78 = character
132
+ local ____cond78 = ____switch78 == PlayerType.PLAYER_BLUEBABY or ____switch78 == PlayerType.PLAYER_BLUEBABY_B
133
+ if ____cond78 then
132
134
  do
133
135
  return "Blue Baby"
134
136
  end
135
137
  end
136
- ____cond77 = ____cond77 or ____switch77 == PlayerType.PLAYER_LAZARUS2
137
- if ____cond77 then
138
+ ____cond78 = ____cond78 or ____switch78 == PlayerType.PLAYER_LAZARUS2
139
+ if ____cond78 then
138
140
  do
139
141
  return "Lazarus II"
140
142
  end
141
143
  end
142
- ____cond77 = ____cond77 or ____switch77 == PlayerType.PLAYER_BLACKJUDAS
143
- if ____cond77 then
144
+ ____cond78 = ____cond78 or ____switch78 == PlayerType.PLAYER_BLACKJUDAS
145
+ if ____cond78 then
144
146
  do
145
147
  return "Dark Judas"
146
148
  end
147
149
  end
148
- ____cond77 = ____cond77 or ____switch77 == PlayerType.PLAYER_JACOB
149
- if ____cond77 then
150
+ ____cond78 = ____cond78 or ____switch78 == PlayerType.PLAYER_JACOB
151
+ if ____cond78 then
150
152
  do
151
153
  return "Jacob & Esau"
152
154
  end
153
155
  end
154
- ____cond77 = ____cond77 or ____switch77 == PlayerType.PLAYER_LAZARUS2_B
155
- if ____cond77 then
156
+ ____cond78 = ____cond78 or ____switch78 == PlayerType.PLAYER_LAZARUS2_B
157
+ if ____cond78 then
156
158
  do
157
159
  return "Dead Tainted Lazarus"
158
160
  end
159
161
  end
160
- ____cond77 = ____cond77 or ____switch77 == PlayerType.PLAYER_JACOB2_B
161
- if ____cond77 then
162
+ ____cond78 = ____cond78 or ____switch78 == PlayerType.PLAYER_JACOB2_B
163
+ if ____cond78 then
162
164
  do
163
165
  return "Dead Tainted Jacob"
164
166
  end
@@ -294,6 +296,10 @@ function ____exports.getAzazelBrimstoneDistance(self, playerOrTearHeight)
294
296
  end
295
297
  return 32 - 2.5 * tearHeight
296
298
  end
299
+ function ____exports.getBlackHearts(self, player)
300
+ local blackHearts = player:GetBlackHearts()
301
+ return countSetBits(nil, blackHearts)
302
+ end
297
303
  function ____exports.getClosestPlayer(self, position)
298
304
  local closestPlayer = nil
299
305
  local closestDistance = math.huge
@@ -475,6 +481,11 @@ function ____exports.getPlayersOfType(self, ...)
475
481
  end
476
482
  )
477
483
  end
484
+ function ____exports.getSoulHearts(self, player)
485
+ local soulHearts = player:GetSoulHearts()
486
+ local blackHearts = ____exports.getBlackHearts(nil, player)
487
+ return soulHearts - blackHearts
488
+ end
478
489
  function ____exports.getTotalCharge(self, player, activeSlot)
479
490
  local activeCharge = player:GetActiveCharge(activeSlot)
480
491
  local batteryCharge = player:GetBatteryCharge(activeSlot)
@@ -573,9 +584,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
573
584
  itemPool:RemoveCollectible(collectibleType)
574
585
  end
575
586
  repeat
576
- local ____switch122 = activeSlot
577
- local ____cond122 = ____switch122 == ActiveSlot.SLOT_PRIMARY
578
- if ____cond122 then
587
+ local ____switch124 = activeSlot
588
+ local ____cond124 = ____switch124 == ActiveSlot.SLOT_PRIMARY
589
+ if ____cond124 then
579
590
  do
580
591
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
581
592
  player:RemoveCollectible(primaryCollectibleType)
@@ -584,8 +595,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
584
595
  break
585
596
  end
586
597
  end
587
- ____cond122 = ____cond122 or ____switch122 == ActiveSlot.SLOT_SECONDARY
588
- if ____cond122 then
598
+ ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_SECONDARY
599
+ if ____cond124 then
589
600
  do
590
601
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
591
602
  player:RemoveCollectible(primaryCollectibleType)
@@ -600,16 +611,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
600
611
  break
601
612
  end
602
613
  end
603
- ____cond122 = ____cond122 or ____switch122 == ActiveSlot.SLOT_POCKET
604
- if ____cond122 then
614
+ ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_POCKET
615
+ if ____cond124 then
605
616
  do
606
617
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
607
618
  player:SetActiveCharge(charge, activeSlot)
608
619
  break
609
620
  end
610
621
  end
611
- ____cond122 = ____cond122 or ____switch122 == ActiveSlot.SLOT_POCKET2
612
- if ____cond122 then
622
+ ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_POCKET2
623
+ if ____cond124 then
613
624
  do
614
625
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
615
626
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.94",
3
+ "version": "1.2.95",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",