isaacscript-common 1.2.276 → 1.2.277

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.
@@ -44,8 +44,9 @@ export declare function isSin(npc: EntityNPC): boolean;
44
44
  * Use this function instead of `spawnNPC` since it handles automatically spawning multiple segments
45
45
  * for multi-segment bosses.
46
46
  *
47
- * By default, this will spawn Chub (and his variants) with 3 segments and other multi-segment
48
- * bosses with 4 segments. You can customize this via the "numSegments" argument.
47
+ * By default, this will spawn Chub (and his variants) with 3 segments, Lokii with 2 copies,
48
+ * Gurglings/Turdlings with 2 copies, and other multi-segment bosses with 4 segments. You can
49
+ * customize this via the "numSegments" argument.
49
50
  */
50
51
  export declare function spawnBoss<T extends number>(entityType: T extends EntityTypeNonNPC ? never : T, variant: int, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined, numSegments?: int): EntityNPC;
51
52
  /**
@@ -3,6 +3,7 @@ local Set = ____lualib.Set
3
3
  local __TS__New = ____lualib.__TS__New
4
4
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
5
5
  local ____exports = {}
6
+ local getNumBossSegments, DEFAULT_BOSS_MULTI_SEGMENTS
6
7
  local ____constants = require("constants")
7
8
  local VectorZero = ____constants.VectorZero
8
9
  local ____bossSets = require("sets.bossSets")
@@ -20,7 +21,45 @@ local ____set = require("functions.set")
20
21
  local copySet = ____set.copySet
21
22
  local ____utils = require("functions.utils")
22
23
  local ____repeat = ____utils["repeat"]
23
- local BOSSES_THAT_REQUIRE_MULTIPLE_SPAWNS = __TS__New(Set, {EntityType.ENTITY_LARRYJR, EntityType.ENTITY_CHUB, EntityType.ENTITY_TURDLET})
24
+ function getNumBossSegments(self, entityType, variant, numSegments)
25
+ if numSegments ~= nil then
26
+ return numSegments
27
+ end
28
+ repeat
29
+ local ____switch18 = entityType
30
+ local ____cond18 = ____switch18 == EntityType.ENTITY_CHUB
31
+ if ____cond18 then
32
+ do
33
+ return 3
34
+ end
35
+ end
36
+ ____cond18 = ____cond18 or ____switch18 == EntityType.ENTITY_LOKI
37
+ if ____cond18 then
38
+ do
39
+ return variant == 1 and 2 or 1
40
+ end
41
+ end
42
+ ____cond18 = ____cond18 or ____switch18 == EntityType.ENTITY_GURGLING
43
+ if ____cond18 then
44
+ do
45
+ return 2
46
+ end
47
+ end
48
+ do
49
+ do
50
+ return DEFAULT_BOSS_MULTI_SEGMENTS
51
+ end
52
+ end
53
+ until true
54
+ end
55
+ local BOSSES_THAT_REQUIRE_MULTIPLE_SPAWNS = __TS__New(Set, {
56
+ EntityType.ENTITY_LARRYJR,
57
+ EntityType.ENTITY_CHUB,
58
+ EntityType.ENTITY_LOKI,
59
+ EntityType.ENTITY_GURGLING,
60
+ EntityType.ENTITY_TURDLET
61
+ })
62
+ DEFAULT_BOSS_MULTI_SEGMENTS = 4
24
63
  function ____exports.getAliveBosses(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
25
64
  if ignoreFriendly == nil then
26
65
  ignoreFriendly = false
@@ -98,9 +137,8 @@ function ____exports.spawnBoss(self, entityType, variant, subType, position, vel
98
137
  seed
99
138
  )
100
139
  if BOSSES_THAT_REQUIRE_MULTIPLE_SPAWNS:has(entityType) then
101
- local numSegmentsDefined = numSegments == nil and 4 or numSegments
102
- local numSegmentsToUse = entityType == EntityType.ENTITY_CHUB and 3 or numSegmentsDefined
103
- local remainingSegmentsToSpawn = numSegmentsToUse - 1
140
+ local numBossSegments = getNumBossSegments(nil, entityType, variant, numSegments)
141
+ local remainingSegmentsToSpawn = numBossSegments - 1
104
142
  ____repeat(
105
143
  nil,
106
144
  remainingSegmentsToSpawn,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.276",
3
+ "version": "1.2.277",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",