summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-03-02 16:28:57 -0300
committerJesusaves <cpntb1@ymail.com>2020-03-02 16:28:57 -0300
commitb31525e40f68045c1bf78feeb69c4cf73d53938a (patch)
tree1b7aed4962ccbc3ea17ca1f4ce615860fa7d18d4 /npc
parentc957417e7a41248eb72178e6b385f187f1f00457 (diff)
downloadserverdata-b31525e40f68045c1bf78feeb69c4cf73d53938a.tar.gz
serverdata-b31525e40f68045c1bf78feeb69c4cf73d53938a.tar.bz2
serverdata-b31525e40f68045c1bf78feeb69c4cf73d53938a.tar.xz
serverdata-b31525e40f68045c1bf78feeb69c4cf73d53938a.zip
Earlier sketch of FYEVENT triggers
Diffstat (limited to 'npc')
-rw-r--r--npc/functions/event.txt115
1 files changed, 81 insertions, 34 deletions
diff --git a/npc/functions/event.txt b/npc/functions/event.txt
index de5df5e3d..7253883f6 100644
--- a/npc/functions/event.txt
+++ b/npc/functions/event.txt
@@ -224,43 +224,54 @@ function script sThanksgiving {
000-0,0,0,0 script #EventCore NPC_HIDDEN,{
end;
+// confEvent(event ID, stday, stmon, endday, endmon)
+function confEvent {
+ setd("."+getarg(0)+"_stday", getarg(1));
+ setd("."+getarg(0)+"_stmon", getarg(2));
+ setd("."+getarg(0)+"_endday", getarg(3));
+ setd("."+getarg(0)+"_endmon", getarg(4));
+ // Save the event key?
+ //.@confname=".conf_"+getarg(2)+"$";
+ //setd(.@confname+"["+getarraysize(.@confname)+"]", getarg(0));
+ // Save only the day? (And use if statement)
+ .@confname$=".conf_"+getarg(2);
+ .@size=getarraysize(getd(.@confname$));
+ setd(.@confname$+"["+.@size+"]", getarg(1));
+ //debugmes "CONFIGURE EVENT, %s[%d] = %d", .@confname$, .@size, getarg(1);
+ //debugmes "CNAME: %s", getarg(0);
+ return;
+}
+
// Event Schedule (all dates are inclusive)
// NEVER, ever, include the last day of the month.
OnInit:
- .valentine_stday=13;
- .valentine_stmon=FEBRUARY;
- .valentine_endday=16;
- .valentine_endmon=FEBRUARY;
-
- .tmw2day_stday=1;
- .tmw2day_stmon=MARCH;
- .tmw2day_endday=7;
- .tmw2day_endmon=MARCH;
-
- .patrick_stday=15;
- .patrick_stmon=MARCH;
- .patrick_endday=19;
- .patrick_endmon=MARCH;
-
- .easter_stday=17;
- .easter_stmon=APRIL;
- .easter_endday=24;
- .easter_endmon=APRIL;
-
- .worker_stday=27;
- .worker_stmon=APRIL;
- .worker_endday=3;
- .worker_endmon=MAY;
-
- .thanks_stday=1;
- .thanks_stmon=NOVEMBER;
- .thanks_endday=29;
- .thanks_endmon=NOVEMBER;
-
- .xmas_stday=19;
- .xmas_stmon=DECEMBER;
- .xmas_endday=2;
- .xmas_endmon=JANUARY;
+ confEvent("valentine",
+ 13, FEBRUARY,
+ 16, FEBRUARY);
+
+ confEvent("tmw2day",
+ 1, MARCH,
+ 7, MARCH);
+
+ confEvent("patrick",
+ 15, MARCH,
+ 19, MARCH);
+
+ confEvent("easter",
+ 17, APRIL,
+ 24, APRIL);
+
+ confEvent("worker",
+ 27, APRIL,
+ 3, MAY);
+
+ confEvent("thanks",
+ 1, NOVEMBER,
+ 29, NOVEMBER); // NEVER use the last day of the month here
+
+ confEvent("xmas",
+ 19, DECEMBER,
+ 2, JANUARY);
// Some setup
disablenpc "sPatrick";
@@ -269,13 +280,49 @@ OnInit:
OnClock0000:
.@d=gettime(GETTIME_DAYOFMONTH);
.@m=gettime(GETTIME_MONTH);
+ .@o=gettime(GETTIME_WEEKDAY); // Resets at 0 (sunday)
debugmes "A new day begins! Today is %02d/%02d", .@d, .@m;
+ $@DEBUG_OD=30;
if ($@DEBUG_OD)
.@d=$@DEBUG_OD;
if ($@DEBUG_OM)
.@m=$@DEBUG_OM;
debugmes "EVENT CORE, the %02d/%02d", .@d, .@m;
+ // Is there another event this week?
+ if (.@o == MONDAY) {
+ .@dofy=true;
+ .@confname$=".conf_"+.@m;
+
+ for (.@i=0;.@i < getarraysize(getd(.@confname$)); .@i++) {
+ .@val=getd(.@confname$+"["+.@i+"]");
+ //debugmes "Looping, %d = %d", .@i, .@val;
+
+ // Erm.
+ if (.@val == 0)
+ continue;
+
+ // This script has a weakness: It cannot predict events starting
+ // at the start or the end of the month.
+ // So they might still overlap.
+ // A possible solution is to, eventually, record start and end date.
+ // And only inhibit FY event if the MONDAY is within the event...?
+ debugmes "%d >= %d && %d <= %d", .@val, .@d-6, .@val, .@d+6;
+ // In this case there's already an event!
+ // .@d == .@val <= .@d+6 AND
+ if ( .@val >= .@d-6 && .@val <= .@d+6 ) {
+ .@dofy=false;
+ break;
+ }
+ // continue...
+ }
+
+ // TODO: Trigger event framework
+ if (.@dofy)
+ debugmes "\033[1mFY event is set to happen...";
+ else
+ debugmes "\033[1mAnother event is scheduled!";
+ }
// Handle Valentine Day
if (.@m >=.valentine_stmon && .@m <= .valentine_endmon) {