Bug - Fixed Possibly a bug while buying items from mall and NPC stores

build: 8621

description: Ronin clear (first ascension); NPC store (black market) provides black paint for 1000 meat; one of mall stores provides black paint for 900 meat; option "buy items from mall whenever needed" set to true; "buy black paint" command buys black paint from NPC store for 1000 meat. Why?

buying_items.jpg

http://195.70.211.9/files/buying_items.jpg

//NightBird
 

slyz

Developer
Checking the mall for prices of NPC items would use server hits than are probably unnecessary.
 

lostcalpolydude

Developer
Staff member
Checking the mall for prices of NPC items would use server hits than are probably unnecessary.

Mafia does a mall search even when it ultimately buys from an NPC. This can be seen by entering "buy soda water", then going to the mall search screen in the relay browser and seeing that "soda water" (with quotes) is pre-filled there.
 

Theraze

Active member
Unless it's a different one you're talking about, the only buy script I know of with any major popularity is the potion buy... which shouldn't really have the slightest bit of affect to buying black paint.

The behaviour listed is the currentl KoLmafia design... in general, NPC store gear is cheaper in mall... If you want cheap, turn off NPC. If you want steady, leave it on.
 

Bale

Minion
Does it always do this, or just if using Bale's script? I honestly don't know -- not sarcasm.

None of my scripts purchase soda water or black paint, so I suspect it has nothing to do with me.

As far as UR is concerned, soda water is not for purchasing since Doc Galaktik is always better, even if you don't complete his quest.
 

Veracity

Developer
Staff member
Bumping for thought, since I was just looking at how acquire/retrieve_item works...
 

slyz

Developer
It looks like any NPCPurchaseRequest is added to the results of StoreManager.searchMall() at the end of the MallSearchRequest, after the MallPurchaseRequests. I guess this means that Mafia tries to buy from the NPC stores first. Maybe the results of StoreManager.searchMall() should be sorted by PurchaseRequest.getPrice() ?

Alternatively, changing line 308 in MallSearchRequest.updateSearchString()
PHP:
if ( count == untradeableCount || ( !canInteract && count == npcItemCount ) )
to
PHP:
if ( count == untradeableCount || count == npcItemCount )
Would make Mafia skip the mall search entirely and simply buy from the NPC store. This would slightly reduce the number of server hits, and since I don't think that many stores offer NPC items at prices lower than the NPC stores themselves, users wouldn't loose out too much. And meatsinks FTW!
 
Last edited:

xKiv

Active member
Would make Mafia skip the mall search entirely and simply buy from the NPC store. This would slightly reduce the number of server hits, and since I don't think that many stores offer NPC items at prices lower than the NPC stores themselves, users wouldn't loose out too much. And meatsinks FTW!

There are people with Travoltian trousers who base their profits on buying below NPC prices and selling less below ...
 

slyz

Developer
And even if you buy an NPC item from the mall, meat has been sunk at one point or another. That wasn't a real argument :)

I guess trying to sort the results of StoreManager.searchMall() (which includes NPC stores, in spite of its name) would be the way to go then.
 

roippi

Developer
Bump for further thought.

We should probably make a command decision if we want to [always buy from NPCs when possible, regardless of mall pricing] or [buy from NPCs when cheaper than the mall.] The former saves server hits whereas the latter saves some players a bit of meat. I may be biased towards the former.

If we do want to do the latter, it is fairly easy. InventoryManager.retrieveItem (line 634):
Code:
		boolean shouldUseNPCStore =
			Preferences.getBoolean( "autoSatisfyWithNPCs" ) &&
			NPCStoreDatabase.contains( item.getName() );

..just needs a cheaperToNPC( AdventureResult item, int qty ) function call. Most of the code for that function can be ported from InventoryManager.cheaperToBuy().
 

roippi

Developer
Bump, another year later.

I still basically Don't Care that people may lose out on a couple meat savings vs. not buying from the mall. I'm just going to make it always buy from NPCs, save the server hit. Sorry Travoltan trouser people.
 

lostcalpolydude

Developer
Staff member
As someone that makes meat off of trouser arbitrage, the only time I expect it to work is for NPC shops that not everyone has access to anyway.
 
Top