diff options
-rw-r--r-- | npc/003-8/jhedia.txt | 76 |
1 files changed, 48 insertions, 28 deletions
diff --git a/npc/003-8/jhedia.txt b/npc/003-8/jhedia.txt index 28ea60bd7..8c7d6cc3b 100644 --- a/npc/003-8/jhedia.txt +++ b/npc/003-8/jhedia.txt @@ -10,31 +10,38 @@ 003-8,28,30,0 script Jhedia NPC_ELVEN_FEMALE,{ goto L_Menu; - // ingot_create( PrizeItem, Price, OreId, OreAmount, CoalAmount ) + // ingot_create( PrizeItem, Price, first_item, first_amount, second_item, second_amount, ..) function ingot_create { .@prize = getarg(0); .@price = getarg(1); - .@ore_id = getarg(2); - .@ore_amount = getarg(3); - .@coal_amount = getarg(4); .@price = POL_AdjustPrice(.@price); + if (getargcount() < 2 || getargcount() % 2 != 0) + return Exception("Faulty ingot_create command invoked - arg count error"); + mesn; mesq l("Do you want to craft %s? For that I will need:", getitemlink(.@prize)); - mesc l("* %d %s", .@ore_amount, getitemlink(.@ore_id)), 9; - mesc l("* %d %s", .@coal_amount, getitemlink(Coal)), 9; - mesc l("* %s gp", fnum(.@price)), 9; + // TODO: Any constant to check for max stack? + .@can_smelt_amount = 32500 - countitem(.@prize); + + for (.@index = 2; .@index < getargcount(); .@index += 2) { + mesc l("* %d %s", getarg(.@index + 1), getitemlink(getarg(.@index))), 9; + .@can_smelt_amount = min(.@can_smelt_amount, + countitem(getarg(.@index)) / getarg(.@index + 1)); + } + + if (.@price != 0) { + .@can_smelt_amount = min(.@can_smelt_amount, + Zeny / .@price); + mesc l("* %s gp", fnum(.@price)), 9; + } next; mesn; - .@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); @@ -44,17 +51,30 @@ close; // repeat calc for cheatan prevention (is this really necessary?) - .@can_smelt_amount = min(countitem(.@ore_id) / .@ore_amount, - countitem(Coal) / .@coal_amount, - Zeny / .@price); + // TODO: Any constant to check for max stack? + .@can_smelt_amount = 32500 - countitem(.@prize); + + for (.@index = 2; .@index < getargcount(); .@index += 2) { + .@can_smelt_amount = min(.@can_smelt_amount, + countitem(getarg(.@index)) / getarg(.@index + 1)); + } + + if (.@price != 0) { + .@can_smelt_amount = min(.@can_smelt_amount, + Zeny / .@price); + } + if (.@amount <= .@can_smelt_amount) { inventoryplace .@prize, .@amount; - delitem .@ore_id, .@amount * .@ore_amount; - delitem Coal, .@amount * .@coal_amount; + .@spent_item_count = 0; + for (.@index = 2; .@index < getargcount(); .@index += 2) { + .@spent_item_count += getarg(.@index + 1); + delitem getarg(.@index), getarg(.@index + 1); + } POL_PlayerMoney (.@amount * .@price); getitem .@prize, .@amount; - getexp .@amount * (JobLevel + .@ore_amount + .@coal_amount), + getexp .@amount * (JobLevel + .@spent_item_count), .@amount; mes ""; @@ -89,37 +109,37 @@ L_Menu: // ingot_create(Ore, Ingot, Nº of Ore, Nº of Coal, Price); switch (@menu) { case 1: - ingot_create(IronIngot, 740, IronOre, 6, 9); + ingot_create(IronIngot, 740, IronOre, 6, Coal, 9); break; case 2: - ingot_create(CopperIngot, 750, CopperOre, 4, 7); + ingot_create(CopperIngot, 750, CopperOre, 4, Coal, 7); break; case 3: - ingot_create(TinIngot, 750, TinOre, 4, 9); + ingot_create(TinIngot, 750, TinOre, 4, Coal, 9); break; case 4: - ingot_create(SilverIngot, 650, SilverOre, 3, 7); + ingot_create(SilverIngot, 650, SilverOre, 3, Coal, 7); break; case 5: - ingot_create(GoldIngot, 850, GoldOre, 3, 9); + ingot_create(GoldIngot, 850, GoldOre, 3, Coal, 9); break; case 6: - ingot_create(GoldPieces, 1100, GoldOre, 1, 20); + ingot_create(GoldPieces, 1100, GoldOre, 1, Coal, 20); break; case 7: - ingot_create(LeadIngot, 760, LeadOre, 4, 1); + ingot_create(LeadIngot, 760, LeadOre, 4, Coal, 1); break; case 8: - ingot_create(TitaniumIngot, 800, TitaniumOre, 4, 9); + ingot_create(TitaniumIngot, 800, TitaniumOre, 4, Coal, 9); break; case 9: - ingot_create(IridiumIngot, 1100, IridiumOre, 4, 10); + ingot_create(IridiumIngot, 1100, IridiumOre, 4, Coal, 10); break; case 10: - ingot_create(PlatinumIngot, 1650, PlatinumOre, 3, 10); + ingot_create(PlatinumIngot, 1650, PlatinumOre, 3, Coal, 10); break; case 11: - ingot_create(TerraniteIngot, 2000, TerraniteOre, 10, 20); + ingot_create(TerraniteIngot, 2000, TerraniteOre, 10, Coal, 20); break; default: goto L_Close; |