diff options
author | gumi <mekolat@users.noreply.github.com> | 2017-08-20 11:34:59 -0400 |
---|---|---|
committer | gumi <mekolat@users.noreply.github.com> | 2017-08-22 11:26:46 -0400 |
commit | e9c90337a6057b66faad6759ff418e8a5f162cfe (patch) | |
tree | 28dd5e161c5cf2d188a93b8f128b5d38c27e1004 | |
parent | 7c7b7cb886290a4b339e15e2f27ce5b5e86aa85a (diff) | |
download | serverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.tar.gz serverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.tar.bz2 serverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.tar.xz serverdata-e9c90337a6057b66faad6759ff418e8a5f162cfe.zip |
reorganize the framework functions
-rw-r--r-- | npc/functions/main.txt | 65 | ||||
-rw-r--r-- | npc/functions/math.txt | 40 | ||||
-rw-r--r-- | npc/functions/string.txt | 9 | ||||
-rw-r--r-- | npc/re/scripts_main.conf | 1 | ||||
-rw-r--r-- | npc/scripts.conf | 12 |
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", |