forked from NighthawkSLO/Autosplitters
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIji.asl
More file actions
196 lines (177 loc) · 6.03 KB
/
Iji.asl
File metadata and controls
196 lines (177 loc) · 6.03 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
state("iji") {}
startup
{
// Optional splits on bosses
// Krotera and Asha are instakilled in a normal run and Iosa 2 is unintersting, short and RNG based.
settings.Add("Krotera", false);
settings.Add("Asha", false);
settings.Add("Proxima", true);
settings.Add("Iosa 1", true);
settings.Add("Iosa 2", false);
settings.SetToolTip("Iosa 2", "After destroying Iosa's annihilator form");
settings.Add("Tor", true);
}
init
{
vars.globalsPtr = new MemoryWatcher<int>(new DeepPointer("iji.exe", 0x189720, 4));
vars.torPtr = new MemoryWatcher<int>(new DeepPointer("iji.exe", 0x1AF2F4, 0x80, 0x390, 0, 0x10C, 4));
vars.watchers = new MemoryWatcherList();
vars.fightingTor = false;
vars.initialized = false;
vars.error = (Action<string>)((string info) => {
MessageBox.Show(timer.Form,
"Couldn't find " + info +
"\nTry restarting the game.",
"Iji Autosplitter script",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
vars.broken = true;
});
vars.broken = false;
}
update
{
if (vars.broken) return false;
bool globalsUpdated = vars.globalsPtr.Update(game);
if (globalsUpdated || !vars.initialized) {
if (vars.globalsPtr.Current == 0) { return false; } // Game loading
bool found = false;
IntPtr ptr = new IntPtr(vars.globalsPtr.Current);
while (true) {
int key = memory.ReadValue<int>(ptr);
if (key < 100000 || key > 105000) break;
if (key == 100058) {
vars.inGame = new MemoryWatcher<double>(ptr + 0x10);
found = true;
break;
}
ptr = ptr + 0x28;
}
if (!found) { return false; } // Still loading
vars.initialized = true;
}
if (!vars.initialized) return false;
vars.inGame.Update(game);
if (vars.inGame.Current == 1) {
if (globalsUpdated || vars.watchers.Count == 0) {
int remaining = 4;
IntPtr sector = IntPtr.Zero,
levelTime = IntPtr.Zero,
totalTime = IntPtr.Zero,
iosa2 = IntPtr.Zero;
IntPtr ptr = new IntPtr(vars.globalsPtr.Current);
while (true) {
int key = memory.ReadValue<int>(ptr);
if (key < 100000 || key > 105000) break;
switch (key) {
case 100159: sector = ptr + 0x10; --remaining; break;
case 100172: levelTime = ptr + 0x10; --remaining; break;
case 100616: totalTime = ptr + 0x10; --remaining; break;
case 100612: iosa2 = ptr + 0x10; --remaining; break;
default: break;
}
if (remaining == 0) break;
ptr = ptr + 0x28;
}
if (remaining > 0) { vars.error("Sector Info memory locations."); return false; }
MemoryWatcher<double> sectorWatcher = new MemoryWatcher<double>(sector) { Name = "Sector" };
MemoryWatcher<double> levelTimeWatcher = new MemoryWatcher<double>(levelTime) { Name = "Level Time" };
MemoryWatcher<double> totalTimeWatcher = new MemoryWatcher<double>(totalTime) { Name = "Total Time" };
MemoryWatcher<double> iosa2Watcher = new MemoryWatcher<double>(iosa2) { Name = "Iosa 2" };
if (vars.watchers.Count > 0) {
sectorWatcher.Old = vars.watchers["Sector"].Old;
sectorWatcher.Current = vars.watchers["Sector"].Current;
levelTimeWatcher.Old = vars.watchers["Level Time"].Old;
levelTimeWatcher.Current = vars.watchers["Level Time"].Current;
totalTimeWatcher.Old = vars.watchers["Total Time"].Old;
totalTimeWatcher.Current = vars.watchers["Total Time"].Current;
iosa2Watcher.Old = vars.watchers["Iosa 2"].Old;
iosa2Watcher.Current = vars.watchers["Iosa 2"].Current;
}
vars.watchers.Clear();
vars.watchers.Add(sectorWatcher);
vars.watchers.Add(levelTimeWatcher);
vars.watchers.Add(totalTimeWatcher);
vars.watchers.Add(iosa2Watcher);
}
vars.watchers.UpdateAll(game);
if (vars.watchers["Sector"].Current == 15) {
//print("Checking tor");
if (vars.torPtr.Update(game)) {
int remaining = 2;
bool tor = false;
IntPtr currentHp = IntPtr.Zero, ptr = new IntPtr(vars.torPtr.Current);
while (true) {
int key = memory.ReadValue<int>(ptr);
if (key < 100000 || key > 105000) break;
switch (key) {
case 100005:
currentHp = ptr + 0x10; --remaining; break;
case 100316:
// identify tor with security stat
tor = memory.ReadValue<double>(ptr + 0x10) == 250;
--remaining; break;
default: break;
}
if (remaining == 0) break;
ptr = ptr + 0x28;
}
if (tor) {
if (remaining > 0) { vars.error("Tor Hp memory location."); return false; }
vars.fightingTor = true;
vars.torHp = new MemoryWatcher<double>(currentHp);
}
}
if (vars.fightingTor)
vars.torHp.Update(game);
}
}
}
start
{
return vars.inGame.Old == 0 && vars.inGame.Current == 1;
}
reset
{
return vars.inGame.Old == 1 && vars.inGame.Current == 0;
}
split
{
if (vars.inGame.Current == 1) {
double oldSector = vars.watchers["Sector"].Old, currentSector = vars.watchers["Sector"].Current;
if (oldSector != currentSector) return (
// standard progression
(oldSector + 1 == currentSector && currentSector != 1) ||
// sector 9 to sector X
(oldSector == 9 && currentSector == 0) ||
// there's a delay between boss room -> sector -> next sector
// these are some (probably obsolete) fail-safes
(oldSector == 11 && currentSector == 4) ||
(oldSector == 12 && currentSector == 6) ||
(oldSector == 13 && currentSector == 8) ||
(oldSector == 14 && currentSector == 0) ||
// entering boss rooms
(settings["Krotera"] && currentSector == 11) ||
(settings["Asha"] && currentSector == 12) ||
(settings["Proxima"] && currentSector == 13) ||
(settings["Iosa 1"] && currentSector == 14) ||
(settings["Tor"] && currentSector == 15));
else if
// destroying Iosa's annihilator form
(settings["Iosa 2"] && currentSector == 14 &&
vars.watchers["Iosa 2"].Old == 0 && vars.watchers["Iosa 2"].current == 1) return true;
else if
// killing Tor - final split
(vars.fightingTor && vars.torHp.Current <= 0) { vars.fightingTor = false; return true; }
}
}
isLoading
{
return true;
}
gameTime
{
if (vars.inGame.Current == 1)
return TimeSpan.FromSeconds(vars.watchers["Level Time"].Current + vars.watchers["Total Time"].Current);
else return TimeSpan.FromSeconds(0);
}