Fix for merchant price bugs
As of right now, the displayed price for an item (whether selling or buying) does not match up to the actual price you see. For example, when you sell an item, you get more money than what is displayed. In addition, everyone, regardless of faction or charisma, receives the same prices.
I looked through the code and it was really a mess. There is an existing function in client.cpp which determines a modifier based on charisma and function, but it isn't used anywhere. Further, the code contains no less than three different, contradictory rates for merchants. So, I polished up the code and fixed the relevant functions, they're down below. If you want to just download the updated .cpp files, here they are: http://70.189.190.124:8000/merchantfix.rar Client::BulkSendMerchantInventory in zone/client_process.cpp: Code:
void Client::BulkSendMerchantInventory(int merchant_id, int16 npcid) { Code:
void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app) Code:
void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) Code:
void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) |
Thanks for the fix, I don't know what's going on with the "official" stuff, nothing seems to get posted. I'm sure Trevius will have added/posted to his upcoming 1110c release.
Can't wait to try this one out, I'll have it in my source today - Also, I always wonder why items sold to vendors never stay there - with me they poof by the next time i click on vendor so as to see what I sold. Thanks again, your fixes are much appreciated. |
I should mention the base rate for merchants is .884 if they're buying and 1/.884 if they're selling. This was just one of the rates in the code so I decided to run with it. A few project for me or someone else could be to make this into a database entry so that people could customize the rates merchants give to people.
|
Thanks for the great fix, I did limited testing and seems to work just as you intended :D
|
Sweet! I will definitely try to get this added to my unofficial updates for the 1110e release. Of course, I will make sure to run some tests on it before posting the new version. Looks like we might have a new coder out to help fix some issues :D I will test out your LoS agro changes too and see how it works. That one seems complex to fix since you don't want things agroing through walls in separate rooms. If it seems pretty good, I will try to get that one added as well.
|
greggg, do you know if this will also affect the "salerate" field in "items" table of the DB, which suposely should control... SOMETHING price related?
if yes, then how? |
Quote:
Fine Steel Short Sword has a value of 5500, and I was able to accurately predict its sell and buy prices without even knowing about sellrate. Its sellrate is 9, apparently. Someone please correct me if I'm wrong, though. |
i was under impression, that 'salerate' was some sort of an option to set a custom sell back for each specific item - could realy be usefull in order to create items which would sell back for 100% base price (i can think for dozen fo reason for having such items) - or at least its the only logical explation that coudl posibly fit the description of the field name.
of course the thing never worked, so... =) but it would be nice to have it actualy working this way =) (could also be interesting to have item which would sell back for ABOVE base price - again for various reasons) =) |
Moving to submission. To make it easier on KLS/Scorp, could you diff your changes?
|
Quote:
Line 3717 of zone/client_packet.cpp should be changed from: Code:
mco->rate = 1.6; Code:
mco->rate = 1/(.884*Client::CalcPriceMod(tmp,true)); Code:
mpo->price = (item->Price*127/100)*mp->quantity; Code:
mpo->price = (item->Price*(1/.884)*Client::CalcPriceMod(tmp,false))*mp->quantity; Code:
price=(int)((item->Price*mp->quantity)*.884); Code:
price=(int)((item->Price*mp->quantity)*.884*Client::CalcPriceMod(vendor,true)+0.5); // need to round, because client does it automatically when displaying price Code:
inst2->SetPrice(item->Price*127/100); Code:
inst2->SetPrice(item->Price*(1/.884)*Client::CalcPriceMod(vendor,false)); Code:
Mob* merch = entity_list.GetMobByNpcTypeID(npcid); Code:
inst->SetPrice(item->Price*127/100); Code:
inst->SetPrice((item->Price*(1/.884)*Client::CalcPriceMod(merch,false))); Code:
inst->SetPrice(item->Price*127/100); Code:
inst->SetPrice((item->Price*(1/.884)*Client::CalcPriceMod(merch,false))); |
Quote:
Thanks |
Another great fix. Keep up the great work, Greg! =)
|
Quote:
When I first started here at EqEmu, I couldn't for the best of me, get the source to compile under my windows box. So I took it to my Linux box where I had little trouble there - it was better this happened to me, because Linux Distros usually come "developer ready" and have all these neat tools like diff, kompare, compilers, etc. They are all just as available as my "dir" or "copy" command in windows. I think I'm gonna try windows compile again with that new compiler package that's posted here, just for the challenge. Anyways, you usually can google what you need for windows - I just googled "diff program for windows xp", and came up with a whole swarm of stuff. The diff toolshould be self explanatory on how you present it here. |
Great fix man thanks, I've been hoping someone would fix factions, and I didn't even realize it was giving the incorrect gold when selling.
|
Quote:
Hey Angelox, try compiling the BOT CODE in Windows and let me know if it works for you. I can't get it to recognize that the BOTS are compiled in. Have everything set as AFGAIK in Preprocessor and files are all in place, but no go. |
I think "diff -Nur ..." is the right command
|
This will be in version 1113.
|
i am looking at new sell prices after thsi patch and it seems to me than vendor now pays you way to much.
with only amiable faction and 100 cha i am geting back like 95% item price, while on most items 50% shoudl be best what you can get. is it posible to change fixed 1.27 vendor modifier into an X variable and put into rules, so we can customly adjust how much extra vendor will charge/pay? curent buy back prices way to high - you should only get to 95% buy back with Ally faction and 500 CHA PS may as well include a rule on MAX % of item price vendor will ever pay regardless your faction |
To go along with the above post, there is a problem with this patch... It can happen that with faction/CHA modifiers, the price the merchant buys an item from a player can actually be HIGHER than they sell it for. A quick example, a player sells an item to a merchant for 300pp, the merchant then sells that item back to the player for 280pp, the player can buy/sell over and over making 20pp per each hand in. Of course, the player needs really high CHA and very good faction for this to work, but it is possible as it was done on TGC.
|
OK I have been looking at this for a bit, and I belive the reason players can sell back for more than they pay is couse vendors mark up price is not high enough to counter the bonuses you get faction and charisma.
On top of that there is STILL a problem that money you get back from NPC do not match up with price shown. Npc tells you : i will pay 1 plat, you click sell, it says - you sold for 1 plat, but if you looking at your invetory you only getting 9 gold and change. But this problem is BEYOND my understanding of code. So I will try to fix the issue with general price scaling. Thsi is the code I dig up from client.cpp Quote:
determiend here: if (chaformula < -5) chaformula = -5; The formula may have been created with pre-kunark EQ in midn when 150 CHA was UBER, but in days of PoP my level 1 bazar mule was runing around 200 CHA on him wearing junk i obtained for less than 100 plat a peace ANd whats important there was definite benefit from going even over 250 CHA So this is changes proposed by me. The intent is to slightly improve the effect from faction bonus and MASSIVLY increase scaling of CHA (note that I am reducing gain increment6s from each 10 CHA above 100, to each 25 CHA but allow it to scale all way up to 400 CHA before CHA becomes useless. I am also increasing penalty for CHA less than 75, per each 5 points all way down to 0. With new formulas the max bonus you can obtain with Ally faction and 400 CHA is 26%, and max penalty with Apprehensive faction and 0 CHA is -25% (from original 10 and 10) (Idealy and realisticly you want faction bonsu to scale in accordance with EXACT numeric value of your curent faction - like 115, rather than just Amiable, then rather than havign price junp by 5 ranks, it woudl scale smoothly, but atm I am not sure how to retrive this value so I am working with what allready in the function (it is probobly GetFactionLevel but I am not sure) the new code Quote:
By default vendor uses +27% mark up when selling and gives 88% when buying basing of scaled price. To easy calculation (and pricing of items) I want to alter thsi approach. The mark up becomes +100%, and buy back is 100% (since ist adjusted by new scalign formulas anyway and fact that mark up price now HUGE) Goign by dif changes made by Greggg, here are my alternatives: Line 3717 of zone/client_packet.cpp should be changed from: Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Overall: I replaced all 0.884 with 1 and all 1/0.884 with 2. (i left *1 in code on purpose for easier tracking) (idealy 1 and 2 can later be repalced by DB Rule variables to give custom server admins chance to make them even more specific) The logic is following: the merchants now will have *2 times mark up when they selling to players, but are 100% of default item price when buying. So a player with 100 cha and indifirent faction vs a Item X with default Db price of 1 plat: will buy it from vendor for: 2 plat will sell it to vendor for: 1 plat (imho this is great cuase this makes item pricing in Db very easy - sicne ist excatly the price player will get) and then the actul price will be adjusted by faction and cha. A player with Ally faction and 400 cha: (-26% total bonus) will buy item from vendor for: 1.48 plat will sell item to vendor for: 1.26 plat so there is a decent margins left in between to prevent the problem cavedude curently described (of course given my assumtions for cuases for the problem are correct) Now.. All modification are based purely on COMMON LOGIC of calculation statements - no actual C code function and calls have been altered. I also cannot test this atm, since I have no compiler. Hopefuly someone can, and tell me if result of my alteration is anything close to what I have predicted :cool: |
few corrections:
the line # for first chunk of code is line 2475 in client.cpp also - i left out } at the end of my replacement code :cool: |
All times are GMT -4. The time now is 10:52 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.