Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.10 KB | None | 0 0
  1. state("Croc2", "US")
  2. {
  3. int CurTribe : 0xA8C44;
  4. int CurLevel : 0xA8C48;
  5. int CurMap : 0xA8C4C;
  6. int CurType : 0xA8C50;
  7. int InGameState : 0xB7880;
  8. int IsCheatMenuOpen : 0xB788C;
  9. bool IsMapLoaded : 0xB78C4;
  10. int NewMainState : 0xB7930;
  11. int IsNewMainStateValid : 0xB7934;
  12. int MainState : 0xB793C;
  13. uint DFCrystal5PosX : 0x223D30;
  14. uint DFCrystal5PosY : 0x223D34;
  15. uint DFCrystal5PosZ : 0x223D38;
  16. }
  17.  
  18. state("Croc2", "EU")
  19. {
  20. int CurTribe : 0xA9C44;
  21. int CurLevel : 0xA9C48;
  22. int CurMap : 0xA9C4C;
  23. int CurType : 0xA9C50;
  24. int InGameState : 0xBEA70;
  25. int IsCheatMenuOpen : 0xBEA7C;
  26. bool IsMapLoaded : 0xBEAB4;
  27. int NewMainState : 0xBEB20;
  28. int IsNewMainStateValid : 0xBEB24;
  29. int MainState : 0xBEB2C;
  30. uint DFCrystal5PosX : 0x22AF20;
  31. uint DFCrystal5PosY : 0x22AF24;
  32. uint DFCrystal5PosZ : 0x22AF28;
  33. }
  34.  
  35. startup
  36. {
  37. settings.Add("SplitOnMapChange", false,
  38. "Split on load");
  39. settings.Add("StartOnFirstLevel", false,
  40. "IL start");
  41. settings.Add("StartOnHubCheat", false,
  42. "IW start");
  43. settings.Add("StartAfterSaveSlotChosen", false,
  44. "Save slot start");
  45.  
  46. settings.Add("createui", false, "Last IL time");
  47.  
  48. // Returns true iff map is "Swap Meet Pete's General Store"
  49. vars.IsShopMap = new Func<dynamic, bool>(state =>
  50. state.CurTribe >= 1 && state.CurTribe <= 4 &&
  51. state.CurLevel == 1 && state.CurMap == 4 && state.CurType == 0);
  52.  
  53. vars.SetTextComponent = (Action<string, string, bool>)((id, text, create) => {
  54. var textSettings = timer.Layout.Components.Where(x => x.GetType().Name == "TextComponent").Select(x => x.GetType().GetProperty("Settings").GetValue(x, null));
  55. var textSetting = textSettings.FirstOrDefault(x => (x.GetType().GetProperty("Text1").GetValue(x, null) as string) == id);
  56. if (textSetting == null && create)
  57. {
  58. var textComponentAssembly = Assembly.LoadFrom("Components\\LiveSplit.Text.dll");
  59. var textComponent = Activator.CreateInstance(textComponentAssembly.GetType("LiveSplit.UI.Components.TextComponent"), timer);
  60. timer.Layout.LayoutComponents.Add(new LiveSplit.UI.Components.LayoutComponent("LiveSplit.Text.dll", textComponent as LiveSplit.UI.Components.IComponent));
  61.  
  62. textSetting = textComponent.GetType().GetProperty("Settings", BindingFlags.Instance | BindingFlags.Public).GetValue(textComponent, null);
  63. textSetting.GetType().GetProperty("Text1").SetValue(textSetting, id);
  64. }
  65.  
  66. if (textSetting != null)
  67. textSetting.GetType().GetProperty("Text2").SetValue(textSetting, text);
  68. });
  69. }
  70.  
  71. init
  72. {
  73. var firstModule = modules.First();
  74. var baseAddr = firstModule.BaseAddress;
  75. switch (firstModule.ModuleMemorySize)
  76. {
  77. case 0x23A000:
  78. version = "US";
  79. vars.AddrSaveSlots = baseAddr + 0x2040C0;
  80. vars.AddrCurSaveSlotIdx = baseAddr + 0x2220FC;
  81. break;
  82. case 0x242000:
  83. version = "EU";
  84. vars.AddrSaveSlots = baseAddr + 0x20B2B0;
  85. vars.AddrCurSaveSlotIdx = baseAddr + 0x2292EC;
  86. break;
  87. }
  88.  
  89. vars.TimeAtLoad = new TimeSpan();
  90. vars.LastILTime = new TimeSpan();
  91. vars.SetTextComponent( "Last IL time",
  92. vars.LastILTime.ToString(),
  93. settings["createui"]);
  94. }
  95.  
  96. update
  97. {
  98. if ((old.InGameState == 7) && (current.InGameState != 7))
  99. {
  100. vars.TimeAtLoad = timer.CurrentTime.GameTime;
  101. }
  102.  
  103. vars.SetTextComponent( "Last IL time",
  104. vars.LastILTime.ToString(),
  105. settings["createui"]);
  106.  
  107. return version != "";
  108. }
  109.  
  110. start
  111. {
  112. const int MainState_ChooseSaveSlot = 2;
  113. const int MainState_Running = 11;
  114. const int MainState_LevelSelect = 18;
  115.  
  116. // Start when main state is in transition from
  117. // "level select" or "save slot selection" to "running"
  118. if (settings["StartAfterSaveSlotChosen"] && (
  119. current.MainState == MainState_ChooseSaveSlot ||
  120. current.MainState == MainState_LevelSelect) &&
  121. current.IsNewMainStateValid != 0 &&
  122. current.NewMainState == MainState_Running)
  123. {
  124. return true;
  125. }
  126.  
  127. // The following start condition checks assume the game is running
  128. // and the current map is an ingame tribe and not a cutscene
  129. if (current.MainState != MainState_Running ||
  130. current.CurTribe < 1 || current.CurTribe > 5 || current.CurType == 3)
  131. {
  132. return false;
  133. }
  134.  
  135. if (settings["StartOnFirstLevel"] && (
  136. // Current map is a non-village map of Dante's World
  137. // or a non-village level of the Gobbo tribes
  138. current.CurTribe == 5 ? current.CurMap > 1 : current.CurLevel > 1))
  139. {
  140. return true;
  141. }
  142.  
  143. if (settings["StartOnHubCheat"] &&
  144. // Cheat menu is open while loading a new map
  145. current.IsCheatMenuOpen != 0 && current.InGameState == 7)
  146. {
  147. return true;
  148. }
  149.  
  150. vars.TimeAtLoad = timer.CurrentTime.GameTime;
  151. vars.LastILTime = timer.CurrentTime.GameTime;
  152. vars.SetTextComponent( "Last IL time",
  153. vars.LastILTime.ToString(),
  154. settings["createui"]);
  155. }
  156.  
  157. split
  158. {
  159. // Cancel if main state is not "running" or
  160. // current tribe is not an ingame tribe
  161. const int MainState_Running = 11;
  162. if (current.MainState != MainState_Running ||
  163. current.CurTribe < 1 || current.CurTribe > 5)
  164. {
  165. ((IDictionary<string, object>)current).Remove("ProgressList");
  166. return false;
  167. }
  168.  
  169. // Read progress list
  170. const int SaveSlotSize = 0x2000;
  171. var addrSaveSlot = vars.AddrSaveSlots +
  172. memory.ReadValue<int>((IntPtr)vars.AddrCurSaveSlotIdx) * SaveSlotSize;
  173. current.ProgressList = memory.ReadBytes((IntPtr)addrSaveSlot + 0x2d0, 0xf0);
  174.  
  175. // Cancel if old progress list is not available
  176. if (!((IDictionary<string, object>)old).ContainsKey("ProgressList")) return false;
  177.  
  178. // "Dante's Final Fight": Split when last crystal is placed
  179. if (current.CurTribe == 4 && current.CurLevel == 2 &&
  180. current.CurMap == 1 && current.CurType == 1 && (
  181. old.DFCrystal5PosX != current.DFCrystal5PosX ||
  182. old.DFCrystal5PosY != current.DFCrystal5PosY ||
  183. old.DFCrystal5PosZ != current.DFCrystal5PosZ) &&
  184. current.DFCrystal5PosX == 0x00004358 &&
  185. current.DFCrystal5PosY == 0x0000315b &&
  186. current.DFCrystal5PosZ == 0x00004d53)
  187. {
  188. return true;
  189. }
  190.  
  191. // Check whether progress has changed
  192. for (int tribe = 1; tribe <= 5; ++tribe)
  193. {
  194. // Level completed?
  195. for (int level = 2; level <= 7; ++level)
  196. {
  197. int index = (tribe * 10 + level) * 4;
  198. if (old.ProgressList[index] != current.ProgressList[index])
  199. {
  200. vars.LastILTime = timer.CurrentTime.GameTime - vars.TimeAtLoad;
  201. return true;
  202. }
  203. }
  204. // Boss defeated?
  205. for (int boss = 1; boss <= 2; ++boss)
  206. {
  207. int index = (tribe * 10 + boss) * 4 + 1;
  208. if (old.ProgressList[index] != current.ProgressList[index])
  209. {
  210. vars.LastILTime = timer.CurrentTime.GameTime - vars.TimeAtLoad;
  211. return true;
  212. }
  213. }
  214. }
  215.  
  216. // Split on map change (except when changing from or to shop map)
  217. if (settings["SplitOnMapChange"] && (
  218. old.CurTribe != current.CurTribe ||
  219. old.CurLevel != current.CurLevel ||
  220. old.CurMap != current.CurMap ||
  221. old.CurType != current.CurType) &&
  222. !vars.IsShopMap(old) && !vars.IsShopMap(current))
  223. {
  224. return true;
  225. }
  226. }
  227.  
  228. isLoading
  229. {
  230. return !current.IsMapLoaded;
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement