isaacscript-common 1.0.567 → 1.0.571

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.
@@ -12,6 +12,7 @@ export declare const BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.
12
12
  /** Bombs explode when their frame count is equal to this value. */
13
13
  export declare const BOMB_EXPLODE_FRAME = 45;
14
14
  export declare const CHARACTERS_WITH_AN_ACTIVE_ITEM: Set<PlayerType>;
15
+ export declare const CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART: Set<PlayerType>;
15
16
  /**
16
17
  * The set of characters where red heart containers will be turned into soul hearts (e.g. Blue
17
18
  * Baby). This includes The Lost and Tainted Lost. This does not include Keeper or Tainted Keeper.
@@ -60,8 +61,8 @@ export declare const FINAL_STAGE: number;
60
61
  * second TMTRAINER item subtracts one from that, and so on.
61
62
  */
62
63
  export declare const FIRST_GLITCHED_COLLECTIBLE_TYPE: number;
63
- export declare const GENESIS_ROOM_VARIANT = 1000;
64
- export declare const GENESIS_ROOM_SUBTYPE = 99;
64
+ export declare const GENESIS_ROOM_VARIANT = -1;
65
+ export declare const GENESIS_ROOM_SUBTYPE = -1;
65
66
  export declare const GOLDEN_TRINKET_SHIFT: number;
66
67
  export declare const GRID_INDEX_CENTER_OF_1X1_ROOM = 67;
67
68
  export declare const GAME_FRAMES_PER_SECOND = 30;
@@ -5,6 +5,7 @@ ____exports.AZAZEL_DEFAULT_BRIMSTONE_DISTANCE = 75.125
5
5
  ____exports.BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png"
6
6
  ____exports.BOMB_EXPLODE_FRAME = 45
7
7
  ____exports.CHARACTERS_WITH_AN_ACTIVE_ITEM = __TS__New(Set, {PlayerType.PLAYER_ISAAC, PlayerType.PLAYER_MAGDALENE, PlayerType.PLAYER_JUDAS, PlayerType.PLAYER_BLUEBABY, PlayerType.PLAYER_EVE, PlayerType.PLAYER_EDEN, PlayerType.PLAYER_THELOST, PlayerType.PLAYER_LILITH, PlayerType.PLAYER_KEEPER, PlayerType.PLAYER_APOLLYON, PlayerType.PLAYER_EDEN_B})
8
+ ____exports.CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART = __TS__New(Set, {PlayerType.PLAYER_BLACKJUDAS, PlayerType.PLAYER_JUDAS_B})
8
9
  ____exports.CHARACTERS_WITH_NO_RED_HEARTS = __TS__New(Set, {PlayerType.PLAYER_BLUEBABY, PlayerType.PLAYER_THELOST, PlayerType.PLAYER_BLACKJUDAS, PlayerType.PLAYER_JUDAS_B, PlayerType.PLAYER_BLUEBABY_B, PlayerType.PLAYER_THELOST_B, PlayerType.PLAYER_THEFORGOTTEN_B, PlayerType.PLAYER_BETHANY_B})
9
10
  ____exports.CHARACTERS_WITH_NO_SOUL_HEARTS = __TS__New(Set, {PlayerType.PLAYER_THELOST, PlayerType.PLAYER_KEEPER, PlayerType.PLAYER_BETHANY, PlayerType.PLAYER_THELOST_B, PlayerType.PLAYER_KEEPER_B})
10
11
  ____exports.COLORS = {
@@ -25,8 +26,8 @@ ____exports.EMPTY_PNG_PATH = "gfx/none.png"
25
26
  ____exports.FAMILIARS_THAT_SHOOT_PLAYER_TEARS = __TS__New(Set, {FamiliarVariant.SCISSORS, FamiliarVariant.INCUBUS, FamiliarVariant.FATES_REWARD, FamiliarVariant.SPRINKLER, FamiliarVariant.LOST_SOUL, FamiliarVariant.TWISTED_BABY, FamiliarVariant.BLOOD_BABY, FamiliarVariant.DECAP_ATTACK})
26
27
  ____exports.FINAL_STAGE = LevelStage.NUM_STAGES - 1
27
28
  ____exports.FIRST_GLITCHED_COLLECTIBLE_TYPE = (1 << 32) - 1
28
- ____exports.GENESIS_ROOM_VARIANT = 1000
29
- ____exports.GENESIS_ROOM_SUBTYPE = 99
29
+ ____exports.GENESIS_ROOM_VARIANT = -1
30
+ ____exports.GENESIS_ROOM_SUBTYPE = -1
30
31
  ____exports.GOLDEN_TRINKET_SHIFT = 1 << 15
31
32
  ____exports.GRID_INDEX_CENTER_OF_1X1_ROOM = 67
32
33
  ____exports.GAME_FRAMES_PER_SECOND = 30
@@ -1,4 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ import { AnyEntity } from "../types/AnyEntity";
2
3
  export declare function anyEntityCloserThan(entities: Entity[], position: Vector, distance: int): boolean;
3
4
  /**
4
5
  * Helper function to get all of the bombs in the room.
@@ -24,6 +25,11 @@ export declare function getBombs(matchingVariant?: number, matchingSubType?: num
24
25
  * ```
25
26
  */
26
27
  export declare function getClosestEntityTo(referenceEntity: Entity, entities: Entity[]): Entity;
28
+ /**
29
+ * Helper function to compare two different arrays of entities. Returns the entities that are in the
30
+ * second array but not in the first array.
31
+ */
32
+ export declare function getFilteredNewEntities<T extends AnyEntity>(oldEntities: T[], newEntities: T[]): T[];
27
33
  /**
28
34
  * Helper function to get all of the effects in the room.
29
35
  *
@@ -251,6 +257,15 @@ export declare function removeAllProjectiles(variant?: ProjectileVariant | int,
251
257
  * @returns True if one or more tears was removed, false otherwise.
252
258
  */
253
259
  export declare function removeAllTears(variant?: TearVariant | int, subType?: int, cap?: int): boolean;
260
+ /**
261
+ * Game().RerollEnemy rerolls a boolean of whether or not the enemy was rerolled. However, you
262
+ * cannot use the same entity object after a reroll. This function calls game.RerollEnemy and
263
+ * returns the new entity object.
264
+ *
265
+ * @param entity The entity to reroll
266
+ * @returns If the entity was not rerolled, returns the original entity. otherwise, returns the resulting entity from the reroll
267
+ */
268
+ export declare function rerollEnemy(entity: Entity): Entity;
254
269
  /**
255
270
  * Helper function to set the position of every entity in the room based on a map of positions. If
256
271
  * an entity is found that does not have matching element in the provided map, then that entity will
@@ -44,6 +44,20 @@ function ____exports.getClosestEntityTo(self, referenceEntity, entities)
44
44
  end
45
45
  return closestEntity
46
46
  end
47
+ function ____exports.getFilteredNewEntities(self, oldEntities, newEntities)
48
+ local oldEntitiesSet = __TS__New(Set)
49
+ for ____, entity in ipairs(oldEntities) do
50
+ local ptrHash = GetPtrHash(entity)
51
+ oldEntitiesSet:add(ptrHash)
52
+ end
53
+ return __TS__ArrayFilter(
54
+ newEntities,
55
+ function(____, entity)
56
+ local ptrHash = GetPtrHash(entity)
57
+ return not oldEntitiesSet:has(ptrHash)
58
+ end
59
+ )
60
+ end
47
61
  function ____exports.getEffects(self, matchingVariant, matchingSubType)
48
62
  if matchingVariant == nil then
49
63
  matchingVariant = -1
@@ -280,6 +294,20 @@ function ____exports.removeAllTears(self, variant, subType, cap)
280
294
  local tears = ____exports.getTears(nil, variant, subType)
281
295
  return ____exports.removeEntities(nil, tears, cap)
282
296
  end
297
+ function ____exports.rerollEnemy(self, entity)
298
+ local game = Game()
299
+ local oldEntities = ____exports.getEntities(nil)
300
+ local wasRerolled = game:RerollEnemy(entity)
301
+ if not wasRerolled then
302
+ return entity
303
+ end
304
+ local newEntities = ____exports.getEntities(nil)
305
+ local filteredNewEntities = ____exports.getFilteredNewEntities(nil, oldEntities, newEntities)
306
+ if #filteredNewEntities ~= 0 then
307
+ error("Failed to find the new entity generated by the \"RerollEnemy\" method.")
308
+ end
309
+ return filteredNewEntities[1]
310
+ end
283
311
  function ____exports.setEntityPositions(self, entityPositions, entities)
284
312
  if entities == nil then
285
313
  entities = ____exports.getEntities(nil)
@@ -39,6 +39,7 @@ export declare function logEntity(this: void, entity: Entity): void;
39
39
  export declare function logKColor(this: void, kColor: KColor): void;
40
40
  export declare function logMap(this: void, map: Map<AnyNotNil, unknown>): void;
41
41
  export declare function logTable(this: void, table: unknown): void;
42
+ export declare function logTemporaryEffects(this: void, player: EntityPlayer): void;
42
43
  export declare function logSet(this: void, set: Set<AnyNotNil>): void;
43
44
  export declare function logVector(this: void, vector: Vector): void;
44
45
  /**
@@ -3,8 +3,12 @@ require("lualib_bundle");
3
3
  local ____exports = {}
4
4
  local ____array = require("functions.array")
5
5
  local arrayToString = ____array.arrayToString
6
+ local ____collectibles = require("functions.collectibles")
7
+ local getCollectibleName = ____collectibles.getCollectibleName
6
8
  local ____flag = require("functions.flag")
7
9
  local hasFlag = ____flag.hasFlag
10
+ local ____trinkets = require("functions.trinkets")
11
+ local getTrinketName = ____trinkets.getTrinketName
8
12
  function ____exports.getDebugPrependString(self, msg, numParentFunctions)
9
13
  if numParentFunctions == nil then
10
14
  numParentFunctions = 3
@@ -166,6 +170,47 @@ function ____exports.logTable(____table)
166
170
  )
167
171
  end
168
172
  end
173
+ function ____exports.logTemporaryEffects(player)
174
+ local effects = player:GetEffects()
175
+ local effectsList = effects:GetEffectsList()
176
+ ____exports.log("Logging all player temporary effects:")
177
+ if effectsList.Size == 0 then
178
+ ____exports.log(" n/a (no temporary effects)")
179
+ return
180
+ end
181
+ do
182
+ local i = 0
183
+ while i < effectsList.Size do
184
+ do
185
+ local effect = effectsList:Get(i)
186
+ if effect == nil then
187
+ goto __continue35
188
+ end
189
+ if effect.Item:IsCollectible() then
190
+ local collectibleName = getCollectibleName(nil, effect.Item.ID)
191
+ ____exports.log(
192
+ ((" " .. tostring(i + 1)) .. ") ") .. collectibleName
193
+ )
194
+ elseif effect.Item:IsTrinket() then
195
+ local trinketName = getTrinketName(nil, effect.Item.ID)
196
+ ____exports.log(
197
+ ((" " .. tostring(i + 1)) .. ") ") .. trinketName
198
+ )
199
+ elseif effect.Item:IsNull() then
200
+ ____exports.log(
201
+ ((" " .. tostring(i + 1)) .. ") Null item: ") .. tostring(effect.Item.ID)
202
+ )
203
+ else
204
+ ____exports.log(
205
+ ((" " .. tostring(i + 1)) .. ") Unknown type of temporary effect: ") .. tostring(effect.Item.ID)
206
+ )
207
+ end
208
+ end
209
+ ::__continue35::
210
+ i = i + 1
211
+ end
212
+ end
213
+ end
169
214
  function ____exports.logSet(set)
170
215
  ____exports.log("Printing out a TSTL Set:")
171
216
  for ____, value in __TS__Iterator(
@@ -1,4 +1,18 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to make an NPC fire a projectile. Returns the fired projectile. Use this function
4
+ * instead of `EntityNPC.FireProjectiles()`, since that returns void.
5
+ *
6
+ * @param npc The NPC to fire the projectile from.
7
+ * @param position The staring position of the projectile.
8
+ * @param velocity The starting velocity of the projectile.
9
+ * @param projectilesMode The mode of the projectile. Optional. Equal to
10
+ * `ProjectilesMode.ONE_PROJECTILE` by default.
11
+ * @param projectileParams The parameters of the projectile. Optional. Equal to `ProjectileParams()`
12
+ * by default.
13
+ * @returns The fired projectile.
14
+ */
15
+ export declare function fireProjectiles(npc: EntityNPC, position: Vector, velocity: Vector, projectilesMode?: ProjectilesMode, projectileParams?: ProjectileParams): EntityProjectile[];
2
16
  /**
3
17
  * Helper function to get all of the non-dead bosses in the room.
4
18
  *
@@ -6,6 +6,8 @@ local ____constants = require("constants")
6
6
  local EGGY_STATE_FRAME_OF_FINAL_SPIDER = ____constants.EGGY_STATE_FRAME_OF_FINAL_SPIDER
7
7
  local ____entity = require("functions.entity")
8
8
  local getEntities = ____entity.getEntities
9
+ local getFilteredNewEntities = ____entity.getFilteredNewEntities
10
+ local getProjectiles = ____entity.getProjectiles
9
11
  local removeEntities = ____entity.removeEntities
10
12
  function ____exports.getBosses(self)
11
13
  local bosses = {}
@@ -75,6 +77,18 @@ NON_ALIVE_NPCS_TYPE_VARIANT_SUBTYPE = __TS__New(
75
77
  (((tostring(EntityType.ENTITY_CHARGER) .. ".") .. 0) .. ".") .. 1
76
78
  }
77
79
  )
80
+ function ____exports.fireProjectiles(self, npc, position, velocity, projectilesMode, projectileParams)
81
+ if projectilesMode == nil then
82
+ projectilesMode = 0
83
+ end
84
+ if projectileParams == nil then
85
+ projectileParams = ProjectileParams()
86
+ end
87
+ local oldProjectiles = getProjectiles(nil, projectileParams.Variant)
88
+ npc:FireProjectiles(position, velocity, projectilesMode, projectileParams)
89
+ local newProjectiles = getProjectiles(nil, projectileParams.Variant)
90
+ return getFilteredNewEntities(nil, oldProjectiles, newProjectiles)
91
+ end
78
92
  function ____exports.getAliveBosses(self)
79
93
  local aliveBosses = {}
80
94
  for ____, boss in ipairs(
@@ -39,6 +39,12 @@ export declare function characterCanHaveRedHearts(character: PlayerType): boolea
39
39
  * false for The Lost and Tainted Lost.
40
40
  */
41
41
  export declare function characterCanHaveSoulHearts(character: PlayerType): boolean;
42
+ /**
43
+ * Normally, characters get a red heart container upon reaching a new floor with an eternal heart,
44
+ * but some characters grant a black heart instead. Returns true for Dark Judas and Tainted Judas.
45
+ * Otherwise, returns false.
46
+ */
47
+ export declare function characterGetsBlackHeartFromEternalHeart(character: PlayerType): boolean;
42
48
  /**
43
49
  * Helper function to get how long Azazel's Brimstone laser should be. You can pass either an
44
50
  * `EntityPlayer` object or a tear height stat.
@@ -3,6 +3,7 @@ require("lualib_bundle");
3
3
  local ____exports = {}
4
4
  local EXCLUDED_CHARACTERS
5
5
  local ____constants = require("constants")
6
+ local CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART = ____constants.CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART
6
7
  local CHARACTERS_WITH_NO_RED_HEARTS = ____constants.CHARACTERS_WITH_NO_RED_HEARTS
7
8
  local CHARACTERS_WITH_NO_SOUL_HEARTS = ____constants.CHARACTERS_WITH_NO_SOUL_HEARTS
8
9
  local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
@@ -59,18 +60,18 @@ function ____exports.getPlayers(self, performExclusions)
59
60
  do
60
61
  local player = Isaac.GetPlayer(i)
61
62
  if player == nil then
62
- goto __continue66
63
+ goto __continue67
63
64
  end
64
65
  if ____exports.isChildPlayer(nil, player) then
65
- goto __continue66
66
+ goto __continue67
66
67
  end
67
68
  local character = player:GetPlayerType()
68
69
  if performExclusions and EXCLUDED_CHARACTERS:has(character) then
69
- goto __continue66
70
+ goto __continue67
70
71
  end
71
72
  __TS__ArrayPush(players, player)
72
73
  end
73
- ::__continue66::
74
+ ::__continue67::
74
75
  i = i + 1
75
76
  end
76
77
  end
@@ -145,6 +146,9 @@ end
145
146
  function ____exports.characterCanHaveSoulHearts(self, character)
146
147
  return not CHARACTERS_WITH_NO_SOUL_HEARTS:has(character)
147
148
  end
149
+ function ____exports.characterGetsBlackHeartFromEternalHeart(self, character)
150
+ return CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART:has(character)
151
+ end
148
152
  function ____exports.getAzazelBrimstoneDistance(self, playerOrTearHeight)
149
153
  local tearHeight = tonumber(playerOrTearHeight)
150
154
  if tearHeight == nil then
@@ -295,14 +299,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
295
299
  do
296
300
  local player = Isaac.GetPlayer(i)
297
301
  if player == nil then
298
- goto __continue58
302
+ goto __continue59
299
303
  end
300
304
  local playerHash = GetPtrHash(player)
301
305
  if playerHash == playerToFindHash then
302
306
  return i
303
307
  end
304
308
  end
305
- ::__continue58::
309
+ ::__continue59::
306
310
  i = i + 1
307
311
  end
308
312
  end
@@ -423,9 +427,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
423
427
  itemPool:RemoveCollectible(collectibleType)
424
428
  end
425
429
  repeat
426
- local ____switch96 = activeSlot
427
- local ____cond96 = ____switch96 == ActiveSlot.SLOT_PRIMARY
428
- if ____cond96 then
430
+ local ____switch97 = activeSlot
431
+ local ____cond97 = ____switch97 == ActiveSlot.SLOT_PRIMARY
432
+ if ____cond97 then
429
433
  do
430
434
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
431
435
  player:RemoveCollectible(primaryCollectibleType)
@@ -434,8 +438,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
434
438
  break
435
439
  end
436
440
  end
437
- ____cond96 = ____cond96 or (____switch96 == ActiveSlot.SLOT_SECONDARY)
438
- if ____cond96 then
441
+ ____cond97 = ____cond97 or (____switch97 == ActiveSlot.SLOT_SECONDARY)
442
+ if ____cond97 then
439
443
  do
440
444
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
441
445
  player:RemoveCollectible(primaryCollectibleType)
@@ -450,16 +454,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
450
454
  break
451
455
  end
452
456
  end
453
- ____cond96 = ____cond96 or (____switch96 == ActiveSlot.SLOT_POCKET)
454
- if ____cond96 then
457
+ ____cond97 = ____cond97 or (____switch97 == ActiveSlot.SLOT_POCKET)
458
+ if ____cond97 then
455
459
  do
456
460
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
457
461
  player:SetActiveCharge(charge, activeSlot)
458
462
  break
459
463
  end
460
464
  end
461
- ____cond96 = ____cond96 or (____switch96 == ActiveSlot.SLOT_POCKET2)
462
- if ____cond96 then
465
+ ____cond97 = ____cond97 or (____switch97 == ActiveSlot.SLOT_POCKET2)
466
+ if ____cond97 then
463
467
  do
464
468
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
465
469
  break
package/dist/index.d.ts CHANGED
@@ -61,6 +61,7 @@ export * from "./maps/transformationMaps";
61
61
  export * from "./maps/transformationNameMap";
62
62
  export * from "./maps/trinketNameMap";
63
63
  export * from "./sets/cards";
64
+ export * from "./types/AnyEntity";
64
65
  export * from "./types/CallbackParametersCustom";
65
66
  export * from "./types/HealthType";
66
67
  export * from "./types/JSONDoor";
@@ -0,0 +1,2 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export declare type AnyEntity = Entity | EntityBomb | EntityEffect | EntityFamiliar | EntityKnife | EntityLaser | EntityNPC | EntityPickup | EntityPlayer | EntityProjectile | EntityTear;
@@ -0,0 +1,3 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.567",
3
+ "version": "1.0.571",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,7 +25,7 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "devDependencies": {
28
- "isaac-typescript-definitions": "^1.0.313",
28
+ "isaac-typescript-definitions": "^1.0.315",
29
29
  "isaacscript-lint": "^1.0.74",
30
30
  "typedoc": "^0.22.10",
31
31
  "typescript": "4.4.4",