Choo-ChooCharles.asl 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. state("Obscure-Win64-Shipping")
  2. {
  3. }
  4. init
  5. {
  6. vars.CurEggCount = 0;
  7. vars.CurColorCount = 10;
  8. vars.CurWeaponCount = 30;
  9. vars.doneMaps = new List<string>();
  10. vars.SaveFiles = new String[188];
  11. vars.logPath = Environment.GetEnvironmentVariable("LocalAppData")+"\\Obscure\\Saved\\SaveGames\\";
  12. // Entire section down (of just init) credits to go Micrologist
  13. if(!vars.scanCooldown.IsRunning)
  14. {
  15. vars.scanCooldown.Start();
  16. }
  17. vars.GetStaticPointerFromSig = (Func<string, int, IntPtr>) ( (signature, instructionOffset) => {
  18. var scanner = new SignatureScanner(game, modules.First().BaseAddress, (int)modules.First().ModuleMemorySize);
  19. var pattern = new SigScanTarget(signature);
  20. var location = scanner.Scan(pattern);
  21. if (location == IntPtr.Zero) return IntPtr.Zero;
  22. int offset = game.ReadValue<int>((IntPtr)location + instructionOffset);
  23. return (IntPtr)location + offset + instructionOffset + 0x4;
  24. });
  25. vars.Loading = vars.GetStaticPointerFromSig("48 8d 0d ?? ?? ?? ?? e8 ?? ?? ?? ?? 48 8b 05 ?? ?? ?? ?? ff 05", 0x3);
  26. vars.GameEngine = vars.GetStaticPointerFromSig("48 89 05 ?? ?? ?? ?? 48 85 c9 74 ?? e8 ?? ?? ?? ?? 48 8d 4d", 0x3);
  27. vars.pBase = vars.GetStaticPointerFromSig("48 8b 1d ?? ?? ?? ?? 48 85 db 74 ?? 41 b0", 0x3);
  28. vars.Transition = vars.GetStaticPointerFromSig("48 8b 0d ?? ?? ?? ?? 48 8d 53 ?? 0f 11 44 24", 03);
  29. print(vars.Loading.ToString("X"));
  30. print(vars.GameEngine.ToString("X"));
  31. print(vars.pBase.ToString("X"));
  32. if (vars.Loading == IntPtr.Zero || vars.GameEngine == IntPtr.Zero || vars.pBase == IntPtr.Zero)
  33. {
  34. throw new Exception("Loading/GameEngine/pBase/ not initialized - trying again");
  35. }
  36. vars.watchers = new MemoryWatcherList
  37. {
  38. new StringWatcher(new DeepPointer(vars.GameEngine, 0x8B0, 0x0), 100) { Name = "CurMap"},
  39. new MemoryWatcher<byte>(new DeepPointer(vars.Loading - 0x2)) { Name = "Loader"},
  40. new MemoryWatcher<byte>(new DeepPointer(vars.Transition, 0xB8)) { Name = "Transition"},
  41. new MemoryWatcher<byte>(new DeepPointer(vars.pBase, 0x30, 0xE8, 0x3A0, 0x200, 0x30, 0x20, 0x798)) {Name = "BossMode"}, // based on pos2
  42. new MemoryWatcher<byte>(new DeepPointer(vars.pBase, 0x30, 0xE8, 0x2B8, 0x200, 0x30, 0x20, 0x758)) {Name = "PlayerMovement"}, // based on pos2
  43. new MemoryWatcher<byte>(new DeepPointer(vars.pBase, 0x30, 0xE8, 0x3A0, 0x200, 0x30, 0x20, 0x870)) {Name = "CharlieDead"}, // baed on something2
  44. };
  45. }
  46. startup
  47. {
  48. settings.Add("SOD", true, "Split On Charlie Death?");
  49. settings.Add("egg", true, "Split On Picking Up Eggs?");
  50. settings.Add("TC", true, "Split on Every Train Color Pickup? (No Specific Order!)");
  51. settings.Add("WO", true, "Split on Every Weapon Obtained? (No Specific Order!)");
  52. vars.missions2 = new Dictionary<string,string>
  53. {
  54. {"2","Red Egg"},
  55. {"4","Green Egg"},
  56. {"6","Blue Egg"},
  57. };
  58. foreach (var Tag in vars.missions2)
  59. {
  60. settings.Add(Tag.Key, true, Tag.Value, "egg");
  61. };
  62. vars.scanCooldown = new Stopwatch();
  63. if (timer.CurrentTimingMethod == TimingMethod.RealTime) // stolen from dude simulator 3, basically asks the runner to set their livesplit to game time
  64. {
  65. var timingMessage = MessageBox.Show (
  66. "This game uses Time without Loads (Game Time) as the main timing method.\n"+
  67. "LiveSplit is currently set to show Real Time (RTA).\n"+
  68. "Would you like to set the timing method to Game Time? This will make verification easier",
  69. "LiveSplit | Choo-Choo Charlie",
  70. MessageBoxButtons.YesNo,MessageBoxIcon.Question
  71. );
  72. if (timingMessage == DialogResult.Yes)
  73. {
  74. timer.CurrentTimingMethod = TimingMethod.GameTime;
  75. }
  76. }
  77. }
  78. update
  79. {
  80. vars.watchers.UpdateAll(game);
  81. current.CurMap = vars.watchers["CurMap"].Current;
  82. current.loading = vars.watchers["Loader"].Current;
  83. current.BossMode = vars.watchers["BossMode"].Current;
  84. current.CharlieDead = vars.watchers["CharlieDead"].Current;
  85. current.PlayerMovement = vars.watchers["PlayerMovement"].Current;
  86. current.Transition = vars.watchers["Transition"].Current;
  87. // print(current.PlayerMovement.ToString());
  88. if ((vars.scanCooldown.Elapsed.TotalMilliseconds >= 500) && (current.PlayerMovement == 1) && (current.CurMap.Contains("Maps")))
  89. {
  90. vars.SaveFiles = Directory.GetFiles(vars.logPath);
  91. foreach (string FileName in vars.SaveFiles)
  92. {
  93. if (FileName.Contains("Egg") && !vars.doneMaps.Contains(FileName))
  94. {
  95. vars.doneMaps.Add(FileName);
  96. vars.CurEggCount++;
  97. print(FileName);
  98. }
  99. if (FileName.Contains("TrainColor") && (!vars.doneMaps.Contains(FileName)))
  100. {
  101. vars.doneMaps.Add(FileName);
  102. vars.CurColorCount++;
  103. print(FileName);
  104. }
  105. if (FileName.Contains("Unlocked") && (!vars.doneMaps.Contains(FileName)))
  106. {
  107. vars.doneMaps.Add(FileName);
  108. vars.CurWeaponCount++;
  109. print(FileName);
  110. }
  111. }
  112. vars.scanCooldown.Reset();
  113. vars.scanCooldown.Start();
  114. }
  115. }
  116. start
  117. {
  118. return ((current.CurMap.Contains("Maps")) && (current.loading == 1) && (old.loading == 0));
  119. }
  120. split
  121. {
  122. String CurEggCountToString = vars.CurEggCount.ToString();
  123. String CurColorCountToString = vars.CurColorCount.ToString();
  124. String CurWeaponCountToString = vars.CurWeaponCount.ToString();
  125. if (!vars.doneMaps.Contains(current.CurMap) && (!current.CurMap.Contains("MainMenu")) && (current.CurMap != old.CurMap) && (current.loading == 1))
  126. {
  127. vars.doneMaps.Add(current.CurMap);
  128. return true;
  129. }
  130. //Splitting on gaining a new egg
  131. if (settings[CurEggCountToString] && (!vars.doneMaps.Contains(CurEggCountToString)))
  132. {
  133. vars.doneMaps.Add(CurEggCountToString);
  134. print("Split on Egg Count Of : " + CurEggCountToString);
  135. return true;
  136. }
  137. // Splitting on gaining a new paint bucket
  138. if (settings["TC"] && (!vars.doneMaps.Contains(CurColorCountToString)) && (vars.CurColorCount != 10))
  139. {
  140. vars.doneMaps.Add(CurColorCountToString);
  141. print("Split on Paint Count Of : " + (vars.CurColorCount -10).ToString());
  142. return true;
  143. }
  144. // Splitting on gaining a new weapon
  145. if (settings["WO"] && (!vars.doneMaps.Contains(CurWeaponCountToString)) && (vars.CurWeaponCount != 30))
  146. {
  147. vars.doneMaps.Add(CurWeaponCountToString);
  148. print("Split on Weapon Count Of : " + (vars.CurWeaponCount - 30).ToString());
  149. return true;
  150. }
  151. // Splitting on killing Charles
  152. if ((current.BossMode == 1) && (current.CharlieDead == 1) && (settings["SOD"]) && (!vars.doneMaps.Contains("EndSplitted")))
  153. {
  154. print("Killed Charles");
  155. vars.doneMaps.Add("EndSplitted");
  156. return true;
  157. }
  158. }
  159. isLoading
  160. {
  161. return (current.loading == 0 || current.Transition == 1 || current.Transition != 0);
  162. }
  163. reset
  164. {
  165. return (current.CurMap.Contains("MainMenu"));
  166. }
  167. onReset
  168. {
  169. vars.doneMaps.Clear();
  170. vars.CurEggCount = 0;
  171. vars.CurColorCount = 10;
  172. vars.CurWeaponCount = 30;
  173. Array.Clear(vars.SaveFiles, 0, vars.SaveFiles.Length);
  174. }