summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2020-08-06 12:22:24 -0400
committergumi <git@gumi.ca>2020-08-06 21:03:32 -0400
commitb53f008adfdd4d42eea3bededc2308d26154cff0 (patch)
tree29957257aadf6608224d947545a9367cb6a94c95
parentcab095a0e7b132d67a03412a6c3a9cf3e89c943a (diff)
downloadserverdata-b53f008adfdd4d42eea3bededc2308d26154cff0.tar.gz
serverdata-b53f008adfdd4d42eea3bededc2308d26154cff0.tar.bz2
serverdata-b53f008adfdd4d42eea3bededc2308d26154cff0.tar.xz
serverdata-b53f008adfdd4d42eea3bededc2308d26154cff0.zip
refactor the narrator function and add S_LAST_CLOSE
-rw-r--r--db/constants.conf9
-rw-r--r--npc/functions/main.txt46
2 files changed, 32 insertions, 23 deletions
diff --git a/db/constants.conf b/db/constants.conf
index 94afab25..1a3c07cd 100644
--- a/db/constants.conf
+++ b/db/constants.conf
@@ -4826,10 +4826,11 @@ constants_db: {
AUTUMN: 3
comment__: "speechflags"
- S_FIRST_BLANK_LINE: 1
- S_LAST_BLANK_LINE: 2
- S_LAST_NEXT: 4
- S_NO_NPC_NAME: 8
+ S_FIRST_BLANK_LINE: 0b00000001
+ S_LAST_BLANK_LINE: 0b00000010
+ S_LAST_NEXT: 0b00000100
+ S_NO_NPC_NAME: 0b00001000
+ S_LAST_CLOSE: 0b00010000
comment__: "npcs"
NPC_KNIVES: 100
diff --git a/npc/functions/main.txt b/npc/functions/main.txt
index 8132a78a..d65f634f 100644
--- a/npc/functions/main.txt
+++ b/npc/functions/main.txt
@@ -89,38 +89,46 @@ function script addremovemapmask {
// Function to show narrator text. Accepts string args.
// If first arg is a number N, then it represents bit flags.
// Bit flags :
-// 0x1 -- blank line at beginning
-// 0x2 -- blank line at the end
-// 0x4 -- use last "next;"
-// 0x8 -- don't use first "mesn;"
+// S_FIRST_BLANK_LINE -- blank line at beginning
+// S_LAST_BLANK_LINE -- blank line at the end
+// S_LAST_NEXT -- use last "next();"
+// S_NO_NPC_NAME -- don't use first "mesn();"
+// S_LAST_CLOSE -- use last "close2();
function script narrator {
.@start = 0;
.@argc = getargcount();
.@flags = 0;
- if (.@argc > 1 && !isstr(getarg(0)))
- {
+ if (.@argc > 1 && (getdatatype(getarg(0)) & DATATYPE_INT) != 0) {
.@start = 1;
.@flags = getarg(0);
}
- if (.@flags & 0x1)
- mes "";
+ if ((.@flags & S_FIRST_BLANK_LINE) != 0) {
+ mes("");
+ }
- if (!(.@flags & 0x8))
- mesn l("Narrator");
+ if ((.@flags & S_NO_NPC_NAME) == 0) {
+ mesn(l("Narrator"));
+ }
- for (.@i = .@start; .@i < .@argc; .@i++)
- {
- mes col(getarg(.@i), 9);
- if (.@i < .@argc - 1)
- next;
+ for (.@i = .@start; .@i < .@argc; .@i++) {
+ mes(col(getarg(.@i), 9));
+
+ if (.@i < .@argc - 1) {
+ next();
+ }
}
- if (.@flags & 0x4)
- next;
- else if (.@flags & 0x2)
- mes "";
+ if ((.@flags & S_LAST_BLANK_LINE) != 0) {
+ mes("");
+ }
+
+ if ((.@flags & S_LAST_NEXT) != 0) {
+ next();
+ } else if ((.@flags & S_LAST_CLOSE) != 0) {
+ close2();
+ }
return;
}