diff options
author | Fedja Beader <fedja@protonmail.ch> | 2024-07-03 00:51:23 +0200 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2024-07-03 00:51:23 +0200 |
commit | a9857b7f096945c8a66b72068d697ae7aef73915 (patch) | |
tree | 7c04a5b091038e35d3d18ebeaa9296f0372818bf | |
parent | 396ffcbe75ebe04098200f5b9644f27a8909d038 (diff) | |
download | serverdata-a9857b7f096945c8a66b72068d697ae7aef73915.tar.gz serverdata-a9857b7f096945c8a66b72068d697ae7aef73915.tar.bz2 serverdata-a9857b7f096945c8a66b72068d697ae7aef73915.tar.xz serverdata-a9857b7f096945c8a66b72068d697ae7aef73915.zip |
Jhedia now says how many ingots she can create using the presented material.
+ a bit of rewrite doesen't hurt
-rw-r--r-- | npc/003-8/jhedia.txt | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/npc/003-8/jhedia.txt b/npc/003-8/jhedia.txt index 3b7cc6710..b1950d7b3 100644 --- a/npc/003-8/jhedia.txt +++ b/npc/003-8/jhedia.txt @@ -12,43 +12,55 @@ // ingot_create( BaseItem, PrizeItem, Amount, Amount_Coal, Price ) function ingot_create { - .@basei=getarg(0); - .@prize=getarg(1); - .@oream=getarg(2); - .@coalm=getarg(3); - .@price=getarg(4); + .@ore_id = getarg(0); + .@prize = getarg(1); + .@ore_amount = getarg(2); + .@coal_amount = getarg(3); + .@price = getarg(4); - // Adjust price - .@price=POL_AdjustPrice(.@price); + .@price = POL_AdjustPrice(.@price); mesn; - mesq l("Do you want to craft @@? For that I will need @@ @@, @@ @@ and @@ gp.", - getitemlink(.@prize), .@oream, getitemlink(.@basei), .@coalm, getitemlink(Coal), .@price); + mesq l("Do you want to craft %s? For that I will need %d %s, %d %s and %s gp.", + getitemlink(.@prize), + .@ore_amount, getitemlink(.@ore_id), + .@coal_amount, getitemlink(Coal), + fnum(.@price)); next; mesn; - mesq l("How many ingots do you want to make?"); + + .@can_smelt_amount = min(countitem(.@ore_id) / .@ore_amount, + countitem(Coal) / .@coal_amount, + Zeny / .@price); + + mesq l("How many ingots do you want to make? You can make at most %d of them.", .@can_smelt_amount); input .@amount; if (.@amount < 1) close; - if (countitem(.@basei) >= .@amount * .@oream && countitem(Coal) >= .@amount * .@coalm && Zeny >= .@price * .@amount) { + // repeat calc for cheatan prevention (is this really necessary?) + .@can_smelt_amount = min(countitem(.@ore_id) / .@ore_amount, + countitem(Coal) / .@coal_amount, + Zeny / .@price); + + if (.@amount <= .@can_smelt_amount) { inventoryplace .@prize, .@amount; - delitem .@basei, .@amount * .@oream; - delitem Coal, .@amount * .@coalm; - POL_PlayerMoney(.@amount * .@price); + delitem .@ore_id, .@amount * .@ore_amount; + delitem Coal, .@amount * .@coal_amount; + POL_PlayerMoney (.@amount * .@price); getitem .@prize, .@amount; - getexp (JobLevel+.@oream+.@coalm)*.@amount, .@amount; + getexp .@amount * (JobLevel + .@ore_amount + .@coal_amount), + .@amount; mes ""; mesn; mesq l("Many thanks! Come back soon."); - close; + } else { + speech S_FIRST_BLANK_LINE,// | S_LAST_NEXT, + l("You don't have enough material, sorry."); } - - speech S_FIRST_BLANK_LINE,// | S_LAST_NEXT, - l("You don't have enough material, sorry."); close; } |