-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDebugScripts.lua
More file actions
1215 lines (1049 loc) · 37.6 KB
/
Copy pathDebugScripts.lua
File metadata and controls
1215 lines (1049 loc) · 37.6 KB
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
--[[ * DEBUG SCRIPTS ]]
-- Camera Unleash
OnKeyPressed{ "ControlShift K", Name = "CameraUnleash",
function( triggerArgs )
ClearCameraClamp({ })
ClearCameraRail({ })
LockCamera({ Id = CurrentRun.Hero.ObjectId, Duration = 2.0 })
end
}
-- UI / ART CHEATS
OnKeyPressed{ "ControlShift L", Name = "LoadCheckpoint", Safe = true,
function( triggerArgs )
DebugPrint({ Text = "Game Loading" })
LoadCheckpoint({ })
DebugPrint({ Text = "Game Loaded" })
end
}
OnKeyPressed{ "ControlShift X", Name = "DamageActiveUnit",
function( triggerArgs )
SacrificeHealth({ SacrificeHealthMin = 45, SacrificeHealthMax = 45, MinHealth = 1 })
end
}
OnKeyPressed{ "Alt W", Name = "Create Weapon loot",
function( triggerArgs )
CreateWeaponLoot()
end
}
OnKeyPressed{ "Alt L", Name = "OpenUpgradeChoiceMenu",
function( triggerArgs )
CreateStackLoot()
end
}
OnKeyPressed{ "Control X", Name = "DestroyActiveUnit",
function( triggerArgs )
Kill( CurrentRun.Hero, triggerArgs )
end
}
OnKeyPressed{ "Control T", Name = "ToggleUI",
function( triggerArgs )
if ConfigOptionCache.ShowUIAnimations then
SetConfigOption({ Name = "ShowUIAnimations", Value = false })
SetConfigOption({ Name = "UseOcclusion", Value = false })
HideCombatUI()
else
SetConfigOption({ Name = "ShowUIAnimations", Value = true })
SetConfigOption({ Name = "UseOcclusion", Value = true })
ShowCombatUI()
end
UpdateConfigOptionCache()
end
}
function ToggleConfigOption( name )
if GetConfigOptionValue({ Name = name }) then
SetConfigOption({ Name = name, Value = false })
else
SetConfigOption({ Name = name, Value = true })
end
DebugPrint({ Text = name.." = "..tostring(GetConfigOptionValue({ Name = name })) })
end
function ToggleDebugScreen( screenName )
if GetTopScreenName({ }) == screenName then
ExitMenu({ Name = screenName })
else
if DebugScreenOpen ~= nil then
ExitMenu({ Name = DebugScreenOpen })
DebugScreenOpen = nil
end
OpenMenu({ Name = screenName, PopExistingToFront = true })
DebugScreenOpen = screenName
end
end
OnKeyPressed{ "ControlShift P", Name = "Toggle AutoPlay",
function( triggerArgs )
if GetConfigOptionValue({ Name = "FastForward" }) then
AutoPlayOff()
else
AutoPlayOn()
end
end
}
OnKeyPressed{ "ControlAltShift P", Name = "Toggle AutoPlay Invulnerable",
function( triggerArgs )
if GetConfigOptionValue({ Name = "FastForward" }) then
AutoPlayOff()
BlockHeroDeath = nil
else
AutoPlayOn()
BlockHeroDeath = true
end
end
}
function AutoPlayOn()
SetConfigOption({ Name = "FastForward", Value = true })
SetConfigOption({ Name = "RequireFocusToUpdate", Value = false })
SetConfigOption({ Name = "UseMouse", Value = false })
end
function AutoPlayOff()
SetConfigOption({ Name = "FastForward", Value = false })
SetConfigOption({ Name = "RequireFocusToUpdate", Value = true })
end
OnAnyLoad
{
function( triggerArgs )
HotLoadInfo = HotLoadInfo or {}
end
}
function ValidateIds( ids )
if ids ~= nil then
for _, id in pairs(ids) do
assert( IdExists({ Id = id }), "Missing id: "..id )
end
end
end
-- Minos Keys
OnKeyPressed{ "ControlShift W", Name = "Grant Upgrade",
function( triggerArgs )
AddMoney( 9000, "GrantUpgrade" )
LiveFillInShopOptions()
StartUpStore()
end
}
function LiveFillInShopOptions()
CurrentRun.CurrentRoom.Store = FillInShopOptions( { StoreData = StoreData.RoomShop , RoomName = CurrentRun.CurrentRoom.Name } )
end
--ForceEvent = "OlympianReunionQuestComplete"
function ForcePlayTextLines( source, textLinesName )
local possibleSets =
{
"OnUsedTextLineSets", "InteractTextLineSets", "RepeatableTextLineSets",
"PriorityPickupTextLineSets", "PickupTextLineSets", "RejectionTextLines", "MakeUpTextLines", "BoughtTextLines", "GiftTextLineSets",
"BossPresentationIntroTextLineSets", "BossPresentationTextLineSets", "BossPresentationRepeatableTextLineSets",
}
for k, possibleSet in pairs( possibleSets ) do
local set = source[possibleSet]
if set ~= nil then
local event = set[textLinesName]
if event ~= nil then
event.Force = true
PlayTextLines( source, event )
event.Force = false
return true
end
end
end
return false
end
OnKeyPressed{ "Control N", Name = "Force Next Room & Encounter",
function( triggerArgs )
ForceNextRoom = "B_MiniBoss02"
-- Stomp any rooms already assigned to doors
for doorId, door in pairs( OfferedExitDoors ) do
local room = door.Room
if room ~= nil then
ForceNextEncounter = "MiniBossSpreadShot"
if ForceNextRoom ~= nil then
DebugPrint({ Text = "ForceNextRoom = "..tostring(ForceNextRoom) })
end
local forcedRoomData = RoomData[ForceNextRoom]
local forcedRoom = CreateRoom( forcedRoomData )
AssignRoomToExitDoor( door, forcedRoom )
end
end
end
}
function SpawnDummyEnemy( args )
if args == nil then
args = {}
end
if args.Name == nil then
args.Name = "HeavyMelee"
end
local enemyData = EnemyData[args.Name]
--local enemyData = EnemyData.HeavyRanged
local newEnemy = DeepCopyTable( enemyData )
if not args.Active then
newEnemy.DisableAIWhenReady = true
end
if args.HealthBuffer ~= nil then
newEnemy.HealthBuffer = args.HealthBuffer
end
newEnemy.BlocksLootInteraction = false
local invaderSpawnPoint = 40000
newEnemy.ObjectId = SpawnUnit({
Name = enemyData.Name,
Group = "Standing",
DestinationId = invaderSpawnPoint, OffsetX = 100, OffsetY = 100 })
SetupEnemyObject( newEnemy, CurrentRun )
if args.Health ~= nil then
newEnemy.MaxHealth = args.Health
newEnemy.Health = args.Health
end
return newEnemy
end
OnKeyPressed{ "ControlShift S", Name = "Fill Super Meter", Safe = true,
function( triggerArgs )
BuildSuperMeter( CurrentRun, 100 )
end
}
OnKeyPressed{ "Shift X", Name = "Spawn God Boon",
function(triggerArgs)
--local debugBoons = {GetRandomValue(GetEligibleLootNames())}
local debugBoons = { "DionysusUpgrade" }
for k, debugBoon in pairs( debugBoons ) do
CreateLoot({ Name = debugBoon, OffsetX = k * 100 })
end
wait(2)
local numDummies = 1
for dummy = 1, numDummies, 1 do
--SpawnDummyEnemy()
end
end
}
OnKeyPressed{ "Alt X", Name = "Spawn MetaUpgrade",
function(triggerArgs)
local debugBoon = "HealthMetaUpgrade"
--local debugBoon = GetRandomKey( MetaUpgradeData )
local lootData = MetaUpgradeData[debugBoon]
local lootArea = GetIdsByType({ Name = "LootPoint" })
local lootId = nil
if lootArea ~= nil then
lootId = SpawnObstacle({ Name = debugBoon, DestinationId = lootArea[1], Group = "MetaUpgrades" })
end
AddResource( "MetaPoints", 100, "Debug" )
wait(2)
SpawnDummyEnemy()
SpawnDummyEnemy()
SpawnDummyEnemy()
SpawnDummyEnemy()
end
}
OnKeyPressed{ "Alt A", Name = "Spawn Ammo",
function(triggerArgs)
local consumableName = "ChaosWeaponUpgrade"
local playerId = GetIdsByType({ Name = "_PlayerUnit" })
local consumableId = SpawnObstacle({ Name = consumableName, DestinationId = playerId, Group = "Standing" })
local consumable = CreateConsumableItem( consumableId, consumableName, 0 )
end
}
OnKeyPressed{ "Alt H", Name = "Spawn Health", Safe = true,
function(triggerArgs)
local playerId = GetIdsByType({ Name = "_PlayerUnit" })
DropHealth( "HealDropMinor", playerId )
end
}
OnKeyPressed{ "Alt R", Name = "Add Rerolls", Safe = true,
function(triggerArgs)
if CurrentRun ~= nil then
AddRerolls( 99, "Debug", { IgnoreMetaUpgrades = true } )
end
end
}
OnKeyPressed{ "Alt M", Name = "Spawn Money", Safe = true,
function(triggerArgs)
thread( GushMoney, { Amount = 50, LocationId = CurrentRun.Hero.ObjectId, Radius = 100, Source = "DebugSpawnMoney" } )
end
}
OnKeyPressed{ "ControlShift G", Name = "Max All Gifts",
function(triggerArgs)
CurrentRun.DebugUnlockGifts = true
for npcName, npcData in pairs(GiftData) do
if true then
IncrementGiftMeter( npcName, GetMaxGiftLevel(npcName))
if GameState.Gift[npcName].NewTraits == nil then
GameState.Gift[npcName].NewTraits = {}
end
for i, data in pairs(npcData) do
if type(data) == "table" and data.Gift ~= nil then
local traitName = data.Gift
table.insert( GameState.Gift[npcName].NewTraits, traitName )
end
end
end
end
end
}
OnKeyPressed{ "ControlAltShift C", Name = "Fully Unlock GhostAdmin",
function(triggerArgs)
for cosmeticName, cosmeticData in pairs( ConditionalItemData ) do
cosmeticData.GameStateRequirements = nil
end
for trackName, trackData in pairs( MusicPlayerTrackData ) do
trackData.GameStateRequirements = nil
end
end
}
OnKeyPressed{ "ControlAltShift R", Name = "Randomize Gift Status",
function(triggerArgs)
CurrentRun.DebugUnlockGifts = true
for npcName, npcData in pairs(GiftData) do
if RandomChance(0.8) then
IncrementGiftMeter( npcName, GetMaxGiftLevel(npcName))
if GameState.Gift[npcName].NewTraits == nil then
GameState.Gift[npcName].NewTraits = {}
end
for i, data in pairs(npcData) do
if type(data) == "table" and data.Gift ~= nil then
local traitName = data.Gift
table.insert( GameState.Gift[npcName].NewTraits, traitName )
if CoinFlip() then
GameState.KeepsakeChambers[traitName] = TraitData[traitName].ChamberThresholds[2]
else
GameState.KeepsakeChambers[traitName] = RandomInt(1, TraitData[traitName].ChamberThresholds[2])
end
end
end
end
end
end
}
OnKeyPressed{ "Alt D", Name = "Spawn Dummy",
function(triggerArgs)
ConfigOptionCache.LogCombatMultipliers = true
--local enemy = SpawnDummyEnemy({ Name = "HydraHeadLavamaker", Health = 1400, HealthBuffer = 0, Active = false })
local enemy = SpawnDummyEnemy({ Name = "PunchingBagUnit", Health = 10, HealthBuffer = 0, Active = false })
--enemy.WeaponOptions = { "HadesCast"}
end
}
OnKeyPressed{ "ControlShift Y", Name = "Show RunClearScreen",
function(triggerArgs)
local traits = {
"SpearThrowBounce",
"ZeusWeaponTrait",
"ZeusWeaponTrait",
"ZeusWeaponTrait",
"ZeusSecondaryTrait",
"ZeusRangedTrait",
"ZeusRangedTrait",
"ZeusRangedTrait",
"ZeusRushTrait",
"ZeusShoutTrait",
"ZeusShoutTrait",
"ZeusShoutTrait",
"ArtemisSupportingFireTrait",
"ArtemisSupportingFireTrait",
"ArtemisSupportingFireTrait",
"CritVulnerabilityTrait",
"ArtemisCriticalTrait",
}
for i, name in pairs(traits) do
AddTraitToHero({TraitData = GetProcessedTraitData({ Unit = CurrentRun.Hero, TraitName = name, Rarity = "Common"}) })
end
AddLastStand({
Name = "ReincarnationTrait",
InsertAtEnd = true,
IncreaseMax = true,
Icon = "ExtraLifeSkelly",
WeaponName = "LastStandReincarnateShield",
HealAmount = GetTotalHeroTraitValue( "KeepsakeLastStandHealAmount" ),
})
AddLastStand({
Name = "ReincarnationTrait",
InsertAtEnd = true,
IncreaseMax = true,
Icon = "ExtraLifeSkelly",
WeaponName = "LastStandReincarnateShield",
HealAmount = GetTotalHeroTraitValue( "KeepsakeLastStandHealAmount" ),
})
AddLastStand({
Name = "ReincarnationTrait",
InsertAtEnd = true,
IncreaseMax = true,
Icon = "ExtraLifeSkelly",
WeaponName = "LastStandReincarnateShield",
HealAmount = GetTotalHeroTraitValue( "KeepsakeLastStandHealAmount" ),
})
ShowRunClearScreen()
end
}
OnKeyPressed{ "Alt Y", Name = "LogCombatMultipliers",
function(triggerArgs)
ConfigOptionCache.LogCombatMultipliers = not ConfigOptionCache.LogCombatMultipliers
end
}
OnKeyPressed{ "ControlAlt R", Name = "Reload All Traits",
function(triggerArgs)
ReloadAllTraits()
end
}
OnKeyPressed{ "Alt T", Name = "Add Traits",
function(triggerArgs)
-- EquipPlayerWeapon( WeaponData.FistWeapon )
local traits = {
"SpearThrowBounce",
}
for i, name in pairs(traits) do
AddTraitToHero({TraitData = GetProcessedTraitData({ Unit = CurrentRun.Hero, TraitName = name, Rarity = "Common"}) })
end
end
}
OnKeyPressed{ "ControlAlt C", Name = "Credits Test",
function(triggerArgs)
AddInputBlock({ Name = "Credits Test" })
StartCredits( "Return02" )
RemoveInputBlock({ Name = "Credits Test" })
end
}
OnKeyPressed{ "ControlShift F", Name = "Full Wrath & Trait",
function(triggerArgs)
for i, traitData in pairs(CurrentRun.Hero.Traits ) do
if traitData.Slot == "Shout" or traitData.AltSlot == "Shout" then
BuildSuperMeter( CurrentRun, 25)
return
end
end
AddTraitToHero({TraitData = GetProcessedTraitData({ Unit = CurrentRun.Hero, TraitName = "ZeusShoutTrait", Rarity = "Epic"}) })
-- BuildSuperMeter( CurrentRun, 100)
end
}
OnKeyPressed{ "Alt K", Name = "Kill Required Kills",
function(triggerArgs)
DestroyRequiredKills()
end
}
OnKeyPressed{ "Alt I", Name = "Display Run Info",
function(triggerArgs)
DebugPrint({ Text = "Run #: "..GetCompletedRuns() })
DebugPrint({ Text = "Depth: "..GetRunDepth( CurrentRun ) })
DebugPrint({ Text = "Encounter: "..CurrentRun.CurrentRoom.Encounter.Name })
end
}
OnKeyPressed{ "Control M", Name = "Add Resources", Safe = true,
function( triggerArgs )
AddResource( "MetaPoints", 99999, "Debug" )
AddResource( "Gems", 9999, "Debug" )
AddResource( "LockKeys", 999, "Debug" )
AddResource( "GiftPoints", 9999, "Debug" )
AddResource( "SuperLockKeys", 99, "Debug" )
AddResource( "SuperGems", 99, "Debug" )
AddResource( "SuperGiftPoints", 99, "Debug" )
PlaySound({ Name = "/Leftovers/Menu Sounds/EmoteExcitement" })
thread( PlayVoiceLines, GlobalVoiceLines.FabulousWealthVoiceLines, true )
end
}
OnKeyPressed{ "ControlAlt F", Name = "Add Fish", Safe = true,
function( triggerArgs )
RecordFish(GetFish("Tartarus", "Good"))
PlaySound({ Name = "/Leftovers/Menu Sounds/EmoteExcitement" })
thread( PlayVoiceLines, GlobalVoiceLines.FabulousWealthVoiceLines, true )
end
}
OnKeyPressed{ "ControlAlt L", Name = "Open MetaUpgradeMenu",
function( triggerArgs )
GameState.Flags.SwapMetaupgradesEnabled = true
GameState.Flags.SwapMetaupgradesEnabledPresentation = true
GameState.MetaUpgradeStagesUnlocked = 5
OpenMetaUpgradeMenu()
end
}
OnKeyPressed{ "ControlAlt S", Name = "Open ShrineUpgradeMenu",
function( triggerArgs )
GameState.WeaponRecordsShrinePoints = {}
GameState.RecordClearedShrineThreshold = {}
for i, weaponName in ipairs( WeaponSets.HeroPhysicalWeapons ) do
GameState.WeaponRecordsShrinePoints[weaponName] = 1000 - ShrineClearData.ClearThreshold
GameState.RecordClearedShrineThreshold[weaponName] = {}
for s, roomName in pairs(ShrineClearData.BossRoomNames) do
GameState.RecordClearedShrineThreshold[weaponName][roomName] = 1000 - ShrineClearData.ClearThreshold
end
end
OpenShrineUpgradeMenu({ BlockRunStartButton = true, IgnoreRequirements = true })
end
}
function CreateDevSaveName( currentRun, args )
-- Only legal Windows file path characters allowed
-- Ordering is now such that sorting by name sorts by 'deepest' saves
local name = ""
name = name.."Run "..(GetCompletedRuns() + 1)..", "
if args ~= nil and args.StartNextMap ~= nil then
name = name.."Dead, "..args.StartNextMap
else
name = name.."Depth "..GetRunDepth( currentRun )..", "
name = name..currentRun.CurrentRoom.Name..", "
name = name..currentRun.CurrentRoom.Encounter.Name
if args ~= nil and args.PostReward then
name = name.." (PostReward)"
elseif currentRun.CurrentRoom.ChosenRewardType ~= nil then
name = name.." ("..currentRun.CurrentRoom.ChosenRewardType
if currentRun.CurrentRoom.ForceLootName ~= nil then
name = name.." - "..currentRun.CurrentRoom.ForceLootName
end
name = name..")"
end
end
return name
end
function EquipDebugWeapons( newEnemy )
local debugContinuousWeapon = "DionysusEnemyWeapon"
EquipWeapon({ Name = debugContinuousWeapon, DestinationId = newEnemy.ObjectId })
SetUnitProperty({ Property = "ContinuousWeapon", Value = debugContinuousWeapon, DestinationId = newEnemy.ObjectId })
end
function OnHotLoadXML()
thread( PostHotloadXML )
end
function PostHotloadXML()
if CurrentRun ~= nil then
SetHeroProperties( CurrentRun )
HideCombatUI()
ShowCombatUI()
end
end
function OnHotLoadLua()
if SetupRunData ~= nil then
SetupRunData()
end
if HotLoadInfo ~= nil then
if HotLoadInfo.CurrentTextLines ~= nil then
HotLoadInfo.CurrentTextLines = TextLinesCache[HotLoadInfo.CurrentTextLines.Name]
end
if HotLoadInfo.TextBoxCache ~= nil then
for id, formatName in pairs( HotLoadInfo.TextBoxCache ) do
local params = ShallowCopyTable( TextFormats[formatName] )
params.Id = id
params.AutoSetDataProperties = true
ModifyTextBox( params )
end
end
end
end
OnKeyPressed{ "ControlShift C", Name = "UnlockEntireCodex",
function(triggerArgs)
UnlockEntireCodex()
thread( ShowCodexUpdate )
end
}
function UnlockEntireCodex()
CodexStatus.Enabled = true
local num = 10
for chapterName, chapterData in pairs(Codex) do
if chapterData.Entries ~= nil then
for entryName, entryData in pairs(chapterData.Entries) do
for i = 1, num do
UnlockCodexEntry(chapterName, entryName, i, true )
end
end
end
end
end
function GetRewardsTaken( room, rewardsTakenTotals )
if room.ChosenRewardType ~= nil then
if rewardsTakenTotals[room.ChosenRewardType] == nil then
rewardsTakenTotals[room.ChosenRewardType] = 0
end
rewardsTakenTotals[room.ChosenRewardType] = rewardsTakenTotals[room.ChosenRewardType] + 1
-- Track boons individually as well, whereas "Boon" is the sum of all boons
--if room.ChosenRewardType == "Boon" and room.ForceLootName ~= nil then
--rewardsTakenTotals[room.ForceLootName] = (rewardsTakenTotals[room.ForceLootName] or 0) + 1
--end
end
if room.ChosenRewardType == "Boon" and room.ForceLootName ~= nil then
return tostring(room.ForceLootName)
else
return tostring(room.ChosenRewardType)
end
end
function GetRewardsOffered( room, rewardsOfferedTotals, sep )
local rewardsOfferedStr = nil
if sep == nil then
sep = ", "
end
if room.OfferedRewards ~= nil then
for doorId, offeredReward in pairs( room.OfferedRewards ) do
local rewardType = offeredReward.Type
if rewardType ~= nil then
if rewardsOfferedStr == nil then
rewardsOfferedStr = rewardType
else
rewardsOfferedStr = rewardsOfferedStr..sep..rewardType
end
if OfferedExitDoors[doorId] ~= nil and OfferedExitDoors[doorId].Room ~= nil then
rewardsOfferedStr = rewardsOfferedStr.." ("..OfferedExitDoors[doorId].Room.Name..")"
end
rewardsOfferedTotals[rewardType] = (rewardsOfferedTotals[rewardType] or 0) + 1
end
end
end
return tostring(rewardsOfferedStr)
end
OnKeyPressed{ "ControlAlt G", Name = "DumpGameStateStats", Safe = true,
function(triggerArgs)
DumpGameStateStats()
end
}
OnKeyPressed{ "ControlShift CapsLock", Name = "DumpGameStateToFile",
function(triggerArgs)
DumpGameStateToFile()
end
}
function DumpGameStateStats()
local runs = TableLength( GameState.RunHistory ) + 1
DebugPrint({ Text = "GameState:" })
DebugPrint({ Text = " Runs: "..runs })
DebugPrint({ Text = " Collected MetaPoints: "..GetTotalAccumulatedMetaPoints() })
DebugPrint({ Text = " Spent MetaPoints: "..GetTotalAccumulatedMetaPoints() - GameState.Resources.MetaPoints })
DebugPrint({ Text = " Damage Dealers: " })
for name, count in pairs( GameState.EnemySpawns ) do
if GameState.EnemyDamage[name] ~= nil then
DebugPrint({ Text = " Name: "..name..", Spawns: "..count..", Kills: "..tostring(GameState.EnemyKills[name]).." Damage: "..tostring(GameState.EnemyDamage[name]) })
end
end
DumpRunStats( CurrentRun, runs )
end
function DumpGameStateToFile()
local gameData =
{
CurrentRun = CurrentRun,
GameState =
{
MetaPoints = GameState.Resources.MetaPoints,
MetaUpgrades = GameState.MetaUpgrades,
LockKeys = GameState.Resources.LockKeys,
GiftPoints = GameState.Resources.GiftPoints,
ShrinePoints = GameState.Resources.ShrinePoints,
SpentShrinePointsCache = GameState.SpentShrinePointsCache,
TimesCleared = GameState.TimesCleared,
CompletedRunsCache = GameState.CompletedRunsCache,
}
}
local json = TableToJSONString(gameData, {}, "GameData")
DebugPrint({ File = "GameData.json", Text = json })
end
function DumpRunHistoryStats()
local runs = TableLength( GameState.RunHistory ) + 1
local outFileBuf = ""
outFileBuf = DebugPrintf({ File = outFileBuf, Text = "GameState:" })
outFileBuf = DebugPrintf({ File = outFileBuf, Text = " Runs: "..runs })
outFileBuf = DebugPrintf({ File = outFileBuf, Text = " Collected MetaPoints: "..GetTotalAccumulatedMetaPoints() })
outFileBuf = DebugPrintf({ File = outFileBuf, Text = " Spent MetaPoints: "..GetTotalAccumulatedMetaPoints() - GameState.Resources.MetaPoints })
-- Full room history of all runs
local gameStatsCsvBuf = DebugWriteCsvRow("", { "Room", "Depth", "Chosen Reward", "Reward Taken", "Next Rewards Offered" })
local csvFile = "GameStatsDump.csv"
local rewardsOfferedTotals = {}
local rewardsTakenTotals = {}
local roomDists = {}
local runDepthHistogram = {}
local runsSampled = 0
local allRunHistory = CollapseTableOrdered( GameState.RunHistory )
table.insert(allRunHistory, CurrentRun)
if runs > 1 then
for runIndex, run in pairs(allRunHistory) do
outFileBuf = DumpRunStats( run, runIndex, outFileBuf )
if run.RoomHistory ~= nil then
for depth, room in ipairs(run.RoomHistory) do
if room ~= nil then
local row = {}
-- Track room distributions
if roomDists[room.Name] == nil then
roomDists[room.Name] = { 1 }
else
roomDists[room.Name] = { roomDists[room.Name][1] + 1 }
end
table.insert(row, room.Name)
table.insert(row, depth)
table.insert(row, room.ChosenRewardType)
table.insert(row, GetRewardsTaken(room, rewardsTakenTotals))
table.insert(row, '"'..GetRewardsOffered(room, rewardsOfferedTotals)..'"')
gameStatsCsvBuf = DebugWriteCsvRow(gameStatsCsvBuf, row)
end
end
local depth = GetRunDepth(run)
runDepthHistogram[depth] = (runDepthHistogram[depth] or 0) + 1
runsSampled = runsSampled + 1
end
end
--DebugPrint({ File = csvFile, Text = gameStatsCsvBuf })
--DebugPrint({ File = "RunHistoryFullDump.txt", Text = outFileBuf })
end
-- RunDepthHistogram.csv
-- We want this sorted by KEY, so use orderedPairs
local depthHistogramCsv = "RunDepthHistogram.csv"
local depthHistogramCsvBuf = DebugWriteCsvRow("", { "Depth", "# of runs at depth", "% of total runs sampled" })
for depth, instances in pairs(runDepthHistogram) do
local percentage = "0%"
if runsSampled > 0 then
percentage = tostring( instances / runsSampled * 100 ).."%"
end
depthHistogramCsvBuf = DebugWriteCsvRow(depthHistogramCsvBuf, { depth, instances, percentage })
end
--DebugPrint({ File = depthHistogramCsv, Text = depthHistogramCsvBuf })
-- Room.csv aggregation
local roomsCsv = "RoomDistributions.csv"
local roomsCsvBuf = DebugWriteCsvRow("", { "Room Name", "Times Seen", "% Seen" })
local totalRoomsSeen = 0
roomDists = CollapseTableAsOrderedKeyValuePairs( roomDists )
for i, kvp in ipairs(roomDists) do
local timesSeen = kvp.Value[1]
totalRoomsSeen = totalRoomsSeen + timesSeen
end
if totalRoomsSeen > 0 then
for i, kvp in ipairs(roomDists) do
local roomName = kvp.Key
local timesSeen = kvp.Value[1]
roomsCsvBuf = DebugWriteCsvRow(roomsCsvBuf, { kvp.Key, timesSeen, tostring(timesSeen / totalRoomsSeen * 100).."%" })
end
end
--DebugPrint({ File = roomCsv, Text = roomsCsvBuf })
-- Rewards taken/offered aggregation
rewardsTakenTotals = CollapseTableAsOrderedKeyValuePairs(rewardsTakenTotals)
rewardsOfferedTotals = CollapseTableAsOrderedKeyValuePairs(rewardsOfferedTotals)
local rewardsCsv = "RewardsData.csv"
local rewardsCsvBuf = ""
header = { "Reward Name", "Times Taken", "Times Offered", "% Taken", "% Offered" }
local rows = {}
local totalRewardsTaken = 0
local totalRewardsOffered = 0
for i, kvp in ipairs(rewardsOfferedTotals) do
local rewardName = kvp.Key
local timesTaken = 0
local timesOffered = kvp.Value
for j, takenKvp in ipairs(rewardsTakenTotals) do
if takenKvp.Key == rewardName then
timesTaken = takenKvp.Value
totalRewardsTaken = totalRewardsTaken + (timesTaken or 0)
end
end
totalRewardsOffered = totalRewardsOffered + (timesOffered or 0)
local row = { rewardName, timesTaken, timesOffered }
table.insert(rows, row)
end
table.sort(rows, function (a, b)
-- Sort by most taken, then by most offered
if a[2] > b[2] == 0 then
return a[3] > b[3]
end
return a[2] > b[2]
end)
if totalRewardsTaken > 0 then
rewardsCsvBuf = DebugWriteCsvRow(rewardsCsvBuf, header)
for i, row in ipairs(rows) do
table.insert(row, tostring(row[2] / totalRewardsTaken * 100).."%")
table.insert(row, tostring(row[3] / totalRewardsOffered * 100).."%")
rewardsCsvBuf = DebugWriteCsvRow(rewardsCsvBuf, row)
end
end
--DebugPrint({ File = rewardsCsv, Text = rewardsCsvBuf })
end
function DebugWriteCsvRow(buffer, row)
return DebugWriteLine(buffer, table.concat(row, ","))
end
function DebugWriteLine(buffer, appendString)
buffer = buffer..appendString.."\r\n"
return buffer
end
function DebugPrintf(args)
if args.File == nil then
DebugPrint(args)
else
return DebugWriteLine(args.File, args.Text)
end
end
function DumpRunStats( currentRun, runIndex, outFile )
if runIndex == nil then
runIndex = 1
end
if currentRun == nil then
return outFile
end
if currentRun.RoomHistory == nil then
return outFile
end
local runDepth = GetRunDepth(currentRun)
outFile = DebugPrintf({ File = outFile, Text = "Run #"..runIndex..":" })
outFile = DebugPrintf({ File = outFile, Text = " Collected Money: "..((currentRun.Money or 0) + (currentRun.MoneySpent or 0)) })
outFile = DebugPrintf({ File = outFile, Text = " Spent Money: "..(currentRun.MoneySpent or 0) })
outFile = DebugPrintf({ File = outFile, Text = " Money Sources: " })
if currentRun.MoneyRecord ~= nil then
for source, amount in pairs( currentRun.MoneyRecord ) do
outFile = DebugPrintf({ File = outFile, Text = " Source: "..source..", Amount: "..amount })
end
end
outFile = DebugPrintf({ File = outFile, Text = " Damage Sources: " })
if currentRun.DamageRecord ~= nil then
for source, amount in pairs( currentRun.DamageRecord ) do
outFile = DebugPrintf({ File = outFile, Text = " Source: "..source..", Amount: "..amount })
end
end
outFile = DebugPrintf({ File = outFile, Text = " Health Sources: " })
if currentRun.HealthRecord ~= nil then
for source, amount in pairs( currentRun.HealthRecord ) do
outFile = DebugPrintf({ File = outFile, Text = " Source: "..source..", Amount: "..amount })
end
end
outFile = DebugPrintf({ File = outFile, Text = " Actual Health Sources: " })
if currentRun.ActualHealthRecord then
for source, amount in pairs( currentRun.ActualHealthRecord ) do
outFile = DebugPrintf({ File = outFile, Text = " Source: "..source..", Amount: "..amount })
end
end
outFile = DebugPrintf({ File = outFile, Text = " Hero Traits (Depth "..runDepth.."):" })
if currentRun.Hero ~= nil and currentRun.Hero.Traits ~= nil then
local collapsedTraits = {}
local traitTxt = "traits_run "..runIndex.."_depth_"..runDepth..".txt"
local traitTxtBuf = ""
for k, traitData in pairs( currentRun.Hero.Traits ) do
collapsedTraits[traitData.Name] = traitData
if not currentRun.Hero.IsDead then
traitTxtBuf = DebugPrintf({ File = traitTxtBuf, Text = traitData.Name..", Depth: "..runDepth })
end
end
DebugPrint({ File = traitTxt, Text = traitTxtBuf })
collapsedTraits = CollapseTableOrdered(collapsedTraits)
-- No sense logging traits if the player is dead
if not currentRun.Hero.IsDead then
local traitsCsv = "Traits at Run "..runIndex..", Depth "..runDepth..".csv"
local traitsCsvBuf = DebugWriteCsvRow( "", { "Trait", "Level", "Rarity", "God", "RemainingUses", "RemainingRooms" })
local traitsCsvRows = {}
for k, traitData in ipairs( collapsedTraits ) do
local level = nil
if currentRun.Hero.TraitDictionary ~= nil then
level = TableLength( currentRun.Hero.TraitDictionary[traitData.Name] )
end
if level == nil then
level = 1
end
table.insert( traitsCsvRows, { traitData.Name, level, tostring(traitData.Rarity), tostring(traitData.God), tostring(traitData.RemainingUses), tostring(traitData.RemainingRooms) })
outFile = DebugPrintf({ File = outFile, Text = " Trait: "..traitData.Name.." ("..tostring(traitData.Rarity)..", level "..level..") God: "..tostring(traitData.God) })
end
-- Sort by most upgraded, then Rarity
table.sort(traitsCsvRows, function (a, b)
if a[2] == b[2] then
local rarityTable = {
Common = 0,
Rare = 1,
Epic = 2,
Legendary = 3
}
local aRarity = rarityTable[a[3]]
local bRarity = rarityTable[b[3]]
if aRarity == nil then
aRarity = -1
end
if bRarity == nil then
bRarity = -1
end
return aRarity > bRarity
end
return a[2] > b[2]
end)
for i, row in ipairs(traitsCsvRows) do
traitsCsvBuf = DebugWriteCsvRow( traitsCsvBuf, row )
end
DebugPrint({ File = traitsCsv, Text = traitsCsvBuf })
end
end
outFile = DebugPrintf({ File = outFile, Text = " Room History:" })
local rewardsOfferedTotals = {}
local rewardsTakenTotals = {}
for depth, room in ipairs( currentRun.RoomHistory ) do
if room ~= nil then
local rewardStr = GetRewardsTaken( room, rewardsTakenTotals )
local rewardsOfferedStr = GetRewardsOffered( room, rewardsOfferedTotals )
outFile = DebugPrintf({ File = outFile, Text = " Depth: "..depth.." | Room: "..room.Name.." | Reward: "..rewardStr.." | Next Rewards Offered: "..rewardsOfferedStr })
end
end
if currentRun.CurrentRoom ~= nil then
local rewardStr = GetRewardsTaken( currentRun.CurrentRoom, rewardsTakenTotals )
local rewardsOfferedStr = GetRewardsOffered( currentRun.CurrentRoom, rewardsOfferedTotals )
outFile = DebugPrintf({ File = outFile, Text = " Current Depth: "..runDepth.." | Room: "..currentRun.CurrentRoom.Name.." | Reward: "..rewardStr.." | Next Rewards Offered: "..rewardsOfferedStr })
else
outFile = DebugPrintf({ File = outFile, Text = " Current Depth: (DeathArea)"})
end
outFile = DebugPrintf({ File = outFile, Text = " Rewards Offered Totals:" })
for rewardType, rewardCount in pairs( rewardsOfferedTotals ) do
outFile = DebugPrintf({ File = outFile, Text = " "..rewardType..": "..rewardCount })
end
outFile = DebugPrintf({ File = outFile, Text = " Rewards Taken Totals:" })
for rewardType, rewardCount in pairs( rewardsTakenTotals ) do
outFile = DebugPrintf({ File = outFile, Text = " "..rewardType..": "..rewardCount })
end
if currentRun.RewardStores ~= nil then