forked from cursedtoast/re7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRE7.asl
366 lines (306 loc) · 11.1 KB
/
RE7.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
//Resident Evil 7 Autosplitter
//Originally by CursedToast 1/28/2017
//Maintained by TheDementedSalad since 2022
//Last updated 13/08/24
//Special thanks to the original creators and testers:
//CursedToast, Souzooka, CarcinogenSDA, Dchaps, shiftweave, mgr.inz.Player, Theumer115 - inventory memory value support, DarkByte, Nexusphobiker
//TheDementedSalad - found pointers for Steam DX12 update & CeroD Splashscreen update + Made Jack's 55th timer.
//Ero - ASL helper and code for mm:ss:fff timer for Jack's 55th
state("re7", "CeroD 20.5.0.2"){}
state("re7", "CeroD 20.4.0.2"){}
state("re7", "12/17 Update"){}
state("re7", "Endof DX11"){}
state("re7", "Next Gen"){}
state("re7", "6/10/22"){}
state("re7", "9/5/23"){}
startup
{
Assembly.Load(File.ReadAllBytes("Components/asl-help")).CreateInstance("Basic");
vars.Helper.Settings.CreateFromXml("Components/RE7.Settings.xml");
vars.TotalTimeInSeconds = 0f;
}
init
{
IntPtr GameManager = vars.Helper.ScanRel(3, "4c 8b 05 ?? ?? ?? ?? 4d 85 c0 75 ?? 45 33 c0 41 8d 50 ?? e9");
IntPtr CurrMap = vars.Helper.ScanRel(3, "48 8b 0d ?? ?? ?? ?? 80 b9 ?? ?? ?? ?? ?? 74 ?? c6 81 ?? ?? ?? ?? ?? eb ?? 83 f8");
IntPtr InventoryManager = vars.Helper.ScanRel(3, "48 8b 05 ?? ?? ?? ?? 48 85 c0 0f 84 ?? ?? ?? ?? 48 83 78");
IntPtr BirthdayGameMaster = vars.Helper.ScanRel(3, "48 8b 15 ?? ?? ?? ?? 74 ?? 45 33 c0");
IntPtr Event = vars.Helper.ScanRel(3, "48 8b 15 ?? ?? ?? ?? 48 8b cb 48 85 d2 0f 84 ?? ?? ?? ?? e8 ?? ?? ?? ?? 0f b6 c8 48 8b 43 ?? 48 83 78 ?? ?? 0f 85 ?? ?? ?? ?? 85 c9 0f 95 c0");
//_CurrentChapter
vars.Helper["Chapter"] = vars.Helper.Make<byte>(GameManager, 0x54);
//CurrentPause
vars.Helper["gamePauseState"] = vars.Helper.Make<int>(GameManager, 0x104);
//IsSceneLoading
//isNotifyGameEnd
vars.Helper["End55"] = vars.Helper.Make<bool>(BirthdayGameMaster, 0xB0);
//app.BirthdayTimer > TotalBonusTime
vars.Helper["Bonus55"] = vars.Helper.Make<int>(BirthdayGameMaster, 0x70, 0x58);
//" > CurrentTimeLeft
vars.Helper["IGT55"] = vars.Helper.Make<int>(BirthdayGameMaster, 0x70, 0x98);
//" > CalcBonusTime
vars.Helper["Extra55"] = vars.Helper.Make<int>(BirthdayGameMaster, 0x70, 0xC0);
//" > isCanAddBonusTime
vars.Helper["Start55"] = vars.Helper.Make<bool>(BirthdayGameMaster, 0x70, 0xC8);
//app.BirthdayTransitionController > StageSetEnum
vars.Helper["Type55"] = vars.Helper.Make<byte>(BirthdayGameMaster, 0x80, 0x58);
//app.BirthdayTransitionController > Jump Target > 0x14
vars.Helper["Level55"] = vars.Helper.MakeString(BirthdayGameMaster, 0x80, 0xC0, 0x14);
//Base address of Inventory
vars.Inv = InventoryManager;
vars.Eve = Event;
vars.splits = new HashSet<string>();
vars.fuse3PickedUp = 0;
vars.fuse2PickedUp = 0;
vars.EoZ = 0;
vars.invMax = 20;
vars.Full55 = 0;
vars.Timer55 = 0;
vars.Finish55 = 0;
string md5 = "";
try {
md5 = (string)vars.Helper.GetMD5Hash();
} catch {
// Failed to open file for MD5 computation.
}
switch (md5) {
case "C505F2F8DD88C1478DA4B98FD49D7991":
version = "12/17 Update";
break;
case "9EDD76273F6653F2B39DE5B9CBB6EFA4":
version = "Next Gen";
break;
case "401BA759C4F1FE95ED06B33084FAA187":
version = "6/10/22";
break;
case "43303BA085DE21ADE83D7D1FB2CC6B86":
version = "9/5/23";
break;
default:
// No version found with hash, fallback to memorySize
switch ((int)vars.Helper.GetMemorySize()) {
case (162795520):
version = "CeroD 20.5.0.2";
break;
case (162783232):
version = "CeroD 20.4.0.2";
break;
case (142331904):
version = "Endof DX11";
break;
}
break;
}
if (version == "Next Gen" || version == "6/10/22" || version == "9/5/23"){
vars.Helper["inventSize"] = vars.Helper.Make<byte>(InventoryManager, 0x60, 0x18);
vars.Helper["Events"] = vars.Helper.MakeString(vars.Eve, 0x78, 0x80, 0x58, 0x10, 0x14);
vars.Helper["Events"].FailAction = MemoryWatcher.ReadFailAction.SetZeroOrNull;
vars.Helper["map"] = vars.Helper.MakeString(CurrMap, 0x960, 0x0);
vars.Helper["isLoading"] = vars.Helper.Make<int>(GameManager, 0x1A4);
}
else{
vars.Helper["inventSize"] = vars.Helper.Make<byte>(InventoryManager, 0x60, 0x28);
vars.Helper["Events"] = vars.Helper.MakeString(vars.Eve, 0x78, 0x80, 0x58, 0x20, 0x24);
vars.Helper["Events"].FailAction = MemoryWatcher.ReadFailAction.SetZeroOrNull;
vars.Helper["map"] = vars.Helper.MakeString(CurrMap, 0x700, 0x0);
vars.Helper["isLoading"] = vars.Helper.Make<int>(GameManager, 0x1AC);
vars.Helper["Inv2"] = vars.Helper.MakeString(InventoryManager, 0x60, 0x20, 0x40, 0x28, 0x80, 0x24);
}
}
update
{
//print(modules.First().ModuleMemorySize.ToString());
vars.Helper.Update();
vars.Helper.MapPointers();
current.inventory = new string[vars.invMax];
if (!settings["55th"]){
vars.Helper.Texts.RemoveAll();
}
else if (current.Chapter == 26 && old.Chapter != 26){
string level = current.Level55 + "_" + current.Type55;
int startTime = 0;
switch (level)
{
case "Stage1_0":
case "Stage3_0":
case "Stage3_1":
startTime = 900000;
break;
case "Stage2_0":
startTime = 600000;
break;
case "Stage2_1":
startTime = 300000;
break;
case "Stage2_2":
startTime = 480000;
break;
}
var timeTaken = current.IGT55 + current.Extra55 - current.Bonus55;
var timeLeft = startTime - timeTaken;
vars.Total55 += timeLeft;
vars.Helper.Texts["Total Time"].Right = TimeSpan.FromMilliseconds(vars.Total55).ToString(@"mm\:ss\.fff");
}
if (version == "Next Gen" || version == "6/10/22" || version == "9/5/23"){
for (int i = 0; i < current.inventSize; i++)
current.inventory[i] = vars.Helper.ReadString(300, ReadStringType.UTF16, vars.Inv, 0x60, 0x10, 0x20 + (i * 8), 0x18, 0x80, 0x14);
}
else{
for (int i = 0; i < current.inventSize; i++)
current.inventory[i] = vars.Helper.ReadString(300, ReadStringType.UTF16, vars.Inv, 0x60, 0x20, 0x30 + (i * 8), 0x28, 0x80, 0x24);
}
if(current.Events == "InteractEvent_GetSerum"){
vars.EoZ = 1;
return true;
}
}
onStart
{
if(settings["55th"]){
vars.Helper.Texts["Total Time"].Left = "Time:";
vars.Helper.Texts["Total Time"].Right = "00:00.000";
}
vars.splits.Clear();
vars.fuse2PickedUp = 0;
vars.fuse3PickedUp = 0;
vars.Full55 = 0;
vars.Finish55 = 0;
vars.Timer55 = 0;
vars.TotalTimeInSeconds = 0f;
vars.EoZ = 0;
}
start
{
return current.Events == "c00e00_00_pl2000" || // Main Game
current.Chapter == 5 && (current.inventory[0] == "Knife" || current.inventory[1] == "Knife") && current.map == "c03_MainHouse1FWash" || // No Guest House
current.map == "c04_CavePassage01" && current.inventory[0] == "CKnife" || // Not a Hero
current.gamePauseState == 0 && old.gamePauseState == 262400 || current.Events == "c09e11_00_pl9000" && old.Events != "c09e11_00_pl9000" || // End of Zoe
current.Events == "c07e40_00_pl3400" || // Daughters
current.Chapter == 29 && current.Events == "c07e10_00_pl3000" || // Bedroom
current.Chapter == 34 && current.map == "c03_OldHouse1FBridge01" && current.inventory[0] == "Knife" || // Ethan Must Die
(current.Chapter == 22 || current.Chapter == 23 || current.Chapter == 24 || current.Chapter == 25) && current.Start55 && !old.Start55; // Jack's 55th
}
split
{
string setting = "";
// Item splits
string[] currentInventory = (current.inventory as string[]);
string[] oldInventory = (old.inventory as string[]); // throws error first update, will be fine afterwards.
if(current.inventSize != old.inventSize){
for (int i = 0; i < current.inventSize; i++) {
if (old.inventory[i] == current.inventory[i])
continue;
var item = current.inventory[i];
if (item == "FuseCh4"){
if (vars.fuse2PickedUp == 0 && current.map != "c04_Ship1FCorridor"){
vars.fuse2PickedUp = 1;
return settings["fuse2"];
}
else if (vars.fuse3PickedUp == 0 && current.map == "c04_Ship1FCorridor"){
if (settings["fuse2"]){
if (vars.fuse2PickedUp == 1){
vars.fuse3PickedUp = 1;
return settings["fuse3"];
}
}
else{
vars.fuse3PickedUp = 1;
return settings["fuse3"];
}
}
}
if(!string.IsNullOrEmpty(item)){
setting = "Item_" + item;
}
}
}
//Removed item splits
var removedItems = oldInventory.Except(currentInventory);
if (removedItems.Contains("ChainSaw") && current.isLoading == 100){
setting = "Event_UseChainsaw";
}
if (removedItems.Contains("Lantern") && current.isLoading == 100){
setting = "Event_UseLantern";
}
if (removedItems.Contains("MachineGun")){
setting = "Event_TapeEnd";
}
// Map splits
if (current.map != old.map){
setting = "Map_" + current.map;
}
if (current.map == "c03_TrailerHouse" && old.map != "c03_TrailerHouse" && current.Chapter == 5){
setting = "Map_Trailer";
}
if(current.map == "c04_ShipB2Corridor01Past" && !vars.splits.Contains("Map_DownElev")){
setting = "Map_DownElev";
}
if(current.map == "c04_Ship2FCorridorCPast" && vars.splits.Contains("Map_DownElev")){
setting = "Map_UpElev";
}
//Events splits
if(current.Events != old.Events && !string.IsNullOrEmpty(current.Events)){
setting = "Event_" + current.Events;
}
if(old.Events == "c01e07_01_pl0000" && string.IsNullOrEmpty(current.Events)){
setting = "Event_Welcome";
}
//End splits
if (removedItems.Contains("Handgun_Albert")){
setting = "Event_End";
}
if (old.map == "c08_BossRoom01" && current.inventory[0] != old.inventory[0] && !vars.splits.Contains("nah_end")){
setting = "Event_NahEnd";
}
if(old.Events == "c09e43_00_pl9000" && string.IsNullOrEmpty(current.Events)){
setting = "Event_ZoeEnd";
}
if(settings["55th"] && current.End55 && !old.End55){
return true;
}
if(current.Events == "c07e46_00_pl3400" || current.Events == "c07e47_00_pl3400"){
setting = "Event_DaughtEnd";
}
if (settings["bed"] && removedItems.Contains("MasterKey")){
setting = "Event_BedEnd";
}
// Debug. Comment out before release.
if (!string.IsNullOrEmpty(setting))
vars.Log(setting);
if (settings.ContainsKey(setting) && settings[setting] && vars.splits.Add(setting)){
return true;
}
}
isLoading
{
if(settings["55th"]){
return current.gamePauseState != 0 && current.gamePauseState != 262400 && current.gamePauseState != 8 && current.gamePauseState != 262144 || current.End55;
}
else return current.gamePauseState != 0 && current.gamePauseState != 262400 && current.gamePauseState != 8 && current.gamePauseState != 262144 || current.Chapter == 3 || current.Chapter == 0 || current.Chapter == 1 || current.Chapter == 21 || current.Chapter == 28;
}
reset
{
if (settings["55th"]){
return current.gamePauseState == 0 && old.gamePauseState == 256;
}
if (settings["EMD"]){
return current.gamePauseState == 0 && old.gamePauseState == 256;
}
if (settings["daught"]){
return current.Chapter == 32 && old.Chapter == 28;
}
if (settings["eoz"]){
if(vars.EoZ == 0 && current.gamePauseState == 262148 && old.gamePauseState == 4){
return true;
}
if(current.Events == "c09e11_00_pl9000" && old.Events != "c09e11_00_pl9000"){
vars.EoZ = 0;
return true;
}
}
if (settings["bed"]){
return current.Chapter == 29 && old.Chapter == 28;
}
if (settings["nah"]){
return current.gamePauseState == 0 && old.Chapter == 28;
}
}