diff options
author | Fedja Beader <fedja@protonmail.ch> | 2023-08-17 12:31:34 +0000 |
---|---|---|
committer | Jesusalva Jesusalva <jesusalva@themanaworld.org> | 2023-08-17 12:31:34 +0000 |
commit | ff594c70b4483c2a9836e5db30522eb0caf8a80f (patch) | |
tree | a5327bbfd93a86921842052ba04e98c93d60683f /npc/craft/tweak.txt | |
parent | 567f2f7bfaa579ae63f40d466a1ab2dc7cb3f1eb (diff) | |
download | serverdata-ff594c70b4483c2a9836e5db30522eb0caf8a80f.tar.gz serverdata-ff594c70b4483c2a9836e5db30522eb0caf8a80f.tar.bz2 serverdata-ff594c70b4483c2a9836e5db30522eb0caf8a80f.tar.xz serverdata-ff594c70b4483c2a9836e5db30522eb0caf8a80f.zip |
Deduplicate SMITH_TWEAK points code between ihclot and tweak scripts.
Diffstat (limited to 'npc/craft/tweak.txt')
-rw-r--r-- | npc/craft/tweak.txt | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/npc/craft/tweak.txt b/npc/craft/tweak.txt index 1124aface..b35c17dc3 100644 --- a/npc/craft/tweak.txt +++ b/npc/craft/tweak.txt @@ -6,6 +6,33 @@ // Notes: // It's like smithing, but it only change an item options +// How many times more can you tweak? +// You regenerate 1 action per hour, capped at 6 actions total. +function script SmithTweakPointsLeft { + .@points = gettimeparam(GETTIME_HOUR) - SMITH_TWEAKS; + if (.@points > 6) { + .@points = 6; + SMITH_TWEAKS = gettimeparam(GETTIME_HOUR) - 6; + } + return .@points; +} + +function script SmithTweakPointsDecrement { + .@item_id = getarg(0, -1); + if (.@item_id != Lightbringer) + SMITH_TWEAKS += 1; +} + +function script SmithTweakPointsExplain { + .@points = SmithTweakPointsLeft(); + mesc l("Note: You can only perform this operation @@/6 times.", .@points); + mesc l("You recover a tweaking point every hour."); + if (!.@points) + mesc l("You currently have no Tweaking AP, so you will need to wait %02d minute(s).", 60-gettime(GETTIME_MINUTE)), 1; + return .@points; +} + + // Usage: SmithTweakReset () // Asks if player wants to remove an item options. And remove them. function script SmithTweakReset { @@ -36,24 +63,15 @@ function script SmithTweakSystem { if (.@retry == 1) .@price=POL_AdjustPrice(.@price); - // How many times more can you tweak? - // You get 1 action, capped to 6 - .@left=gettimeparam(GETTIME_HOUR)-SMITH_TWEAKS; - if (.@left > 6) { - .@left=6; - SMITH_TWEAKS=gettimeparam(GETTIME_HOUR)-6; - } - mes l("Which item will you tweak?"); - mesc l("Note: You can only perform this operation @@/6 times.", .@left); - mesc l("You recover a tweaking point every hour."); + .@points_left = SmithTweakPointsExplain(); mesc l("EXPERTS ONLY - If you are not a talented crafter, avoid this."), 1; mesc l("The item must have a previous bonus, which WILL BE LOST!"), 1; mesc l("Note: You may fail to write skills to it."), 1; mesc l("Operation Cost: @@ GP", .@price), 3; // Do you have money or AP - if (Zeny < .@price || !.@left) { + if (Zeny < .@price || !.@points_left) { mesc l("You lack money or Action Points."), 1; return false; } @@ -96,8 +114,7 @@ function script SmithTweakSystem { // Take the money and AP away POL_PlayerMoney(.@price); - if (.@x != Lightbringer) - SMITH_TWEAKS+=1; + SmithTweakPointsDecrement(.@x); // Apply the bonuses. This will only loop if `continue;` is cast. // `continue` will only be cast if .@retry is set |