-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathFEAR2.asl
167 lines (140 loc) · 4.47 KB
/
FEAR2.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
//FEAR 2 Autosplitter/Load Remover by rythin
state("FEAR2", "Steam") {
int gameLoading: 0x32E2E8; //0 during gameplay, seemingly random numbers when loading
string4 mapName: 0x2F5F98;
//int hasControl: 0x002ED454, 0xA4, 0x1C, 0x3EC;
//int cutsceneWatcher: 0x2EF5DC;
}
state("FEAR2", "GOG") {
int gameLoading: 0x2F4454; //random numbers during gameplay, 0 when loading
string4 mapName: 0x2F5F98;
}
startup {
settings.Add("missions", true, "Missions");
settings.Add("dbg", false, "Display debug info under splits");
settings.SetToolTip("dbg", "Might have to remove the extra displays from your layout later");
vars.m = new Dictionary<string, string>{
{"M01", "Sanctuary"},
{"M03", "Awakening"},
{"M04", "Discovery"},
{"M04b", "Withdrawal"},
{"M05", "Replica"},
{"M06", "Ruin"},
{"m07", "Top"},
{"M09", "Elementary"},
{"m10", "Nurse's Office"},
{"M11", "Snake Fist"},
{"M14", "Keegan"},
{"M15", "Epicenter"},
{"M16", "Approach"}
};
foreach (var Tag in vars.m) {
settings.Add(Tag.Key, true, Tag.Value, "missions");
};
vars.ds = new List<string>();
vars.isGameLoading = 0;
vars.setGameTime = false;
vars.timerOffset = 48.983;
vars.lastMap = "";
vars.SetTextComponent = (Action<string, string>)((id, text) =>
{
var textSettings = timer.Layout.Components.Where(x => x.GetType().Name == "TextComponent").Select(x => x.GetType().GetProperty("Settings").GetValue(x, null));
var textSetting = textSettings.FirstOrDefault(x => (x.GetType().GetProperty("Text1").GetValue(x, null) as string) == id);
if (textSetting == null)
{
var textComponentAssembly = Assembly.LoadFrom("Components\\LiveSplit.Text.dll");
var textComponent = Activator.CreateInstance(textComponentAssembly.GetType("LiveSplit.UI.Components.TextComponent"), timer);
timer.Layout.LayoutComponents.Add(new LiveSplit.UI.Components.LayoutComponent("LiveSplit.Text.dll", textComponent as LiveSplit.UI.Components.IComponent));
textSetting = textComponent.GetType().GetProperty("Settings", BindingFlags.Instance | BindingFlags.Public).GetValue(textComponent, null);
textSetting.GetType().GetProperty("Text1").SetValue(textSetting, id);
}
if (textSetting != null)
textSetting.GetType().GetProperty("Text2").SetValue(textSetting, text);
});
}
init {
//yoinked this from Gelly, who yoinked it from someone else
//thanks for that
byte[] exeMD5HashBytes = new byte[0];
using (var md5 = System.Security.Cryptography.MD5.Create())
{
using (var s = File.Open(modules.First().FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
exeMD5HashBytes = md5.ComputeHash(s);
}
}
var MD5Hash = exeMD5HashBytes.Select(x => x.ToString("X2")).Aggregate((a, b) => a + b);
//print("MD5Hash: " + MD5Hash.ToString()); //Lets DebugView show me the MD5Hash of the game executable, which is actually useful.
if (MD5Hash == "B99447BA544DB7B7B235333740CF5427") {
version = "GOG";
}
if (MD5Hash == "54E27BA4855ADCE4A42B241FB2BF20AE") {
version = "Steam";
}
}
update {
if (version == "GOG") {
if (current.gameLoading == 0) {
vars.isGameLoading = 1;
}
else {
vars.isGameLoading = 0;
}
}
if (version == "Steam") {
if (current.gameLoading != 0) {
vars.isGameLoading = 1;
}
else {
vars.isGameLoading = 0;
}
}
if (settings["dbg"]) {
vars.SetTextComponent("map", (current.mapName).ToString());
vars.SetTextComponent("load", (current.gameLoading).ToString());
vars.SetTextComponent("last map", (vars.lastMap).ToString());
}
}
start {
if (current.mapName == "M01" && version == "GOG") {
if (current.gameLoading != 0 && old.gameLoading == 0) {
vars.setGameTime = true;
vars.lastMap = "M01";
vars.ds.Clear();
return true;
}
}
if (current.mapName == "M01" && version == "Steam") {
if (current.gameLoading == 0 && old.gameLoading != 0) {
vars.setGameTime = true;
vars.lastMap = "M01";
vars.ds.Clear();
return true;
}
}
}
split {
//generic level transition splits
if (current.mapName != "" && current.mapName != vars.lastMap && current.mapName != "menu" && !vars.ds.Contains(old.mapName)) {
if (settings[vars.lastMap]) {
vars.lastMap = current.mapName;
vars.ds.Add(old.mapName);
return true;
}
else if (!settings[vars.lastMap]) {
vars.lastMap = current.mapName;
}
}
}
gameTime {
if (vars.setGameTime == true) {
vars.setGameTime = false;
return TimeSpan.FromSeconds(-vars.timerOffset);
}
}
isLoading {
return (vars.isGameLoading == 1);
}
exit {
timer.IsGameTimePaused = true;
}