summaryrefslogtreecommitdiff
path: root/npc/functions
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-07-19 18:59:20 -0300
committerJesusaves <cpntb1@ymail.com>2019-07-19 18:59:20 -0300
commit490b3ef02d6420c78f19f5525443bce393252b3e (patch)
treea354c6629179cdb7d4a220297fe32c6565e81633 /npc/functions
parent0c7de4dc5c467e7d81035c8eb7a91bd8dd513dbf (diff)
downloadserverdata-490b3ef02d6420c78f19f5525443bce393252b3e.tar.gz
serverdata-490b3ef02d6420c78f19f5525443bce393252b3e.tar.bz2
serverdata-490b3ef02d6420c78f19f5525443bce393252b3e.tar.xz
serverdata-490b3ef02d6420c78f19f5525443bce393252b3e.zip
Reintroduce mlearn(), and optimize the code.
Diffstat (limited to 'npc/functions')
-rw-r--r--npc/functions/util.txt34
1 files changed, 30 insertions, 4 deletions
diff --git a/npc/functions/util.txt b/npc/functions/util.txt
index 426219bb5..51f366b4b 100644
--- a/npc/functions/util.txt
+++ b/npc/functions/util.txt
@@ -599,11 +599,9 @@ function script sk_points {
}
// Returns true if a skill can be leveled up.
-// sk_canlvup( item{, cost=1} )
+// sk_canlvup( {cost=1} )
function script sk_canlvup {
- return (
- countitem(getarg(0)) &&
- (MAGIC_PTS+getarg(1,1)) <= sk_maxpoints());
+ return ((MAGIC_PTS+getarg(0,1)) <= sk_maxpoints());
}
// Level up a skill in 1 level
@@ -619,6 +617,34 @@ function script sk_lvup {
return;
}
+// NEW Magic School Learning Interface
+// mlearn( skill, MAX_LV, AP cost, item, amount )
+// returns false if cheater
+function script mlearn {
+ .@sk=getarg(0);
+ .@ff=getarg(1);
+ .@ap=getarg(2);
+ .@it=getarg(3);
+ .@am=getarg(4);
+ if (getskilllv(.@sk) >= .@ff) {
+ mesc l("You've reached the maximum level for this skill."), 1;
+ return true;
+ }
+ mesc l("To learn @@ you'll need @@/@@ point(s).", .@sk, .@ap, sk_points());
+ mesc l("You'll also need to pay a fee of @@x @@", .@am, getitemlink(.@it));
+ next;
+ if (askyesno() == ASK_NO)
+ return true;
+ if (countitem(.@it) < .@am)
+ return false;
+ if (!sk_canlvup(.@ap))
+ return false;
+
+ delitem .@it, .@am;
+ sk_lvup(.@sk, .@ap);
+ return true;
+}
+
/*
// Magic School Learning Interface
// mlearn( skill, {item 1, amount 1}, {item 2, amount 2}... )