Bug retrieve_price incorrect values

taltamir

Member
There are some issues with retrieve_price function

Code:
> ash retrieve_price($item[staff of the grease trap])

Returned: 89307
Searching for "sleaze wad"...
Preference _concoctionDatabaseRefreshes changed from 163 to 164
Search complete.
Searching for "flirtatious feather"...
Search complete.

> ash retrieve_item($item[staff of the grease trap])

Searching for "sleaze wad"...
Search complete.
Verifying ingredients for Staff of the Grease Trap (1)...
Purchasing sleaze wad (10 @ 850 = 8,500) from #1321271...
Preference _concoctionDatabaseRefreshes changed from 164 to 165
Purchases complete.
Searching for "flirtatious feather"...
Preference _concoctionDatabaseRefreshes changed from 165 to 166
Search complete.
Purchasing flirtatious feather (1 @ 110) from #730737...
Preference _concoctionDatabaseRefreshes changed from 166 to 167
Purchases complete.
You acquire an item: Staff of the Grease Trap
Preference _concoctionDatabaseRefreshes changed from 167 to 168
Successfully created Staff of the Grease Trap (1)
Returned: true

> ash retrieve_price($item[staff of the grease trap])

Returned: 25
1. retrieve_price was incorrectly returning 89307 when the actual retrieve price was 8610
2. retrieve_price for an item I already have is incorrectly returning 25 when it should be returning 0

Also there is a problem with the documentation
Code:
> ashref retrieve

boolean retrieve_item( item )
boolean retrieve_item( item, int )
boolean retrieve_item( int, item )
int retrieve_price( item )
int retrieve_price( item, int )
int retrieve_price( int, item )
int retrieve_price( item, int, boolean )
int retrieve_price( int, item, boolean )
retrieve_price is a hyperlink that leads to this missing page

I can guess what int and item do.
but what is the boolean for?
 

taltamir

Member
another example
Code:
> ash retrieve_price(1,$item[Staff of the Kitchen Floor],true)

Searching for "stench wad"...
Preference _concoctionDatabaseRefreshes changed from 186 to 187
Search complete.
Returned: 34944

> ash retrieve_price(1,$item[Staff of the Kitchen Floor],false)

Returned: 34944
I bought all the ingredients. so it should cost 0.
I tried true and false and it makes no difference.
does the boolean indicate refreshing mall prices?
 

heeheehee

Developer
Staff member
There is apparently a preference debugBuy which you can set to true if you want to debug retrieve_price and its internals.

The boolean parameter is "exact", which looks like it just forces new mall searches as you observed.
 

taltamir

Member
The boolean parameter is "exact", which looks like it just forces new mall searches as you observed.
Thanks. With this info I think I should be able to start creating the wiki entry. although much of it is still unknown to me
There is apparently a preference debugBuy which you can set to true if you want to debug retrieve_price and its internals.
Thanks. Well, it seems that in debug log it does nothing but just put a copy of the same results as gcli
with the advantage though of not having the weird copy issues of added random whitespace that happens when copying directly from gcli. so that is good.
> ash retrieve_price($item[staff of the grease trap])

☯ Staff of the Grease Trap onhand=1 price = 25
Returned: 25
not anything useful on why it does 25 meat for items I already own.
> ash retrieve_price($item[Staff of the Kitchen Floor])

☯ linoleum staff onhand=1 price = 10420
☯ stinky hi mein (3) onhand=3 price = 13132
☯ mushroom fermenting solution mall=21700 make=∞
☯ stinky mushroom onhand=1 price = 100
☯ stinky mushroom wine mall=4440 make=25800
☯ stench wad (10) onhand=10 price = 6897
☯ fetid feather onhand=1 price = 55
☯ Staff of the Kitchen Floor mall=∞ make=34944
Returned: 34944
Alright. so looking at it, it clearly counts the price values of items I already have on hand.

take the total which is 34944
subtract the onhand items of:
☯ linoleum staff onhand=1 price = 10420
☯ stinky hi mein (3) onhand=3 price = 13132
☯ stench wad (10) onhand=10 price = 6897
☯ fetid feather onhand=1 price = 55

gives 4440 meat. for these items:
☯ mushroom fermenting solution mall=21700 make=∞
☯ stinky mushroom onhand=1 price = 100
☯ stinky mushroom wine mall=4440 make=25800
so yea, it went with the mall price since it is cheapest.

I went ahead and acquired it and now it says
☯ linoleum staff onhand=1 price = 10420
☯ stinky hi mein (3) onhand=3 price = 13106
☯ stinky mushroom wine onhand=1 price = 3557
☯ stench wad (10) onhand=10 price = 6617
☯ fetid feather onhand=1 price = 55
☯ Staff of the Kitchen Floor mall=∞ make=33755

tried using exact
> ash retrieve_price(1, $item[Staff of the Kitchen Floor], true)

Searching for "linoleum staff"...
Search complete.
☯ linoleum staff onhand=1 price = 10420
☯ stinky hi mein (3) onhand=3 price = 13106
☯ stinky mushroom wine onhand=1 price = 3557
Searching for "stench wad"...
Search complete.
☯ stench wad (10) onhand=10 price = 6617
Searching for "fetid feather"...
Search complete.
☯ fetid feather onhand=1 price = 55
☯ Staff of the Kitchen Floor mall=∞ make=33755
Returned: 33755
just forces more mall searches
 

heeheehee

Developer
Staff member
not anything useful on why it does 25 meat for items I already own.
Autosell price of staff of the grease trap is 25 meat.

Code:
        AdventureResult instance = item.getInstance(onhand);
        price = mallPriceOnly ? 0 : InventoryManager.itemValue(instance, exact);

If you want to entirely ignore the value of things you have on hand, you can set valueOfInventory = 0. This is probably a bad idea. More precisely:

jasonharper said:
0.0 - Items already in inventory are considered free.
1.0 - Items are valued at their autosell price.
2.0 - Items are valued at current Mall price, unless they are min-priced.
3.0 - Items are always valued at Mall price (not really realistic).


Values in between are interpolated. The preference default is 1.8. That said: since the item is not tradeable, it does not have a mall price. Thus, it defaults to the only price we can give it: the autosell price.
 

taltamir

Member
Alright. I created wiki page for it. thanks @heeheehee for the info about what the boolean did.
do you know if there is a CLI equivalent command to it?

Autosell price of staff of the grease trap is 25 meat.
why is retrieve_price using the autosell value? selling is the opposite of retrieving

How would you even use this? it doesn't actually tell me what the actual price is to retrieve_item would be.
 

taltamir

Member
actually. in retrospect it is obvious how it should be used. for determining values of consumables for items that automatically eat, drink, or restore hp/mp.

would be great if there was either another function, or same function with an extra bool. that provided only the price of creation...
I can also probably make a wrapper which backs up valueOfInventory, sets it to 0, runs retrive_price, then sets valueOfInventory to its prior value
 

Ryo_Sangnoir

Developer
Staff member
A while back I created concoction_price to tell you the price of making a concoction, but it doesn't recurse (you have to recurse yourself, if you want). Also, if the concoction takes an adventure, it includes valueOfAdventure in the pricing. This was the reason for not recursing, because crafts might be free, but we don't know if recursive crafts will still be free and it was much more complicated to do that.
 
Top