-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLiveSplit.Parallax.asl
More file actions
137 lines (120 loc) · 3.82 KB
/
LiveSplit.Parallax.asl
File metadata and controls
137 lines (120 loc) · 3.82 KB
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
state("Parallax") {
// float copyPlayerX : 0xA31220, 0x238;
// float copyPlayerY : 0xA31220, 0x23C;
// float copyPlayerZ : 0xA31220, 0x240;
// int actions : 0xA30BA4, 0x30, 0x0, 0x1DC, 0x5C, 0x20;
int levelId : 0xA01428;
}
startup {
settings.Add("Split on chapter completion", true);
settings.Add("Split on level completion", false);
settings.Add("deathcount", false, "Override first text component with a resets counter");
vars.gameTime = null;
// | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
// ---+---+---+---+---+---+---+---+---
// A | 14| 32| 16| 26| 19| 3| 13| 4
// B | 20| 9| 11| 17| 27| 30| 21| 8
// C | 5| 34| 28| 25| 33| 24| 29| 18
// D | 23| 31| 10| 6| 7| 22| 15| 12
vars.levels = new List<string>(){
" ", " ", "Main Menu", "A6", "A8", "C1", "D4", "D5", "B8", "B2",
"D3", "B3", "D8", "A7", "A1", "D7", "A3", "B4", "C8", "A5",
"B1", "B7", "D6", "D1", "C6", "C4", "A4", "B5", "C3", "C7",
"B6", "D2", "A2", "C5", "C2"
};
}
init {
vars.gameTime = null;
vars.fadeOut = null;
foreach (var module in modules) {
if (module.ModuleName.ToLower() == "mono.dll") {
// 0.3f (0x3E99999A) = Paused
// 0.0f (0x00000000) = End of level / score screen
// 1.0f (0x3F800000) = Playing
vars.fadeOut = new MemoryWatcher<float>(new DeepPointer(module.BaseAddress + 0x1F20AC, 0xA8, 0xF8));
break;
}
}
vars.deathCount = 0;
vars.updateText = false;
vars.tcs = null;
if (settings["deathcount"]) {
foreach (LiveSplit.UI.Components.IComponent component in timer.Layout.Components) {
if (component.GetType().Name == "TextComponent") {
vars.tc = component;
vars.tcs = vars.tc.Settings;
vars.updateText = true;
print("Found text component at " + component);
break;
}
}
}
}
update {
if (old.levelId != current.levelId) {
print("Changed from " + vars.levels[old.levelId] + " to " + vars.levels[current.levelId]);
}
// gameTime hasn't been found yet, and we're in a valid level
if (vars.gameTime == null && current.levelId > 2) {
var scan = new SigScanTarget(5,
"D9 C9", // fxch st(1)
"DE C1", // faddp
"B8 ????????" // mov eax, [target]
);
foreach (var page in game.MemoryPages()) {
var scanner = new SignatureScanner(game, page.BaseAddress, (int)page.RegionSize);
var ptr = scanner.Scan(scan);
if (ptr != IntPtr.Zero) {
vars.gameTime = new MemoryWatcher<float>(game.ReadPointer(ptr));
print("Found game time at 0x" + ptr.ToString("X"));
}
}
}
if (vars.gameTime != null) vars.gameTime.Update(game);
vars.fadeOut.Update(game);
if (vars.updateText) {
vars.tcs.Text1 = "Resets:";
vars.tcs.Text2 = vars.deathCount.ToString();
}
}
isLoading {
return true; // Disable gameTime approximation
}
gameTime {
if (vars.gameTime != null) {
return TimeSpan.FromSeconds(vars.gameTime.Current);
}
}
start {
if (vars.gameTime != null) {
if (vars.gameTime.Old == 0 && vars.gameTime.Current > 0) {
print("gameTime is valid and no longer zero -- run started");
return true;
}
}
}
reset {
if (old.levelId > 2 && current.levelId <= 2) {
print("Returned to main menu, resetting");
return true;
}
}
split {
// Finished a level (active -> menu)
if (vars.fadeOut.Old == 1.0f && vars.fadeOut.Current == 0.0f) {
string level = vars.levels[current.levelId];
print("Completed level " + level);
if (level == "D8") {
print("Beat the game!");
return true;
}
if (level == "A8" || level == "B8" || level == "C8") {
if (settings["Split on chapter completion"]) return true;
}
if (settings["Split on level completion"]) return true;
}
// Reset a level (menu -> reload)
if (vars.fadeOut.Old == 0.3f && vars.fadeOut.Current == 0.0f) {
vars.deathCount++;
}
}