-
Notifications
You must be signed in to change notification settings - Fork 10
/
NuclearThrone.asl
96 lines (85 loc) · 2.67 KB
/
NuclearThrone.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
//Nuclear Throne Autosplitter by Gelly and rythin
//Honestly it was just Gelly i barely did anything here
state("nuclearthrone") {
byte gameLoading: 0x74C6746;
}
// SPLIT NUMBERS IN THE SAVEFILE THING WHO KNOWS FUCK YOU ERO
//Character | Run count | Win count
//1 | 68 | 79
//2 | 154 | 166
//3 | 240 | 252
//4 | 326 | 338
//5 | 411 | 424
//6 | 498 | 510
//7 | 586 | 598
//8 | 672 | 684
//9 | 758 | 770
//10 | 844 | 856
//11 | 930 | 942
//12 | 1016 | 1028
//13 | 1102 | 1114
//14 | 1188 | 1200
//15 | 1274 | 1286
//16 | 1360 | 1372
//17 | 1446 | 1458
init {
vars.reader = new StreamReader(new FileStream((Environment.GetEnvironmentVariable("appdata"))+"\\..\\Local\\nuclearthrone\\nuclearthrone.sav", FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
//in order to keep track of the history of the runs/wins
//we need a current array and an old array keeping track
vars.runValues = new double[17];
vars.oldrunValues = new double[17];
vars.winValues = new double[17];
vars.oldwinValues = new double[17];
vars.line = "";
vars.runStrings = new String[1];
vars.winStrings = new String[1];
vars.runDelim = new String[] {"\"ctot_runs\" "};
vars.winDelim = new String[] {"\"ctot_wins\" "};
}
update {
if(vars.reader == null) return false;
//read the line from the reader
vars.line = vars.reader.ReadLine();
//split it up based on wins/reads
if(vars.line!=null){
vars.runStrings = vars.line.Split(vars.runDelim,StringSplitOptions.None);
vars.winStrings = vars.line.Split(vars.winDelim,StringSplitOptions.None);
print(vars.runStrings.Length.ToString());
//17 total win/runs to go through
for(int i = 0; i < 17; i++){
//first, maintain the history
vars.oldrunValues[i] = vars.runValues[i];
vars.oldwinValues[i] = vars.winValues[i];
//then, get the new values from vars.reader
vars.runValues[i] = Double.Parse(vars.runStrings[i+1].Split(',')[0]);
vars.winValues[i] = Double.Parse(vars.winStrings[i+1].Split(',')[0]);
}
}
//then, reset the save file reader
vars.reader.DiscardBufferedData();
vars.reader.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
}
exit {
vars.reader = null;
}
start {
return (current.gameLoading == 0 && old.gameLoading == 8);
}
reset {
double d = 0.0;
for(int i = 0; i < 17; i++){
d += vars.runValues[i] - vars.oldrunValues[i];
}
return (d>0.0);
}
split {
double d = 0.0;
for(int i = 0; i < 17; i++){
d += vars.winValues[i] - vars.oldwinValues[i];
}
return (current.gameLoading == 0 && old.gameLoading == 8) ||
(d>0.0);
}
isLoading {
return current.gameLoading == 8;
}