-
Notifications
You must be signed in to change notification settings - Fork 21
/
commands.ts
1859 lines (1585 loc) · 50.2 KB
/
commands.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// cspell:ignore addcharges
/*
eslint "sort-exports/sort-exports": [
"error",
{
sortDir: "asc",
},
],
*/
/* eslint "jsdoc/require-jsdoc": "error" */
/**
* __DOCS_LINE_THAT_WILL_BE_AUTOMATICALLY_REMOVED__
*
* This is a list of custom console commands that are included with the standard library. By
* default, they will not be enabled. You can enable them by upgrading your mod with
* `ISCFeature.EXTRA_CONSOLE_COMMANDS`. (Also see the [Extra Console Commands](ExtraConsoleCommands)
* feature documentation.)
*
* As a quality of life feature, you do not have to match the casing of the command. For example,
* you can type the "addCharges" command as "addcharges", and it will still work the same.
*
* Additionally, you can also abbreviate any command by omitting letters that do not overlap with
* any other command. For example, the command of "c" will be interpreted as the "card" command.
*
* In order for the custom console commands to work, you first have to enable
* `ISCFeature.EXTRA_CONSOLE_COMMANDS` when upgrading your mod. (See the "Extra Console Commands
* (Init)" page for more details.)
*
* Each command has a corresponding function of the same name, but these functions are not exported
* for end-user consumption. (This is to cut down on namespace conflicts and because the names of
* the functions are not very descriptive.)
*
* @module
*/
import type {
CardType,
PillEffect,
TrinketType,
} from "isaac-typescript-definitions";
import {
ActiveSlot,
BossID,
CacheFlag,
Challenge,
CollectibleType,
Direction,
DisplayFlag,
GameStateFlag,
GridEntityType,
GridRoom,
LevelStage,
PillColor,
PlayerType,
PocketItemSlot,
RoomType,
SoundEffect,
StageType,
} from "isaac-typescript-definitions";
import { GRID_ENTITY_TYPE_VALUES } from "../../../../cachedEnumValues";
import { game, sfxManager } from "../../../../core/cachedClasses";
import {
DOGMA_ROOM_GRID_INDEX,
MAX_LEVEL_GRID_INDEX,
MAX_NUM_FAMILIARS,
} from "../../../../core/constants";
import {
FIRST_CARD_TYPE,
FIRST_HORSE_PILL_COLOR,
FIRST_PILL_COLOR,
LAST_VANILLA_CARD_TYPE,
} from "../../../../core/constantsFirstLast";
import { HealthType } from "../../../../enums/HealthType";
import { getCardName, isValidCardType } from "../../../../functions/cards";
import { getCharacterName } from "../../../../functions/characters";
import { addCharge, getTotalCharge } from "../../../../functions/charge";
import { isValidCollectibleType } from "../../../../functions/collectibles";
import { printEnabled } from "../../../../functions/console";
import { runDeepCopyTests } from "../../../../functions/deepCopyTests";
import { getNPCs } from "../../../../functions/entitiesSpecific";
import { isEnumValue } from "../../../../functions/enums";
import { addFlag } from "../../../../functions/flag";
import { spawnGridEntity } from "../../../../functions/gridEntities";
import { getRoomGridIndexesForType } from "../../../../functions/levelGrid";
import {
logMusic,
logPlayerEffects,
logRoom,
logSeedEffects,
logSounds,
} from "../../../../functions/logMisc";
import { runMergeTests } from "../../../../functions/mergeTests";
import {
spawnCard,
spawnPill,
spawnTrinket as spawnTrinketFunction,
} from "../../../../functions/pickupsSpecific";
import {
getHorsePillColor,
getPillEffectName,
isValidPillEffect,
} from "../../../../functions/pills";
import {
addCollectibleCostume,
removeCollectibleCostume,
useActiveItemTemp,
} from "../../../../functions/playerCollectibles";
import { getPlayers } from "../../../../functions/playerIndex";
import { getPlayerName } from "../../../../functions/players";
import { getRoomData } from "../../../../functions/roomData";
import { gridCoordinatesToWorldPosition } from "../../../../functions/roomGrid";
import { reloadRoom as reloadRoomFunction } from "../../../../functions/roomTransition";
import { changeRoom } from "../../../../functions/rooms";
import { onSetSeed, restart, setUnseeded } from "../../../../functions/run";
import { spawnCollectible as spawnCollectibleFunc } from "../../../../functions/spawnCollectible";
import { onStage, setStage } from "../../../../functions/stage";
import { getMapPartialMatch } from "../../../../functions/string";
import {
getGoldenTrinketType,
isValidTrinketType,
} from "../../../../functions/trinkets";
import { parseIntSafe } from "../../../../functions/types";
import { iRange } from "../../../../functions/utils";
import { CARD_NAME_TO_TYPE_MAP } from "../../../../maps/cardNameToTypeMap";
import { CHARACTER_NAME_TO_TYPE_MAP } from "../../../../maps/characterNameToTypeMap";
import { COLLECTIBLE_NAME_TO_TYPE_MAP } from "../../../../maps/collectibleNameToTypeMap";
import { PILL_NAME_TO_EFFECT_MAP } from "../../../../maps/pillNameToEffectMap";
import { ROOM_NAME_TO_TYPE_MAP } from "../../../../maps/roomNameToTypeMap";
import { TRINKET_NAME_TO_TYPE_MAP } from "../../../../maps/trinketNameToTypeMap";
import { ROOM_TYPE_NAMES } from "../../../../objects/roomTypeNames";
import {
addHeart,
devilAngel,
listEntities,
listGridEntities,
movePlayer,
spawnTrapdoorOrCrawlSpace,
warpNextToRoomType,
warpToRoomType,
} from "./subroutines";
import { v } from "./v";
/**
* Adds a single charge to the player's specified active item. You must provide the active slot
* number. Provide a second number to give a custom amount of charges. (You can use negative numbers
* to remove charge.)
*/
export function addCharges(params: string): void {
if (params === "") {
print(
"You must specify a slot number. (Use 0 for the primary slot, 1 for the Schoolbag slot, 2 for the pocket item slot, and 3 for the Dice Bag slot.)",
);
return;
}
const args = params.split(" ");
if (args.length !== 1 && args.length !== 2) {
print(`Invalid amount of arguments: ${args.length}`);
return;
}
const [activeSlotString, numChargeString] = args;
if (activeSlotString === undefined) {
return;
}
const activeSlot = parseIntSafe(activeSlotString);
if (activeSlot === undefined || !isEnumValue(activeSlot, ActiveSlot)) {
print(`Invalid slot number: ${activeSlot}`);
return;
}
let numCharges = 1;
if (numChargeString !== undefined) {
const numChargesAttempt = parseIntSafe(numChargeString);
if (numChargesAttempt === undefined) {
print(`Invalid charge amount: ${numChargeString}`);
return;
}
numCharges = numChargesAttempt;
}
const player = Isaac.GetPlayer();
addCharge(player, activeSlot, numCharges);
}
/**
* Warps to the Angel Room for the floor. If the Devil Room has already been visited or initialized,
* this will uninitialize it and make an Angel Room instead.
*/
export function angelRoom(): void {
devilAngel(false);
}
/** Activates the flags for the Ascent (i.e. Backwards Path). */
export function ascent(): void {
game.SetStateFlag(GameStateFlag.BACKWARDS_PATH_INIT, true);
game.SetStateFlag(GameStateFlag.BACKWARDS_PATH, true);
print("Set Ascent flags.");
}
/** Warps to the first Clean Bedroom or Dirty Bedroom on the floor. */
export function bedroom(): void {
const cleanBedroomGridIndexes = getRoomGridIndexesForType(
RoomType.CLEAN_BEDROOM,
);
if (cleanBedroomGridIndexes.length > 0) {
warpToRoomType(RoomType.CLEAN_BEDROOM);
return;
}
const dirtyBedroomGridIndexes = getRoomGridIndexesForType(
RoomType.DIRTY_BEDROOM,
);
if (dirtyBedroomGridIndexes.length > 0) {
warpToRoomType(RoomType.DIRTY_BEDROOM);
return;
}
print("There are no Clean Bedrooms or Dirty Bedrooms on this floor.");
}
/**
* Gives a half black heart. Provide a number to give a custom amount of hearts. (You can use
* negative numbers to remove hearts.)
*/
export function blackHearts(params: string): void {
addHeart(params, HealthType.BLACK);
}
/** Warps to the Black Market for the floor. */
export function blackMarket(): void {
changeRoom(GridRoom.BLACK_MARKET);
}
/** Toggles permanent Curse of the Blind. */
export function blind(): void {
v.persistent.blind = !v.persistent.blind;
printEnabled(v.persistent.blind, "permanent Curse of the Blind");
}
/**
* Gives a blood charge. This only affects Bethany. Provide a number to give a custom amount of
* charges. (You can use negative numbers to remove charges.)
*/
export function bloodCharges(params: string): void {
let charges = 1;
if (params !== "") {
const num = parseIntSafe(params);
if (num === undefined) {
print(`Invalid charge amount: ${num}`);
return;
}
charges = num;
}
const player = Isaac.GetPlayer();
player.AddBloodCharge(charges);
}
/** Alias for the "blackMarket" command. */
export function bm(): void {
blackMarket();
}
/**
* Gives a bomb. Provide a number to give a custom amount of bombs. (You can use negative numbers to
* remove bombs.)
*/
export function bomb(params: string): void {
let numBombs = 1;
if (params !== "") {
const num = parseIntSafe(params);
if (num === undefined) {
print(`Invalid bomb amount: ${num}`);
return;
}
numBombs = num;
}
const player = Isaac.GetPlayer();
player.AddBombs(numBombs);
}
/**
* Gives 99 bombs. Provide a number to give a custom amount of bombs. (You can use negative numbers
* to remove bombs.)
*/
export function bombs(params: string): void {
let numBombs = 99;
if (params !== "") {
const num = parseIntSafe(params);
if (num === undefined) {
print(`Invalid bomb amount: ${num}`);
return;
}
numBombs = num;
}
const player = Isaac.GetPlayer();
player.AddBombs(numBombs);
}
/**
* Gives a bone heart. Provide a number to give a custom amount of hearts. (You can use negative
* numbers to remove hearts.)
*/
export function boneHearts(params: string): void {
addHeart(params, HealthType.BONE);
}
/** Alias for the "bossRoom" command. */
export function boss(): void {
bossRoom();
}
/** Warps to the room next to the first Boss Room on the floor. */
export function bossNextRoom(): void {
warpNextToRoomType(RoomType.BOSS);
}
/** Warps to the first Boss Room on the floor (or the Delirium Boss Room if on The Void). */
export function bossRoom(): void {
// Most of the logic here is copied from the "warpToRoomType" function.
const roomType = RoomType.BOSS;
const roomGridIndexes = getRoomGridIndexesForType(roomType);
let roomGridIndex = roomGridIndexes[0];
if (onStage(LevelStage.VOID)) {
roomGridIndex = roomGridIndexes.find(
(thisRoomGridIndex) =>
getRoomData(thisRoomGridIndex)?.Subtype === BossID.DELIRIUM,
);
}
const roomTypeName = ROOM_TYPE_NAMES[RoomType.BOSS];
if (roomGridIndex === undefined) {
print(`There are no ${roomTypeName}s on this floor.`);
return;
}
changeRoom(roomGridIndex);
print(`Warped to room type: ${roomTypeName} (${roomType})`);
}
/** Warps to the Boss Rush for the floor. */
export function bossRush(): void {
changeRoom(GridRoom.BOSS_RUSH);
}
/**
* Gives a broken heart. Provide a number to give a custom amount of hearts. (You can use negative
* numbers to remove hearts.)
*/
export function brokenHearts(params: string): void {
addHeart(params, HealthType.BROKEN);
}
/**
* Gives the specified card. Accepts either the card type or the partial name of the card.
*
* For example:
* - card 5 - Gives The Emperor.
* - card spa - Gives 2 of Spades.
*/
export function card(params: string): void {
if (params === "") {
print("You must specify a card name or number.");
return;
}
let cardType: CardType;
const num = parseIntSafe(params);
if (num === undefined) {
const match = getMapPartialMatch(params, CARD_NAME_TO_TYPE_MAP);
if (match === undefined) {
print(`Unknown card: ${params}`);
return;
}
cardType = match[1];
} else {
if (!isValidCardType(num)) {
print(`Invalid card type: ${num}`);
return;
}
cardType = num;
}
const cardName = getCardName(cardType);
Isaac.ExecuteCommand(`g k${cardType}`);
print(`Gave card: ${cardName} (${cardType})`);
}
/** Spawns every card on the ground, starting at the top-left-most tile. */
export function cards(): void {
let cardType = FIRST_CARD_TYPE;
for (let y = 0; y <= 6; y++) {
for (let x = 0; x <= 12; x++) {
if (cardType > LAST_VANILLA_CARD_TYPE) {
return;
}
const worldPosition = gridCoordinatesToWorldPosition(x, y);
spawnCard(cardType, worldPosition);
cardType++; // eslint-disable-line isaacscript/strict-enums
}
}
}
/** Alias for the "chaosCardTears" command. */
export function cc(): void {
chaosCardTears();
}
/**
* Toggles Chaos Card tears for the player. Useful for killing enemies very fast without using
* "debug 10".
*/
export function chaosCardTears(): void {
v.persistent.chaosCardTears = !v.persistent.chaosCardTears;
printEnabled(v.persistent.chaosCardTears, "Chaos Card tears");
}
/**
* Restart as the specified character. Accepts either the character sub-type or the partial name of
* the character.
*
* For example:
* - character 2 - Restarts as Cain.
* - character ta - Restarts as Tainted Azazel.
*/
export function character(params: string): void {
if (params === "") {
print("You must specify a character name or number.");
return;
}
let playerType: PlayerType;
const num = parseIntSafe(params);
if (num === undefined) {
const match = getMapPartialMatch(params, CHARACTER_NAME_TO_TYPE_MAP);
if (match === undefined) {
print(`Unknown character: ${params}`);
return;
}
playerType = match[1];
} else {
if (!isEnumValue(num, PlayerType) || num === PlayerType.POSSESSOR) {
print(`Invalid character number: ${num}`);
return;
}
playerType = num;
}
const characterName = getCharacterName(playerType);
restart(playerType);
print(`Restarting as character: ${characterName} (${playerType})`);
}
/** Alias for the "addCharges" command. */
export function charge(params: string): void {
addCharges(params);
}
/** Warps to the first Clean Bedroom on the floor. */
export function cleanBedroom(): void {
warpToRoomType(RoomType.CLEAN_BEDROOM);
}
/**
* Gives a coin. Provide a number to give a custom amount of coins. (You can use negative numbers to
* remove coins.)
*/
export function coin(params: string): void {
let numCoins = 1;
if (params !== "") {
const num = parseIntSafe(params);
if (num === undefined) {
print(`Invalid coin amount: ${num}`);
return;
}
numCoins = num;
}
const player = Isaac.GetPlayer();
player.AddCoins(numCoins);
}
/**
* Gives 999 coins. Provide a number to give a custom amount of coins. (You can use negative numbers
* to remove coins.)
*/
export function coins(params: string): void {
let numCoins = 999;
if (params !== "") {
const num = parseIntSafe(params);
if (num === undefined) {
print(`Invalid coin amount: ${num}`);
return;
}
numCoins = num;
}
const player = Isaac.GetPlayer();
player.AddCoins(numCoins);
}
/** Alias for the "spawnCollectible" command. */
export function collectible(params: string): void {
spawnCollectible(params);
}
/** Creates a crawl space next to the player. */
export function crawlSpace(): void {
spawnTrapdoorOrCrawlSpace(false);
}
/** Toggles permanent Curse of the Cursed. */
export function cursed(): void {
v.persistent.cursed = !v.persistent.cursed;
printEnabled(v.persistent.cursed, "permanent Curse of the Cursed");
}
/** Uses the D20. */
export function d20(): void {
const player = Isaac.GetPlayer();
useActiveItemTemp(player, CollectibleType.D20);
}
/** Uses the D6. */
export function d6(): void {
const player = Isaac.GetPlayer();
useActiveItemTemp(player, CollectibleType.D6);
}
/** Warps to the Mausoleum 2 Boss Room that has Dad's Note in it. */
export function dadsNote(): void {
game.SetStateFlag(GameStateFlag.BACKWARDS_PATH_INIT, true);
setStage(LevelStage.DEPTHS_2, StageType.REPENTANCE);
bossRoom();
}
/**
* Toggles a set damage stat for the player. You can provide an optional argument to this command in
* order to set the damage to a specific amount. Default is 500.
*/
export function damage(params: string): void {
if (params !== "") {
const num = tonumber(params); // Can be a float.
if (num === undefined) {
print(`Invalid damage amount: ${params}`);
return;
}
v.persistent.damageAmount = num;
}
v.persistent.damage = !v.persistent.damage;
const player = Isaac.GetPlayer();
player.AddCacheFlags(CacheFlag.DAMAGE);
player.EvaluateItems();
printEnabled(v.persistent.damage, "set damage");
}
/** Toggles permanent Curse of Darkness. */
export function darkness(): void {
v.persistent.darkness = !v.persistent.darkness;
printEnabled(v.persistent.darkness, "permanent Curse of Darkness");
}
/** Alias for the "devil" command. */
export function dd(): void {
devilRoom();
}
/**
* Warps to the Devil Room for the floor. If the Angel Room has already been visited or initialized,
* this will uninitialize it and make an Devil Room instead.
*/
export function devilRoom(): void {
devilAngel(true);
}
/** Warps to the first Dirty Bedroom on the floor. */
export function dirtyBedroom(): void {
warpToRoomType(RoomType.DIRTY_BEDROOM);
}
/** Toggles whether curses can appear. */
export function disableCurses(): void {
v.persistent.disableCurses = !v.persistent.disableCurses;
printEnabled(!v.persistent.disableCurses, "curses");
}
/** Warps to the Dogma Boss Room. */
export function dogma(): void {
setStage(LevelStage.HOME, StageType.WRATH_OF_THE_LAMB);
changeRoom(DOGMA_ROOM_GRID_INDEX);
}
/** Moves the player 0.5 units down. Provide a number to move a custom amount of units. */
export function down(params: string): void {
movePlayer(params, Direction.DOWN);
}
/** Warps to the Dungeon (i.e. the crawl space room) for the floor. */
export function dungeon(): void {
changeRoom(GridRoom.DUNGEON);
}
/** Logs the player's current temporary effects to the "log.txt" file. */
export function effects(): void {
const player = Isaac.GetPlayer();
logPlayerEffects(player);
print('Logged the player\'s effects to the "log.txt" file.');
}
/** Alias for the "iAmError" command. */
export function errorRoom(): void {
iAmErrorRoom();
}
/**
* Gives an eternal heart. Provide a number to give a custom amount of hearts. (You can use negative
* numbers to remove hearts.)
*/
export function eternalHearts(params: string): void {
addHeart(params, HealthType.ETERNAL);
}
/** Grants the maximum amount of blue flies to the player. */
export function flies(): void {
const player = Isaac.GetPlayer();
player.AddBlueFlies(MAX_NUM_FAMILIARS, player.Position, undefined);
}
/** Toggles flight for the player. */
export function flight(params: string): void {
const player = Isaac.GetPlayer();
v.persistent.flight = !v.persistent.flight;
// Optionally, allow the toggle to be overridden by a parameter.
if (params === "true") {
v.persistent.flight = true;
} else if (params === "false") {
v.persistent.flight = false;
}
player.AddCacheFlags(CacheFlag.FLYING);
player.EvaluateItems();
const collectibleUsedToShowFlight = CollectibleType.FATE;
if (v.persistent.flight) {
addCollectibleCostume(player, collectibleUsedToShowFlight);
} else {
removeCollectibleCostume(player, collectibleUsedToShowFlight);
}
printEnabled(v.persistent.flight, "flight");
}
/** Alias for the "startingRoom" command. */
export function fool(): void {
startingRoom();
}
/** Displays the current challenge, if any. */
export function getChallenge(): void {
const challenge = Isaac.GetChallenge();
const challengeName = Challenge[challenge];
const challengeDescription =
// Handle modded challenges.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
challengeName === undefined
? `${challenge} (custom)`
: `Challenge.${challengeName} (${challenge})`;
print(`The current challenge is: ${challengeDescription}`);
}
/** Prints the charge for the specified slot. By default, will use `ActiveSlot.PRIMARY`. */
export function getCharge(params: string): void {
let activeSlot = ActiveSlot.PRIMARY;
if (params !== "") {
const num = parseIntSafe(params);
if (num === undefined || !isEnumValue(num, ActiveSlot)) {
print(`Invalid slot number: ${params}`);
return;
}
activeSlot = num;
}
const player = Isaac.GetPlayer();
const totalCharge = getTotalCharge(player, activeSlot);
print(
`Total charge for ActiveSlot.${ActiveSlot[activeSlot]} (${activeSlot}) is: ${totalCharge}`,
);
}
/** Prints the current position of all players. */
export function getPosition(): void {
for (const player of getPlayers()) {
const playerName = getPlayerName(player);
print(
`Player position for ${playerName}: (${player.Position.X}, ${player.Position.Y})`,
);
}
}
/** Toggles permanent Curse of the Giant. */
export function giant(): void {
v.persistent.giant = !v.persistent.giant;
printEnabled(v.persistent.giant, "permanent Curse of the Giant");
}
/**
* Gives a Giga Bomb. Provide a number to give a custom amount of Giga Bombs. (You can use negative
* numbers to remove bombs.)
*/
export function gigaBomb(params: string): void {
let numBombs = 1;
if (params !== "") {
const num = parseIntSafe(params);
if (num === undefined) {
print(`Invalid Giga Bomb amount: ${num}`);
return;
}
numBombs = num;
}
const player = Isaac.GetPlayer();
player.AddGigaBombs(numBombs);
}
/** Alias for the "goldenBomb" command. */
export function goldBomb(): void {
goldenBomb();
}
/** Alias for the "goldenHearts" command. */
export function goldHearts(params: string): void {
goldenHearts(params);
}
/** Alias for the "goldenKey" command. */
export function goldKey(): void {
goldenKey();
}
/** Alias for the "goldenPill" command. */
export function goldPill(): void {
goldenPill();
}
/** Alias for the "spawnGoldenTrinket" command. */
export function goldTrinket(params: string): void {
spawnGoldenTrinket(params);
}
/** Gives the player a golden bomb. */
export function goldenBomb(): void {
const player = Isaac.GetPlayer();
player.AddGoldenBomb();
}
/**
* Gives a golden heart. Provide a number to give a custom amount of hearts. (You can use negative
* numbers to remove hearts.)
*/
export function goldenHearts(params: string): void {
addHeart(params, HealthType.GOLDEN);
}
/** Gives the player a golden key. */
export function goldenKey(): void {
const player = Isaac.GetPlayer();
player.AddGoldenKey();
}
/** Gives the player a golden pill. */
export function goldenPill(): void {
const player = Isaac.GetPlayer();
player.AddPill(PillColor.GOLD);
}
/** Alias for the "spawnGoldenTrinket" command. */
export function goldenTrinket(params: string): void {
spawnGoldenTrinket(params);
}
/**
* Alias for the "debug 11" command. Useful for seeing the coordinates and grid index of each tile
* in the room.
*/
export function grid(): void {
Isaac.ExecuteCommand("debug 11");
}
/** Alias for the "gridCosts" command. */
export function grid2(): void {
gridCosts();
}
/** Alias for the "debug 2" command. Useful for seeing the grid costs of each tile in the room. */
export function gridCosts(): void {
Isaac.ExecuteCommand("debug 2");
}
/** Spawns every grid entity, starting at the top-left-most tile. */
export function gridEntities(): void {
let gridEntityTypeIndex = -1;
for (let y = 0; y <= 6; y++) {
for (let x = 0; x <= 12; x++) {
gridEntityTypeIndex++;
const gridEntityType = GRID_ENTITY_TYPE_VALUES[gridEntityTypeIndex];
if (gridEntityType === undefined) {
return;
}
const worldPosition = gridCoordinatesToWorldPosition(x, y);
spawnGridEntity(gridEntityType, worldPosition);
}
}
}
/**
* Gives a half red heart. Provide a number to give a custom amount of hearts. (You can use negative
* numbers to remove hearts.)
*/
export function hearts(params: string): void {
addHeart(params, HealthType.RED);
}
/** Alias for the "debug 6" command. */
export function hitboxes(): void {
Isaac.ExecuteCommand("debug 6");
}
/** The same thing as the `pill` command, but gives a horse pill instead of a normal pill. */
export function horse(params: string): void {
pill(params, true);
}
/** Warps to the Blue Womb Boss Room. */
export function hush(): void {
setStage(LevelStage.BLUE_WOMB, StageType.ORIGINAL);
bossRoom();
}
/** Warps to the I AM ERROR room for the floor. */
export function iAmErrorRoom(): void {
changeRoom(GridRoom.ERROR);
}
/**
* Gives a key. Provide a number to give a custom amount of key. (You can use negative numbers to
* remove keys.)
*/
export function key(params: string): void {
let numKeys = 1;
if (params !== "") {
const num = parseIntSafe(params);
if (num === undefined) {
print(`Invalid key amount: ${num}`);
return;
}
numKeys = num;
}
const player = Isaac.GetPlayer();
player.AddKeys(numKeys);
}
/**
* Gives 99 keys. Provide a number to give a custom amount of coins. (You can use negative numbers
* to remove keys.)
*/
export function keys(params: string): void {
let numKeys = 99;
if (params !== "") {
const num = parseIntSafe(params);
if (num === undefined) {
print(`Invalid key amount: ${num}`);
return;
}
numKeys = num;
}
const player = Isaac.GetPlayer();
player.AddKeys(numKeys);
}
/** Toggles permanent Curse of the Labyrinth. */
export function labyrinth(): void {
v.persistent.labyrinth = !v.persistent.labyrinth;
printEnabled(v.persistent.labyrinth, "permanent Curse of the Labyrinth");
}
/** Moves the player 0.5 units left. Provide a number to move a custom amount of units. */
export function left(params: string): void {
movePlayer(params, Direction.LEFT);
}
/** Warps to the first Library on the floor. */
export function library(): void {
warpToRoomType(RoomType.LIBRARY);
}
/**
* Logs the entities in the room to the "log.txt" file. Provide a number to only log that specific
* `EntityType`.
*
* By default, this command will exclude background effects. If that is not desired, use the
* "listAll" command instead.
*/
export function list(params: string): void {
listEntities(params, false);
}
/**
* Logs the entities in the room to the "log.txt" file. Provide a number to only log that specific
* `EntityType`.
*/
export function listAll(params: string): void {
listEntities(params, true);
}
/**
* Logs the grid entities in the room to the "log.txt" file. Provide a number to only log that
* specific `GridEntityType`.
*
* By default, this command will exclude walls. If that is not desired, use the "listGridAll"
* command instead.
*/
export function listGrid(params: string): void {
listGridEntities(params, false);
}
/**
* Logs the grid entities in the room to the "log.txt" file. Provide a number to only log that
* specific `GridEntityType`.
*/
export function listGridAll(params: string): void {
listGridEntities(params, true);
}
/** Toggles permanent Curse of the Lost. */
export function lost(): void {
v.persistent.lost = !v.persistent.lost;
printEnabled(v.persistent.lost, "permanent Curse of the Lost");
}
/** Alias for the "1hp" command. */
export function lowHP(): void {
oneHP();
}
/** Alias for "debug 9". */
export function luck(): void {
Isaac.ExecuteCommand("debug 9");
}
/** Alias for the "poopMana" command. */
export function mana(params: string): void {
poopMana(params);
}
/** Completely reveals the entire map, including the Ultra Secret Room. */
export function map(): void {
const level = game.GetLevel();
const displayFlags = addFlag(
DisplayFlag.VISIBLE, // 1 << 0
DisplayFlag.SHADOW, // 1 << 1
DisplayFlag.SHOW_ICON, // 1 << 2
);
for (const roomGridIndex of iRange(MAX_LEVEL_GRID_INDEX)) {