Merchants

EQ2Emulator Development forum.

Moderator: Team Members

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Merchants

Post by LethalEncounter » Sat Sep 20, 2008 12:07 pm

You might have noticed some item/merchant changes coming from the update server recently. This is still a work in progress, so if any of the code makes its way onto public SVN please hold off on any bug reports until I am done :)

This is how I am designing the merchant system. Please let me know if you have a better idea or believe that I forgot something:
  • 1. The table structure:
    • "Field"
      "id" - standard auto increment
      "merchant_id" - merchant_id that matches the merchant_id found in the spawns table
      "item_id" - item id
      "quantity" - quantity that the NPC will carry
      "low_buy_multiplier" - see below
      "high_buy_multiplier" - see below
      "low_sell_multiplier" - see below
      "high_sell_multiplier" - see below
      "multiplier_faction_id" - see below
      "min_faction" - see below
      "max_faction" - see below
The multipliers are faction based values that are optional, but can be used to increase or decrease the price for both buying and selling items. if you want to use them, you must specify a faction that the NPC uses and both the min and max faction range. If a Player's faction is below the min faction they will not be able to use the merchant. Have a higher value than max will still allow them to use it, but they will get the best prices for both buying and selling. The multipliers are how much the items base price is multiplied by to get the final cost.

An example:
  • item base price = 50 copper
    low_buy_multiplier = .5
    high_buy_multiplier = 10
    low_sell_multiplier = 1
    high_sell_multiplier = 5
    min_faction -20000;
    max_faction 50000;
If the player wanted to buy it from a merchant, the MAX price that the above item would sell for (if the player had a faction level of -20000) would be 500 copper (base * 10). The MIN price would be 25 copper if the use had a faction of 50000. If the player was selling the above item to a merchant, the MAX price they would get would be 250 copper and the MIN price would be 50 copper.

Lets assume that a player's faction level with the given merchant is 15000. The calculation below would determine the price that the player could BUY if for from the merchant:
  • float diff_low = 15000 - (-20000);
    float total_diff = 50000 - (-20000);
    float buy_multiplier = 10 - .5;
    float total1 = (diff_low/total_diff);
    float final_buy_multiplier = total1*buy_multiplier + total1*.5;
Result: The player would have a buy multiplier of 5, which would mean he could buy the item for 250 copper.

Now lets calculate how much he could SELL it for:
  • float diff_low = 15000 - (-20000);
    float total_diff = 50000 - (-20000);
    float sell_multiplier = 5 - 1;
    float total1 = (diff_low/total_diff);
    float final_sell_multiplier = total1*sell_multiplier + total1*1;
Result: The player would have a sell multiplier of 2.5, which would mean he could sell the item for 125 copper.

One additional thing - the system would keep track of how much the player paid for an item so that they could not make money by buying and selling the items to different merchants. The max price for which they could sell an item would be the price they bought it for, even if the multipliers would have allowed them a better rate.

I know it is complicated, but I think it is fairly straightforward once you actually start messing with it. And it should allow for some good customizations.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Sat Sep 20, 2008 12:14 pm

It is brilliant, perfect, and shockingly makes perfect sense to me. This is the kinda math that makes sense to me.
SHOW ME THE MONEY!
And yes, I am chompin at the bit for Merchants and Items that can be equipped and seen in-game, so our little testers can gear up and head into battle! But then, I am chompin at the bit for about 100 other things, too... so take your time. The system looks solid though, nice job.

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Sat Sep 20, 2008 12:24 pm

Hmm, I was just thinking. I might two tables for this instead of 1. merchants and merchant_multipliers. Having the ability to set the multiplier on every item seems pretty overkill and would probably just be a waste of resources. I doubt anyone would ever want to have different multipliers for different items on the same merchant.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Sat Sep 20, 2008 12:27 pm

I just thought of something. "Buy Back". How long do your sold items stay on the merchant for re-purchase, and are you considering the tie-in to the player who sold the item that is currently in the merchants inventory for buy-back purposes? (char_id)

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Sat Sep 20, 2008 12:31 pm

Buy backs aren't actually stored in the database, but they are stored in memory until the world is restarted. I believe that is how they are done on Live as well.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Sat Sep 20, 2008 12:39 pm

Hmm, either the Guk server has not been restarted in months, or Buy back stuff is stored somewhere. I have toons I haven't played literally in 2 years that offer buy back items on merchants. That's why I thought they were stored somewhere, though I was confusing EQ1 where the merchant temp items eventually did fall off the market after a duration.
I have abalone shells to buy back from 6 mos ago that I sold on the isle of refuge. :)

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Sat Sep 20, 2008 12:48 pm

Really? heh OK guess I make an additional table. I thought they were just temporary. Does it still keep a max of 20(?) items?

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Sat Sep 20, 2008 1:01 pm

Yes buy back items can last forever. We used to bring backup gear to sell on raids if we needed to repair (because on a pvp server you lose your money if you can killed by a player) so we would just sell gear to the repair bot in raids so we could have money to repair then buy it back later. Or use fuels to sell because the buy:sell ratio is 1:1 :P.
The system looks great LE, nice job! I agree with you that a second table should be made for the multipliers. It's always the merchants that are faction-based, not the specific items.

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Sat Sep 20, 2008 1:08 pm

LethalEncounter wrote: If the player was selling the above item to a merchant, the MAX price they would get would be 250 copper and the MIN price would be 50 copper.
Shouldn't the player not be able to sell the item back for more than he purchased it for? Or am I reading what you're saying there wrong?

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Sat Sep 20, 2008 1:35 pm

Well there are two cases:
1. A player buys the item from a merchant. He will not be able to sell it back for more than he bought it for. It will be capped at this original buy price.
2. A player gets an item as loot. Since he didn't buy the item from a merchant, he can sell that item to a merchant at the full price as determined by his faction.
Now say a player buys a stack of water for 6 copper each, and the sell price for a looted water is 10 copper each. If the player tries to combine 19 of the cheap ones with the 1 that is a higher value, the entire stack will be revalued to avoid someone cheating. (1*10 + 19*6) = 6.2 So all of the items in the new stack will be set to a max sell value of 6.2

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Sat Sep 20, 2008 1:41 pm

Like day trading! As long as I go out and loot water, I could eventually be a millionaire!

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Sat Sep 20, 2008 3:13 pm

heh good luck with that :P
So anyone know if there is a max number of items that can be bought back?

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Sat Sep 20, 2008 3:19 pm

I had thought it was around 10. Let me log on live real fast and check it out.

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Sat Sep 20, 2008 3:24 pm

Yep, 10.

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Sat Sep 20, 2008 3:29 pm

heh, that is a small number. Maybe I'll add a configuration option that will allow people to set it to a higher number. That is when I have more free time :P

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest