diff options
author | Jesusaves <cpntb1@ymail.com> | 2022-05-15 18:13:59 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2022-05-15 18:13:59 -0300 |
commit | 46361d4055beb2443ed33c6eb765427f71048189 (patch) | |
tree | 07b5473a06f69e2b693ea2111cf417758260cae0 | |
parent | 36e607842a42977c0da539911a579004712c6091 (diff) | |
download | serverdata-46361d4055beb2443ed33c6eb765427f71048189.tar.gz serverdata-46361d4055beb2443ed33c6eb765427f71048189.tar.bz2 serverdata-46361d4055beb2443ed33c6eb765427f71048189.tar.xz serverdata-46361d4055beb2443ed33c6eb765427f71048189.zip |
Price for some recipes is now automatically generated.
This means you'll sell items by the total cost of their materials.
It also makes possible to buy the items in theory.
And dismantling them is no longer a profitable "cheat"
-rw-r--r-- | db/re/item_db.conf | 28 | ||||
-rw-r--r-- | npc/craft/price.txt | 158 | ||||
-rw-r--r-- | npc/craft/recipes.txt | 4 | ||||
-rw-r--r-- | npc/scripts.conf | 1 |
4 files changed, 175 insertions, 16 deletions
diff --git a/db/re/item_db.conf b/db/re/item_db.conf index 5f6081bec..c2469b147 100644 --- a/db/re/item_db.conf +++ b/db/re/item_db.conf @@ -2639,8 +2639,8 @@ item_db: ( AegisName: "PrecisionPotion" Name: "Precision Potion" Type: "IT_USABLE" - Buy: 500000 - Sell: 0 + Buy: 10000 + Sell: 100 Weight: 20 Refine: false Delay: 500 @@ -2902,7 +2902,7 @@ item_db: ( Name: "Sacred Life Potion" Type: "IT_USABLE" Buy: 1000000 - Sell: 0 + Sell: 5600 Weight: 50 Refine: false Delay: 500 @@ -2920,7 +2920,7 @@ item_db: ( Name: "Sacred Mana Potion" Type: "IT_USABLE" Buy: 1000000 - Sell: 0 + Sell: 5600 Weight: 50 Refine: false Delay: 500 @@ -2937,8 +2937,8 @@ item_db: ( AegisName: "DodgePotion" Name: "Dodge Potion" Type: "IT_USABLE" - Buy: 1000000 - Sell: 0 + Buy: 10000 + Sell: 100 Weight: 20 Refine: false Delay: 500 @@ -3161,7 +3161,7 @@ item_db: ( Name: "Magic Apple" Type: "IT_USABLE" Buy: 1000000 - Sell: 0 + Sell: 15000 Weight: 10 Refine: false Delay: 500 @@ -4391,8 +4391,8 @@ item_db: ( AegisName: "MylarinDust" Name: "Mylarin Dust" Type: "IT_ETC" - Buy: 10000 - Sell: 500 + Buy: 1000000 + Sell: 50000 Weight: 20 Refine: false }, @@ -4557,8 +4557,8 @@ item_db: ( AegisName: "SunnyCrystal" Name: "Sunny Crystal" Type: "IT_ETC" - Buy: 500000 - Sell: 10000 + Buy: 5000000 + Sell: 200000 Weight: 300 Refine: false }, @@ -5115,7 +5115,7 @@ item_db: ( Name: "Mana Piou Feathers" Type: "IT_ETC" Buy: 20 - Sell: 9 + Sell: 8 Weight: 1 Refine: false }, @@ -18772,7 +18772,7 @@ item_db: ( Name: "Sacred Immortality Potion" Type: "IT_USABLE" Buy: 1000000 - Sell: 0 + Sell: 11100 Weight: 500 Refine: false Delay: 500 @@ -18924,7 +18924,7 @@ item_db: ( Name: "Homun Stat Reset Potion" Type: "IT_USABLE" Buy: 50000 - Sell: 5000 + Sell: 5250 Weight: 20 Refine: false KeepAfterUse: false diff --git a/npc/craft/price.txt b/npc/craft/price.txt new file mode 100644 index 000000000..88e90f5ce --- /dev/null +++ b/npc/craft/price.txt @@ -0,0 +1,158 @@ +// TMW-2 Script. +// Author: +// Jesusalva +// Description: +// Modifies the sell price for crafts +// Always run this when casting @reloaditemdb +function script _fix_cPrice { + .@const$ = data_to_string(getarg(0)); + .@m = getarg(1, 35); + + // 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 _fix_cPrice"); + return; + } + + .@price = 0; + // 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 + break; + } + // inventory does not exist + break; + } + + // More shady code to build new price + for (.@it = 0; .@it < .@size; ++.@it) { + .@recipe_item = .@item_id[.@it]; + .@recipe_qty = .@qty[.@it]; + + if (.@recipe_item <= 0) { + break; + } + + // Increase the final price + debugmes("Price %d + %d GP (%dx %s)", .@price, getiteminfo(.@recipe_item, ITEMINFO_SELLPRICE), + .@recipe_qty, getitemname(.@recipe_item)); + .@price += getiteminfo(.@recipe_item, ITEMINFO_SELLPRICE) * .@recipe_qty; + debugmes("New price: %d", .@price); + } + + // Update the final price + if (.@price > 0) { + consoleinfo("Price for %s adjusted from %d (%d) to %d (%d) GP", getitemname(.@item), getiteminfo(.@item, ITEMINFO_BUYPRICE), getiteminfo(.@item, ITEMINFO_SELLPRICE), .@price * .@m / 10, .@price); + setiteminfo(.@item, ITEMINFO_BUYPRICE, .@price * .@m / 10); + setiteminfo(.@item, ITEMINFO_SELLPRICE, .@price); + debugmes("New Price for %s is now %d (%d) GP", getitemname(.@item), getiteminfo(.@item, ITEMINFO_BUYPRICE), getiteminfo(.@item, ITEMINFO_SELLPRICE)); + } + } + debugmes "\n\n-------------------------------------------------------"; + return; +} + +function script fix_cPrice { + // In some cases, we don't care + if (debug) return; + + // Otherwise... + // Fix potions prices + _fix_cPrice(AgiPotionA); + _fix_cPrice(AgiPotionB); + _fix_cPrice(AgiPotionC); + _fix_cPrice(VitPotionA); + _fix_cPrice(VitPotionB); + _fix_cPrice(VitPotionC); + _fix_cPrice(IntPotionA); + _fix_cPrice(IntPotionB); + _fix_cPrice(IntPotionC); + _fix_cPrice(DexPotionA); + _fix_cPrice(DexPotionB); + _fix_cPrice(DexPotionC); + _fix_cPrice(LukPotionA); + _fix_cPrice(LukPotionB); + _fix_cPrice(LukPotionC); + //_fix_cPrice(HastePotion); // 240 -> 75 + //_fix_cPrice(StrengthPotion); // 240 -> 195 + + // TODO: Scrolls? Reagents? + // And reagents should happen before potions + + // And weapons + _fix_cPrice(WoodenSword); + _fix_cPrice(BugSlayer); + _fix_cPrice(ShortGladius); + _fix_cPrice(Backsword); + _fix_cPrice(ShortSword); + _fix_cPrice(Kitana); + _fix_cPrice(BoneKnife); + _fix_cPrice(LongSword); + _fix_cPrice(RockKnife); + _fix_cPrice(DivineSword); + + // And two hand weapons + _fix_cPrice(MiereCleaver); + _fix_cPrice(Broadsword); + _fix_cPrice(Halberd); + _fix_cPrice(ImmortalSword); + + // And archery + _fix_cPrice(ShortBow); + _fix_cPrice(ForestBow); + _fix_cPrice(ElficBow); + _fix_cPrice(ChampionshipBow); + _fix_cPrice(BansheeBow); + + // And magic + _fix_cPrice(TrainingWand, 22); + _fix_cPrice(NoviceWand, 27); + _fix_cPrice(ApprenticeWand); + _fix_cPrice(LeaderWand); + _fix_cPrice(MysticWand); + + // And Firestaves + _fix_cPrice(PynRevolver); + _fix_cPrice(PynRifle); + _fix_cPrice(PynGatling); + _fix_cPrice(PynShotgun); + + // And misc + _fix_cPrice(TerranitePants); + _fix_cPrice(TerraniteArmor); + _fix_cPrice(Skypiercer); + return; +} + +- script craft_price_fix -1,{ + end; + +OnCall: + atcommand("@reloaditemdb"); + fix_cPrice(); + end; + +OnInit: + bindatcmd "reloaditemdb2", "craft_price_fix::OnCall", 99, 100, 1; + // This should be called last + sleep(750); + fix_cPrice(); + end; +} + diff --git a/npc/craft/recipes.txt b/npc/craft/recipes.txt index 4dd2cbcfc..7f49114d6 100644 --- a/npc/craft/recipes.txt +++ b/npc/craft/recipes.txt @@ -138,9 +138,9 @@ function readAlchemy { mesc "----------"+l("General Boosts")+"----------", 2; showRecipe(HastePotion, StrengthPotion, - StatusResetPotion, + StatusResetPotion, // BROKEN HomunResetPotion, - MoveSpeedPotion, + MoveSpeedPotion, // BROKEN PrecisionPotion, DodgePotion, SacredLifePotion, diff --git a/npc/scripts.conf b/npc/scripts.conf index 737f2df8a..fcf973775 100644 --- a/npc/scripts.conf +++ b/npc/scripts.conf @@ -97,6 +97,7 @@ "npc/craft/smith.txt", "npc/craft/tweak.txt", "npc/craft/recipes.txt", +"npc/craft/price.txt", // custom atcommands "npc/commands/music.txt", |