summaryrefslogtreecommitdiff
path: root/npc/functions/util.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/functions/util.txt')
-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}... )