summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2022-05-15 23:36:39 -0300
committerJesusaves <cpntb1@ymail.com>2022-05-15 23:36:39 -0300
commitd9fb49a6701be213ae9b63b536212ebb761f5cbd (patch)
tree1428ad91b63a34c772f9c21dd458026b128c1d19
parenta6d68cfe1e7a8ed3b2f54533b809fbd514c6040c (diff)
downloadserverdata-d9fb49a6701be213ae9b63b536212ebb761f5cbd.tar.gz
serverdata-d9fb49a6701be213ae9b63b536212ebb761f5cbd.tar.bz2
serverdata-d9fb49a6701be213ae9b63b536212ebb761f5cbd.tar.xz
serverdata-d9fb49a6701be213ae9b63b536212ebb761f5cbd.zip
Rewrite Meltdown Forge
-rw-r--r--npc/020-5/bracco.txt207
1 files changed, 86 insertions, 121 deletions
diff --git a/npc/020-5/bracco.txt b/npc/020-5/bracco.txt
index 910eea9df..3dde27c3d 100644
--- a/npc/020-5/bracco.txt
+++ b/npc/020-5/bracco.txt
@@ -10,10 +10,78 @@
020-5,31,25,0 script Bracco NPC_M_SHOPKEEPER,{
goto L_Start;
- // Meltdown( item, price, {id1, amount1}, {id2, amount2}... )
+ // NewMeltdown( item )
+ // Meltdown the item for realz
+ function NewMeltdown {
+ .@const$ = data_to_string(getarg(0));
+
+ // Shady code by gumi
+ if (startswith(.@const$, "Craft")) {
+ // infer the item constant from the craft constant
+ .@recipe = getarg(0);
+
+ .@item = string_to_data(substr(.@const$, 5, getstrlen(.@const$) - 1));
+ } else {
+ // infer the craft constant from the item constant
+ .@recipe = string_to_data(sprintf("Craft%s", .@const$));
+ .@item = getarg(0);
+ }
+
+ if (.@item <= 0) {
+ // target item not found
+ consolebug("ERROR, INVALID ITEM ID DETECTED at NewMeltdown");
+ return;
+ }
+ // More shady code by gumi
+ for (.@inv = 0; .@inv < 9; ++.@inv) {
+ .@size = getcraftrecipe(.@recipe, .@inv, .@qty[0], .@item_id[0]);
+
+ if (.@size < 0) {
+ if (.@size == -1) {
+ // recipe does not exist
+ return 0;
+ break;
+ }
+ // inventory does not exist
+ return 0;
+ break;
+ }
+
+ // More shady code
+ for (.@it = 0; .@it < .@size; ++.@it) {
+ .@recipe_item = .@item_id[.@it];
+ .@recipe_qty = .@qty[.@it];
+
+ if (.@recipe_item <= 0) {
+ break;
+ }
+
+ // "Unique" items are never refunded
+ if (.@recipe_qty <= 1) continue;
+
+ // Coal is NEVER refunded
+ if (.@recipe_item == Coal) continue;
+
+ // New rates
+ .@mini = .@recipe_qty * 3 / 10 + 1; // Minimum: 30% + 1
+ .@maxi = .@recipe_qty / 2; // Maximum: 50% + 1
+
+ // Some sanitizing (should never happen but you can never be sure)
+ // (Could only happen if qty == 1, which is skipped)
+ if (.@mini > .@maxi)
+ .@maxi = .@mini;
+
+ .@ammo = rand2(.@mini, .@maxi);
+
+ getitem .@recipe_item, .@ammo;
+ mesc l("* Acquired @@ @@!", .@ammo, getitemlink(.@recipe_item));
+ }
+ }
+ return .@item;
+ }
+
+ // Meltdown( item, price )
function Meltdown {
- if (getargcount() < 2 || getargcount() % 2 != 0)
- return Exception("Faulty learning Meltdown command invoked - error");
if (countitem(getarg(0)) != 1) {
mesc l("Wait, if you try to melt more than one item, manaplus will get buggy."), 1;
mesc l("Please try again later!"), 1;
@@ -21,7 +89,7 @@
}
.@index=getarg(0);
- .@price=getarg(1);
+ .@price=getarg(1, getiteminfo(.@item, ITEMINFO_SELLPRICE)/10);
.@price=POL_AdjustPrice(.@price);
// Confirmation
@@ -32,25 +100,19 @@
return;
// Report it was done
- mesc l("@@ melt down your @@...", .name$, getitemlink(.@index));
+ mesc l("@@ melt down your @@...", .name$, getitemlink(.@index)), 2;
delitem .@index, 1;
POL_PlayerMoney(.@price);
// TODO: Inventoryplace.
// Add Items (if inventory is full, your fault and not mine)
- for (.@i=2;.@i < getargcount(); .@i++) {
- if (getarg(.@i+1)) {// It may be zero
- getitem getarg(.@i), getarg(.@i+1);
- mesc l("* Acquired @@ @@!", getarg(.@i+1), getitemlink(getarg(.@i)));
- }
- .@i++;
- }
+ NewMeltdown(.@index);
@indexisbroken=true;
return;
}
- // MassMeltdown( item, price, {id1, amount1}, {id2, amount2}... )
+ // MassMeltdown( item, price )
function MassMeltdown {
if (getargcount() < 2 || getargcount() % 2 != 0)
return Exception("Faulty learning Meltdown command invoked - error");
@@ -85,16 +147,10 @@
//delitemidx .@index, 1;
POL_PlayerMoney(.@price);
// Report it was done
- mesc l("@@ melt down your @@...", .name$, getitemlink(.@x));
-
- for (.@i=2;.@i < getargcount(); .@i++) {
- .@v=getarg(.@i+1)+any(-1, 0, 0, 0, 1);
- if (.@v > 0) {// It may be zero
- getitem getarg(.@i), .@v;
- mesc l("* Acquired @@ @@!", .@v, getitemlink(getarg(.@i)));
- }
- .@i++;
- }
+ mesc l("@@ melt down your @@...", .name$, getitemlink(.@x)), 2;
+
+ // Really melt it down
+ NewMeltdown(.@x);
}
}
@indexisbroken=true;
@@ -233,6 +289,7 @@ L_Irreversible:
case Dagger:
MassMeltdown(.@it, 100, IronOre, any(2, 2, 3, 3, 4));
break;
+ // MISSING
}
close;
@@ -247,7 +304,7 @@ L_Meltdown:
if (.@id <= 0)
close;
mes "";
- // Returns 50~70% of invested ingots, rounded down. Never returns Coal.
+ // Returns 30~50% of invested ingots, rounded down. Never returns Coal.
switch (.@id) {
// Special Exceptions
case SilverMirror:
@@ -268,107 +325,15 @@ L_Meltdown:
case Dagger:
Meltdown(.@id, 100, IronOre, any(2, 2, 3, 3, 4, 5)); // Exception
break;
- // Official Weapons
- case WoodenSword:
- Meltdown(.@id, 500, WoodenLog, rand2(5,10)); // Exception: 25~50% returned
- break;
- case BugSlayer:
- Meltdown(.@id, 1000, IronIngot, rand2(4,5));
- break;
- case ShortGladius:
- Meltdown(.@id, 1500, IronIngot, rand2(6,8));
- break;
- case Backsword:
- Meltdown(.@id, 2000, IronIngot, rand2(9,12), TinIngot, rand2(1,2));
- break;
- case ShortSword:
- Meltdown(.@id, 2500, IronIngot, rand2(12,16), TinIngot, rand2(2,3));
- break;
- case Kitana:
- Meltdown(.@id, 2500, IronIngot, rand2(15,21), TinIngot, rand2(4,6));
- break;
- case BoneKnife:
- Meltdown(.@id, 3000, IronIngot, rand2(18,25), Bone, rand2(45,62));
- break;
- case LongSword:
- Meltdown(.@id, 3000, IronIngot, rand2(21,29), IridiumIngot, rand2(0,1));
- break;
- case RockKnife:
- Meltdown(.@id, 3000, TerraniteOre, rand2(25,35), IridiumIngot, 1);
- break;
- case DivineSword:
- Meltdown(.@id, 3000, DivineApple, 1, PlatinumIngot, rand2(1,2), IridiumIngot, rand2(2,3));
- break;
- // 2 hand swords
- case MiereCleaver:
- Meltdown(.@id, 2000, SilverIngot, rand2(6,8));
- break;
- case Broadsword:
- Meltdown(.@id, 2000, SilverIngot, rand2(13,18));
- break;
- case Halberd:
- Meltdown(.@id, 2000, SilverIngot, rand2(22,31), TinIngot, rand2(2,3));
- break;
- case ImmortalSword:
- Meltdown(.@id, 2000, SilverIngot, rand2(20,28), IridiumIngot, 1);
- break;
- // Bows can go up to 100% but only wood is returned
- case ShortBow:
- Meltdown(.@id, 2000, WoodenLog, rand2(9,18));
- break;
- case ForestBow:
- Meltdown(.@id, 2000, WoodenLog, rand2(12,24));
- break;
- case ElficBow:
- Meltdown(.@id, 1500, WoodenLog, rand2(16,33));
- break;
- case ChampionshipBow:
- Meltdown(.@id, 1000, WoodenLog, rand2(24,48));
- break;
- case BansheeBow:
- Meltdown(.@id, 500, WoodenLog, rand2(35,70));
- break;
-
- // Wands have no warranted min. and are more expensive because they are sold
- case TrainingWand:
- Meltdown(.@id, 12000, WoodenLog, rand2(1,14), ManaPiouFeathers, rand2(0, 21), FluoPowder, rand2(0,3));
- break;
- case NoviceWand:
- Meltdown(.@id, 12000, WoodenLog, rand2(2,28), ManaPiouFeathers, rand2(1, 42), FluoPowder, rand2(0,5));
- break;
- case ApprenticeWand:
- Meltdown(.@id, 12000, WoodenLog, rand2(3,42), ManaPiouFeathers, rand2(2, 63), FluoPowder, rand2(0,8));
- break;
- case LeaderWand:
- Meltdown(.@id, 12000, WoodenLog, rand2(5,70), ManaPiouFeathers, rand2(3, 84), FluoPowder, rand2(2,10));
- break;
- case MysticWand:
- Meltdown(.@id, 12000, WoodenLog, rand2(7,77), GoldenApple, rand2(0, 1), FluoPowder, rand2(4,14));
- break;
- // Shields - same rule (except leather shield)
- case RoundLeatherShield:
- Meltdown(.@id, 500, LeatherPatch, rand2(0,1));
- break;
- case LeatherShield:
- Meltdown(.@id, 500, LeatherPatch, rand2(1,3));
- break;
- case WoodenShield:
- Meltdown(.@id, 1500, WoodenLog, rand2(20,28), LeatherPatch, 1);
- break;
- case BladeShield:
- Meltdown(.@id, 1500, IronIngot, rand2(7,9), TitaniumIngot, 1);
- break;
- case BraknarShield:
- Meltdown(.@id, 1500, CopperIngot, rand2(9,12), TinIngot, 1);
- break;
- // Etc
case GoldenRing:
Meltdown(.@id, 1500, GoldPieces, rand2(2,3));
break;
default:
- mesn;
- mesq l("I cannot melt this. I only melt down equipment, and not everything I know how to!");
- next;
+ if (!Meltdown(.@id)) {
+ mesn;
+ mesq l("I cannot melt this. I only melt down equipment, and not everything I know how to!");
+ next;
+ }
break;
}
mesc l("Melt something else?");