Bug - Fixed Buying Bowl of Scorpions from the hidden tavern doesn't work in-run

antimarty

Member
If I type "buy bowl of scorpions" at the cli while in HC, mafia says
Code:
Purchasing Bowl of Scorpions (1 @ 469)...
Purchases complete.

But it doesn't actually buy one (and the actual NPC price for me is 475). The tavern is open to me, and I can go there in the relay browser and shop.

It also thinks the price is 469 for my char in aftercore, but that purchase works OK.

r14374
 

lostcalpolydude

Developer
Staff member
If you use "acquire bowl of scorpions" you will get the result you want. You got one from the mall (which went into storage) because they are cheaper there.
 

Veracity

Developer
Staff member
This is a change in behavior.

Used to be, if you were in Hardcore or Ronin, "buy" would always go to an NPC, if available, and would fail, otherwise. The item always went into inventory and was paid for with Meat on hand. If you were out of Ronin or in aftercore, "buy" would go to the cheapest place - mall or NPC store. Again, the item would go to inventory and be paid for with Meat from inventory.

When they changed the Mall to allow you to spend Meat from Storage to buy from it, leaving the item in storage, we changed the "buy" command to allow that. Now, we considered ALL places to buy from - NPC or mall - regardless of whether you were in ROnin or Hardcore or not. We still put NPC stores first.

- if the item was not available from an NPC store, it always took Meat from storage and the item went to storage.
- if the item was available from an NPC store, it always took Meat from inventory and the item went to inventory.

What if the item is available from both an NPC store and the mall, but the mall, but is cheaper in the mall? There was no programatic way to force it to go to the mall. Well, perhaps there was: you could say that you were willing to pay at most 1 Meat LESS than the NPC store's price. I'm also not sure what happened if you didn't have enough Meat to pay the NPC store's price; did it stop immediately and say "you can't afford that?" or did it skip the NPC and buy from the mall and leave the item in storage?

In summary, the "buy" command sometimes used Meat from inventory, sometimes from storage, and the item sometimes ended up in inventory, and sometimes in storage.

I recently changed things so that it does NOT automatically favor the NPC store. The net result is the same, in that sometimes the "buy" command uses Meat from inventory and sometimes from storage, but you can no longer guarantee that if an item is available from an NPC store, it will come from there; it will always buy the cheapest available item.

Now, as always, if you want to guarantee that the item uses Meat from inventory and ends up there, use "acquire". That also has the nice property that if you are trying to make sure you have X of an item and already have some, "acquire X" will only buy enough to get you up to X.

In other words, we already have a mechanism which guarantees that your purchase will come only from NPCs and will end up in inventory. That is why we rejected a Feature Request that says "make a way for buy to go ONLY to NPC stores". The answer was "use acquire" - and the counterarguments were not rational; "but I WANT to spend extra Meat buying from an NPC store than buying from a mall store with the same item for less!"

However, the recent change seems to have confused an awful lot of people, and I think that's not good. Perhaps "buy" should still go to NPC stores first if you are in Hardcore or Ronin. I think we we need some more discussion on it.
 

antimarty

Member
This is a change in behavior.

I can see the logic of it, though my play style is to never use the CLI "buy" command for anything but NPC purchases, so I find it extra-confusing.

In any case I think mafia should still respect my preference selection - I have "Buy items from the mall whenever needed" unchecked.
 

fronobulax

Developer
Staff member
I am fine with the existing distinction between buy and acquire. What does bother me is when I use someone elses script and they use buy under circumstances where I would choose acquire. I'm still selling accordions at a loss ;-)

I can certainly propose an opt-in preference that forces buy to behave like acquire. I don't buy stuff for Hangks during a run, normally, and if I manually went to the Purchases tab to do so that would be fine with me.

To the extent that I identify such scripts I can petition the author to change the script and maintain a local copy until they do but there is a burden in identifying such scripts.

I could propose opening a new can of worms and ask for the ability to alias or override built in commands. I'd write a version of buy that logged it was called and then called acquire.

If I understand this is a problem and KoLmafia does not address it then I certainly have the tools to address it myself so No Changes is acceptable although not as convenient.


(When something similar came up with the two and three parameter versions of buy, I just ran for several weeks with a locally modified version of mafia that logged when my preferred version wasn't used and forced it to be used until the scripts so identified were changed).
 

fronobulax

Developer
Staff member
"Buy items from the mall whenever needed"

I have it always checked but that is because buying "for" Hagnks was not an option and it effectively was meaningless during Ronin or Hardcore. If the buy command completely respected that preference then people like me would have pre- and post-ascension scripts that saved and cleared the preference and then reset it.
 

Veracity

Developer
Staff member
That preference is on the "Item ACQUISITION" panel of the Preferences, which controls how ACQUIRE decides to get items. "acquire" - and commands that implicitly call it, like "use" or "drink" - are "automated". Everything else is "manual" - the user intentionally decides to do something and KoLmafia obeys the users command. If we change "autoSatisfyWithMall" and "autoBuyPriceLimit" to apply to non-automated purchases, should we do the following?

- On the Purchases tab, if the user selects a store and says "buy", KoLmafia says "no. You said you didn't want to get items from the mall" or "no. That's costs more than 20,000 Meat."
- If the user says "buy ten-leaf clover", KoLmafia says "no. You said you only want to buy from NPC stores" or "no. Even though you didn't specify a limit in your command, that is too expensive for you."

Actually, you ARE arguing for that second one by saying that the "buy" command should be treated as "automated", even though it's always been treated as "manual"; the user SAID "buy", so, by golly, we will "buy".

Well, when KoL started to allow mall purchasing via Storage, we accommodated that but did not change the "buy" command.

Question: if you are out of Ronin (or in aftercore) and have a bunch of Meat in storage, can you still use that to buy from the mall? If so, does the item end up in storage, where the Meat came from, or does it end up in inventory? Looking at our code, I suspect that once you can pull freely from storage, you are expected to remove Meat from there in order to purchase. But I don't recall. I'll check tomorrow, when I free the king.

Perhaps the "buy" command should, like "acquire", always assume that inventory is involved, and "buy using storage" should be used for stocking storage. I don't know.

In any case, I think the Item Acquisition panel of Preferences could stand to have some text that explicitly says "the following checkboxes apply to the "acquire" command" - and we should have autoBuyPriceLimit be configurable in that section, as well.

Edit: I just looked at the mall while in Hardcore. The link to "buy" an item is identical to what I expect while in aftercore. The only difference is that if I click it, the Results say that the Meat came from storage and the item went to storage. Given that, I expect that if I have insufficient Meat while in aftercore (or out of Ronin), KoL will tell me that my purchase failed, rather than going to storage to fulfill it.
 
Last edited:

lostcalpolydude

Developer
Staff member
I'm pretty sure KoL picks where the item goes and then tries to take meat from that location (meaning that meat in storage would not be used for aftercore purchases, like you said).
 

Crowther

Active member
I'm sure no one is surprised by this, but you can't buy stuff in the mall with meat in Hangk's once you free the king. I just got "You can't afford that item."
 

Veracity

Developer
Staff member
Thanks for checking! So, the bottom line is, should we:

- Leave the "buy" command as it is now: it will get the item you asked for as cheaply as possible. If that happens to be from an NPC store, it will use Meat from inventory and the item will end up in inventory. If that happens to be from the mall, it will use inventory if post-Ronin or aftercore, or storage otherwise. If you are in Hardcore or Ronin, you can't predict which will happen, for items that are available from an NPC store, although you can always use "acquire" for those items to force them to come from an NPC and end up in inventory.

- Change the "buy" command to always use inventory. So, unless you are post-Ronin or in aftercore, it will only work for NPC items. Otherwise, it will get it from the mall or an NPC store, as appropriate.
- Additionally, make "buy using storage" use the mall - and only the mall - when you are in Hardcore or Ronin, for people who really do want to put things into storage. In Normal, you can then use "pull" to extract them.

- Something else.
 

roippi

Developer
- Change the "buy" command to always use inventory. So, unless you are post-Ronin or in aftercore, it will only work for NPC items. Otherwise, it will get it from the mall or an NPC store, as appropriate.
- Additionally, make "buy using storage" use the mall - and only the mall - when you are in Hardcore or Ronin, for people who really do want to put things into storage. In Normal, you can then use "pull" to extract them.

^ My vote. Principle of least astonishment.
 

Winterbay

Active member
Not that I'm likely to do so, but: Is there a way in ash (apart from cli_execute) to call the new "buy from storage" command?
 

Veracity

Developer
Staff member
Revision 14389 adds:

boolean buy_using_storage( count, item )
int buy_using_storage( count, item, max_price )

which are like the equivalent buy() functions, but use Meat from storage to get items into storage if you are in Ronin or Hardcore.
 
Top