-
Notifications
You must be signed in to change notification settings - Fork 0
/
LiveSplit.CnCRemastered.asl
106 lines (92 loc) · 2.72 KB
/
LiveSplit.CnCRemastered.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
state("ClientG")
{
/*
* The internal game ticks (used to calculate game time)
*/
uint ticks : "ClientG.exe", 0x1B661D0, 0x18, 0x104, 0x1C, 0x0, 0x70;
/*
* The speed setting for the game (1-7)
*/
byte speed : "ClientG.exe", 0x1C98334;
/*
* The state of the game, values can be:
* 0 - Playing the game
* 1 - "Mission Accomplished" / results screen
* 2 - Main menu
* 3 - Loading screen
*/
byte controlStatus : "ClientG.exe", 0x1B81768, 0xE8;
/*
* The name of the map that is loaded
*/
string24 currentMap : "ClientG.exe", 0x1B81804, 0xF0, 0x7;
}
init
{
vars.speedDivider = 1.0;
vars.lastKnownTicks = 0;
vars.lastKnownTicksOld = 0;
vars.storedGT = 0;
}
startup
{
settings.Add("startAnyLevel", false, "Start the timer on any level");
settings.SetToolTip("startAnyLevel", "Will start the timer at the beginning of any level (good for IL runs)");
settings.Add("resetOnRestart", false, "Reset on Restart");
settings.SetToolTip("resetOnRestart", "Will reset the timer if a level is restarted (good for IL runs)");
}
onStart
{
vars.lastKnownTicks = 0;
vars.lastKnownTicksOld = 0;
vars.storedGT = 0;
}
update
{
if (current.speed == 7) {
vars.speedDivider = 1.0 / 17.0;
} else if (current.speed == 6) {
vars.speedDivider = 1.0 / 18.0;
} else if (current.speed == 5) {
vars.speedDivider = 7.0 / 180.0;
} else {
vars.speedDivider = (current.speed + 1) / 180.0;
}
if (current.ticks != 0) {
vars.lastKnownTicks = current.ticks;
}
if (old.ticks != 0) {
vars.lastKnownTicksOld = old.ticks;
}
if (vars.lastKnownTicks < vars.lastKnownTicksOld) {
vars.storedGT = vars.storedGT + (vars.lastKnownTicksOld - vars.lastKnownTicks) / vars.speedDivider;
}
}
start
{
if (settings["startAnyLevel"]) {
// When the loading screen ends and the game starts
return old.controlStatus == 3 && current.controlStatus == 0;
} else {
// When the loading screen starts for level 1
return (old.controlStatus != 3 && current.controlStatus == 3 && current.currentMap.Contains("CAMPAIGN_1_MA"))
|| (current.controlStatus == 3 && !old.currentMap.Contains("CAMPAIGN_1_MA") && current.currentMap.Contains("CAMPAIGN_1_MA"));
}
}
reset
{
return (current.speed != old.speed) // Changed game speed
|| (settings["resetOnRestart"] && old.controlStatus == 0 && current.controlStatus == 3); // Restarted level
}
split
{
return old.controlStatus == 0 && current.controlStatus == 1;
}
isLoading
{
return true;
}
gameTime
{
return TimeSpan.FromMilliseconds(vars.storedGT + vars.lastKnownTicks / vars.speedDivider);
}