-
Notifications
You must be signed in to change notification settings - Fork 324
/
DefaultCommands.cs
2834 lines (2469 loc) · 137 KB
/
DefaultCommands.cs
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
using UnityEngine;
using Wenzil.Console.Commands;
using DaggerfallWorkshop.Game;
using System.Linq;
using System;
using DaggerfallConnect.Arena2;
using System.Collections;
using System.Collections.Generic;
using DaggerfallWorkshop;
using DaggerfallWorkshop.Game.Entity;
using System.IO;
using DaggerfallWorkshop.Utility;
using DaggerfallWorkshop.Game.Items;
using DaggerfallWorkshop.Game.Weather;
using DaggerfallWorkshop.Game.Questing;
using DaggerfallWorkshop.Game.MagicAndEffects;
using DaggerfallWorkshop.Game.UserInterface;
using DaggerfallWorkshop.Game.UserInterfaceWindows;
using DaggerfallWorkshop.Game.Formulas;
using DaggerfallConnect;
using DaggerfallWorkshop.Game.Serialization;
using DaggerfallWorkshop.Utility.AssetInjection;
using DaggerfallConnect.FallExe;
using DaggerfallWorkshop.Game.Utility.ModSupport;
using DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings;
namespace Wenzil.Console
{
public class DefaultCommands : MonoBehaviour
{
public static bool showDebugStrings = false;
void Start()
{
ConsoleCommandsDatabase.RegisterCommand(QuitCommand.name, QuitCommand.description, QuitCommand.usage, QuitCommand.Execute);
ConsoleCommandsDatabase.RegisterCommand(HelpCommand.name, HelpCommand.description, HelpCommand.usage, HelpCommand.Execute);
ConsoleCommandsDatabase.RegisterCommand(LoadCommand.name, LoadCommand.description, LoadCommand.usage, LoadCommand.Execute);
ConsoleCommandsDatabase.RegisterCommand(GodCommand.name, GodCommand.description, GodCommand.usage, GodCommand.Execute);
ConsoleCommandsDatabase.RegisterCommand(NoClipCommand.name, NoClipCommand.description, NoClipCommand.usage, NoClipCommand.Execute);
ConsoleCommandsDatabase.RegisterCommand(NoTargetCommand.name, NoTargetCommand.description, NoTargetCommand.usage, NoTargetCommand.Execute);
ConsoleCommandsDatabase.RegisterCommand(ToggleAICommand.name, ToggleAICommand.description, ToggleAICommand.usage, ToggleAICommand.Execute);
ConsoleCommandsDatabase.RegisterCommand(CreateMobileCommand.name, CreateMobileCommand.description, CreateMobileCommand.usage, CreateMobileCommand.Execute);
ConsoleCommandsDatabase.RegisterCommand(Suicide.name, Suicide.description, Suicide.usage, Suicide.Execute);
ConsoleCommandsDatabase.RegisterCommand(ShowDebugStrings.name, ShowDebugStrings.description, ShowDebugStrings.usage, ShowDebugStrings.Execute);
ConsoleCommandsDatabase.RegisterCommand(SetWeather.name, SetWeather.description, SetWeather.usage, SetWeather.Execute);
ConsoleCommandsDatabase.RegisterCommand(TeleportToMapPixel.name, TeleportToMapPixel.description, TeleportToMapPixel.usage, TeleportToMapPixel.Execute);
ConsoleCommandsDatabase.RegisterCommand(TeleportToDungeonDoor.name, TeleportToDungeonDoor.description, TeleportToDungeonDoor.usage, TeleportToDungeonDoor.Execute);
ConsoleCommandsDatabase.RegisterCommand(TeleportToQuestSpawnMarker.name, TeleportToQuestSpawnMarker.description, TeleportToQuestSpawnMarker.usage, TeleportToQuestSpawnMarker.Execute);
ConsoleCommandsDatabase.RegisterCommand(TeleportToQuestItemMarker.name, TeleportToQuestItemMarker.description, TeleportToQuestItemMarker.usage, TeleportToQuestItemMarker.Execute);
ConsoleCommandsDatabase.RegisterCommand(TeleportToQuestMarker.name, TeleportToQuestMarker.description, TeleportToQuestMarker.usage, TeleportToQuestMarker.Execute);
ConsoleCommandsDatabase.RegisterCommand(GetAllQuestItems.name, GetAllQuestItems.description, GetAllQuestItems.usage, GetAllQuestItems.Execute);
ConsoleCommandsDatabase.RegisterCommand(EndDebugQuest.name, EndDebugQuest.description, EndDebugQuest.usage, EndDebugQuest.Execute);
ConsoleCommandsDatabase.RegisterCommand(EndQuest.name, EndQuest.description, EndQuest.usage, EndQuest.Execute);
ConsoleCommandsDatabase.RegisterCommand(PurgeAllQuests.name, PurgeAllQuests.description, PurgeAllQuests.usage, PurgeAllQuests.Execute);
ConsoleCommandsDatabase.RegisterCommand(PurgeNonStoryQuests.name, PurgeNonStoryQuests.description, PurgeNonStoryQuests.usage, PurgeNonStoryQuests.Execute);
ConsoleCommandsDatabase.RegisterCommand(ModNPCRep.name, ModNPCRep.description, ModNPCRep.usage, ModNPCRep.Execute);
ConsoleCommandsDatabase.RegisterCommand(SetLevel.name, SetLevel.description, SetLevel.usage, SetLevel.Execute);
ConsoleCommandsDatabase.RegisterCommand(Levitate.name, Levitate.description, Levitate.usage, Levitate.Execute);
ConsoleCommandsDatabase.RegisterCommand(OpenAllDoors.name, OpenAllDoors.description, OpenAllDoors.usage, OpenAllDoors.Execute);
ConsoleCommandsDatabase.RegisterCommand(OpenDoor.name, OpenDoor.description, OpenDoor.usage, OpenDoor.Execute);
ConsoleCommandsDatabase.RegisterCommand(ActivateAction.name, ActivateAction.description, ActivateAction.usage, ActivateAction.Execute);
ConsoleCommandsDatabase.RegisterCommand(KillAllEnemies.name, KillAllEnemies.description, KillAllEnemies.usage, KillAllEnemies.Execute);
ConsoleCommandsDatabase.RegisterCommand(TransitionToExterior.name, TransitionToExterior.description, TransitionToExterior.usage, TransitionToExterior.Execute);
ConsoleCommandsDatabase.RegisterCommand(SetHealth.name, SetHealth.description, SetHealth.usage, SetHealth.Execute);
ConsoleCommandsDatabase.RegisterCommand(RerollMaxHealth.name, RerollMaxHealth.description, RerollMaxHealth.usage, RerollMaxHealth.Execute);
ConsoleCommandsDatabase.RegisterCommand(ResetAssets.name, ResetAssets.description, ResetAssets.usage, ResetAssets.Execute);
ConsoleCommandsDatabase.RegisterCommand(RetryAssetImports.name, RetryAssetImports.description, RetryAssetImports.usage, RetryAssetImports.Execute);
ConsoleCommandsDatabase.RegisterCommand(SetWalkSpeed.name, SetWalkSpeed.description, SetWalkSpeed.usage, SetWalkSpeed.Execute);
ConsoleCommandsDatabase.RegisterCommand(SetMouseSensitivity.name, SetMouseSensitivity.description, SetMouseSensitivity.usage, SetMouseSensitivity.Execute);
ConsoleCommandsDatabase.RegisterCommand(ToggleMouseSmoothing.name, ToggleMouseSmoothing.description, ToggleMouseSmoothing.usage, ToggleMouseSmoothing.Execute);
ConsoleCommandsDatabase.RegisterCommand(AddPopupText.name, AddPopupText.description, AddPopupText.usage, AddPopupText.Execute);
//ConsoleCommandsDatabase.RegisterCommand(SetMouseSmoothing.name, SetMouseSmoothing.description, SetMouseSmoothing.usage, SetMouseSmoothing.Execute);
ConsoleCommandsDatabase.RegisterCommand(SetVSync.name, SetVSync.description, SetVSync.usage, SetVSync.Execute);
ConsoleCommandsDatabase.RegisterCommand(SetRunSpeed.name, SetRunSpeed.description, SetRunSpeed.usage, SetRunSpeed.Execute);
ConsoleCommandsDatabase.RegisterCommand(SetJumpSpeed.name, SetJumpSpeed.description, SetJumpSpeed.usage, SetJumpSpeed.Execute);
ConsoleCommandsDatabase.RegisterCommand(ToggleAirControl.name, ToggleAirControl.description, ToggleAirControl.usage, ToggleAirControl.Execute);
ConsoleCommandsDatabase.RegisterCommand(SetTimeScale.name, SetTimeScale.description, SetTimeScale.usage, SetTimeScale.Execute);
ConsoleCommandsDatabase.RegisterCommand(SetGravity.name, SetGravity.description, SetGravity.usage, SetGravity.Execute);
ConsoleCommandsDatabase.RegisterCommand(GotoLocation.name, GotoLocation.description, GotoLocation.usage, GotoLocation.Execute);
ConsoleCommandsDatabase.RegisterCommand(GetLocationMapPixel.name, GetLocationMapPixel.description, GetLocationMapPixel.usage, GetLocationMapPixel.Execute);
ConsoleCommandsDatabase.RegisterCommand(Teleport.name, Teleport.description, Teleport.usage, Teleport.Execute);
ConsoleCommandsDatabase.RegisterCommand(Groundme.name, Groundme.description, Groundme.usage, Groundme.Execute);
ConsoleCommandsDatabase.RegisterCommand(ExecuteScript.name, ExecuteScript.description, ExecuteScript.usage, ExecuteScript.Execute);
ConsoleCommandsDatabase.RegisterCommand(AddInventoryItem.name, AddInventoryItem.description, AddInventoryItem.usage, AddInventoryItem.Execute);
ConsoleCommandsDatabase.RegisterCommand(AddArtifact.name, AddArtifact.description, AddArtifact.usage, AddArtifact.Execute);
ConsoleCommandsDatabase.RegisterCommand(AddWeapon.name, AddWeapon.description, AddWeapon.usage, AddWeapon.Execute);
ConsoleCommandsDatabase.RegisterCommand(AddArmor.name, AddArmor.description, AddArmor.usage, AddArmor.Execute);
ConsoleCommandsDatabase.RegisterCommand(AddClothing.name, AddClothing.description, AddClothing.usage, AddClothing.Execute);
ConsoleCommandsDatabase.RegisterCommand(AddAllEquip.name, AddAllEquip.description, AddAllEquip.usage, AddAllEquip.Execute);
ConsoleCommandsDatabase.RegisterCommand(AddBook.name, AddBook.description, AddBook.usage, AddBook.Execute);
ConsoleCommandsDatabase.RegisterCommand(ShowBankWindow.name, ShowBankWindow.description, ShowBankWindow.usage, ShowBankWindow.Execute);
ConsoleCommandsDatabase.RegisterCommand(ShowSpellmakerWindow.name, ShowSpellmakerWindow.description, ShowSpellmakerWindow.usage, ShowSpellmakerWindow.Execute);
ConsoleCommandsDatabase.RegisterCommand(ShowItemMakerWindow.name, ShowItemMakerWindow.description, ShowItemMakerWindow.usage, ShowItemMakerWindow.Execute);
ConsoleCommandsDatabase.RegisterCommand(ShowPotionMakerWindow.name, ShowPotionMakerWindow.description, ShowPotionMakerWindow.usage, ShowPotionMakerWindow.Execute);
ConsoleCommandsDatabase.RegisterCommand(AddSpellBook.name, AddSpellBook.description, AddSpellBook.usage, AddSpellBook.Execute);
ConsoleCommandsDatabase.RegisterCommand(StartQuest.name, StartQuest.usage, StartQuest.description, StartQuest.Execute);
ConsoleCommandsDatabase.RegisterCommand(DiseasePlayer.name, DiseasePlayer.usage, DiseasePlayer.description, DiseasePlayer.Execute);
ConsoleCommandsDatabase.RegisterCommand(PoisonPlayer.name, PoisonPlayer.usage, PoisonPlayer.description, PoisonPlayer.Execute);
ConsoleCommandsDatabase.RegisterCommand(DumpRegion.name, DumpRegion.description, DumpRegion.usage, DumpRegion.Execute);
ConsoleCommandsDatabase.RegisterCommand(DumpLocation.name, DumpLocation.description, DumpLocation.usage, DumpLocation.Execute);
ConsoleCommandsDatabase.RegisterCommand(DumpBlock.name, DumpBlock.description, DumpBlock.usage, DumpBlock.Execute);
ConsoleCommandsDatabase.RegisterCommand(DumpLocBlocks.name, DumpLocBlocks.description, DumpLocBlocks.usage, DumpLocBlocks.Execute);
ConsoleCommandsDatabase.RegisterCommand(DumpBuilding.name, DumpBuilding.description, DumpBuilding.usage, DumpBuilding.Execute);
ConsoleCommandsDatabase.RegisterCommand(IngredientUsage.name, IngredientUsage.description, IngredientUsage.usage, IngredientUsage.Execute);
ConsoleCommandsDatabase.RegisterCommand(PlayFLC.name, PlayFLC.description, PlayFLC.usage, PlayFLC.Execute);
ConsoleCommandsDatabase.RegisterCommand(PlayVID.name, PlayVID.description, PlayVID.usage, PlayVID.Execute);
ConsoleCommandsDatabase.RegisterCommand(PrintCrimeCommitted.name, PrintCrimeCommitted.description, PrintCrimeCommitted.usage, PrintCrimeCommitted.Execute);
ConsoleCommandsDatabase.RegisterCommand(ClearCrimeCommitted.name, ClearCrimeCommitted.description, ClearCrimeCommitted.usage, ClearCrimeCommitted.Execute);
ConsoleCommandsDatabase.RegisterCommand(PrintLegalRep.name, PrintLegalRep.description, PrintLegalRep.usage, PrintLegalRep.Execute);
ConsoleCommandsDatabase.RegisterCommand(ClearNegativeLegalRep.name, ClearNegativeLegalRep.description, ClearNegativeLegalRep.usage, ClearNegativeLegalRep.Execute);
ConsoleCommandsDatabase.RegisterCommand(PrintQuests.name, PrintQuests.description, PrintQuests.usage, PrintQuests.Execute);
ConsoleCommandsDatabase.RegisterCommand(SummonDaedra.name, SummonDaedra.description, SummonDaedra.usage, SummonDaedra.Execute);
ConsoleCommandsDatabase.RegisterCommand(ChangeModSettings.name, ChangeModSettings.description, ChangeModSettings.usage, ChangeModSettings.Execute);
}
private static class DumpRegion
{
public static readonly string name = "dumpregion";
public static readonly string error = "Player not in a region, unable to dump";
public static readonly string usage = "dumpregion";
public static readonly string description = "Dump the current region (from MAPS.BSA) that the player is currently in to json file";
public static string Execute(params string[] args)
{
if (args.Length != 0)
{
return HelpCommand.Execute(DumpRegion.name);
}
else
{
PlayerGPS playerGPS = GameManager.Instance.PlayerGPS;
if (playerGPS)
{
DFRegion region = playerGPS.CurrentRegion;
string regionJson = SaveLoadManager.Serialize(region.GetType(), region);
string fileName = WorldDataReplacement.GetDFRegionReplacementFilename(playerGPS.CurrentRegionIndex);
File.WriteAllText(Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, fileName), regionJson);
return "Region data json written to " + Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, fileName);
}
return error;
}
}
}
private static class DumpLocation
{
public static readonly string name = "dumplocation";
public static readonly string error = "Player not at a location, unable to dump";
public static readonly string usage = "dumplocation";
public static readonly string description = "Dump the current location (from MAPS.BSA) that the player is currently in to json file";
public static string Execute(params string[] args)
{
if (args.Length != 0)
{
return HelpCommand.Execute(DumpLocation.name);
}
else
{
PlayerGPS playerGPS = GameManager.Instance.PlayerGPS;
if (playerGPS.HasCurrentLocation)
{
DFLocation location = playerGPS.CurrentLocation;
string locJson = SaveLoadManager.Serialize(location.GetType(), location);
string fileName = WorldDataReplacement.GetDFLocationReplacementFilename(location.RegionIndex, location.LocationIndex);
File.WriteAllText(Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, fileName), locJson);
return "Location data json written to " + Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, fileName);
}
return error;
}
}
}
private static class DumpBlock
{
public static readonly string name = "dumpblock";
public static readonly string error = "Failed to dump block";
public static readonly string usage = "dumpblock [blockName]";
public static readonly string description = "Dump a block to json file, or index if no block name specified";
public static string Execute(params string[] args)
{
if (args.Length == 0)
{
string blockIndex = "";
BsaFile blockBsa = DaggerfallUnity.Instance.ContentReader.BlockFileReader.BsaFile;
for (int b = 0; b < blockBsa.Count; b++)
{
blockIndex += string.Format("{0}: {1}\n", b, blockBsa.GetRecordName(b));
}
string fileName = Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, "BlockIndex.txt");
File.WriteAllText(fileName, blockIndex);
return "Block index data written to " + Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, fileName);
}
else
{
DFBlock blockData;
if (!RMBLayout.GetBlockData(args[0], out blockData))
{
if (args[0].EndsWith(".RDB", StringComparison.InvariantCultureIgnoreCase))
{
blockData = DaggerfallUnity.Instance.ContentReader.BlockFileReader.GetBlock(args[0]);
}
}
if (!string.IsNullOrEmpty(blockData.Name))
{
string blockJson = SaveLoadManager.Serialize(blockData.GetType(), blockData);
string fileName = WorldDataReplacement.GetDFBlockReplacementFilename(blockData.Name);
File.WriteAllText(Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, fileName), blockJson);
return "Block data json written to " + Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, fileName);
}
return error;
}
}
}
private static class DumpLocBlocks
{
public static readonly string name = "dumplocblocks";
public static readonly string error = "Failed to dump locations";
public static readonly string usage = "dumplocblocks [locindex|(blockName.RMB )*]\nExamples:\ndumplocblocks\ndumplocblocks locindex\ndumplocblocks RESIAM10.RMB GEMSAM02.RMB";
public static readonly string description = "Dump the names of blocks for each location, location index or locations for list of given block(s), to json file";
public static string Execute(params string[] args)
{
MapsFile mapFileReader = DaggerfallUnity.Instance.ContentReader.MapFileReader;
if (args.Length == 0)
{
Dictionary<string, string[]> locBlocks = new Dictionary<string, string[]>();
for (int region = 0; region < mapFileReader.RegionCount; region++)
{
DFRegion dfRegion = mapFileReader.GetRegion(region);
for (int location = 0; location < dfRegion.LocationCount; location++)
{
DFLocation dfLoc = mapFileReader.GetLocation(region, location);
locBlocks[dfLoc.Name] = dfLoc.Exterior.ExteriorData.BlockNames;
}
}
string locJson = SaveLoadManager.Serialize(locBlocks.GetType(), locBlocks);
string fileName = Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, "LocationBlockNames.json");
File.WriteAllText(fileName, locJson);
return "Location block names json written to " + fileName;
}
else if (args.Length == 1 && args[0] == "locindex")
{
string locIndex = "";
for (int region = 0; region < mapFileReader.RegionCount; region++)
{
DFRegion dfRegion = mapFileReader.GetRegion(region);
for (int location = 0; location < dfRegion.LocationCount; location++)
{
DFLocation dfLoc = mapFileReader.GetLocation(region, location);
locIndex += string.Format("{0}, {1}: {2}\n", region, dfLoc.LocationIndex, dfLoc.Name);
}
}
string fileName = Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, "LocationIndex.txt");
File.WriteAllText(fileName, locIndex);
return "Location index written to " + fileName;
}
else
{
Dictionary<string, List<string>> regionLocs = new Dictionary<string, List<string>>();
for (int region = 0; region < mapFileReader.RegionCount; region++)
{
DFRegion dfRegion = mapFileReader.GetRegion(region);
if (string.IsNullOrEmpty(dfRegion.Name))
{
Debug.Log("region null: " + region);
continue;
}
List<string> locs;
if (regionLocs.ContainsKey(dfRegion.Name))
locs = regionLocs[dfRegion.Name];
else
{
locs = new List<string>();
regionLocs[dfRegion.Name] = locs;
}
for (int location = 0; location < dfRegion.LocationCount; location++)
{
DFLocation dfLoc = mapFileReader.GetLocation(region, location);
foreach (string blockName in dfLoc.Exterior.ExteriorData.BlockNames)
for (int i = 0; i < args.Length; i++)
if (blockName == args[i])
locs.Add(dfLoc.Name);
if (dfLoc.Dungeon.Blocks != null)
foreach (DFLocation.DungeonBlock dBlock in dfLoc.Dungeon.Blocks)
for (int i = 0; i < args.Length; i++)
if (dBlock.BlockName == args[i])
locs.Add(dfLoc.Name);
}
}
string locJson = SaveLoadManager.Serialize(regionLocs.GetType(), regionLocs);
string blocks = "";
for (int i = 0; i < args.Length; i++)
blocks = blocks + "-" + args[i];
string fileName = Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, blocks.Substring(1) + "-locations.json");
File.WriteAllText(fileName, locJson);
return "Location block names json written to " + fileName;
}
}
}
private static class DumpBuilding
{
public static readonly string name = "dumpbuilding";
public static readonly string error = "Failed to dump building";
public static readonly string usage = "dumpbuilding";
public static readonly string description = "Dump the current building player is inside to json file";
public static string Execute(params string[] args)
{
DaggerfallInterior interior = GameManager.Instance.PlayerEnterExit.Interior;
int blockIndex = interior.EntryDoor.blockIndex;
int recordIndex = interior.EntryDoor.recordIndex;
DFBlock blockData = DaggerfallUnity.Instance.ContentReader.BlockFileReader.GetBlock(blockIndex);
if (blockData.Type == DFBlock.BlockTypes.Rmb)
{
string fileName = WorldDataReplacement.GetBuildingReplacementFilename(blockData.Name, blockIndex, recordIndex);
BuildingReplacementData buildingData = new BuildingReplacementData()
{
RmbSubRecord = blockData.RmbBlock.SubRecords[recordIndex],
BuildingType = (int)blockData.RmbBlock.FldHeader.BuildingDataList[recordIndex].BuildingType,
Quality = blockData.RmbBlock.FldHeader.BuildingDataList[recordIndex].Quality,
};
string buildingJson = SaveLoadManager.Serialize(buildingData.GetType(), buildingData);
File.WriteAllText(Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, fileName), buildingJson);
return "Building data written to " + Path.Combine(DaggerfallUnity.Settings.PersistentDataPath, fileName);
}
return error;
}
}
private static class IngredientUsage
{
public static readonly string name = "ingredUsage";
public static readonly string description = "Log an analysis of potion recipe usage of ingredients";
public static readonly string usage = "ingredUsage";
public static string Execute(params string[] args)
{
if (args == null || args.Length > 0)
return usage;
GameManager.Instance.EntityEffectBroker.LogRecipeIngredientUsage();
return "Finished";
}
}
private static class GodCommand
{
public static readonly string name = "tgm";
public static readonly string error = "Failed to set God Mode - Player health object not found?";
public static readonly string usage = "tgm";
public static readonly string description = "Toggle god mode";
public static string Execute(params string[] args)
{
PlayerHealth playerHealth = GameManager.Instance.PlayerHealth;//GameObject.FindObjectOfType<PlayerHealth>();
if (playerHealth)
{
PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
playerEntity.GodMode = !playerEntity.GodMode;
return string.Format("Godmode enabled: {0}", playerEntity.GodMode);
}
else
return error;
}
}
private static class NoClipCommand
{
public static readonly string name = "tcl";
public static readonly string error = "Failed to set TCL, PlayerEntity or Levitate could not be found";
public static readonly string usage = "tcl";
public static readonly string description = "Toggle noclip by turning off all collisions and activates levitate";
public static string Execute(params string[] args)
{
PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
LevitateMotor levitateMotor = GameManager.Instance.PlayerMotor.GetComponent<LevitateMotor>();
if (playerEntity != null && levitateMotor != null)
{
playerEntity.NoClipMode = !playerEntity.NoClipMode;
levitateMotor.IsLevitating = playerEntity.NoClipMode;
GameManager.Instance.PlayerController.gameObject.layer = playerEntity.NoClipMode ? LayerMask.NameToLayer("NoclipLayer") : LayerMask.NameToLayer("Player");
return string.Format("Noclip enabled: {0}", playerEntity.NoClipMode);
}
else
return error;
}
}
private static class NoTargetCommand
{
public static readonly string name = "nt";
public static readonly string error = "Failed to set NoTarget mode";
public static readonly string usage = "nt";
public static readonly string description = "Toggle NoTarget mode";
public static string Execute(params string[] args)
{
PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
if (playerEntity != null)
{
playerEntity.NoTargetMode = !playerEntity.NoTargetMode;
return string.Format("NoTarget enabled: {0}", playerEntity.NoTargetMode);
}
else
return error;
}
}
private static class ToggleAICommand
{
public static readonly string name = "tai";
public static readonly string error = "Failed to toggle AI";
public static readonly string usage = "tai";
public static readonly string description = "Toggles AI on or off";
public static string Execute(params string[] args)
{
GameManager gameManager = GameManager.Instance;
if (gameManager != null)
{
gameManager.DisableAI = !gameManager.DisableAI;
return string.Format("AI disabled: {0}", gameManager.DisableAI);
}
else
return error;
}
}
private static class CreateMobileCommand
{
public static readonly string name = "cm";
public static readonly string error = "Failed to create mobile";
public static readonly string usage = "cm [n] [team]";
public static readonly string description = "Creates a mobile of type [n] on [team]. Omit team argument for default team.";
public static string Execute(params string[] args)
{
if (args.Length < 1) return "See usage.";
GameObject player = GameManager.Instance.PlayerObject;
if (player != null)
{
int id = 0;
if (!int.TryParse(args[0], out id))
return "Invalid mobile ID.";
if (!Enum.IsDefined(typeof(MobileTypes), id) && DaggerfallEntity.GetCustomCareerTemplate(id) == null)
return "Invalid mobile ID.";
int team = 0;
if (args.Length > 1)
{
if (!int.TryParse(args[1], out team))
return "Invalid team.";
if (!Enum.IsDefined(typeof(MobileTeams), team))
return "Invalid team.";
}
GameObject[] mobile = GameObjectHelper.CreateFoeGameObjects(player.transform.position + player.transform.forward * 2, (MobileTypes)id, 1);
DaggerfallEntityBehaviour behaviour = mobile[0].GetComponent<DaggerfallEntityBehaviour>();
EnemyEntity entity = behaviour.Entity as EnemyEntity;
if (args.Length > 1)
{
entity.Team = (MobileTeams)team;
}
else
team = (int)entity.Team;
mobile[0].transform.LookAt(mobile[0].transform.position + (mobile[0].transform.position - player.transform.position));
mobile[0].SetActive(true);
return string.Format("Created {0} on team {1}", (MobileTypes)id, (MobileTeams)team);
}
else
return error;
}
}
private static class ShowDebugStrings
{
public static readonly string name = "tdbg";
public static readonly string error = "Failed to toggle debug string ";
public static readonly string description = "Toggles if the debug information is displayed";
public static readonly string usage = "tdbg";
public static string Execute(params string[] args)
{
DaggerfallWorkshop.StreamingWorld streamingWorld = GameManager.Instance.StreamingWorld;//GameObject.FindObjectOfType<DaggerfallWorkshop.StreamingWorld>();
DaggerfallWorkshop.DaggerfallUnity daggerfallUnity = DaggerfallUnity.Instance;
DaggerfallSongPlayer[] songPlayers = GameObject.FindObjectsOfType<DaggerfallSongPlayer>();
DefaultCommands.showDebugStrings = !DefaultCommands.showDebugStrings;
bool show = DefaultCommands.showDebugStrings;
if (streamingWorld)
streamingWorld.ShowDebugString = show;
if (daggerfallUnity)
daggerfallUnity.WorldTime.ShowDebugString = show;
foreach (DaggerfallSongPlayer songPlayer in songPlayers)
{
if (songPlayer && songPlayer.IsPlaying)
{
songPlayer.ShowDebugString = show;
break;
}
}
if (FPSDisplay.fpsDisplay == null)
GameManager.Instance.gameObject.AddComponent<FPSDisplay>();
FPSDisplay.fpsDisplay.ShowDebugString = show;
return string.Format("Debug string show: {0}", show);
}
}
private static class SetHealth
{
public static readonly string name = "set_health";
public static readonly string error = "Failed to set health - invalid setting or player object not found";
public static readonly string description = "Set Health";
public static readonly string usage = "set_Health [#]";
public static string Execute(params string[] args)
{
DaggerfallEntityBehaviour playerBehavior = GameManager.Instance.PlayerEntityBehaviour;
int health = 0;
if (args == null || args.Length < 1 || !int.TryParse(args[0], out health))
{
return HelpCommand.Execute(SetHealth.name);
}
else if (playerBehavior != null)
{
playerBehavior.Entity.SetHealth(health);
return string.Format("Set health to: {0}", playerBehavior.Entity.CurrentHealth);
}
else
return error;
}
}
private static class RerollMaxHealth
{
public static readonly string name = "reroll_maxhealth";
public static readonly string error = "";
public static readonly string description = @"Repair permanently reduced maximum health caused by a level-up bug in 0.10.3 and earlier. " +
@"This bug is resolved in 0.10.4 and later but some older save games might still need repair. " +
@"Note that new maximum health is set by forumla and may be slightly higher or lower than before bug.";
public static readonly string usage = "reroll_maxhealth";
public static string Execute(params string[] args)
{
DaggerfallEntityBehaviour playerBehavior = GameManager.Instance.PlayerEntityBehaviour;
int rerolledHealth = FormulaHelper.RollMaxHealth(GameManager.Instance.PlayerEntity);
GameManager.Instance.PlayerEntity.MaxHealth = rerolledHealth;
return string.Format("Your new maximum health is {0}", rerolledHealth);
}
}
private static class ResetAssets
{
public static readonly string name = "reset_assets";
public static readonly string error = "Could not reset assets";
public static readonly string description = "Clears mesh and material asset caches then reloads game. Warning: Uses QuickSave slot to reload game in-place. The in-place reload will trigger a longer than usual delay.";
public static readonly string usage = "reset_assets";
public static string Execute(params string[] args)
{
DaggerfallUnity.Instance.MeshReader.ClearCache();
DaggerfallUnity.Instance.MaterialReader.ClearCache();
SaveLoadManager.Instance.QuickSave(true);
return "Cleared cache and reloaded world.";
}
}
private static class RetryAssetImports
{
public static readonly string name = "retry_assets";
public static readonly string error = "Could not retry asset imports";
public static readonly string description = "Clears records of import attempts for assets from loose files and mods.";
public static readonly string usage = "retry_assets";
public static string Execute(params string[] args)
{
MeshReplacement.RetryAssetImports();
return "Cleared records of import attempts for assets from loose files and mods.";
}
}
private static class Suicide
{
public static readonly string name = "suicide";
public static readonly string error = "Failed to suicide :D";
public static readonly string description = "Kill self";
public static readonly string usage = "suicide";
public static string Execute(params string[] args)
{
DaggerfallEntityBehaviour playerBehavior = GameManager.Instance.PlayerEntityBehaviour;
if (playerBehavior == null)
return error;
else
{
playerBehavior.Entity.SetHealth(0);
return "Are you still there?";
}
}
}
private static class SetWeather
{
public static readonly string name = "set_weather";
public static readonly string description = "Sets the weather to indicated type";
public static readonly string usage = "set_weather [#] \n0 = Sunny \n1 = Cloudy \n2 = Overcast \n3 = Fog \n4 = Rain \n5 = Thunder \n6 = Snow";
public static string Execute(params string[] args)
{
WeatherManager weatherManager = GameManager.Instance.WeatherManager;
int weatherCode;
if (args == null || args.Length < 1)
return HelpCommand.Execute(SetWeather.name);
if (weatherManager == null)
return HelpCommand.Execute(SetWeather.name);
if (int.TryParse(args[0], out weatherCode) && weatherCode >= 0 && weatherCode <= 6)
{
var type = (WeatherType)weatherCode;
weatherManager.SetWeather(type);
return "Set weather: " + type.ToString();
}
return HelpCommand.Execute(SetWeather.name);
}
}
private static class SetWalkSpeed
{
public static readonly string name = "set_walkspeed";
public static readonly string error = "Failed to set walk speed - invalid setting or PlayerMotor object not found";
public static readonly string description = "Set walk speed by multiplying current walk speed by inserted percentage. Set to -1 to disable or enable speed overrides. Set to -2 to clear out all speed modifiers";
public static readonly string usage = "set_walkspeed [#]";
public static string Execute(params string[] args)
{
float speed;
string UID;
PlayerSpeedChanger speedChanger = GameManager.Instance.SpeedChanger;
if (speedChanger == null)
return error;
if (args == null || args.Length < 1)
{
try
{
Console.Log(string.Format("Current Walk Speed: ", speedChanger.RefreshWalkSpeed().ToString()));
return HelpCommand.Execute(SetWalkSpeed.name);
}
catch
{
return HelpCommand.Execute(SetWalkSpeed.name);
}
}
else if (!float.TryParse(args[0], out speed))
{
if (speedChanger.RemoveSpeedMod(args[0].ToString()))
return string.Format("Walk speed modifier " + args[0].ToString() + " removed");
else
return error + " Walk speed: " + speedChanger.RefreshWalkSpeed().ToString();
}
else if (speed != -1 && speed != -2 && speed < 0)
{
return error + " Walk speed: " + speedChanger.RefreshWalkSpeed().ToString();
}
else if (speed == -1)
{
speedChanger.walkSpeedOverride = !speedChanger.walkSpeedOverride;
return string.Format("Walk speed override set to: " + speedChanger.walkSpeedOverride);
}
else if (speed == -2)
{
speedChanger.ResetSpeed(true, false);
return string.Format("Walk speed modifiers cleared. Walk speed is " + speedChanger.RefreshWalkSpeed().ToString());
}
else
{
speedChanger.AddWalkSpeedMod(out UID, speed);
return string.Format("Walk speed Modifier added (UID: " + UID + "). Walk speed is " + speedChanger.RefreshWalkSpeed().ToString());
}
}
}
private static class SetRunSpeed
{
public static readonly string name = "set_runspeed";
public static readonly string error = "Failed to set run speed - invalid setting or PlayerMotor object not found.";
public static readonly string description = "Set run speed by multiplying current run speed by inserted percentage. Set to -1 to disable or enable speed overrides. Set to -2 to clear out all speed modifiers";
public static readonly string usage = "set_runspeed [#]";
public static string Execute(params string[] args)
{
float speed;
string UID;
PlayerSpeedChanger speedChanger = GameManager.Instance.SpeedChanger;
if (speedChanger == null)
return error;
if (args == null || args.Length < 1)
{
try
{
Console.Log(string.Format("Current Run Speed: {0}", speedChanger.RefreshRunSpeed().ToString()));
return HelpCommand.Execute(SetRunSpeed.name);
}
catch
{
return HelpCommand.Execute(SetRunSpeed.name);
}
}
else if (!float.TryParse(args[0], out speed))
{
if (speedChanger.RemoveSpeedMod(args[0].ToString(), true))
return string.Format("Run speed modifier " + args[0].ToString() + " removed");
else
return error + " Run speed is " + speedChanger.RefreshRunSpeed().ToString();
}
else if (speed != -1 && speed != -2 && speed < 0)
{
return error;
}
else if (speed == -1)
{
speedChanger.runSpeedOverride = !speedChanger.runSpeedOverride;
return string.Format("Run speed override set to: " + speedChanger.runSpeedOverride.ToString());
}
else if (speed == -2)
{
speedChanger.ResetSpeed(false, true);
return string.Format("Run speed modifiers cleared. Run speed is " + speedChanger.RefreshRunSpeed().ToString());
}
else
{
speedChanger.AddRunSpeedMod(out UID, speed);
return string.Format("Run speed Modifier added (UID: " + UID + "). Run speed is " + speedChanger.RefreshRunSpeed().ToString());
}
}
}
private static class SetTimeScale
{
public static readonly string name = "set_timescale";
public static readonly string error = "Failed to set timescale - invalid setting or DaggerfallUnity singleton object";
public static readonly string description = "Set Timescale; Default 12. Setting it too high can have adverse affects";
public static readonly string usage = "set_timescale [#]";
public static string Execute(params string[] args)
{
int speed;
DaggerfallWorkshop.DaggerfallUnity daggerfallUnity = DaggerfallWorkshop.DaggerfallUnity.Instance;
if (daggerfallUnity == null)
return error;
if (args == null || args.Length < 1)
{
try
{
Console.Log(string.Format("Current TimeScale: {0}", DaggerfallWorkshop.DaggerfallUnity.Instance.WorldTime.TimeScale));
return HelpCommand.Execute(SetTimeScale.name);
}
catch
{
return HelpCommand.Execute(SetTimeScale.name);
}
}
else if (!int.TryParse(args[0], out speed))
return error;
else if (speed < 0)
return "Invalid time scale";
else
{
try
{
DaggerfallWorkshop.DaggerfallUnity.Instance.WorldTime.TimeScale = speed;
return string.Format("Time Scale set to: {0}", speed);
}
catch
{
return "Unspecified error; failed to set timescale";
}
}
}
}
private static class SetMouseSensitivity
{
public static readonly string name = "set_mspeed";
public static readonly string error = "Failed to set mouse sensitivity- invalid setting or PlayerMouseLook object not found";
public static readonly string description = "Set mouse sensitivity. Default is 1.5";
public static readonly string usage = "set_mspeed [#]";
public static string Execute(params string[] args)
{
PlayerMouseLook mLook = GameManager.Instance.PlayerMouseLook;//GameObject.FindObjectOfType<PlayerMouseLook>();
float speed = 0;
if (args == null || args.Length < 1 || !float.TryParse(args[0], out speed))
{
if (mLook)
Console.Log(string.Format("Current mouse sensitivity: {0}", mLook.sensitivity));
return HelpCommand.Execute(SetMouseSensitivity.name);
}
else if (mLook == null)
return error;
else
{
mLook.sensitivity = new Vector2(speed, speed);
return string.Format("Set mouse sensitivity to: {0}", mLook.sensitivity.ToString());
}
}
}
private static class ToggleMouseSmoothing
{
public static readonly string name = "tmsmooth";
public static readonly string error = "Failed to toggle mouse smoothing - PlayerMouseLook object not found?";
public static readonly string description = "Toggle mouse smoothing.";
public static readonly string usage = "tmsmooth";
public static string Execute(params string[] args)
{
PlayerMouseLook mLook = GameManager.Instance.PlayerMouseLook;//GameObject.FindObjectOfType<PlayerMouseLook>();
if (mLook == null)
return error;
else
{
//mLook.smoothing = new Vector2(speed, speed);
mLook.enableSmoothing = !mLook.enableSmoothing;
return string.Format("Mouse smoothing is on: {0}", mLook.enableSmoothing.ToString());
}
}
}
private static class SetMouseSmoothing
{
public static readonly string name = "set_msmooth";
public static readonly string error = "Failed to set mouse smoothing - invalid setting or PlayerMouseLook object not found";
public static readonly string description = "Set mouse smoothing. Default is 3";
public static readonly string usage = "set_msmooth [#]";
public static string Execute(params string[] args)
{
PlayerMouseLook mLook = GameManager.Instance.PlayerMouseLook;//GameObject.FindObjectOfType<PlayerMouseLook>();
float speed = 0;
if (args == null || args.Length < 1 || !float.TryParse(args[0], out speed))
{
if (mLook)
Console.Log(string.Format("Current mouse smoothing: {0}", mLook.smoothing));
return HelpCommand.Execute(SetMouseSmoothing.name);
}
else if (mLook == null)
return error;
else
{
mLook.smoothing = new Vector2(speed, speed);
return string.Format("Set mouse smoothing to: {0}", mLook.smoothing.ToString());
}
}
}
private static class SetVSync
{
public static readonly string name = "set_vsync";
public static readonly string error = "Failed to toggle vsync";
public static readonly string description = "Set Vertical Sync count. Must be 0, 1, 2;";
public static readonly string usage = "set_vsync";
public static string Execute(params string[] args)
{
int count = 0;
if (args == null || args.Count() < 1)
{
Console.Log(string.Format("Current VSync Count: {0}", UnityEngine.QualitySettings.vSyncCount));
return HelpCommand.Execute(SetVSync.name);
}
else if (!int.TryParse(args[0], out count))
{
Console.Log(string.Format("Current VSync Count: {0}", UnityEngine.QualitySettings.vSyncCount));
return HelpCommand.Execute(SetVSync.name);
}
else if (count == 0 || count == 1 || count == 2)
{
UnityEngine.QualitySettings.vSyncCount = count;
return string.Format("Set vSyncCount to: {0}", UnityEngine.QualitySettings.vSyncCount.ToString());
}
else
return error;
}
}
private static class SetGravity
{
public static readonly string name = "set_grav";
public static readonly string error = "Failed to set gravity - invalid setting or PlayerMotor object not found";
public static readonly string description = string.Format("Set gravity. Use -1 for default (namely, {0})", AcrobatMotor.defaultGravity);
public static readonly string usage = "set_grav [#]";
public static string Execute(params string[] args)
{
float gravity = 0;
AcrobatMotor acrobatMotor = GameManager.Instance.AcrobatMotor;
if (acrobatMotor == null)
return error;
if (args == null || args.Length < 1)
{
try
{
Console.Log(string.Format("Current gravity: {0}", acrobatMotor.gravity));
return HelpCommand.Execute(SetGravity.name);
}
catch
{
return HelpCommand.Execute(SetGravity.name);
}
}
else if (!float.TryParse(args[0], out gravity))
return error;
else if (gravity != -1 && gravity < 0)
return error;
else
{
acrobatMotor.gravity = gravity == -1 ? AcrobatMotor.defaultGravity : gravity;
return string.Format("Gravity set to: {0}", acrobatMotor.gravity);
}
}
}
private static class SetJumpSpeed
{
public static readonly string name = "set_jump";
public static readonly string error = "Failed to set jump speed - invalid setting or PlayerMotor object not found";
public static readonly string description = string.Format("Set jump speed. Use -1 for default (namely, {0})", AcrobatMotor.defaultJumpSpeed);
public static readonly string usage = "set_jump [#]";
public static string Execute(params string[] args)
{
float speed;
AcrobatMotor acrobatMotor = GameManager.Instance.AcrobatMotor;