isaacscript-common 17.2.0 → 17.3.0

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.
Files changed (38) hide show
  1. package/dist/index.d.ts +63 -56
  2. package/dist/isaacscript-common.lua +109 -97
  3. package/dist/src/classes/features/other/CustomHotkeys.d.ts +4 -0
  4. package/dist/src/classes/features/other/CustomHotkeys.d.ts.map +1 -1
  5. package/dist/src/classes/features/other/SpawnCollectible.d.ts +4 -4
  6. package/dist/src/classes/features/other/SpawnCollectible.d.ts.map +1 -1
  7. package/dist/src/classes/features/other/SpawnCollectible.lua +4 -4
  8. package/dist/src/classes/features/other/SpawnRockAltRewards.d.ts +3 -2
  9. package/dist/src/classes/features/other/SpawnRockAltRewards.d.ts.map +1 -1
  10. package/dist/src/classes/features/other/SpawnRockAltRewards.lua +4 -1
  11. package/dist/src/functions/bosses.d.ts +2 -2
  12. package/dist/src/functions/bosses.d.ts.map +1 -1
  13. package/dist/src/functions/bosses.lua +5 -5
  14. package/dist/src/functions/entities.d.ts +5 -5
  15. package/dist/src/functions/entities.d.ts.map +1 -1
  16. package/dist/src/functions/entities.lua +10 -8
  17. package/dist/src/functions/entitiesSpecific.d.ts +20 -20
  18. package/dist/src/functions/entitiesSpecific.d.ts.map +1 -1
  19. package/dist/src/functions/entitiesSpecific.lua +40 -40
  20. package/dist/src/functions/pickupsSpecific.d.ts +18 -18
  21. package/dist/src/functions/pickupsSpecific.d.ts.map +1 -1
  22. package/dist/src/functions/pickupsSpecific.lua +36 -36
  23. package/dist/src/functions/spawnCollectible.d.ts +4 -4
  24. package/dist/src/functions/spawnCollectible.d.ts.map +1 -1
  25. package/dist/src/functions/spawnCollectible.lua +6 -6
  26. package/dist/src/functions/stage.d.ts +4 -1
  27. package/dist/src/functions/stage.d.ts.map +1 -1
  28. package/dist/src/functions/stage.lua +10 -0
  29. package/package.json +1 -1
  30. package/src/classes/features/other/CustomHotkeys.ts +4 -0
  31. package/src/classes/features/other/SpawnCollectible.ts +6 -6
  32. package/src/classes/features/other/SpawnRockAltRewards.ts +7 -3
  33. package/src/functions/bosses.ts +13 -5
  34. package/src/functions/entities.ts +14 -8
  35. package/src/functions/entitiesSpecific.ts +40 -40
  36. package/src/functions/pickupsSpecific.ts +84 -36
  37. package/src/functions/spawnCollectible.ts +6 -6
  38. package/src/functions/stage.ts +15 -2
@@ -330,7 +330,7 @@ export function removeAllTrinkets(
330
330
  */
331
331
  export function spawnBattery(
332
332
  batterySubType: BatterySubType,
333
- position: Vector,
333
+ positionOrGridIndex: Vector | int,
334
334
  velocity: Vector = VectorZero,
335
335
  spawner: Entity | undefined = undefined,
336
336
  seedOrRNG: Seed | RNG | undefined = undefined,
@@ -338,7 +338,7 @@ export function spawnBattery(
338
338
  return spawnPickup(
339
339
  PickupVariant.LIL_BATTERY,
340
340
  batterySubType,
341
- position,
341
+ positionOrGridIndex,
342
342
  velocity,
343
343
  spawner,
344
344
  seedOrRNG,
@@ -351,18 +351,24 @@ export function spawnBattery(
351
351
  */
352
352
  export function spawnBatteryWithSeed(
353
353
  batterySubType: BatterySubType,
354
- position: Vector,
354
+ positionOrGridIndex: Vector | int,
355
355
  seedOrRNG: Seed | RNG,
356
356
  velocity: Vector = VectorZero,
357
357
  spawner: Entity | undefined = undefined,
358
358
  ): EntityPickupBattery {
359
- return spawnBattery(batterySubType, position, velocity, spawner, seedOrRNG);
359
+ return spawnBattery(
360
+ batterySubType,
361
+ positionOrGridIndex,
362
+ velocity,
363
+ spawner,
364
+ seedOrRNG,
365
+ );
360
366
  }
361
367
 
362
368
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.BOMB` (40). */
363
369
  export function spawnBombPickup(
364
370
  bombSubType: BombSubType,
365
- position: Vector,
371
+ positionOrGridIndex: Vector | int,
366
372
  velocity: Vector = VectorZero,
367
373
  spawner: Entity | undefined = undefined,
368
374
  seedOrRNG: Seed | RNG | undefined = undefined,
@@ -370,7 +376,7 @@ export function spawnBombPickup(
370
376
  return spawnPickup(
371
377
  PickupVariant.BOMB,
372
378
  bombSubType,
373
- position,
379
+ positionOrGridIndex,
374
380
  velocity,
375
381
  spawner,
376
382
  seedOrRNG,
@@ -383,12 +389,18 @@ export function spawnBombPickup(
383
389
  */
384
390
  export function spawnBombPickupWithSeed(
385
391
  bombSubType: BombSubType,
386
- position: Vector,
392
+ positionOrGridIndex: Vector | int,
387
393
  seedOrRNG: Seed | RNG,
388
394
  velocity: Vector = VectorZero,
389
395
  spawner: Entity | undefined = undefined,
390
396
  ): EntityPickupBomb {
391
- return spawnBombPickup(bombSubType, position, velocity, spawner, seedOrRNG);
397
+ return spawnBombPickup(
398
+ bombSubType,
399
+ positionOrGridIndex,
400
+ velocity,
401
+ spawner,
402
+ seedOrRNG,
403
+ );
392
404
  }
393
405
 
394
406
  /**
@@ -396,7 +408,7 @@ export function spawnBombPickupWithSeed(
396
408
  */
397
409
  export function spawnCard(
398
410
  cardType: CardType,
399
- position: Vector,
411
+ positionOrGridIndex: Vector | int,
400
412
  velocity: Vector = VectorZero,
401
413
  spawner: Entity | undefined = undefined,
402
414
  seedOrRNG: Seed | RNG | undefined = undefined,
@@ -404,7 +416,7 @@ export function spawnCard(
404
416
  return spawnPickup(
405
417
  PickupVariant.TAROT_CARD,
406
418
  cardType,
407
- position,
419
+ positionOrGridIndex,
408
420
  velocity,
409
421
  spawner,
410
422
  seedOrRNG,
@@ -417,18 +429,18 @@ export function spawnCard(
417
429
  */
418
430
  export function spawnCardWithSeed(
419
431
  cardType: CardType,
420
- position: Vector,
432
+ positionOrGridIndex: Vector | int,
421
433
  seedOrRNG: Seed | RNG,
422
434
  velocity: Vector = VectorZero,
423
435
  spawner: Entity | undefined = undefined,
424
436
  ): EntityPickupCard {
425
- return spawnCard(cardType, position, velocity, spawner, seedOrRNG);
437
+ return spawnCard(cardType, positionOrGridIndex, velocity, spawner, seedOrRNG);
426
438
  }
427
439
 
428
440
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.COIN` (20). */
429
441
  export function spawnCoin(
430
442
  coinSubType: CoinSubType,
431
- position: Vector,
443
+ positionOrGridIndex: Vector | int,
432
444
  velocity: Vector = VectorZero,
433
445
  spawner: Entity | undefined = undefined,
434
446
  seedOrRNG: Seed | RNG | undefined = undefined,
@@ -436,7 +448,7 @@ export function spawnCoin(
436
448
  return spawnPickup(
437
449
  PickupVariant.COIN,
438
450
  coinSubType,
439
- position,
451
+ positionOrGridIndex,
440
452
  velocity,
441
453
  spawner,
442
454
  seedOrRNG,
@@ -449,18 +461,24 @@ export function spawnCoin(
449
461
  */
450
462
  export function spawnCoinWithSeed(
451
463
  coinSubType: CoinSubType,
452
- position: Vector,
464
+ positionOrGridIndex: Vector | int,
453
465
  seedOrRNG: Seed | RNG,
454
466
  velocity: Vector = VectorZero,
455
467
  spawner: Entity | undefined = undefined,
456
468
  ): EntityPickupCoin {
457
- return spawnCoin(coinSubType, position, velocity, spawner, seedOrRNG);
469
+ return spawnCoin(
470
+ coinSubType,
471
+ positionOrGridIndex,
472
+ velocity,
473
+ spawner,
474
+ seedOrRNG,
475
+ );
458
476
  }
459
477
 
460
478
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.HEART` (10). */
461
479
  export function spawnHeart(
462
480
  heartSubType: HeartSubType,
463
- position: Vector,
481
+ positionOrGridIndex: Vector | int,
464
482
  velocity: Vector = VectorZero,
465
483
  spawner: Entity | undefined = undefined,
466
484
  seedOrRNG: Seed | RNG | undefined = undefined,
@@ -468,7 +486,7 @@ export function spawnHeart(
468
486
  return spawnPickup(
469
487
  PickupVariant.HEART,
470
488
  heartSubType,
471
- position,
489
+ positionOrGridIndex,
472
490
  velocity,
473
491
  spawner,
474
492
  seedOrRNG,
@@ -477,18 +495,24 @@ export function spawnHeart(
477
495
 
478
496
  export function spawnHeartWithSeed(
479
497
  heartSubType: HeartSubType,
480
- position: Vector,
498
+ positionOrGridIndex: Vector | int,
481
499
  seedOrRNG: Seed | RNG,
482
500
  velocity: Vector = VectorZero,
483
501
  spawner: Entity | undefined = undefined,
484
502
  ): EntityPickupHeart {
485
- return spawnHeart(heartSubType, position, velocity, spawner, seedOrRNG);
503
+ return spawnHeart(
504
+ heartSubType,
505
+ positionOrGridIndex,
506
+ velocity,
507
+ spawner,
508
+ seedOrRNG,
509
+ );
486
510
  }
487
511
 
488
512
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.KEY` (30). */
489
513
  export function spawnKey(
490
514
  keySubType: KeySubType,
491
- position: Vector,
515
+ positionOrGridIndex: Vector | int,
492
516
  velocity: Vector = VectorZero,
493
517
  spawner: Entity | undefined = undefined,
494
518
  seedOrRNG: Seed | RNG | undefined = undefined,
@@ -496,7 +520,7 @@ export function spawnKey(
496
520
  return spawnPickup(
497
521
  PickupVariant.KEY,
498
522
  keySubType,
499
- position,
523
+ positionOrGridIndex,
500
524
  velocity,
501
525
  spawner,
502
526
  seedOrRNG,
@@ -509,18 +533,24 @@ export function spawnKey(
509
533
  */
510
534
  export function spawnKeyWithSeed(
511
535
  keySubType: KeySubType,
512
- position: Vector,
536
+ positionOrGridIndex: Vector | int,
513
537
  seedOrRNG: Seed | RNG,
514
538
  velocity: Vector = VectorZero,
515
539
  spawner: Entity | undefined = undefined,
516
540
  ): EntityPickupKey {
517
- return spawnKey(keySubType, position, velocity, spawner, seedOrRNG);
541
+ return spawnKey(
542
+ keySubType,
543
+ positionOrGridIndex,
544
+ velocity,
545
+ spawner,
546
+ seedOrRNG,
547
+ );
518
548
  }
519
549
 
520
550
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.PILL` (70). */
521
551
  export function spawnPill(
522
552
  pillColor: PillColor,
523
- position: Vector,
553
+ positionOrGridIndex: Vector | int,
524
554
  velocity: Vector = VectorZero,
525
555
  spawner: Entity | undefined = undefined,
526
556
  seedOrRNG: Seed | RNG | undefined = undefined,
@@ -528,7 +558,7 @@ export function spawnPill(
528
558
  return spawnPickup(
529
559
  PickupVariant.PILL,
530
560
  pillColor,
531
- position,
561
+ positionOrGridIndex,
532
562
  velocity,
533
563
  spawner,
534
564
  seedOrRNG,
@@ -541,18 +571,24 @@ export function spawnPill(
541
571
  */
542
572
  export function spawnPillWithSeed(
543
573
  pillColor: PillColor,
544
- position: Vector,
574
+ positionOrGridIndex: Vector | int,
545
575
  seedOrRNG: Seed | RNG,
546
576
  velocity: Vector = VectorZero,
547
577
  spawner: Entity | undefined = undefined,
548
578
  ): EntityPickupPill {
549
- return spawnPill(pillColor, position, velocity, spawner, seedOrRNG);
579
+ return spawnPill(
580
+ pillColor,
581
+ positionOrGridIndex,
582
+ velocity,
583
+ spawner,
584
+ seedOrRNG,
585
+ );
550
586
  }
551
587
 
552
588
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.SACK` (69). */
553
589
  export function spawnSack(
554
590
  sackSubType: SackSubType,
555
- position: Vector,
591
+ positionOrGridIndex: Vector | int,
556
592
  velocity: Vector = VectorZero,
557
593
  spawner: Entity | undefined = undefined,
558
594
  seedOrRNG: Seed | RNG | undefined = undefined,
@@ -560,7 +596,7 @@ export function spawnSack(
560
596
  return spawnPickup(
561
597
  PickupVariant.SACK,
562
598
  sackSubType,
563
- position,
599
+ positionOrGridIndex,
564
600
  velocity,
565
601
  spawner,
566
602
  seedOrRNG,
@@ -573,12 +609,18 @@ export function spawnSack(
573
609
  */
574
610
  export function spawnSackWithSeed(
575
611
  sackSubType: SackSubType,
576
- position: Vector,
612
+ positionOrGridIndex: Vector | int,
577
613
  seedOrRNG: Seed | RNG,
578
614
  velocity: Vector = VectorZero,
579
615
  spawner: Entity | undefined = undefined,
580
616
  ): EntityPickupSack {
581
- return spawnSack(sackSubType, position, velocity, spawner, seedOrRNG);
617
+ return spawnSack(
618
+ sackSubType,
619
+ positionOrGridIndex,
620
+ velocity,
621
+ spawner,
622
+ seedOrRNG,
623
+ );
582
624
  }
583
625
 
584
626
  /**
@@ -586,7 +628,7 @@ export function spawnSackWithSeed(
586
628
  */
587
629
  export function spawnTrinket(
588
630
  trinketType: TrinketType,
589
- position: Vector,
631
+ positionOrGridIndex: Vector | int,
590
632
  velocity: Vector = VectorZero,
591
633
  spawner: Entity | undefined = undefined,
592
634
  seedOrRNG: Seed | RNG | undefined = undefined,
@@ -594,7 +636,7 @@ export function spawnTrinket(
594
636
  return spawnPickup(
595
637
  PickupVariant.TRINKET,
596
638
  trinketType,
597
- position,
639
+ positionOrGridIndex,
598
640
  velocity,
599
641
  spawner,
600
642
  seedOrRNG,
@@ -607,10 +649,16 @@ export function spawnTrinket(
607
649
  */
608
650
  export function spawnTrinketWithSeed(
609
651
  trinketType: TrinketType,
610
- position: Vector,
652
+ positionOrGridIndex: Vector | int,
611
653
  seedOrRNG: Seed | RNG,
612
654
  velocity: Vector = VectorZero,
613
655
  spawner: Entity | undefined = undefined,
614
656
  ): EntityPickupTrinket {
615
- return spawnTrinket(trinketType, position, velocity, spawner, seedOrRNG);
657
+ return spawnTrinket(
658
+ trinketType,
659
+ positionOrGridIndex,
660
+ velocity,
661
+ spawner,
662
+ seedOrRNG,
663
+ );
616
664
  }
@@ -21,7 +21,7 @@ import { getRandomSeed, isRNG } from "./rng";
21
21
  * (which is provided by `ISCFeature.SPAWN_COLLECTIBLE`).
22
22
  *
23
23
  * @param collectibleType The collectible type to spawn.
24
- * @param position The position to spawn the collectible at.
24
+ * @param positionOrGridIndex The position or grid index to spawn the collectible at.
25
25
  * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
26
26
  * `RNG.Next` method will be called. Default is `getRandomSeed()`.
27
27
  * @param options Optional. Set to true to make the collectible a "There's Options" style
@@ -32,7 +32,7 @@ import { getRandomSeed, isRNG } from "./rng";
32
32
  */
33
33
  export function spawnCollectibleUnsafe(
34
34
  collectibleType: CollectibleType,
35
- position: Vector,
35
+ positionOrGridIndex: Vector | int,
36
36
  seedOrRNG: Seed | RNG = getRandomSeed(),
37
37
  options = false,
38
38
  forceFreeItem = false,
@@ -42,7 +42,7 @@ export function spawnCollectibleUnsafe(
42
42
  const collectible = spawnPickupWithSeed(
43
43
  PickupVariant.COLLECTIBLE,
44
44
  collectibleType,
45
- position,
45
+ positionOrGridIndex,
46
46
  seed,
47
47
  VectorZero,
48
48
  spawner,
@@ -80,17 +80,17 @@ export function spawnCollectibleUnsafe(
80
80
  * Instead, this function arbitrarily spawns a collectible with `CollectibleType.SAD_ONION`, and
81
81
  * then converts it to an empty pedestal afterward.
82
82
  *
83
- * @param position The position to spawn the empty collectible at.
83
+ * @param positionOrGridIndex The position or grid index to spawn the empty collectible at.
84
84
  * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
85
85
  * `RNG.Next` method will be called. Default is `getRandomSeed()`.
86
86
  */
87
87
  export function spawnEmptyCollectible(
88
- position: Vector,
88
+ positionOrGridIndex: Vector | int,
89
89
  seedOrRNG: Seed | RNG = getRandomSeed(),
90
90
  ): EntityPickup {
91
91
  const collectible = spawnCollectibleUnsafe(
92
92
  CollectibleType.SAD_ONION,
93
- position,
93
+ positionOrGridIndex,
94
94
  seedOrRNG,
95
95
  false,
96
96
  true,
@@ -95,11 +95,24 @@ export function getEffectiveStage(): int {
95
95
  * which will not display correctly on some fonts.
96
96
  *
97
97
  * Note that this returns "Blue Womb" instead of "???" for stage 9.
98
+ *
99
+ * @param stage Optional. If not specified, the current stage will be used.
100
+ * @param stageType Optional. If not specified, the current stage type will be used.
98
101
  */
99
102
  export function getEnglishLevelName(
100
- stage: LevelStage,
101
- stageType: StageType,
103
+ stage?: LevelStage,
104
+ stageType?: StageType,
102
105
  ): string {
106
+ const level = game.GetLevel();
107
+
108
+ if (stage === undefined) {
109
+ stage = level.GetStage();
110
+ }
111
+
112
+ if (stageType === undefined) {
113
+ stageType = level.GetStageType();
114
+ }
115
+
103
116
  const stageNames = ENGLISH_LEVEL_NAMES[stage];
104
117
  return stageNames[stageType];
105
118
  }