diff options
-rw-r--r-- | npc/functions/util.txt | 78 |
1 files changed, 62 insertions, 16 deletions
diff --git a/npc/functions/util.txt b/npc/functions/util.txt index 9b5d63d02..73218f5f9 100644 --- a/npc/functions/util.txt +++ b/npc/functions/util.txt @@ -709,38 +709,84 @@ function script sk_lvup { } // NEW Magic School Learning Interface -// mlearn( skill, MAX_LV, AP cost, item, amount ) +// learn_magic(Skill) +function script learn_magic { + .@ski=getarg(0); + .@learn$=l("Learning"); + + // Load a few temporary variables + .@pre=$@MSK_PREREQ[.@ski]; + .@it=$@MSK_ITEM[.@ski]; + .@am=$@MSK_AMOUNT[.@ski]; + .@msp=$@MSK_MSPCOST[.@ski]; + .@ap=$@MSK_COST[.@ski]; + .@mlv=$@MSK_MAXLV[.@ski]; + + // Pre-requisite check + if (.@pre) { + if (getskilllv(.@pre) < 1) { + mesc l("Pre-requisites not met!"), 1; + return false; + } + } + + // Max level reached + if (getskilllv(.@ski) >= .@mlv) { + mesc l("You've reached the maximum level for this skill."), 1; + return false; + } + + // Skill level check + if (getskilllv(.@sk)) { + .@msp=1; + .@learn$=l("Upgrading"); + } + + mesc l("%s %s will require:", .@learn$, str(.@ski)); + mes l("* %d/%d MSP (Magic Skill Points)", .@msp, sk_points()); + //mes l("* %d/%d AP (???)", .@ap, MAGIC_AP); + mes l("% %d/%d %s", .@am, countitem(.@it), getitemlink(.@it)); + mes ""; + mesc l("Really learn this skill?"); + if (askyesno() == ASK_NO) + return false; + + return mlearn(.@ski, .@mlv, .@msp, .@it, .@am); +} + +// LEGACY Magic School Learning Interface +// mlearn( skill, MAX_LV, MSP cost, item, amount{, AP cost} ) // returns false if cheater function script mlearn { .@sk=getarg(0); .@ff=getarg(1); - .@ap=getarg(2); + .@msp=getarg(2); .@it=getarg(3); .@am=getarg(4); - .@learn$=l("learn"); + .@ap=getarg(5, 0); + // Max level reached if (getskilllv(.@sk) >= .@ff) { - mesc l("You've reached the maximum level for this skill."), 1; - return true; - } - if (getskilllv(.@sk)) { - .@ap=1; - .@learn$=l("upgrade"); + return false; } - mesc l("To @@ @@ you'll need @@/@@ point(s).", .@learn$, .@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; + // Not enough items if (countitem(.@it) < .@am && !(countitem(ScholarshipBadge))) return false; - if (!sk_canlvup(.@ap)) + // Not enough MSP + if (!sk_canlvup(.@msp)) return false; + // TODO: Not enough AP + //if (MAGIC_AP < .@ap) { + // return false; + //} + // Payment if (countitem(.@it) < .@am) delitem ScholarshipBadge, 1; else delitem .@it, .@am; - sk_lvup(.@sk, .@ap); + + // Level up + sk_lvup(.@sk, .@msp); return true; } |