summaryrefslogtreecommitdiff
path: root/npc/annuals/fathertime.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/annuals/fathertime.txt')
-rw-r--r--npc/annuals/fathertime.txt46
1 files changed, 42 insertions, 4 deletions
diff --git a/npc/annuals/fathertime.txt b/npc/annuals/fathertime.txt
index 6a92e7dc..bb2361a1 100644
--- a/npc/annuals/fathertime.txt
+++ b/npc/annuals/fathertime.txt
@@ -2,17 +2,55 @@
end;
OnInit:
+ .evtc = htnew; // event : time in seconds
if (debug >= 2) end;
- donpcevent strnpcinfo(0) + "::OnTimer20000";
- end;
OnClock0000:
-OnTimer20000:
donpcevent "#XmasConfig::OnCommandRestartQuest";
donpcevent "#HalloweenConfig::OnCommandRestartQuest";
donpcevent "Easter Eggs::OnCheckEaster";
- //initnpctimer;
+ 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 {