PDA

View Full Version : Becoming an Omnivore



Donavin69
11-27-2011, 08:06 PM
Omnivore 1.0

Like a lot of scripts, I utilize ZLib (thanks Zarqon)

This script is designed to list all items you haven't consumed, the output is sorted by fullness/inebriety, and then by mall price. (it won't show you items that you can't buy)

Any suggestions, let me know.

Revision History:
0.1 Initial release (Nov 27, 2011)
0.2 Added Vars for eat, drink, usemilk, and limit. Will automatically consume if set to true.
0.3 Changed Acquire to Retrieve_item, added Total counters, and add up both total, and within limit items
0.4 Changed Total price counters to Float
0.5 Misc Tweaks to fix minor issues
0.6 Remove eating/drinking for items that hit both (Drunki-bears)
0.7 Removed the Retrieve_item to avoid buying an item that might be the daily special.
0.8 Added limit adjustment for autoBuyPriceLimit, other fixes
0.9 Rearrange code, reduce server hits and time to avoid checking prices on items already consumed.
1.0 Resolve properly for foods/drinks with partial name matches

bumcheekcity
11-27-2011, 08:08 PM
Any suggestions, let me know.

Where is it attached? :P

Donavin69
11-27-2011, 08:09 PM
I forgot to save it when I did it the first time, and you were very quick...and I already need to update it, with the correct page number for the versioning

Donavin69
11-27-2011, 08:18 PM
Updated with functioning version checking.

How do you find out what the post is before you post it? So you can post it with working version checking?

Bale
11-27-2011, 09:11 PM
Updated with functioning version checking.

Are you sure it is functioning? You have to boldface the relevant portion of your post to make it function.



How do you find out what the post is before you post it?

You cannot.

Donavin69
11-27-2011, 09:19 PM
I only knew that it didn't crash anymore, I bolded the script name and the version number.

Donavin69
12-02-2011, 04:26 PM
Suggestion to make it auto-consume. I changed the sort order to sort by reverse fullness first, then price. It will consume the most filling item then the lesser ones.
Zlib vars added:
omnivore_eat - default of FALSE
omnivore_drink - default of FALSE
omnivore_limit - default of 100,000
omnivore_usemilk - default of TRUE

Theraze
12-07-2011, 08:24 PM
Suggestion: Filtering out the items outside your omnivore_limit. Among other reasons, because with the max price booze items in the mall, the total cost for booze actually loops over and goes negative.

I've implemented it in my copy by turning each of the spots with
(price > 0) into this:
(price > 0 && price < Omni_Limit)

There are 4 of them total... one for food/drink each while computing max fullness, and one each for food/drink on displaying/consuming. With this set and a max value of 100k, I get this now:
Total unconsumed food: 204 items, with a total mall price of: 1405622
Total unconsumed booze: 104 items, with a total mall price of: 1220218Not that I'm likely to spend the 2.6 million in the next few weeks to pick up on these, but that's a lot more reasonable than:
Total unconsumed food: 211 items, with a total mall price of: 6446612
Total unconsumed booze: 126 items, with a total mall price of: -2007106957

What I am likely to take advantage of though...
ashq import <omnivore> Omni_Limit=1000; omnivore();
<snip>
Total unconsumed food: 73 items, with a total mall price of: 29612
Total unconsumed booze: 28 items, with a total mall price of: 10750100 items for about 40k? Sure, I can do that! :D

Edit: One question... the CLI command acquire is functionally equivalent to the ASH command retrieve_item, right? If so, can keep it in ASH by just doing retrieve_item(1, food[cntr]) instead of using the current acquire through CLI bit. :)

Donavin69
12-08-2011, 11:51 AM
Suggestion: Filtering out the items outside your omnivore_limit.

(price > 0 && price < Omni_Limit)


I do only buy items up to your limit, but I list them all (things like the TPS drinks are really expensive in the mall, but it prompted me to borrow a TPS for a day)
I added some code to add up the items within your limit also (it still rolls over and becomes negative on the total):

Total unconsumed food: 156 items, 317 fullness, with a total mall price of: 5707069
Total unconsumed booze: 60 items, 147 with a total mall price of: -1821064298
Unconsumed food within limit: 152 items, 309 with a total mall price of: 1009069
Unconsumed booze within limit: 50 items, 125 with a total mall price of: 437002
For all items, including those above your limit -- MaxFull: 7 -- MaxDrunk: 6


CLI command acquire is functionally equivalent to the ASH command retrieve_item, right? If so, can keep it in ASH by just doing retrieve_item(1, food[cntr])

Thank you!, I wasn't sure if retreive_item was equivalent, and couldn't find anything to confirm it (since I wrote it while already full and drunk, couldn't test that) I liked the acquire option over mallbuy because it would make it if it would make it if it was cheaper.

I'm thinking about adding another variable (or two). There are a lot of items that aren't buyable (a lot that aren't even obtainable in any other method now). You can still obtain the consumption listing by using tacos/thermoses. So I'm thinking about adding variables Omni_Taco & Omni_Thermos, I'll default them to false, but it will check for the consumption listing for those special items and use the tacos/thermoses to get those consumption items too. Thoughts?

Theraze
12-08-2011, 02:36 PM
Sounds like a good plan.

And part of the reason I had for suggesting cutting out the above-limit was due to the problems with ints and the boundary... this isn't exactly useful:
Total unconsumed food: 221 items, 470 fullness, with a total mall price of: 6382621
Total unconsumed booze: 126 items, 356 with a total mall price of: -2007123084Can turn the total costs into floats if you like, which makes them potentially less accurate, but gives a better ballpark figure...
Total unconsumed food: 221 items, 470 fullness, with a total mall price of: 6382621.0
Total unconsumed booze: 126 items, 356 with a total mall price of: 6.5828127E9

Theraze
12-28-2011, 03:36 AM
One more thing I've noticed. Apparently currently the limit checks are mixed between < and <=, so it will say that items are within your limit but it will skip them. The fix is to make them both consistent...

Donavin69
12-28-2011, 06:33 PM
That's apparently one of the little tweaks I've made in my version...I've uploaded a new copy of the current version.

Current to-dos: Add in all the 'Taco only/Thermos only' foods/drinks...(maybe assume if it is over the limit to try for them with tacos/thermos)

Donavin69
01-20-2012, 12:04 PM
The drunki-bears are listed as both food and drink, but are not booze (they are food that gets you drunk...kinda like rum-cake). So Omnivore would crash if that was the thing selected to drink. I've uploaded a new version that excludes eating or drinking anything that hits both.

Theraze
01-23-2012, 03:01 AM
One note from a recent change in EatDrink... daily special items. You can check if they're available by doing something like this, which also looks for items buyable from the shopkeepers but not the mall, like mugcakes and so on...
int check_price(item shopfor) {
if(npc_price(shopfor) > 0))
return npc_price(shopfor);
else if(daily_special() == shopfor)
return autosell_price(shopfor) * 3;
else if(historical_age(shopfor) > 1)
return mall_price(shopfor);
return historical_price(shopfor);
}

Donavin69
01-23-2012, 01:37 PM
I'll add that in, maybe be able to get a few more consumables that way.

Thanks Theraze!

Theraze
01-23-2012, 02:02 PM
Welcome. :) I'd somehow managed to forget that the cheapest bad consumable is the mugcake... for 20 meat, you can increase your adventures by 1. Half the meat of the fortune cookie if you already know your counter or are avoiding them for some reason. :) That's one of the items that I found when that got added to ED.

Theraze
03-04-2012, 05:01 PM
Found a problem with the daily_special addition. Omnivore always tries to manually retrieve the item first, but that doesn't work on the daily item, since it's automatically consumed, so retrieve_item will buy from the mall, then consume from the store. Like so:
Searching for "unfortunate dumplings"...
Search complete.
Purchasing unfortunate dumplings (1 @ 8,484)...
You acquire an item: unfortunate dumplings
Purchases complete.
Purchasing unfortunate dumplings at the Chez Snootée...
You acquire an effect: Really Quite Poisoned (duration: 20 Adventures)
You lose 73 hit points
You gain 3 Fullness
You spent 45 Meat
Goodie purchased.8484 meat spent in addition to the 45 actually needed... this could get QUITE pricey if it's something more rare. :)

What I've done is made the retrieve_item checks (one for food, one for booze) check if the item is NOT the daily special before moving on. Like so:
if (daily_special() != food[cntr]) retrieve_item(1, food[cntr]);
eat(1, food[cntr]);
Really, there's not too much reason to force the retrieve_item check... eat and drink will succeed or fail using exactly the same retrieval logic as retrieve_item uses, so those lines could be completely eliminated, but... that's your choice. :)

Donavin69
03-05-2012, 01:08 PM
Thanks Theraze! I'll remove the retrieve_item, and test that out...assuming it works OK, I'll publish the new version...

Theraze
03-05-2012, 02:22 PM
Heh. Something funny about the release 0.7 is that it removes the NPC and Daily items again. :) To add them back in, change this:
int check_price(item shopfor) {
if(historical_age(shopfor) > 1)
to this:
int check_price(item shopfor) {
if(npc_price(shopfor) > 0)
return npc_price(shopfor);
else if(daily_special() == shopfor)
return autosell_price(shopfor) * 3;
else if(historical_age(shopfor) > 1)
Also, I added a can_interact check to my milk using, and a check for Glorious Lunch, to make it easier to (try to) take advantage of the daily special during Boris runs. I replaced this line:
if((omni_usemilk) && (food[cntr].fullness > have_effect($effect[got milk]))) cli_execute("use milk of magnesium");
with this:
if((omni_usemilk) && can_interact() && (food[cntr].fullness > have_effect($effect[got milk]))) cli_execute("use milk of magnesium");
if((have_skill($skill[song of the glorious lunch])) && (food[cntr].fullness > have_effect($effect[song of glorious lunch]))) cli_execute("cast song of the glorious lunch");
Not sure if the milk change is always the best, since if you're a Sauceror you might legitimately have milk even without mall access, but... unlikely enough in my case that I liked the change. :)

Donavin69
03-06-2012, 12:43 PM
I'll add those checks, thanks again Theraze...One issue I had yesterday with NPC items...it finally got to a 'gift shop' item...that I didn't have access to yet...

Is there a good way to check for that availability, or would it need to be hard coded?

Theraze
03-06-2012, 02:14 PM
The npc_price function uses NPCStoreDatabase.contains, with validating that you can actually purchase it. As such, if npc_price(item) > 0 and you can't buy it... mafia needs to realize that shop isn't open yet. :) Make the mafia bug report with as much info as possible on the store and your conditions so they can fix it.

Donavin69
03-06-2012, 02:42 PM
Since I didn't have that code when I ran into the issue, it might be resolved now...I'll check on that (the item that I needed I had someone else buy for me at the time)

I've also noticed an issue with the Omni_limit being above the autoPriceBuyLimit, I'm adding some code for the next version to adjust the limit appropriately (you can either choose to let the default of autoBuyPriceLimit replace the value in Omni_Limit, or temporarily set the autoBuyPriceLimit to the value in Omni_Limit)

Donavin69
03-08-2012, 02:29 PM
Uploaded new version with the changes discussed.

adeyke
03-12-2012, 07:37 AM
When I ran the script, it took a long time searching for prices. It might be worth removing all consumed items from consideration first and only then checking prices on the remainder.

Donavin69
03-12-2012, 05:44 PM
I like that idea, it will also reduce server hits. I've changed the code, so that it only checks prices for the items you haven't consumed. v0.9

Donavin69
04-25-2012, 02:47 PM
It appears that the new drinks aren't all listed in the 'all food/drinks' yet?

When Omnivore runs, it doesn't find that I am missing several of them yet...am I missing something? Or has the master data not been updated to include the new siphoned drinks?

Theraze
04-25-2012, 07:30 PM
Appears that the issue is when fullness or inebriety isn't set yet on an item, it isn't considered to be a food or drink item. As per this:
if ((i.fullness > 0) && (!contains_text(consumed, to_upper_case(to_string(i))))){
food[foodcount]=i;
foodcount=foodcount+1;
}
if ((i.inebriety > 0) && (!contains_text(consumed, to_upper_case(to_string(i))))) {
booze[boozecount]=i;
boozecount=boozecount+1;
}
But that's mafia not having the information yet... if you're trying to do an override, say for siphoned drinks, just do something like this:
if ((i.to_int() >= 5573 && i.to_int() <= 5638) && (!contains_text(consumed, to_upper_case(to_string(i))))) {
booze[boozecount]=i;
boozecount=boozecount+1;
}
Boom, done. We know all those numbers are the siphon drinks, and we don't really know necessarily (since mafia doesn't know) much much inebriety they have, but it would work great as drink/overdrink code for the end of the day.

Veracity
04-25-2012, 07:54 PM
we don't really know necessarily (since mafia doesn't know) much much inebriety they have
I am under the impression that we have inebriety - and adventure gains and stat gains - for all the siphon drinks.

What info do you think is missing?

Theraze
04-25-2012, 09:08 PM
I am under the impression that we have inebriety - and adventure gains and stat gains - for all the siphon drinks.

What info do you think is missing?


It appears that the new drinks aren't all listed in the 'all food/drinks' yet?

When Omnivore runs, it doesn't find that I am missing several of them yet...am I missing something? Or has the master data not been updated to include the new siphoned drinks?

Donavin reported that it's missing some drinks. He didn't specify which exactly, making it rather hard to guess. I was just pulling out the relevant part of his script which decides, using inebriety and fullness, which items are food and which are drinks.

lostcalpolydude
04-25-2012, 10:45 PM
> ash for i from 5573 to 5638 print(to_item(i) + ": " + to_item(i).inebriety)
According to that little check, mafia knows that all of the drinks are 2 inebriety (as of 10936 at least).

Donavin69
05-23-2012, 03:48 PM
Modified the consumption search to find all items, including ones that have partial matches.