-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetdurations-tbc.pike
More file actions
44 lines (40 loc) · 1.35 KB
/
getdurations-tbc.pike
File metadata and controls
44 lines (40 loc) · 1.35 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
#!/usr/bin/env pike
int main(int argc, array argv) {
string spells = Stdio.read_file("MagicComm/CCSpellIDsClassic.lua");
array(int) spellids = ({});
int spellid;
constant url = "curl -L -q https://tbc.wowhead.com/spell=%d 2>/dev/null";
sscanf(spells, "%*s]]%s-- Spell durations in seconds", spells);
write("comm.spellIdToDuration = {\n");
mapping output = ([]);
while(sscanf(spells, "%*s[%d]%s", spellid, spells) > 1) {
// spellids += ({spellid});
// write("Found spell ID %d\n", spellid);
werror("Getting data for spell id %d...\n", spellid);
string spelldata = Process.popen(sprintf(url, spellid));
if(!spelldata) {
werror(" UNKNOWN SPELL %d\n", spellid);
continue;
}
int duration;
// werror("%O\n", array_sscanf(spelldata, "%sDuration<%s><%s>%d second"));
// exit(1);
string scale;
if(sscanf(spelldata, "%*s<th>Duration</th>%*s<%*s>%d %s<", duration, scale) == 5) {
if(scale[..2] == "min") {
duration = duration * 60;
}
output[spellid] = duration;
} else {
if(spellid == 5782) {
output[spellid] = 20; // hard coded since duratioon isn't obvious
} else {
werror(" Didn't find duration...\n");
}
}
}
foreach(sort(indices(output)), int spellid) {
write(" [%d] = %d, \n", spellid, output[spellid]);
}
write("}\n");
}