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
|
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;
OnMinute13:
if (gettime(GETTIME_WEEKDAY) == FRIDAY && gettime(GETTIME_DAYOFMONTH) == 13) {
areamonster("009-1", 20, 20,
getmapinfo(MAPINFO_SIZE_X, "009-1"), getmapinfo(MAPINFO_SIZE_Y, "009-1"),
"Friday", FridayCat, any(1,3), "#HolidayConfig::OnFriday");
areamonster("020-1", 20, 20,
getmapinfo(MAPINFO_SIZE_X, "009-1"), getmapinfo(MAPINFO_SIZE_Y, "009-1"),
"Friday", FridayCat, any(1,3), "#HolidayConfig::OnFriday");
areamonster("001-1", 20, 20,
getmapinfo(MAPINFO_SIZE_X, "009-1"), getmapinfo(MAPINFO_SIZE_Y, "009-1"),
"Friday", FridayCat, any(1,3), "#HolidayConfig::OnFriday");
}
end;
OnFriday:
if (!playerattached()) end;
getmapxy(.@m$, .@x, .@y, 0);
sleep2(rand(500, 1200)); // Plenty time to move away
if (gettime(GETTIME_WEEKDAY) == FRIDAY && gettime(GETTIME_DAYOFMONTH) == 13)
monster .@m$, .@x, .@y, "JackO", JackO, 1;
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;
}
|