-
Notifications
You must be signed in to change notification settings - Fork 7
/
LiveSplit.JermasBigAdventure.asl
113 lines (95 loc) · 3.15 KB
/
LiveSplit.JermasBigAdventure.asl
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
state("Jerma's Big Adventure")
{
// unknown/default version
}
startup
{
vars.Dbg = (Action<dynamic>) ((output) => print("[LiveSplit.JermasBigAdventure] " + output));
vars.cancelSource = null;
settings.Add("check0", false, "Above Ground");
settings.Add("check1", false, "Cave Start");
settings.Add("check2", false, "Raptor Tutorial");
settings.Add("check3", false, "Raptor Region 1");
settings.Add("check4", false, "Raptor Region 2");
settings.Add("check5", false, "Target Region");
settings.Add("check6", false, "Warlock Region 1");
settings.Add("check7", false, "Warlock Region 2");
settings.Add("check8", false, "Pre-Boss Region");
settings.Add("check9", false, "Boss Region");
settings.Add("check10", true, "Post-Boss Region");
}
init
{
var dataPtr = IntPtr.Zero;
vars.cancelSource = new CancellationTokenSource();
vars.scanThread = new Thread(() =>
{
Func<SigScanTarget, IntPtr> scanPages = (target) =>
{
var result = IntPtr.Zero;
foreach (var page in game.MemoryPages())
{
var scanner = new SignatureScanner(game, page.BaseAddress, (int)page.RegionSize);
if ((result = scanner.Scan(target)) != IntPtr.Zero) break;
}
return result;
};
vars.Dbg("Starting scan thread");
var dataTrg = new SigScanTarget(0xA, "00 00 37 13 37 13 37 13 37 13");
while (!vars.cancelSource.Token.IsCancellationRequested)
{
if (dataPtr == IntPtr.Zero && (dataPtr = scanPages(dataTrg)) != IntPtr.Zero)
vars.Dbg("Found AutoSplitterData class at 0x" + dataPtr.ToString("X"));
if (new[] { dataPtr }.All(ptr => ptr != IntPtr.Zero))
{
vars.Dbg("Found all pointers successfully");
vars.autoSplitterData = new MemoryWatcherList {
new MemoryWatcher<double>(new DeepPointer((IntPtr)dataPtr + 0x00)) { Name = "inGameTime" },
// new MemoryWatcher<int>(new DeepPointer((IntPtr)dataPtr + 0x08)) { Name = "isLoading" },
new MemoryWatcher<int>(new DeepPointer((IntPtr)dataPtr + 0x0C)) { Name = "levelID" },
new MemoryWatcher<int>(new DeepPointer((IntPtr)dataPtr + 0x10)) { Name = "isRunning" }
};
break;
}
vars.Dbg("Not all pointers found, retrying");
Thread.Sleep(2000);
}
vars.Dbg("Exiting scan thread");
});
vars.scanThread.Start();
}
update
{
if (vars.scanThread.IsAlive) return false;
vars.autoSplitterData.UpdateAll(game);
}
start
{
return vars.autoSplitterData["isRunning"].Old == 0 && vars.autoSplitterData["isRunning"].Current == 1;
}
split
{
return settings["check"+vars.autoSplitterData["levelID"].Old.ToString()]
&& (vars.autoSplitterData["levelID"].Current > vars.autoSplitterData["levelID"].Old
|| vars.autoSplitterData["isRunning"].Old == 1 && vars.autoSplitterData["isRunning"].Current == 2);
}
reset
{
return vars.autoSplitterData["isRunning"].Old != 0 && vars.autoSplitterData["isRunning"].Current == 0;
}
gameTime
{
return TimeSpan.FromSeconds(vars.autoSplitterData["inGameTime"].Current);
}
isLoading
{
return true;
}
exit
{
if (vars.cancelSource != null) vars.cancelSource.Cancel();
}
shutdown
{
if (vars.cancelSource != null) vars.cancelSource.Cancel();
}