isaacscript-common 1.0.340 → 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
@@ -27,5 +27,6 @@ export declare function getNPCs(): EntityNPC[];
27
27
  * in secret rooms and I AM ERROR rooms if the "Corrupted Data" achievement is unlocked.
28
28
  */
29
29
  export declare function isGlitchedCollectible(entity: Entity): boolean;
30
- export declare function removeAllEntities(entities: Entity[]): void;
30
+ /** Removes all of the entities in the supplied array. */
31
+ export declare function removeEntities(entities: Entity[]): void;
31
32
  export declare function removeAllMatchingEntities(entityType: int, entityVariant?: number, entitySubType?: number): void;
@@ -47,7 +47,7 @@ end
47
47
  function ____exports.isGlitchedCollectible(self, entity)
48
48
  return ((entity.Type == EntityType.ENTITY_PICKUP) and (entity.Variant == PickupVariant.PICKUP_COLLECTIBLE)) and (entity.SubType > GLITCHED_ITEM_THRESHOLD)
49
49
  end
50
- function ____exports.removeAllEntities(self, entities)
50
+ function ____exports.removeEntities(self, entities)
51
51
  for ____, entity in ipairs(entities) do
52
52
  entity:Remove()
53
53
  end
@@ -60,6 +60,6 @@ function ____exports.removeAllMatchingEntities(self, entityType, entityVariant,
60
60
  entitySubType = -1
61
61
  end
62
62
  local entities = Isaac.FindByType(entityType, entityVariant, entitySubType)
63
- ____exports.removeAllEntities(nil, entities)
63
+ ____exports.removeEntities(nil, entities)
64
64
  end
65
65
  return ____exports
@@ -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.
@@ -163,5 +169,10 @@ export declare function isJacobOrEsau(player: EntityPlayer): boolean;
163
169
  export declare function isKeeper(player: EntityPlayer): boolean;
164
170
  export declare function isLost(player: EntityPlayer): boolean;
165
171
  export declare function removeDeadEyeMultiplier(player: EntityPlayer): void;
166
- /** This function was originally created by im_tem. */
172
+ /**
173
+ * If you want to stop the player from shooting without the blindfold costume, then simply call
174
+ * `player.TryRemoveNullCostume(NullItemID.ID_BLINDFOLD)` after invoking this function.
175
+ *
176
+ * This function was originally created by im_tem.
177
+ */
167
178
  export declare function setBlindfold(player: EntityPlayer, enabled: boolean): void;
@@ -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 __continue38
26
+ goto __continue46
22
27
  end
23
28
  if ____exports.isChildPlayer(nil, player) then
24
- goto __continue38
29
+ goto __continue46
25
30
  end
26
31
  local character = player:GetPlayerType()
27
32
  if performExclusions and EXCLUDED_CHARACTERS:has(character) then
28
- goto __continue38
33
+ goto __continue46
29
34
  end
30
35
  __TS__ArrayPush(players, player)
31
36
  end
32
- ::__continue38::
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
@@ -159,16 +205,10 @@ function ____exports.getPlayerCollectibleMap(self, player)
159
205
  for ____, collectibleType in __TS__Iterator(
160
206
  collectibleSet:values()
161
207
  ) do
162
- do
163
- if not player:HasCollectible(collectibleType) then
164
- goto __continue31
165
- end
166
- local collectibleNum = player:GetCollectibleNum(collectibleType)
167
- if collectibleNum > 0 then
168
- collectibleMap:set(collectibleType, collectibleNum)
169
- end
208
+ local collectibleNum = player:GetCollectibleNum(collectibleType, true)
209
+ if collectibleNum > 0 then
210
+ collectibleMap:set(collectibleType, collectibleNum)
170
211
  end
171
- ::__continue31::
172
212
  end
173
213
  return collectibleMap
174
214
  end
@@ -204,14 +244,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
204
244
  do
205
245
  local player = Isaac.GetPlayer(i)
206
246
  if player == nil then
207
- goto __continue47
247
+ goto __continue55
208
248
  end
209
249
  local playerHash = GetPtrHash(player)
210
250
  if playerHash == playerToFindHash then
211
251
  return i
212
252
  end
213
253
  end
214
- ::__continue47::
254
+ ::__continue55::
215
255
  i = i + 1
216
256
  end
217
257
  end
@@ -45,11 +45,11 @@ export declare function getRoomName(): string;
45
45
  /**
46
46
  * Helper function to get the stage ID for the room from the XML/STB data. The room stage ID will
47
47
  * correspond to the first number in the filename of the XML/STB file. For example, a Depths room
48
- * would have a stage ID of 7. (Use the `StageID` enum for comparison.)
48
+ * would have a stage ID of 7.
49
49
  *
50
50
  * @returns The room stage ID. Returns -1 if the stage ID was not found.
51
51
  */
52
- export declare function getRoomStageID(): int;
52
+ export declare function getRoomStageID(): StageID;
53
53
  /**
54
54
  * Helper function to get the subtype for the room from the XML/STB data. The room subtype will
55
55
  * correspond to different things depending on what XML/STB file it draws from. For example, in the
@@ -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.340",
3
+ "version": "1.0.344",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,8 +25,8 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "devDependencies": {
28
- "isaac-typescript-definitions": "^1.0.208",
29
- "isaacscript-lint": "^1.0.61",
28
+ "isaac-typescript-definitions": "^1.0.212",
29
+ "isaacscript-lint": "^1.0.63",
30
30
  "typedoc": "^0.22.5",
31
31
  "typescript": "4.4.3",
32
32
  "typescript-to-lua": "^1.0.1"