summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
Diffstat (limited to 'npc')
-rw-r--r--npc/functions/main.txt65
-rw-r--r--npc/functions/math.txt40
-rw-r--r--npc/functions/string.txt9
-rw-r--r--npc/re/scripts_main.conf1
-rw-r--r--npc/scripts.conf12
5 files changed, 77 insertions, 50 deletions
diff --git a/npc/functions/main.txt b/npc/functions/main.txt
index ffac13bd..f3fca9b4 100644
--- a/npc/functions/main.txt
+++ b/npc/functions/main.txt
@@ -50,10 +50,6 @@ function script adddefaultskills {
return;
}
-function script str {
- return "" + getarg(0);
-}
-
function script addremovemapmask {
setmapmask getarg(0), (getmapmask(getarg(0)) | (getarg(1) + getarg(2))) ^ getarg(2);
return;
@@ -145,11 +141,6 @@ function script npcdebug {
return;
}
-function script abs {
- .@n = getarg(0);
- return .@n >= 0 ? .@n : -.@n;
-}
-
function script askyesno {
return select (menuaction(l("Yes")),
menuaction(l("No")));
@@ -178,51 +169,37 @@ function script compareandsetq {
// 1 = npctalk
// 2 = message
function script npctalkonce {
- if ((.@current_time = gettimetick(2)) < Repeat_NPC_lock)
+ if (getarg(2, 0) == 0)
{
- return false;
+ if (now() <= @misc_NPC_lock)
+ {
+ @misc_NPC_lock = now() + getarg(1, 1);
+ return false;
+ }
+ npctalk3(getarg(0));
}
- Repeat_NPC_lock = .@current_time + getarg(1,1);
-
- if (getarg(2,0) == 0)
- {
- npctalk3 getarg(0);
- }
- else if (getarg(2,0) == 1)
+ else if (getarg(2, 0) == 1)
{
- npctalk getarg(0);
+ if (now() <= .talk_lock)
+ {
+ .talk_lock = now() + getarg(1, 1);
+ return false;
+ }
+ npctalk(getarg(0));
}
- else if (getarg(2,0) == 2)
+ else if (getarg(2, 0) == 2)
{
- message strcharinfo(0), getarg(0);
+ if (now() <= @misc_NPC_lock)
+ {
+ @misc_NPC_lock = now() + getarg(1, 1);
+ return false;
+ }
+ message(strcharinfo(0), getarg(0));
}
return true;
}
-// A somehow of BaseLevel * logn (BaseLevel * alpha).
-// alpha = multiplicator factor.
-// min = minimum result value.
-function script lognbaselvl {
- .@alpha = getarg(0, 1);
- .@min = getarg(1, 1);
- .@ret = 0;
- .@pc_level = BaseLevel * .@alpha;
-
- while (.@pc_level >>= 1)
- {
- ++.@ret;
- }
- .@ret *= BaseLevel;
-
- if (.@ret <= .@min)
- {
- .@ret = .@min;
- }
-
- return .@ret;
-}
-
function script getquestlink {
return "[@@q" + getarg(0) + "|@@]";
}
diff --git a/npc/functions/math.txt b/npc/functions/math.txt
new file mode 100644
index 00000000..004125c7
--- /dev/null
+++ b/npc/functions/math.txt
@@ -0,0 +1,40 @@
+// Evol functions.
+// Authors:
+// 4144
+// Reid
+// Description:
+// Math functions
+
+
+// abs(<int>)
+// returns the absolute value of the passed integer
+
+function script abs {
+ .@n = getarg(0);
+ return .@n >= 0 ? .@n : -.@n;
+}
+
+
+
+// lognbaselvl({<multiplicator>{, <min value>}})
+// returns BaseLevel * logn (BaseLevel * alpha).
+
+function script lognbaselvl {
+ .@alpha = getarg(0, 1);
+ .@min = getarg(1, 1);
+ .@ret = 0;
+ .@pc_level = BaseLevel * .@alpha;
+
+ while (.@pc_level >>= 1)
+ {
+ ++.@ret;
+ }
+ .@ret *= BaseLevel;
+
+ if (.@ret <= .@min)
+ {
+ .@ret = .@min;
+ }
+
+ return .@ret;
+}
diff --git a/npc/functions/string.txt b/npc/functions/string.txt
index 782179d5..efeaf476 100644
--- a/npc/functions/string.txt
+++ b/npc/functions/string.txt
@@ -2,6 +2,15 @@
// ** does not require PCRE
+// str(<int>)
+// returns whatever is passed, converted to string
+
+function script str {
+ return "" + getarg(0);
+}
+
+
+
// startswith("<string>", "<search>")
// returns true if <string> begins with <search>
diff --git a/npc/re/scripts_main.conf b/npc/re/scripts_main.conf
index 1861cabc..8574cb92 100644
--- a/npc/re/scripts_main.conf
+++ b/npc/re/scripts_main.conf
@@ -1,5 +1,4 @@
// Only files that are included here will be read by the server
npc_global_list: (
-"npc/functions/main.txt",
@include "npc/scripts.conf"
) // npc_global_list
diff --git a/npc/scripts.conf b/npc/scripts.conf
index 3c5bc7cf..9b753693 100644
--- a/npc/scripts.conf
+++ b/npc/scripts.conf
@@ -3,11 +3,6 @@
// Critical functions
"npc/functions/permissions.txt",
-// Item functions
-"npc/items/croconut.txt",
-"npc/items/shovel.txt",
-"npc/items/rand_sc_heal.txt",
-
// General-purpose Framework functions
"npc/functions/array.txt",
"npc/functions/time.txt",
@@ -15,8 +10,10 @@
"npc/functions/input.txt",
"npc/functions/string.txt",
"npc/functions/RNGesus.txt",
+"npc/functions/math.txt",
// Misc functions
+"npc/functions/main.txt",
"npc/functions/asleep.txt",
"npc/functions/barber.txt",
"npc/functions/clientversion.txt",
@@ -83,6 +80,11 @@
"npc/functions/quest-debug/032-ArtisQuests_MonaDad.txt",
"npc/functions/quest-debug/033-Artis_Legion_Progress.txt",
+// Item functions
+"npc/items/croconut.txt",
+"npc/items/shovel.txt",
+"npc/items/rand_sc_heal.txt",
+
// custom atcommands
"npc/commands/music.txt",
"npc/commands/warp.txt",