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
|
017-9,26,28,0 script #HolidayConfig NPC32767,{
end;
OnInit:
.evtc = htnew; // event : time in seconds
if (debug >= 2) end;
OnClock0000:
donpcevent "#XmasConfig::OnCommandRestartQuest";
donpcevent "#HalloweenConfig::OnCommandRestartQuest";
donpcevent "Easter Eggs::OnCheckEaster";
initnpctimer;
end;
OnTimer1000:
// There are no NPC timers ongoing, loop forever
if (!htsize(.evtc)) {
initnpctimer;
end;
}
// Otherwise, we got a job to do
.@hti = htiterator(.evtc);
.@cur = gettimetick(2);
for (.@key$ = htinextkey(.@hti); hticheck(.@hti); .@key$ = htinextkey(.@hti))
{
.@target=htget(.evtc, .@key$, 0);
// Not yet expired
if (.@target > .@cur)
continue;
// Execute NPC Event after removing it from hashtable
htput(.evtc, .@key$, 0);
donpcevent(.@key$);
}
// Deallocate memory and cycle forever
htidelete(.@hti);
initnpctimer;
end;
public function addnpcevent {
.@ev$=getarg(1);
.@t=getarg(0);
htput(.evtc, .@ev$, gettimetick(2)+.@t);
return true;
}
// NPC Father Time end
}
function script addnpctimer {
.@t=getarg(0)/1000;
.@ev$=getarg(1);
"#HolidayConfig"::addnpcevent(.@t, .@ev$);
return true;
}
function script TMWBirthday {
if (gettime(GETTIME_MONTH) != APRIL) return;
if (gettime(GETTIME_DAYOFMONTH) != 11) return;
.@age=gettime(GETTIME_YEAR)-2004;
.@end=(.@age % 10);
.@mo$=(.@end == 1 ? "st" : (.@end == 2 ? "nd" : (.@end == 3 ? "rd" : "th")));
dispbottom l("It is TMW's %d%s birthday!", .@age, .@mo$);
// Handle gifts
if (#TMWBDAY < .@age) {
#TMWBDAY=.@age;
getitem TMWBirthdayGift, 1;
}
return;
}
|