summaryrefslogtreecommitdiff
path: root/npc/functions/util.txt
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-05-24 15:40:24 -0300
committerJesusaves <cpntb1@ymail.com>2019-05-24 15:40:24 -0300
commitdb020f7cccf3894ace14558b4c737ccc9f16886d (patch)
treea3d06ce383427ab09162170fe8c589f2dcda5b50 /npc/functions/util.txt
parent9de7d8b72c6f83131d563fc64e5c8fe4da9bd300 (diff)
downloadserverdata-db020f7cccf3894ace14558b4c737ccc9f16886d.tar.gz
serverdata-db020f7cccf3894ace14558b4c737ccc9f16886d.tar.bz2
serverdata-db020f7cccf3894ace14558b4c737ccc9f16886d.tar.xz
serverdata-db020f7cccf3894ace14558b4c737ccc9f16886d.zip
mlearn() skill, meant to reduce the maintenance cost on Magic Schools.
Diffstat (limited to 'npc/functions/util.txt')
-rw-r--r--npc/functions/util.txt39
1 files changed, 39 insertions, 0 deletions
diff --git a/npc/functions/util.txt b/npc/functions/util.txt
index 644954942..c83f040b0 100644
--- a/npc/functions/util.txt
+++ b/npc/functions/util.txt
@@ -603,6 +603,45 @@ function script sk_intcost {
return 0;
}
+// Magic School Learning Interface
+// mlearn( skill, {item 1, amount 1}, {item 2, amount 2}... )
+// returns false if cheater
+function script mlearn {
+ if (getargcount() < 2 || getargcount() % 2 != 1)
+ return Exception("Faulty learning skill command invoked - error");
+
+ .@sk=getarg(0);
+
+ // List required ingredients
+ mesq l("This useful skill will only require:");
+ for (.@i=1;.@i < getargcount(); .@i++) {
+ mesc l("@@/@@ @@", countitem(getarg(.@i)), (getskilllv(.@sk)+1)*getarg(.@i+1), getitemlink(getarg(.@i)));
+ .@i++;
+ }
+ // getarg(.@i)
+ next;
+ if (askyesno() == ASK_NO)
+ return true;
+
+ // Count items
+ for (.@i=1;.@i < getargcount(); .@i++) {
+ if (countitem(getarg(.@i)) < (getskilllv(.@sk)+1)*getarg(.@i+1))
+ return false;
+ .@i++;
+ }
+
+ // Delete Items
+ for (.@i=1;.@i < getargcount(); .@i++) {
+ delitem getarg(.@i), (getskilllv(.@sk)+1)*getarg(.@i+1);
+ .@i++;
+ }
+
+ sk_lvup(.@sk);
+ next;
+
+ 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.
// abizit()