-
Notifications
You must be signed in to change notification settings - Fork 2
/
LiveSplit.SpaceChem.asl
46 lines (41 loc) · 1.36 KB
/
LiveSplit.SpaceChem.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
state("SpaceChem") {}
startup {
settings.Add("Split on level completion", true);
}
init {
IntPtr ptr = IntPtr.Zero;
vars.cycleCount = null;
foreach (var page in game.MemoryPages()) {
var scanner = new SignatureScanner(game, page.BaseAddress, (int)page.RegionSize);
ptr = scanner.Scan(new SigScanTarget(4, // Targeting byte 4
"FF D0", // call eax
"FF 05 ????????", // inc [target]
"8B 3D ????????" // mov edi, [???]
));
if (ptr != IntPtr.Zero) {
int tmp = game.ReadValue<int>(ptr) - (int)game.Modules[0].BaseAddress;
print(tmp.ToString("X"));
vars.state = new MemoryWatcher<int>(new DeepPointer(tmp-8));
vars.cycleFraction = new MemoryWatcher<float>(new DeepPointer(tmp-4));
vars.cycleCount = new MemoryWatcher<int>(new DeepPointer(tmp));
}
}
if (vars.cycleCount == null) {
// Thread.Sleep(100);
throw new Exception("Sigscans failed!");
}
}
update {
vars.state.Update(game);
vars.cycleFraction.Update(game);
vars.cycleCount.Update(game);
}
split {
if (vars.cycleCount.Old > 0 && vars.cycleCount.Current == 0) {
print("---------");
print(vars.state.Old + " " + vars.state.Current);
print(vars.cycleFraction.Old + " " + vars.cycleFraction.Current);
print(vars.cycleCount.Old + " " + vars.cycleCount.Current);
// return settings["Split on level completion"];
}
}