summaryrefslogtreecommitdiff
path: root/npc/functions/util.txt
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-08-10 22:26:02 -0300
committerJesusaves <cpntb1@ymail.com>2019-08-10 22:26:02 -0300
commitc52867f3e29d35044fad5c74e42cf5f28809b3e3 (patch)
treeeaeec32e5c2cba472b128ae04579040caa4e8384 /npc/functions/util.txt
parenteb97c9821bf5bf9af11fd9a24f5dad280701cf06 (diff)
downloadserverdata-c52867f3e29d35044fad5c74e42cf5f28809b3e3.tar.gz
serverdata-c52867f3e29d35044fad5c74e42cf5f28809b3e3.tar.bz2
serverdata-c52867f3e29d35044fad5c74e42cf5f28809b3e3.tar.xz
serverdata-c52867f3e29d35044fad5c74e42cf5f28809b3e3.zip
Introduce a transcheck helper to optimize transmigration code
Diffstat (limited to 'npc/functions/util.txt')
-rw-r--r--npc/functions/util.txt20
1 files changed, 20 insertions, 0 deletions
diff --git a/npc/functions/util.txt b/npc/functions/util.txt
index 0e50e2d30..df4cc8463 100644
--- a/npc/functions/util.txt
+++ b/npc/functions/util.txt
@@ -699,6 +699,26 @@ function script mlearn {
return true;
}
*/
+// transcheck( {item 1, amount 1}, {item 2, amount 2}... )
+// returns true upon success
+function script transcheck {
+ if (getargcount() < 2 || getargcount() % 2 != 0)
+ return Exception("Faulty learning skill command invoked - error");
+
+ // Count items
+ for (.@i=0;.@i < getargcount(); .@i++) {
+ if (countitem(getarg(.@i)) < getarg(.@i+1))
+ return false;
+ .@i++;
+ }
+
+ // Delete Items
+ for (.@i=0;.@i < getargcount(); .@i++) {
+ delitem getarg(.@i), getarg(.@i+1);
+ .@i++;
+ }
+ return true;
+}
// Returns a value defining your current magic control (affects success ratio, higher is better)
// A value of '5' means perfect control, and a value of '0' means overwhelm.