isaacscript-common 44.0.0 → 45.0.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 (69) hide show
  1. package/dist/index.rollup.d.ts +31 -11
  2. package/dist/isaacscript-common.lua +5383 -5236
  3. package/dist/src/classes/features/other/{EdenStartingStats.d.ts → EdenStartingStatsHealth.d.ts} +17 -5
  4. package/dist/src/classes/features/other/EdenStartingStatsHealth.d.ts.map +1 -0
  5. package/dist/src/classes/features/other/EdenStartingStatsHealth.lua +75 -0
  6. package/dist/src/classes/features/other/ItemPoolDetection.d.ts.map +1 -1
  7. package/dist/src/classes/features/other/ItemPoolDetection.lua +2 -1
  8. package/dist/src/classes/features/other/Pause.lua +2 -2
  9. package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +4 -3
  10. package/dist/src/enums/ISCFeature.d.ts +1 -1
  11. package/dist/src/enums/ISCFeature.d.ts.map +1 -1
  12. package/dist/src/enums/ISCFeature.lua +2 -2
  13. package/dist/src/features.d.ts +3 -3
  14. package/dist/src/features.d.ts.map +1 -1
  15. package/dist/src/features.lua +3 -3
  16. package/dist/src/functions/characters.d.ts +9 -2
  17. package/dist/src/functions/characters.d.ts.map +1 -1
  18. package/dist/src/functions/characters.lua +13 -4
  19. package/dist/src/functions/charge.lua +2 -2
  20. package/dist/src/functions/math.d.ts +1 -0
  21. package/dist/src/functions/math.d.ts.map +1 -1
  22. package/dist/src/functions/math.lua +1 -0
  23. package/dist/src/functions/playerCollectibles.d.ts +127 -0
  24. package/dist/src/functions/playerCollectibles.d.ts.map +1 -0
  25. package/dist/src/functions/playerCollectibles.lua +308 -0
  26. package/dist/src/functions/playerHealth.d.ts +1 -1
  27. package/dist/src/functions/playerHealth.d.ts.map +1 -1
  28. package/dist/src/functions/playerHealth.lua +10 -6
  29. package/dist/src/functions/playerTrinkets.d.ts +69 -0
  30. package/dist/src/functions/playerTrinkets.d.ts.map +1 -0
  31. package/dist/src/functions/playerTrinkets.lua +160 -0
  32. package/dist/src/functions/players.d.ts +5 -166
  33. package/dist/src/functions/players.d.ts.map +1 -1
  34. package/dist/src/functions/players.lua +20 -389
  35. package/dist/src/functions/trinketGive.lua +2 -2
  36. package/dist/src/functions/trinkets.d.ts +0 -30
  37. package/dist/src/functions/trinkets.d.ts.map +1 -1
  38. package/dist/src/functions/trinkets.lua +0 -71
  39. package/dist/src/index.d.ts +2 -0
  40. package/dist/src/index.d.ts.map +1 -1
  41. package/dist/src/index.lua +16 -0
  42. package/dist/src/objects/{characterStartingCollectibles.d.ts → characterStartingCollectibleTypes.d.ts} +2 -2
  43. package/dist/src/objects/characterStartingCollectibleTypes.d.ts.map +1 -0
  44. package/dist/src/objects/{characterStartingCollectibles.lua → characterStartingCollectibleTypes.lua} +1 -1
  45. package/dist/src/objects/characterStartingTrinketTypes.d.ts +46 -0
  46. package/dist/src/objects/characterStartingTrinketTypes.d.ts.map +1 -0
  47. package/dist/src/objects/characterStartingTrinketTypes.lua +49 -0
  48. package/package.json +1 -1
  49. package/src/classes/features/other/{EdenStartingStats.ts → EdenStartingStatsHealth.ts} +38 -5
  50. package/src/classes/features/other/ItemPoolDetection.ts +2 -4
  51. package/src/classes/features/other/Pause.ts +1 -1
  52. package/src/classes/features/other/extraConsoleCommands/commands.ts +3 -3
  53. package/src/enums/ISCFeature.ts +1 -1
  54. package/src/features.ts +3 -3
  55. package/src/functions/characters.ts +20 -4
  56. package/src/functions/charge.ts +1 -1
  57. package/src/functions/math.ts +1 -0
  58. package/src/functions/playerCollectibles.ts +372 -0
  59. package/src/functions/playerHealth.ts +23 -15
  60. package/src/functions/playerTrinkets.ts +184 -0
  61. package/src/functions/players.ts +16 -481
  62. package/src/functions/trinketGive.ts +1 -1
  63. package/src/functions/trinkets.ts +1 -84
  64. package/src/index.ts +2 -0
  65. package/src/objects/{characterStartingCollectibles.ts → characterStartingCollectibleTypes.ts} +1 -1
  66. package/src/objects/characterStartingTrinketTypes.ts +129 -0
  67. package/dist/src/classes/features/other/EdenStartingStats.d.ts.map +0 -1
  68. package/dist/src/classes/features/other/EdenStartingStats.lua +0 -54
  69. package/dist/src/objects/characterStartingCollectibles.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
+ import type { TrinketType } from "isaac-typescript-definitions";
1
2
  import {
2
- ActiveSlot,
3
3
  Challenge,
4
4
  CollectibleType,
5
5
  ControllerIndex,
@@ -7,17 +7,10 @@ import {
7
7
  PlayerForm,
8
8
  PlayerType,
9
9
  TearFlag,
10
- TrinketType,
11
10
  } from "isaac-typescript-definitions";
12
- import {
13
- ACTIVE_SLOT_VALUES,
14
- TRINKET_SLOT_VALUES,
15
- } from "../arrays/cachedEnumValues";
16
- import { game, itemConfig } from "../core/cachedClasses";
11
+ import { game } from "../core/cachedClasses";
17
12
  import { ReadonlySet } from "../types/ReadonlySet";
18
- import { sumArray } from "./array";
19
13
  import { getCharacterName, isVanillaCharacter } from "./characters";
20
- import { getCollectibleMaxCharges } from "./collectibles";
21
14
  import { hasFlag } from "./flag";
22
15
  import {
23
16
  getAllPlayers,
@@ -27,64 +20,6 @@ import {
27
20
  import { isNumber } from "./types";
28
21
  import { assertDefined, repeat } from "./utils";
29
22
 
30
- /**
31
- * Helper function to add one or more collectibles to a player.
32
- *
33
- * This function is variadic, meaning that you can supply as many collectible types as you want to
34
- * add.
35
- */
36
- export function addCollectible(
37
- player: EntityPlayer,
38
- ...collectibleTypes: CollectibleType[]
39
- ): void {
40
- for (const collectibleType of collectibleTypes) {
41
- player.AddCollectible(collectibleType);
42
- }
43
- }
44
-
45
- export function addCollectibleCostume(
46
- player: EntityPlayer,
47
- collectibleType: CollectibleType,
48
- ): void {
49
- const itemConfigItem = itemConfig.GetCollectible(collectibleType);
50
- if (itemConfigItem === undefined) {
51
- return;
52
- }
53
-
54
- player.AddCostume(itemConfigItem, false);
55
- }
56
-
57
- export function addTrinketCostume(
58
- player: EntityPlayer,
59
- trinketType: TrinketType,
60
- ): void {
61
- const itemConfigTrinket = itemConfig.GetTrinket(trinketType);
62
- if (itemConfigTrinket === undefined) {
63
- return;
64
- }
65
-
66
- player.AddCostume(itemConfigTrinket, false);
67
- }
68
-
69
- /**
70
- * Helper function to check to see if any player has a particular collectible.
71
- *
72
- * @param collectibleType The collectible type to check for.
73
- * @param ignoreModifiers If set to true, only counts collectibles the player actually owns and
74
- * ignores effects granted by items like Zodiac, 3 Dollar Bill and Lemegeton.
75
- * Default is false.
76
- */
77
- export function anyPlayerHasCollectible(
78
- collectibleType: CollectibleType,
79
- ignoreModifiers?: boolean,
80
- ): boolean {
81
- const players = getAllPlayers();
82
-
83
- return players.some((player) =>
84
- player.HasCollectible(collectibleType, ignoreModifiers),
85
- );
86
- }
87
-
88
23
  /** Helper function to check to see if any player has a temporary collectible effect. */
89
24
  export function anyPlayerHasCollectibleEffect(
90
25
  collectibleType: CollectibleType,
@@ -107,24 +42,6 @@ export function anyPlayerHasNullEffect(nullItemID: NullItemID): boolean {
107
42
  });
108
43
  }
109
44
 
110
- /**
111
- * Helper function to check to see if any player has a particular trinket.
112
- *
113
- * @param trinketType The trinket type to check for.
114
- * @param ignoreModifiers If set to true, only counts trinkets the player actually holds and ignores
115
- * effects granted by other items. Default is false.
116
- */
117
- export function anyPlayerHasTrinket(
118
- trinketType: TrinketType,
119
- ignoreModifiers?: boolean,
120
- ): boolean {
121
- const players = getAllPlayers();
122
-
123
- return players.some((player) =>
124
- player.HasTrinket(trinketType, ignoreModifiers),
125
- );
126
- }
127
-
128
45
  /** Helper function to check to see if any player has a temporary trinket effect. */
129
46
  export function anyPlayerHasTrinketEffect(trinketType: TrinketType): boolean {
130
47
  const players = getAllPlayers();
@@ -198,20 +115,6 @@ export function dequeueItem(player: EntityPlayer): boolean {
198
115
  return true;
199
116
  }
200
117
 
201
- /**
202
- * Helper function to find the active slots that the player has the corresponding collectible type
203
- * in. Returns an empty array if the player does not have the collectible in any active slot.
204
- */
205
- export function getActiveItemSlots(
206
- player: EntityPlayer,
207
- collectibleType: CollectibleType,
208
- ): ActiveSlot[] {
209
- return ACTIVE_SLOT_VALUES.filter((activeSlot) => {
210
- const activeItem = player.GetActiveItem(activeSlot);
211
- return activeItem === collectibleType;
212
- });
213
- }
214
-
215
118
  /**
216
119
  * Helper function to get how long Azazel's Brimstone laser should be. You can pass either an
217
120
  * `EntityPlayer` object or a tear height stat.
@@ -327,27 +230,6 @@ export function getPlayerCloserThan(
327
230
  );
328
231
  }
329
232
 
330
- /**
331
- * Helper function to return the total amount of collectibles that a player has that match the
332
- * collectible type(s) provided.
333
- *
334
- * This function is variadic, meaning that you can specify N collectible types.
335
- *
336
- * Note that this will filter out non-real collectibles like Lilith's Incubus.
337
- */
338
- export function getPlayerCollectibleCount(
339
- player: EntityPlayer,
340
- ...collectibleTypes: CollectibleType[]
341
- ): int {
342
- let numCollectibles = 0;
343
- for (const collectibleType of collectibleTypes) {
344
- // We specify "true" as the second argument to filter out things like Lilith's Incubus.
345
- numCollectibles += player.GetCollectibleNum(collectibleType, true);
346
- }
347
-
348
- return numCollectibles;
349
- }
350
-
351
233
  /**
352
234
  * Helper function to get the player from a tear, laser, bomb, etc. Returns undefined if the entity
353
235
  * does not correspond to any particular player.
@@ -448,9 +330,9 @@ export function getPlayersOfType(...characters: PlayerType[]): EntityPlayer[] {
448
330
  }
449
331
 
450
332
  /**
451
- * Helper function to get all of the players that match the provided controller index. This function
452
- * returns an array of players because it is possible that there is more than one player with the
453
- * same controller index (e.g. Jacob & Esau).
333
+ * Helper function to get all of the players that are using keyboard (i.e.
334
+ * `ControllerIndex.KEYBOARD`). This function returns an array of players because it is possible
335
+ * that there is more than one player with the same controller index (e.g. Jacob & Esau).
454
336
  *
455
337
  * Note that this function includes players with a non-undefined parent like e.g. the Strawman
456
338
  * Keeper.
@@ -463,24 +345,6 @@ export function getPlayersOnKeyboard(): EntityPlayer[] {
463
345
  );
464
346
  }
465
347
 
466
- /**
467
- * Helper function to get only the players that have a certain collectible.
468
- *
469
- * This function is variadic, meaning that you can supply as many collectible types as you want to
470
- * check for. It only returns the players that have all of the collectibles.
471
- */
472
- export function getPlayersWithCollectible(
473
- ...collectibleTypes: CollectibleType[]
474
- ): EntityPlayer[] {
475
- const players = getPlayers();
476
-
477
- return players.filter((player) =>
478
- collectibleTypes.every((collectibleType) =>
479
- player.HasCollectible(collectibleType),
480
- ),
481
- );
482
- }
483
-
484
348
  /**
485
349
  * Helper function to get all of the players that match the provided controller index. This function
486
350
  * returns an array of players because it is possible that there is more than one player with the
@@ -496,78 +360,6 @@ export function getPlayersWithControllerIndex(
496
360
  return players.filter((player) => player.ControllerIndex === controllerIndex);
497
361
  }
498
362
 
499
- /**
500
- * Helper function to get only the players that have a certain trinket.
501
- *
502
- * This function is variadic, meaning that you can supply as many trinket types as you want to check
503
- * for. It only returns the players that have all of the trinkets.
504
- */
505
- export function getPlayersWithTrinket(
506
- ...trinketTypes: TrinketType[]
507
- ): EntityPlayer[] {
508
- const players = getPlayers();
509
-
510
- return players.filter((player) =>
511
- trinketTypes.every((trinketType) => player.HasTrinket(trinketType)),
512
- );
513
- }
514
-
515
- /**
516
- * Returns the total number of collectibles amongst all players. For example, if player 1 has 1 Sad
517
- * Onion and player 2 has 2 Sad Onions, then this function would return 3.
518
- *
519
- * Note that this will filter out non-real collectibles like Lilith's Incubus.
520
- */
521
- export function getTotalPlayerCollectibles(
522
- collectibleType: CollectibleType,
523
- ): int {
524
- const players = getPlayers();
525
- const numCollectiblesArray = players.map((player) =>
526
- // We specify "true" as the second argument to filter out things like Lilith's Incubus.
527
- player.GetCollectibleNum(collectibleType, true),
528
- );
529
-
530
- return sumArray(numCollectiblesArray);
531
- }
532
-
533
- /**
534
- * Helper function to check to see if a player has one or more collectibles.
535
- *
536
- * This function is variadic, meaning that you can supply as many collectible types as you want to
537
- * check for. Returns true if the player has any of the supplied collectible types.
538
- *
539
- * This function always passes `false` to the `ignoreModifiers` argument.
540
- */
541
- export function hasCollectible(
542
- player: EntityPlayer,
543
- ...collectibleTypes: CollectibleType[]
544
- ): boolean {
545
- return collectibleTypes.some((collectibleType) =>
546
- player.HasCollectible(collectibleType),
547
- );
548
- }
549
-
550
- /**
551
- * Helper function to check to see if a player has a specific collectible in one or more active
552
- * slots.
553
- *
554
- * This function is variadic, meaning that you can specify as many active slots as you want to check
555
- * for. This function will return true if the collectible type is located in any of the active slots
556
- * provided.
557
- */
558
- export function hasCollectibleInActiveSlot(
559
- player: EntityPlayer,
560
- collectibleType: CollectibleType,
561
- ...activeSlots: ActiveSlot[]
562
- ): boolean {
563
- const matchingActiveSlotsSet = new ReadonlySet(activeSlots);
564
- const activeItemSlots = getActiveItemSlots(player, collectibleType);
565
-
566
- return activeItemSlots.some((activeSlot) =>
567
- matchingActiveSlotsSet.has(activeSlot),
568
- );
569
- }
570
-
571
363
  /**
572
364
  * Helper function to check to see if a player has one or more transformations.
573
365
  *
@@ -587,32 +379,6 @@ export function hasLostCurse(player: EntityPlayer): boolean {
587
379
  return effects.HasNullEffect(NullItemID.LOST_CURSE);
588
380
  }
589
381
 
590
- /**
591
- * Returns whether the player can hold an additional active item, beyond what they are currently
592
- * carrying. This takes the Schoolbag into account.
593
- *
594
- * If the player is the Tainted Soul, this always returns false, since that character cannot pick up
595
- * items. (Only Tainted Forgotten can pick up items.)
596
- */
597
- export function hasOpenActiveItemSlot(player: EntityPlayer): boolean {
598
- if (isCharacter(player, PlayerType.SOUL_B)) {
599
- return false;
600
- }
601
-
602
- const activeItemPrimary = player.GetActiveItem(ActiveSlot.PRIMARY);
603
- const activeItemSecondary = player.GetActiveItem(ActiveSlot.SECONDARY);
604
- const hasSchoolbag = player.HasCollectible(CollectibleType.SCHOOLBAG);
605
-
606
- if (hasSchoolbag) {
607
- return (
608
- activeItemPrimary === CollectibleType.NULL ||
609
- activeItemSecondary === CollectibleType.NULL
610
- );
611
- }
612
-
613
- return activeItemPrimary === CollectibleType.NULL;
614
- }
615
-
616
382
  /**
617
383
  * Helper function to check if a player has piercing tears.
618
384
  *
@@ -631,35 +397,6 @@ export function hasSpectral(player: EntityPlayer): boolean {
631
397
  return hasFlag(player.TearFlags, TearFlag.SPECTRAL);
632
398
  }
633
399
 
634
- /**
635
- * Helper function to check to see if a player has one or more trinkets.
636
- *
637
- * This function is variadic, meaning that you can supply as many trinket types as you want to check
638
- * for. Returns true if the player has any of the supplied trinket types.
639
- *
640
- * This function always passes `false` to the `ignoreModifiers` argument.
641
- */
642
- export function hasTrinket(
643
- player: EntityPlayer,
644
- ...trinketTypes: TrinketType[]
645
- ): boolean {
646
- return trinketTypes.some((trinketType) => player.HasTrinket(trinketType));
647
- }
648
-
649
- /**
650
- * Helper function to check if the active slot of a particular player is empty.
651
- *
652
- * @param player The player to check.
653
- * @param activeSlot Optional. The active slot to check. Default is `ActiveSlot.PRIMARY`.
654
- */
655
- export function isActiveSlotEmpty(
656
- player: EntityPlayer,
657
- activeSlot = ActiveSlot.PRIMARY,
658
- ): boolean {
659
- const activeCollectibleType = player.GetActiveItem(activeSlot);
660
- return activeCollectibleType === CollectibleType.NULL;
661
- }
662
-
663
400
  /**
664
401
  * Helper function for detecting when a player is Bethany or Tainted Bethany. This is useful if you
665
402
  * need to adjust UI elements to account for Bethany's soul charges or Tainted Bethany's blood
@@ -709,6 +446,17 @@ export function isEden(player: EntityPlayer): boolean {
709
446
  return character === PlayerType.EDEN || character === PlayerType.EDEN_B;
710
447
  }
711
448
 
449
+ function isTaintedModded(player: EntityPlayer) {
450
+ // This algorithm only works for modded characters because the `Isaac.GetPlayerTypeByName` method
451
+ // is bugged.
452
+ // https://github.com/Meowlala/RepentanceAPIIssueTracker/issues/117
453
+ const character = player.GetPlayerType();
454
+ const name = player.GetName();
455
+ const taintedCharacter = Isaac.GetPlayerTypeByName(name, true);
456
+
457
+ return character === taintedCharacter;
458
+ }
459
+
712
460
  export function isFirstPlayer(player: EntityPlayer): boolean {
713
461
  return getPlayerIndexVanilla(player) === 0;
714
462
  }
@@ -737,17 +485,6 @@ export function isLost(player: EntityPlayer): boolean {
737
485
  return character === PlayerType.LOST || character === PlayerType.LOST_B;
738
486
  }
739
487
 
740
- function isTaintedModded(player: EntityPlayer) {
741
- // This algorithm only works for modded characters because the `Isaac.GetPlayerTypeByName` method
742
- // is bugged.
743
- // https://github.com/Meowlala/RepentanceAPIIssueTracker/issues/117
744
- const character = player.GetPlayerType();
745
- const name = player.GetName();
746
- const taintedCharacter = Isaac.GetPlayerTypeByName(name, true);
747
-
748
- return character === taintedCharacter;
749
- }
750
-
751
488
  export function isModdedPlayer(player: EntityPlayer): boolean {
752
489
  return !isVanillaPlayer(player);
753
490
  }
@@ -785,96 +522,6 @@ export function isVanillaPlayer(player: EntityPlayer): boolean {
785
522
  return isVanillaCharacter(character);
786
523
  }
787
524
 
788
- /**
789
- * Helper function to remove all of the active items from a player. This includes the Schoolbag item
790
- * and any pocket actives.
791
- */
792
- export function removeAllActiveItems(player: EntityPlayer): void {
793
- for (const activeSlot of ACTIVE_SLOT_VALUES) {
794
- const collectibleType = player.GetActiveItem(activeSlot);
795
- if (collectibleType === CollectibleType.NULL) {
796
- continue;
797
- }
798
-
799
- let stillHasCollectible: boolean;
800
- do {
801
- player.RemoveCollectible(collectibleType);
802
- stillHasCollectible = player.HasCollectible(collectibleType);
803
- } while (stillHasCollectible);
804
- }
805
- }
806
-
807
- /**
808
- * Helper function to remove all of the held trinkets from a player.
809
- *
810
- * This will not remove any smelted trinkets, unless the player happens to also be holding a trinket
811
- * that they have smelted. (In that case, both the held and the smelted trinket will be removed.)
812
- */
813
- export function removeAllPlayerTrinkets(player: EntityPlayer): void {
814
- for (const trinketSlot of TRINKET_SLOT_VALUES) {
815
- const trinketType = player.GetTrinket(trinketSlot);
816
- if (trinketType === TrinketType.NULL) {
817
- continue;
818
- }
819
-
820
- let alreadyHasTrinket: boolean;
821
- do {
822
- player.TryRemoveTrinket(trinketType);
823
- alreadyHasTrinket = player.HasTrinket(trinketType);
824
- } while (alreadyHasTrinket);
825
- }
826
- }
827
-
828
- /**
829
- * Helper function to remove one or more collectibles to a player.
830
- *
831
- * This function is variadic, meaning that you can supply as many collectible types as you want to
832
- * remove.
833
- */
834
- export function removeCollectible(
835
- player: EntityPlayer,
836
- ...collectibleTypes: CollectibleType[]
837
- ): void {
838
- for (const collectibleType of collectibleTypes) {
839
- player.RemoveCollectible(collectibleType);
840
- }
841
- }
842
-
843
- /**
844
- * Helper function to remove a collectible costume from a player. Use this helper function to avoid
845
- * having to request the collectible from the item config.
846
- */
847
- export function removeCollectibleCostume(
848
- player: EntityPlayer,
849
- collectibleType: CollectibleType,
850
- ): void {
851
- const itemConfigItem = itemConfig.GetCollectible(collectibleType);
852
- if (itemConfigItem === undefined) {
853
- return;
854
- }
855
-
856
- player.RemoveCostume(itemConfigItem);
857
- }
858
-
859
- /**
860
- * Helper function to remove one or more collectibles from all players. If any player has more than
861
- * one copy of the item, then all copies of it will be removed.
862
- *
863
- * This function is variadic, meaning that you can specify as many collectibles as you want to
864
- * remove.
865
- */
866
- export function removeCollectibleFromAllPlayers(
867
- ...collectibleTypes: CollectibleType[]
868
- ): void {
869
- for (const player of getAllPlayers()) {
870
- for (const collectibleType of collectibleTypes) {
871
- while (player.HasCollectible(collectibleType, true)) {
872
- player.RemoveCollectible(collectibleType);
873
- }
874
- }
875
- }
876
- }
877
-
878
525
  /**
879
526
  * Helper function to remove the Dead Eye multiplier from a player.
880
527
  *
@@ -887,107 +534,6 @@ export function removeDeadEyeMultiplier(player: EntityPlayer): void {
887
534
  });
888
535
  }
889
536
 
890
- /**
891
- * Helper function to remove a trinket costume from a player. Use this helper function to avoid
892
- * having to request the trinket from the item config.
893
- */
894
- export function removeTrinketCostume(
895
- player: EntityPlayer,
896
- trinketType: TrinketType,
897
- ): void {
898
- const itemConfigTrinket = itemConfig.GetTrinket(trinketType);
899
- if (itemConfigTrinket === undefined) {
900
- return;
901
- }
902
-
903
- player.RemoveCostume(itemConfigTrinket);
904
- }
905
-
906
- /**
907
- * Helper function to set an active collectible to a particular slot. This has different behavior
908
- * than calling the `player.AddCollectible` method with the `activeSlot` argument, because this
909
- * function will not shift existing items into the Schoolbag and it handles
910
- * `ActiveSlot.SLOT_POCKET2`.
911
- *
912
- * Note that if an item is set to `ActiveSlot.SLOT_POCKET2`, it will disappear after being used and
913
- * will be automatically removed upon entering a new room.
914
- *
915
- * @param player The player to give the item to.
916
- * @param collectibleType The collectible type of the item to give.
917
- * @param activeSlot Optional. The slot to set. Default is `ActiveSlot.PRIMARY`.
918
- * @param charge Optional. The argument of charges to set. If not specified, the item will be set
919
- * with maximum charges.
920
- * @param keepInPools Optional. Whether to remove the item from pools. Default is false.
921
- */
922
- export function setActiveItem(
923
- player: EntityPlayer,
924
- collectibleType: CollectibleType,
925
- activeSlot = ActiveSlot.PRIMARY,
926
- charge?: int,
927
- keepInPools = false,
928
- ): void {
929
- const itemPool = game.GetItemPool();
930
- const primaryCollectibleType = player.GetActiveItem(ActiveSlot.PRIMARY);
931
- const primaryCharge = player.GetActiveCharge(ActiveSlot.PRIMARY);
932
- const secondaryCollectibleType = player.GetActiveItem(ActiveSlot.SECONDARY);
933
-
934
- if (charge === undefined) {
935
- charge = getCollectibleMaxCharges(collectibleType);
936
- }
937
-
938
- if (!keepInPools) {
939
- itemPool.RemoveCollectible(collectibleType);
940
- }
941
-
942
- switch (activeSlot) {
943
- case ActiveSlot.PRIMARY: {
944
- // If there is a Schoolbag item, removing the primary item will shift the Schoolbag item to
945
- // the primary slot.
946
- if (primaryCollectibleType !== CollectibleType.NULL) {
947
- player.RemoveCollectible(primaryCollectibleType);
948
- }
949
-
950
- // If there was a Schoolbag item, adding a new primary item will shift it back into the
951
- // secondary slot.
952
- player.AddCollectible(collectibleType, charge, false);
953
-
954
- break;
955
- }
956
-
957
- case ActiveSlot.SECONDARY: {
958
- if (primaryCollectibleType !== CollectibleType.NULL) {
959
- player.RemoveCollectible(primaryCollectibleType);
960
- }
961
-
962
- if (secondaryCollectibleType !== CollectibleType.NULL) {
963
- player.RemoveCollectible(secondaryCollectibleType);
964
- }
965
-
966
- // Add the new item, which will go to the primary slot.
967
- player.AddCollectible(secondaryCollectibleType, charge, false);
968
-
969
- // Add back the original primary item, if any.
970
- if (primaryCollectibleType !== CollectibleType.NULL) {
971
- player.AddCollectible(primaryCollectibleType, primaryCharge, false);
972
- }
973
-
974
- break;
975
- }
976
-
977
- case ActiveSlot.POCKET: {
978
- player.SetPocketActiveItem(collectibleType, activeSlot, keepInPools);
979
- player.SetActiveCharge(charge, activeSlot);
980
-
981
- break;
982
- }
983
-
984
- case ActiveSlot.POCKET_SINGLE_USE: {
985
- player.SetPocketActiveItem(collectibleType, activeSlot, keepInPools);
986
- break;
987
- }
988
- }
989
- }
990
-
991
537
  /**
992
538
  * Helper function to blindfold the player by using a hack with the challenge variable.
993
539
  *
@@ -1024,14 +570,3 @@ export function setBlindfold(
1024
570
  }
1025
571
  }
1026
572
  }
1027
-
1028
- /**
1029
- * Helper function to use an active item without showing an animation, keeping the item, or adding
1030
- * any costumes.
1031
- */
1032
- export function useActiveItemTemp(
1033
- player: EntityPlayer,
1034
- collectibleType: CollectibleType,
1035
- ): void {
1036
- player.UseActiveItem(collectibleType, false, false, true, false, -1);
1037
- }
@@ -4,7 +4,7 @@ import {
4
4
  TrinketType,
5
5
  } from "isaac-typescript-definitions";
6
6
  import type { TrinketSituation } from "../interfaces/TrinketSituation";
7
- import { useActiveItemTemp } from "./players";
7
+ import { useActiveItemTemp } from "./playerCollectibles";
8
8
  import { getGoldenTrinketType } from "./trinkets";
9
9
  import { repeat } from "./utils";
10
10