diff options
author | Jesusalva Jesusalva <jesusalva@themanaworld.org> | 2023-08-17 12:31:35 +0000 |
---|---|---|
committer | Jesusalva Jesusalva <jesusalva@themanaworld.org> | 2023-08-17 12:31:35 +0000 |
commit | aed8aeb9340e98eb633b644a2ce01e31d2b5ce07 (patch) | |
tree | 5369b91756a293afdfe33c1f674b1d6a0c45b3d1 /npc | |
parent | 9e8f26db93528aa74dfbafdf4a642ff5c3d5b623 (diff) | |
parent | ff594c70b4483c2a9836e5db30522eb0caf8a80f (diff) | |
download | serverdata-aed8aeb9340e98eb633b644a2ce01e31d2b5ce07.tar.gz serverdata-aed8aeb9340e98eb633b644a2ce01e31d2b5ce07.tar.bz2 serverdata-aed8aeb9340e98eb633b644a2ce01e31d2b5ce07.tar.xz serverdata-aed8aeb9340e98eb633b644a2ce01e31d2b5ce07.zip |
Merge branch 'smith_tweak_points_dedup' into 'master'
Deduplicate SMITH_TWEAK points code between ihclot and tweak scripts.
See merge request ml/serverdata!114
Diffstat (limited to 'npc')
-rw-r--r-- | npc/025-1/ihclot.txt | 18 | ||||
-rw-r--r-- | npc/craft/tweak.txt | 43 |
2 files changed, 33 insertions, 28 deletions
diff --git a/npc/025-1/ihclot.txt b/npc/025-1/ihclot.txt index 10ebb0a44..243adbbd6 100644 --- a/npc/025-1/ihclot.txt +++ b/npc/025-1/ihclot.txt @@ -5,17 +5,14 @@ // Ihclot is Tolchi spelled backwards 025-1,96,66,0 script Ihclot NPC_RAIJIN_FEMALE_LEGION_ARTIS,{ - function apRefresh; function getPrice; function getPriceInt; - .@left=apRefresh(); mesn; mesq l("I put options on items upon request, but I am very expensive! This is deducted from your tweaking quota."); - if (!.@left) { - mesc l("You currently have no Tweaking AP, so you will need to wait %02d minute(s).", 60-gettime(GETTIME_MINUTE)), 1; + if (!SmithTweakPointsExplain()) // also returns number of tweaking pts left close; - } + next; mesn; mesq l("I'll read the options from you, but the level will be paid by me, and failure rate is non-existant. I am the best. blacksmith. in. the. universe! Use %s if you need to change any options.", b("@ucp")); @@ -94,7 +91,7 @@ // Perform payment Zeny-=getPriceInt(.@price, .@level); - SMITH_TWEAKS+=1; + SmithTweakPointsDecrement(); // even if lightbringer. // Apply the bonuses csys_ApplyPerfect(.@id, .@level); @@ -111,15 +108,6 @@ close; /* *************************************************************************** */ -function apRefresh { - .@left=gettimeparam(GETTIME_HOUR)-SMITH_TWEAKS; - if (.@left > 6) { - .@left=6; - SMITH_TWEAKS=gettimeparam(GETTIME_HOUR)-6; - } - return .@left; -} - function getPriceInt { .@price=getarg(0); .@level=getarg(1); 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 |