isaacscript-common 1.0.343 → 1.0.344

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.
@@ -45,6 +45,12 @@ function getCurrentHealthValue(self, player, healthType)
45
45
  return player:GetHearts()
46
46
  end
47
47
  end
48
+ ____cond10 = ____cond10 or (____switch10 == HealthType.ROTTEN)
49
+ if ____cond10 then
50
+ do
51
+ return player:GetRottenHearts()
52
+ end
53
+ end
48
54
  ____cond10 = ____cond10 or (____switch10 == HealthType.SOUL)
49
55
  if ____cond10 then
50
56
  do
@@ -1,4 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ import HealthType from "../types/HealthType";
2
3
  import PocketItemDescription from "../types/PocketItemDescription";
3
4
  /**
4
5
  * PlayerIndex is a specific type of string; see the documentation for the [[`getPlayerIndex`]]
@@ -24,6 +25,11 @@ export declare function getClosestPlayer(position: Vector): EntityPlayer;
24
25
  * The Lost and Tainted Lost use a 38 frame death animation (i.e. the "LostDeath" animation).
25
26
  */
26
27
  export declare function getDeathAnimationName(player: EntityPlayer): string;
28
+ /**
29
+ * Helper function that returns the type of the rightmost heart, not including golden hearts since
30
+ * they can't be damaged directly.
31
+ */
32
+ export declare function getLastHeart(player: EntityPlayer): HealthType;
27
33
  /**
28
34
  * Helper function to get the first player with the lowest frame count of 0. Useful to find a
29
35
  * freshly spawned player after using items like Esau Jr.
@@ -1,8 +1,13 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
+ local ____HealthType = require("types.HealthType")
5
+ local HealthType = ____HealthType.default
4
6
  local ____PocketItemType = require("types.PocketItemType")
5
7
  local PocketItemType = ____PocketItemType.default
8
+ local ____bitwise = require("functions.bitwise")
9
+ local getKBitOfN = ____bitwise.getKBitOfN
10
+ local getNumBitsOfN = ____bitwise.getNumBitsOfN
6
11
  local ____collectibles = require("functions.collectibles")
7
12
  local getCollectibleSet = ____collectibles.getCollectibleSet
8
13
  local EXCLUDED_CHARACTERS
@@ -18,18 +23,18 @@ function ____exports.getPlayers(self, performExclusions)
18
23
  do
19
24
  local player = Isaac.GetPlayer(i)
20
25
  if player == nil then
21
- goto __continue37
26
+ goto __continue46
22
27
  end
23
28
  if ____exports.isChildPlayer(nil, player) then
24
- goto __continue37
29
+ goto __continue46
25
30
  end
26
31
  local character = player:GetPlayerType()
27
32
  if performExclusions and EXCLUDED_CHARACTERS:has(character) then
28
- goto __continue37
33
+ goto __continue46
29
34
  end
30
35
  __TS__ArrayPush(players, player)
31
36
  end
32
- ::__continue37::
37
+ ::__continue46::
33
38
  i = i + 1
34
39
  end
35
40
  end
@@ -109,6 +114,47 @@ function ____exports.getDeathAnimationName(self, player)
109
114
  local isLostTypeCharacter = (((character == PlayerType.PLAYER_THELOST) or (character == PlayerType.PLAYER_THELOST_B)) or (character == PlayerType.PLAYER_THESOUL)) or (character == PlayerType.PLAYER_THESOUL_B)
110
115
  return (isLostTypeCharacter and "LostDeath") or "Death"
111
116
  end
117
+ function ____exports.getLastHeart(self, player)
118
+ local hearts = player:GetHearts()
119
+ local effectiveMaxHearts = player:GetEffectiveMaxHearts()
120
+ local soulHearts = player:GetSoulHearts()
121
+ local blackHearts = player:GetBlackHearts()
122
+ local eternalHearts = player:GetEternalHearts()
123
+ local boneHearts = player:GetBoneHearts()
124
+ local rottenHearts = player:GetRottenHearts()
125
+ local soulHeartSlots = soulHearts / 2
126
+ local lastHeartIndex = (boneHearts + soulHeartSlots) - 1
127
+ local isLastHeartBone = player:IsBoneHeart(lastHeartIndex)
128
+ if isLastHeartBone then
129
+ local isLastContainerEmpty = hearts <= (effectiveMaxHearts - 2)
130
+ if isLastContainerEmpty then
131
+ return HealthType.BONE
132
+ end
133
+ if rottenHearts > 0 then
134
+ return HealthType.ROTTEN
135
+ end
136
+ if eternalHearts > 0 then
137
+ return HealthType.ETERNAL
138
+ end
139
+ return HealthType.RED
140
+ end
141
+ local numBits = getNumBitsOfN(nil, blackHearts)
142
+ local finalBit = getKBitOfN(nil, numBits - 1, blackHearts)
143
+ local isBlack = finalBit == 1
144
+ if soulHearts > 0 then
145
+ if isBlack then
146
+ return HealthType.BLACK
147
+ end
148
+ return HealthType.SOUL
149
+ end
150
+ if eternalHearts > 0 then
151
+ return HealthType.ETERNAL
152
+ end
153
+ if rottenHearts > 0 then
154
+ return HealthType.ROTTEN
155
+ end
156
+ return HealthType.RED
157
+ end
112
158
  function ____exports.getNewestPlayer(self)
113
159
  local newestPlayer = nil
114
160
  local lowestFrame = math.huge
@@ -198,14 +244,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
198
244
  do
199
245
  local player = Isaac.GetPlayer(i)
200
246
  if player == nil then
201
- goto __continue46
247
+ goto __continue55
202
248
  end
203
249
  local playerHash = GetPtrHash(player)
204
250
  if playerHash == playerToFindHash then
205
251
  return i
206
252
  end
207
253
  end
208
- ::__continue46::
254
+ ::__continue55::
209
255
  i = i + 1
210
256
  end
211
257
  end
@@ -1,10 +1,11 @@
1
1
  declare enum HealthType {
2
2
  RED = 0,
3
3
  SOUL = 1,
4
- BLACK = 2,
5
- BONE = 3,
4
+ ETERNAL = 2,
5
+ BLACK = 3,
6
6
  GOLDEN = 4,
7
- ETERNAL = 5,
8
- MAX_HEARTS = 6
7
+ BONE = 5,
8
+ ROTTEN = 6,
9
+ MAX_HEARTS = 7
9
10
  }
10
11
  export default HealthType;
@@ -5,15 +5,17 @@ HealthType.RED = 0
5
5
  HealthType[HealthType.RED] = "RED"
6
6
  HealthType.SOUL = 1
7
7
  HealthType[HealthType.SOUL] = "SOUL"
8
- HealthType.BLACK = 2
8
+ HealthType.ETERNAL = 2
9
+ HealthType[HealthType.ETERNAL] = "ETERNAL"
10
+ HealthType.BLACK = 3
9
11
  HealthType[HealthType.BLACK] = "BLACK"
10
- HealthType.BONE = 3
11
- HealthType[HealthType.BONE] = "BONE"
12
12
  HealthType.GOLDEN = 4
13
13
  HealthType[HealthType.GOLDEN] = "GOLDEN"
14
- HealthType.ETERNAL = 5
15
- HealthType[HealthType.ETERNAL] = "ETERNAL"
16
- HealthType.MAX_HEARTS = 6
14
+ HealthType.BONE = 5
15
+ HealthType[HealthType.BONE] = "BONE"
16
+ HealthType.ROTTEN = 6
17
+ HealthType[HealthType.ROTTEN] = "ROTTEN"
18
+ HealthType.MAX_HEARTS = 7
17
19
  HealthType[HealthType.MAX_HEARTS] = "MAX_HEARTS"
18
20
  ____exports.default = HealthType
19
21
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.343",
3
+ "version": "1.0.344",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",