summaryrefslogtreecommitdiff
path: root/npc/functions
diff options
context:
space:
mode:
authorgumi <mekolat@users.noreply.github.com>2017-08-20 11:34:59 -0400
committergumi <mekolat@users.noreply.github.com>2017-08-22 11:26:46 -0400
commite9c90337a6057b66faad6759ff418e8a5f162cfe (patch)
tree28dd5e161c5cf2d188a93b8f128b5d38c27e1004 /npc/functions
parent7c7b7cb886290a4b339e15e2f27ce5b5e86aa85a (diff)
downloadserverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.tar.gz
serverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.tar.bz2
serverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.tar.xz
serverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.zip
reorganize the framework functions
Diffstat (limited to 'npc/functions')
-rw-r--r--npc/functions/main.txt65
-rw-r--r--npc/functions/math.txt40
-rw-r--r--npc/functions/string.txt9
3 files changed, 70 insertions, 44 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>