summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/constants.conf4
-rw-r--r--npc/008-1/confused-tree.txt191
-rw-r--r--npc/functions/util.txt35
-rw-r--r--npc/scripts.conf1
4 files changed, 145 insertions, 86 deletions
diff --git a/db/constants.conf b/db/constants.conf
index 249374ec..e50a692f 100644
--- a/db/constants.conf
+++ b/db/constants.conf
@@ -3832,6 +3832,8 @@ constants_db: {
NPC_OSCAR: 145
NPC_SHOP_BAG_TEST: 146
NPC_RED: 147
+
+ NPC_CONFUSED_TREE: 400
NPC_ALIGE: 401
NPC_ORC_SAILOR: 402
NPC_RATTO_SAILOR: 403
@@ -3880,10 +3882,10 @@ constants_db: {
NPC_DEVIS_ARTIS: 448
NPC_MOUBOO: 449
NPC_MONA: 450
- NPC_CONFUSED_TREE: 451
NPC_TEST1: 800
NPC_PLAYER: 801
+
NPC_SAVE_POINT: 901
NPC_LEFT_HAMMOCK: 904
NPC_RIGHT_HAMMOCK: 905
diff --git a/npc/008-1/confused-tree.txt b/npc/008-1/confused-tree.txt
index b9ca1273..c273f843 100644
--- a/npc/008-1/confused-tree.txt
+++ b/npc/008-1/confused-tree.txt
@@ -817,100 +817,121 @@ OnTalkNearby:
end;
OnTouch:
- if (rand(.touch_rate) == 0) {
- face();
- }
- end;
+ if (rand(.touch_rate) == 0) {
+ face();
+ }
+ end;
OnDoReply:
- if (@tree_reply$ != "") {
- npctalk(@tree_reply$);
- @tree_reply$ = "";
- }
- end;
+ if (@tree_reply$ != "") {
+ npctalk(@tree_reply$);
+ @tree_reply$ = "";
+ }
+ end;
OnPCLogoutEvent:
- seen_me();
- end;
+ seen_me();
+ end;
OnTimer3600000:
- // scheduled janitor
- .@now = gettimetick(2);
- initnpctimer(); // schedule next
-
- if (.last_activity > (.@now - 3600)) {
- end; // last activity is too recent
- }
-
- // cleanup routine below
- .lastsender = 0;
- .last_activity = 0;
- .last_reply = 0;
- .last_emote = 0;
- .last_query = 0;
- .blocked = 0;
- .enable_janitor = 0;
-
- htclear(.msg_ht); // empty the message table (quotegrabs)
- htclear(.ignore_ht); // empty the ignore table
-
- .@it = htiterator(.seen_ht); // allocate new iterator
- for (.@key$ = htinextkey(.@it); hticheck(.@it); .@key$ = htinextkey(.@it)) {
- if (.@key$ == "") {
- continue;
- }
-
- if (htget(.seen_ht, .@key$, 0) < (.@now - 86400)) {
- htput(.seen_ht, .@key$, 0); // remove from hash table if older than 24h
- }
- }
- htidelete(.@it); // free the iterator
-
- face(); // do an emote (because why not)
- end;
+ // scheduled janitor
+ .@now = gettimetick(2);
+ initnpctimer(); // schedule next
+
+ if (.last_activity > (.@now - 3600)) {
+ end; // last activity is too recent
+ }
+
+ // cleanup routine below
+ .lastsender = 0;
+ .last_activity = 0;
+ .last_reply = 0;
+ .last_emote = 0;
+ .last_query = 0;
+ .blocked = 0;
+ .enable_janitor = 0;
+
+ htclear(.msg_ht); // empty the message table (quotegrabs)
+ htclear(.ignore_ht); // empty the ignore table
+
+ .@it = htiterator(.seen_ht); // allocate new iterator
+ for (.@key$ = htinextkey(.@it); hticheck(.@it); .@key$ = htinextkey(.@it)) {
+ if (.@key$ == "") {
+ continue;
+ }
+
+ if (htget(.seen_ht, .@key$, 0) < (.@now - 86400)) {
+ htput(.seen_ht, .@key$, 0); // remove from hash table if older than 24h
+ }
+ }
+ htidelete(.@it); // free the iterator
+
+ face(); // do an emote (because why not)
+ end;
+
+
+OnDay0320:
+ .dir = DOWNLEFT;
+ end;
+
+
+OnDay0621:
+ .dir = LEFT;
+ end;
+
+
+OnDay0922:
+ .dir = LEFTUP;
+ end;
+
+
+OnDay1221:
+ .dir = DOWN;
+ end;
OnInit:
- // config below
- .hotwords$ = "tree"; // what hot words the npc should listen to, besides its own name (regex)
- .distance = 14; // the npc will only listen to player within X tiles
- .sex = G_OTHER; // gender of the npc
- .talk_rate = 1; // min number of seconds to wait between replies
- .repeat_rate = 1; // min number of seconds to wait before sending the same message twice in a row
- .block_time = 600; // how long to stay quiet after someone says shut up, in seconds
- .emote_rate = 3; // min number of seconds to wait between emotes
- .sdrop_rate = 8; // 1 in X chances to get a special drop
- .sname_rate = 8; // 1 in X chances to get a special name
- .dunno_rate = 2; // 1 in X chances to get a reply when the command is not found
- .hiall_rate = 2; // 1 in X chances to reply to a "hi everyone"
- .touch_rate = 4; // 1 in X chances to trigger the OnTouch action
- .qpoll_rate = 1; // min number of seconds to wait before calling the sql db again for GMs
- .qpoll_rate2 = 5; // min number of seconds to wait before calling the sql db again for non-GMs (currently unused)
- .delay_reply = 250; // number of ms to wait to reply
- .enable_janitor = true; // automatically free memory when idle
- .symbol$ = "~"; // symbol for GM-only commands
-
- // register some arrays
- callfunc("TREE_dictionaries");
-
- // do random stuff
- make_quote_table();
- face();
-
- // boring stuff below
- .version = 20; // increase this when you make a change
- .uptime = gettimetick(2);
- .alwaysVisible = true; // the NPC doesn't de-spawn when moving away
- .pid = 1; // regex pattern id
- .msg_ht = htnew(); // hashtable id for message history
- .seen_ht = htnew(); // hashtable id for seen log
- .ignore_ht = htnew(); // hashtable id for ignored players
- .roulette = rand(1, 7); // spin the chambers
- defpattern(.pid, "^(.*)$", "OnTalkNearby");
- activatepset(.pid);
- if (.enable_janitor) {
- initnpctimer();
- }
+ // config below
+ .hotwords$ = "tree"; // what hot words the npc should listen to, besides its own name (regex)
+ .distance = 14; // the npc will only listen to player within X tiles
+ .sex = G_OTHER; // gender of the npc
+ .dir = season_direction(); // sprite direction according to the season
+ .talk_rate = 1; // min number of seconds to wait between replies
+ .repeat_rate = 1; // min number of seconds to wait before sending the same message twice in a row
+ .block_time = 600; // how long to stay quiet after someone says shut up, in seconds
+ .emote_rate = 3; // min number of seconds to wait between emotes
+ .sdrop_rate = 8; // 1 in X chances to get a special drop
+ .sname_rate = 8; // 1 in X chances to get a special name
+ .dunno_rate = 2; // 1 in X chances to get a reply when the command is not found
+ .hiall_rate = 2; // 1 in X chances to reply to a "hi everyone"
+ .touch_rate = 4; // 1 in X chances to trigger the OnTouch action
+ .qpoll_rate = 1; // min number of seconds to wait before calling the sql db again for GMs
+ .qpoll_rate2 = 5; // min number of seconds to wait before calling the sql db again for non-GMs (currently unused)
+ .delay_reply = 250; // number of ms to wait to reply
+ .enable_janitor = true; // automatically free memory when idle
+ .symbol$ = "~"; // symbol for GM-only commands
+
+ // register some arrays
+ callfunc("TREE_dictionaries");
+
+ // do random stuff
+ make_quote_table();
+ face();
+
+ // boring stuff below
+ .version = 20; // increase this when you make a change
+ .uptime = gettimetick(2);
+ .alwaysVisible = true; // the NPC doesn't de-spawn when moving away
+ .pid = 1; // regex pattern id
+ .msg_ht = htnew(); // hashtable id for message history
+ .seen_ht = htnew(); // hashtable id for seen log
+ .ignore_ht = htnew(); // hashtable id for ignored players
+ .roulette = rand(1, 7); // spin the chambers
+ defpattern(.pid, "^(.*)$", "OnTalkNearby");
+ activatepset(.pid);
+ if (.enable_janitor) {
+ initnpctimer();
+ }
}
// Duplicates below
diff --git a/npc/functions/util.txt b/npc/functions/util.txt
new file mode 100644
index 00000000..fb4541f8
--- /dev/null
+++ b/npc/functions/util.txt
@@ -0,0 +1,35 @@
+// Evol functions.
+// Authors:
+// Reid
+// Description:
+// Util functions
+
+
+// season_direction({day, month})
+// returns the direction that represents our current season (approximation)
+// DOWN: Winter, 21/12
+// DOWNLEFT: Spring, 20/03
+// LEFT: Summer, 21/06
+// LEFTUP: Autumn, 22/09
+
+function script season_direction {
+ .@current_month = getarg(0, gettime(GETTIME_MONTH));
+
+ if (.@current_month % 3 == 0)
+ {
+ .@current_day = getarg(1, gettime(GETTIME_DAYOFMONTH));
+
+ switch (.@current_month)
+ {
+ case MARCH: .@season_day = 20; break;
+ case JUNE: .@season_day = 21; break;
+ case SEPTEMBER: .@season_day = 22; break;
+ case DECEMBER: .@season_day = 21; break;
+ default: break;
+ }
+
+ .@is_after_season_day = .@current_day >= .@season_day ? 0 : -1;
+ }
+
+ return (.@current_month / 3 + .@is_after_season_day) % 4;
+}
diff --git a/npc/scripts.conf b/npc/scripts.conf
index 9b753693..83fb0348 100644
--- a/npc/scripts.conf
+++ b/npc/scripts.conf
@@ -43,6 +43,7 @@
"npc/functions/riddle.txt",
"npc/functions/bank.txt",
"npc/functions/confused-tree-dict.txt",
+"npc/functions/util.txt",
// quest debug
"npc/functions/quest-debug/functions.txt",