Auto use meat-drop and item-drop items.

MCroft

Developer
Staff member
Really basic script to figure out if I have items that drop other items or that drop meat and use them right away.

The impetus for this was "I have how many Penultimate Fantasy Chests in inventory?"

I didn't want to have to make and maintain a list of items to use (which is different from sell or destroy), so I wanted to use the Boolean_modifiers "Drops Meat" and "Drops Items"

So far so good, but it seems to miss things, like Warm Subject Gift Certificates:

Here's the script:

Code:
void main()
{

item myItem;
   
foreach myItem in $items[] {
if (boolean_modifier(myItem,"Drops Meat") && item_amount(myItem) > 0)
	print(myItem + " is a meat dropping item");   
if (boolean_modifier(myItem,"Drops Items") && item_amount(myItem) > 0)
	print(myItem + " is an item dropping item");

 } //  end foreach item
} // end main

What am I doing wrong?
 

lostcalpolydude

Developer
Staff member
Drops Meat and Drops Items are for equipment that drops meat/items during combat, like KoL Con 13 snowglobe. I don't think there's anything that would be useful for the script you want.
 

Veracity

Developer
Staff member
In VMF, I have a hard-coded list of items that I will auto-use at the end of my daily run (not immediately after I acquire them, which would go in a between battle script, or something).

Code:
// Items dropped by Mr. Screege's spectacles or other equipment which will be "used"
// *** Must contain at least one token. Use "none" for no items.
static item_set GENERAL_USE_LOOT = $items[
     ancient vinyl coin purse,
     black pension check,
     CSA discount card,
     duct tape wallet,
     fat wallet,
     old coin purse,
     old leather wallet,
     pixel coin,
     pixellated moneybag,
     shiny stones,
     solid gold jewel,
     stolen meatpouch,
     Gathered Meat-Clip
];
Not to say you should use this specific list, but, yeah - I think you have to make your own list. We don't have built-in modifiers for "items which drop meat or items when you use them".
 

MCroft

Developer
Staff member
Thanks for the clarification.

I looked in modref and I made a bad assumption (because there are numeric_modifiers for Meat Drop and Item Drop, I assumed the bools were what I wanted).

But it is "drops" and not "contains", so I guess it's on me.

So back to revision1, which was iterating over a list of items.

the wiki has a category for items with meat in them, which makes that a good start. I just need to find or make a list of things which, when used, drop other things...
 

MCroft

Developer
Staff member
I haven't decided if I want it to be a between battle script or a on login script. First I was going to get it working, then I was going to figure out if I should reasonably delay it or if iterating through 30-40 items and using some if they showed up was quick enough for between battles.

Is the static item_set (constant?) CONTAINS_LOOT something that it would be useful to add to KoLmafia for anyone who wants to use it?
 
Last edited:

MCroft

Developer
Staff member
This is auto-use loot script. It's got a few additions in the loot string and it doesn't use item_set, but it works.

additions welcome.

Code:
void main()
{


static String CONTAINS_LOOT = "ancient vinyl coin purse,bag of park garbage,black pension check,black picnic basket,briefcase,canopic jar,chest of the Bonerdagon,collection of tiny spooky objects,CSA discount card,dungeon dragon chest,duct tape wallet,fat wallet,flytrap pellet,Gathered Meat-Clip,giant jar of protein powder,kobold treasure hoard,LOLmec statuette,meat globe,nest egg,old coin purse,old leather wallet,Penultimate Fantasy chest,pixel coin,pixellated moneybag,old coin purse,red box,Roll of meat,shiny stones,solid gold jewel,stolen meatpouch,Warm Subject gift certificate";

String[int] lootArray;
lootArray = split_string(CONTAINS_LOOT,",");

int myIndex, itemCount;
item myItem;
int myItemCount;   
   
foreach myIndex in lootArray {
    myItem = to_item(lootArray[myIndex]);
    myItemCount = item_amount(myItem);

	if (myItemCount > 0) {
		// print(myItem + " is a loot dropping item.  Count: "+myItemCount);
		use(myItemCount, myItem);
		} // end if
 	} //  end foreach LOOT_ARRAY
} // end main
 

zarqon

Well-known member
I would like to mention that there are some publicly maintained maps on the Map Manager of items that drop meat or items when used. Your script can access and load them with just three lines of code:

Code:
import <zlib.ash>

float[item] useformeat;
load_current_map("use_for_meat",useformeat);

At this point your script will be able to reference two maps, one for meat and another for items.

1) The useformeat variable contains a float[item] map, with items keyed to the average amount of meat they produce when used.
b) The useforitems variable contains a float[item, item] map, with items keyed to the items they produce, which are in turn keyed to the average amount of that item dropped (frequently less than 1). This map is already loaded into a global variable by ZLib so you don't need to load it in your script.

Your script could then foreach both of these maps, add perhaps a little logic for skipping certain items (I'd recommend a test script first before actually using all the items) or not using unprofitable items (perhaps the container is worth more than the contents), and then use the rest!
 
Top