Harvest – A highly customisable farming script

Banana Lord

Member
Harvest
Prepare thy work without, and make it fit for thyself in the field; and afterwards build thine house - Proverbs 24:27



Features
  • Quick and easy to set up
  • Can be configured to farm for anything, anywhere, anyhow you like
  • Bountyhunts optimally
  • Collects and displays farming stats
  • Runs from login to logout, handling all your daily activities eg: buffbot buffs, prismatic wads, equipping optimal rollover gear etc.
  • Ties in with many of your favourite scripts eg: EatDrink, OCD, CounterChecker
  • See FAQs for more.

Harvest%20Screenshot.png


Setup
  1. Install the script by copy/pasting the following line into KoLmafia's CLI and pressing enter. Use a recent build.
    Code:
    svn checkout https://svn.code.sf.net/p/mafia-harvest/code/
    * This will also install EatDrink, OCD and ZLib automatically.
  2. You need to manually install the required script htmlform since it is not on SVN.
  3. Run Harvset from the relay browser (use the dropdown menu in the upper menu pane).
  4. Configure the script's settings to your liking and click Save (stay on the page until the green confirmation text appears).
  5. Add this to the top of the Custom Combat Script you will be using with Harvest:
Code:
[default]
consult Harvest Combat.ash
NB: You may forego this step if you do not intend to use Harvest Combat.ash to automate combat (but you will still need something to run your combats for you).


Requirements
Scripts Required
Zarqon's Zlib
dj_d's EatDrink NB: It is possible to specify a different consumption script for Harvest to use
jasonharper's htmlform
Bale's OCD Inventory Control
NB: Harvest comes preloaded with default data for OCD (giant's castle farming only) so you do not have to categorise any of the items in your inventory yourself if you do not need the full functionality of the script. Simply downloading OCD to your /scripts directory and running relay_OCD_db_Manager.ash once is enough to set the script up to work with Harvest.

Scripts Recommended
NB: Harvest will run fine without these, but I suggest that you look at what they can do as they may well enhance your farming
Bale's CounterChecker (if you want to automatically get semirares while farming)
Bale's Universal Recovery (for optimal HP/MP recovery)
jasonharper's Pyromania (allows you to fine tune your MP burning settings)
jasonharper's breakables.ash (for fine tuning Mafia's handling of breakable equipment, such as sugar items)


Acknowledgements
This script was based on flypapermonk's Neo-Cow Farming Script. While little remains of the original script I took direction from his work and borrowed a number of ideas from it. Special mention goes to slyz and Winterbay who have answered a metric bucketload of my questions and contributed immensely to Harvest. Finally, I would like to thank the entire KoLMafia community without whose patient assistance this script would never have been produced.

Old Versions
Here you can find the last stable version of Harvest and its supporting scripts. This version will usually be one or two builds behind the main release and can be used as a backup, should a new update prove to be broken or buggy.
View attachment Harvest - Stable.zip

Old Versions
Harvest 2.0.8: View attachment Harvest.ash
relay_Harvest 2.0.4: View attachment relay_Harvest.ash
Harvest Combat 1.2.5: View attachment Harvest Combat.ash
View attachment Harvest - Stable.zip
[requires revision 11418]
 
Last edited by a moderator:

Banana Lord

Member
Changelog

Harvest.ash
2.0.8
>Modified for Castle update (thanks Ioeth)
2.0.7
*have_foldable works properly now
*get_foldable works properly now
*Fixed spooky putty monster/sheet typo
*Fixed logic for using munchies pills
*Now includes the cost of overdrinking when recording farmings statistics
2.0.6
+Added support for the Rain-Doh black box (thanks for your help eegee!)
*Removed unreachable code.
2.0.5
*Fix for "reserved word" error introduced with new mafia build.
2.0.4
*Fix for stupid mistake in previous update (thanks again eegee).
2.0.3
>Handling for the situation where mafia doesn't update item quantities after using a putty monster.
>If you leave the Farming Location field blank, bountyhunting will now work correctly.
*Capitalisation for Linux users.
*Improvement to avoid skipping ode if you only have a few turns active when filling organs/overdrinking. Thanks eegee!
*No longer counts all buffs as AT buffs.
2.0.2
+Can now call an "End-of-day" script during "Finishing up for day".
+Will now make use of The Legendary Beat if you have it.
>Now captures result of adventure() during Duck Hunting (should have listened to Bale in the first place).
2.0.1
+While farming under the sea, Harvest will now beat up dolphins if the value of a stolen item is greater than the cost of a whistle.
*No longer aborts if you have not specified a CCS.
*Now properly equips hats to your hatrack.
*Now fights the right number of ducks.
*Now properly gets ode from a buffbot if you cannot cast it yourself.
2.0
+Harvest's budget can now be set with the har_gen_budget setting in your vars file (cannot be accessed from the relay script). Choose -1 to keep all of your meat on hand (not recommended).
+It is now possible to choose a buff to get from the Hatter each day before farming.
+Harvest can now hunt ducks (note that farming-related buffs will be acquired after duck hunting).
+You can now specify a pre and a post consumption script for Harvest to call. You should ensure that these do not interfere with Harvest's activities.
+If Harvest cannot get enough turns of specified AT buff from a buffbot it is now possible to allow it to buy recordings from the mall to make up the difference.
+Will now get ode from a buffbot if you cannot cast it yourself. NB: If you CAN cast it yourself Harvest will make sure you have a slot free for ode, but it is left up to your consumption script to actually make use of the skill (EatDrink will do this automatically, but if you use a different script it is up to you to make sure it does this).
+Aborts if you are adventuring in the sea, have one adventure remaining and have no turns of fishy (prevents infinite loop).
>Harvest can now be directed to olfact monsters other than goth giants while you farm.
>Minor tweaks to improve the efficiency of the bountyhunting code.
>Bountyhunting takes place before consumption to avoid wasting turns of effects acquired from food, booze and/or spleen items.
>Harvest is now much more intelligent about leaving room for fortune cookies if you have enabled semi-rare collection.
*Harvest will now actually use the Still (I, Banana Lord, am an idiot).
*The structure of some data files has been changed. The names of the affected files have been modified to avoid collisions with the old versions (new names are: HAR_Bounty_Data.txt, HAR_Buffbot_Info.txt, HAR_Options.txt). It is safe to delete the old files once you have updated (old versions are: HAR_Bounty_Info.txt, HAR_Buffbot_Data.txt, HAR_Options_Data.txt)
*Fixed bug that was making Harvest think ED had failed to fill your organs completely.
1.1.6
>Now removes On the Trail before starting a bounty if you're not currently tracking your bounty monster, and before farming if you're not tracking a Goth Giant.
+Optimally makes use of the Still, buying ingredients as appropriate (thanks for the code Bale!)
1.1.5
*If you have completed a bounty today without Harvest (e.g.: manually), the script will now properly detect that you cannot do another.
1.1.4
>Harvest will no longer try to fold your origami into pastie form if you can't wear shirts.
1.1.3
>If there is a bountyhunt available in your farming location Harvest will now always choose it and proceed to farm as normal rather than wasting turns with sub-optimal gear/effects.
1.1.2
*Bug fix and adjustments to take advantage of Bale's update to OCD.
1.1.1
>Better handling for selecting a bounty when the airship is an option.
*Fix minor bug in equip_song_raiser.
1.1
+Harvest can now bountyhunt for you.
*Numerous minor bug fixes and improvements.
1.0.2
*Fixed rare bug which caused Harvest to abort if you finished farming before using the extra stomach space left for a fortune cookie.
1.0.1
*Fixed an oversight that meant that the script would not allow you to choose to use sugar shields.
1.0
Initial release


relay_Harvest.ash
2.0.4
>Modified for Castle update (thanks Ioeth)
2.0.3
>Updated have_foldable to match Harvest.ash
2.0.2
+Added support for the Rain-Doh black box.
*You can now modify your copyfarming settings while you have only a spooky putty monster or Rain-Doh box full of monster in your inventory.
2.0.1
*Can now access Hatter setting without a VIP key in inventory.
2.0
>Complete rewrite. CSS prettiness prevails!
+Now displays even more stats.
1.0
Initial release


Harvest Combat.ash
1.2.5
>Modified for Castle update (thanks Ioeth)
1.2.4
>Updated have_foldable to match Harvest.ash
1.2.3
+Added support for the Rain-Doh black box (thanks for your help eegee!)
1.2.2
*Disco combos now actually work!
>Changes to accomodation the SBIP.
1.2.1
*Now employs stasis while duck hunting.
1.2
+Performs disco and rave combos.
>Changes to accommodate updates to other scripts.
1.1.3
+Support for using stasis items other than the spectre scepter.
*Now aborts cleanly if a stasis item cannot be found.
1.1.2
+Added support for stasising with NPZR and cocoabo.
1.1.1
+Implemented jywlot's request for automatic stocking mimic stasising.
1.1
+Handling for bountyhunting.
1.0.1
*Fixed typo. Thanks peter50216!
1.0
Initial release.


Key
+ = New feature
> = Feature modified
* = Bug fix
 
Last edited:

Banana Lord

Member
FAQs

I just want to farm the Giant's Castle
That's not a question, but let's answer it anyway. Because this is the most common farming location, Harvest comes pre-configured with settings for farming the Castle, so when you go to set it up you'll find that some options have been set for you. On a related note, if you're farming the Castle, Harvest will pass default data for castle items on to OCD. This means that if all you want to do is farm the Castle (or test the script out) you don't have to sort through your entire inventory before you can get started.

Do I have to do anything before I run the script each day?
Nope. After you've completed the initial setup Harvest will take care of everything.

Can Harvest get buffs from a buffbot for me?
Open HAR_Buffbot_Buffs.txt (in your KoLmafia>Data folder) and enter the names of the effects you would like to get. Each effect must be on a separate line and must be followed by a tab.

Could you help me set EatDrink up?
Setting up EatDrink.ash for the first time can be a bit daunting, but if all you want to do is set it up to work with Harvest simply follow these instructions and you'll be sorted.
  • Put EatDrink.ash into you /kolmafia/scripts folder
  • Copy paste this into the gCLI and run it: ash set_property("autoSatisfyWithNPCs", true); set_property("autoSatisfyWithMall", true);

    What does this option do?
    If you're unsure of the function of an option that you've come across in the relay script you can simply mouse over its name for a more detailed description. If you're still not sure just post in this thread and I (or someone else) will be happy to help.

    Is Harvest safe? Will it ever go crazy and set fire to my meat?
    Very rarely updates are made to KoL which cause scripts or even Mafia itself to behave in unexpected ways. It is therefore possible, however unlikely it may be, that Harvest may one day go nuts and use all your meat. Fortunately Harvest has a built in safety feature: It will closet all of your meat (keeping 100K on hand for farming-related expenses) before doing anything, meaning that if something does go horribly wrong it can only ever burn through 100K of your meat. If you would like Harvest to keep more or less of your meat on hand you can adjust the script's budget by typing this into the gCLI: set har_gen_budget=100000 substituting whatever value you feel is appropriate. If you set this to -1 Harvest will keep all of your meat on hand and closet nothing (this is not recommended, use at your own risk).

    I'd like to use some foldable equipment with Harvest, how do I fold it up each day?
    Harvest will automatically fold your stinky cheese and origami into their most suitable forms depending on what you're doing (eg: eye for farming, diaper for rollover). Currently only cheese and origami are supported but I'll be happy to add more if someone posts a request.

    Can Harvest automatically remove certain effects while farming?
    Open HAR_Effects_to_Remove.txt (in your KoLmafia>Data folder) and enter the names of the effects you would like to avoid. Each effect must be on a separate line and must be followed by a tab.

    How do I get Harvest to burn my mana on librarm summons?
    This is actually built into mafia. To enable it, check "cast summoning skills during buff balancing" in Mafia's preferences (under the General tab) and then adjust your burning settings under the "HP/MP Usage" tab in the Adventure window.

    How does Harvest handle sugar gear?
    Again, Mafia will handle this for you if you know how to set it up. I suggest using jasonharper's breakables.ash (see "Scripts Recommended" in the first post).

    What's the deal with the pre and post consumption scripts, and the End-of-day script?
    As the names suggest, Harvest will run the specified pre-consumption script immediately before filling your organs, the specified post-consumption script immediately after, and the specified End-of-day script immediately after farming. This could be useful if you need to do something special during your daily farming routine that Harvest does not cater for. For example: You could use the pre-consumption script to drink sake and eat sushi before EatDrink gets a chance to fill up your stomach, and then use the post-consumption script to get enough turns of fishy for you to farm the sea.

    How do I get the script to do this, that or the other thing?
    Feel free to ask for help, suggest improvements, or request features in this thread.

    The script doesn't work/I found a bug
    Please post any problems you have in this thread along with any gCLI output you think is relevant (even better would be setting verbosity to 3 from the relay script, recreating the error and then posting the gCLI output). Describe what you were doing when the error occurred.

    What does HAR stand for?
    I'm glad you asked. Hardcore Automated Reaping.

    What exactly does this script do?
    Harvest is smart. It applies good judgement to all situations and does its best to figure out what it is that you want it to do. It also uses a lot of neat tricks to eke every last bit of meat out of your day. The list below details Harvest's capabilities in broad terms, and in roughly chronological order.
    • Remembers prerun settings like CCS, mood and autoattack so it can restore them when you're done for the day, or in the event of a call to abort().
    • Closets your meat as an added safeguard against the script malfunctioning.
    • Has the ability to get semirares for you as you adventure using CounterChecker.ash.
    • Can complete a bountyhunt for you each day before farming. Tick the appropriate option and Harvest will use your spooky putty and/or Rain-Doh to speed up bounty hunting.
    • If you cannot cast Ode yourself Harvest will get it from a buffbot before consuming.
    • Uses EatDrink.ash to optimally fill your stomach, liver and spleen (you may specify a different consumption script to use).
    • Can be configured to farm a monster trapped in your spooky putty and/or Rain-Doh each day.
    • Can hunt ducks at McMillicancuddy's Farm.
    • Makes sure you have buffing items such as the Rock and Roll Legend and the Mace of the Tortoise.
    • Gets any buffs you specify from a buffbot (note that, if you can, Harvest will cause you to cast the skill yourself, because you really shouldn't be mooching off a buffbot if you don't have to).
    • Can play pool, visit the friars, attend a concert on the Mysterious Island of Mystery, summon your demon and visit the hatter
    • Farms anywhere you choose using any outfit, familiar or familiar equipment you specify (folds up your stinky cheese and/or origami automatically before equipping your farming outfit).
    • You can specify a monster to olfact while you farm.
    • Can use putty and/or Rain-Doh on your trailed monster to speed up re-olfaction.
    • Allows you to specify any effects you want to avoid while farming and removes them as soon as they are detected.
    • Uses dolphin whistles (if profitable) while sea farming.
    • Casts Rainbow Gravitation if possible, buying wads as needed.
    • Makes optimal use of the Still if you can still use it at the end of the day.
    • Uses Bale's OCD Inventory Control to tidy up your inventory after farming (mallsells, autosells, pulverizes and carries out other inventory-related actions of your choice).
    • Uses EatDrink to overdrink when you've finished farming.
    • Equips the most optimal rollover gear you have in your inventory and updates your specified rollover outfit accordingly.
    • Prints a summary of the day's earnings (this, along with other farming statistics, can be viewed at any time with the relay script).
 
Last edited:

fronobulax

Developer
Staff member
  • Closets your meat as an added safeguard against the script malfunctioning.
  • Uses EatDrink.ash (or another consumption scrtipt that you specify) to optimally fill your stomach, liver and spleen.

Sounds awesome. Do those steps occur in that order? If so EatDrink might be challenged. I implemented a mafia preference that allowed you to set a daily budget for ED. It kept track of what you spent each day and closeted meat so you could not exceed the budget. The budget is only enforced when ED is called in a way that enforces the budget, certain abort conditions can get things confused and meat spent to restore MP (to cast Ode) or build boxen does come out of the budget. If this sounds useful maybe I should add it to the supported release of ED.
 

Banana Lord

Member
Yes, in that order. At the moment I have it set up to keep 100K on hand and closet the rest, so that if something does break (I'm thinking of the ghastly results of that chef/bartender change) there's only so much meat to be lost. But even so, I'm always happy to have extra safeguards. I won't have a chance to sit down and make changes to the script for about a week, but as long as any changes you make don't break how eatdrink is currently called I'd very much like to see you add that.
 

peter50216

New member
Have to set
zlib eatdrink_simConsume = false

or the script will fail.

Edit: And in Harvest Combat.ash, activity should be "har_current_activity", not "ncf_current_activity"...
 
Last edited:

Banana Lord

Member
Have to set
zlib eatdrink_simConsume = false

or the script will fail.
That's an EatDrink setting which you should have configured when you set up eatdrink. I don't want to modify people's settings for other scripts if I can avoid it. If it turns out that a lot of people get caught by this then I'll think about changing that.

Edit: And in Harvest Combat.ash, activity should be "har_current_activity", not "ncf_current_activity"...
Thanks! Well spotted. When I changed the script name I knew I was bound to miss one!
 

Alhifar

Member
You could always call it with the 9 parameter version of eatdrink(), so that it doesn't simulate, even if the setting is to simulate normally.
 

peter50216

New member
In shrug_an_at_buff():

if(cost < previous_cost)
buff_to_shrug = buff;
previous_cost = cost;

Should it be:
if(cost < previous_cost){
buff_to_shrug = buff;
previous_cost = cost;
}

?
 

Banana Lord

Member
@Alhifar: Yeah I considered that when I wrote that bit of the script. But in the end I decided that if a user hasn't run eatdrink before (ie: they haven't set simConsume to false) then there're a bunch of other settings that they might want to take a look at. In short, I wanted to encourage people to double check their eatdrink settings. What's your opinion?

@peter: Yes. Right again. I'm so glad you're checking through my code (especially the buffbot bit). It's amazing how easy it is to miss things like that, even after multiple revisions and re-reads.

EDIT: Script updated, but without a version number change. It's not a critical bug, and since I'm sure I'll need to roll another update soon people'll get the fix soon enough (besides which I only have three users so far :p).

EDIT2: Oh and do you know about the [CODE*][/CODE*] and [PHP*][/PHP*] tags (without the *, obviously)? They'll preserve indentation in any code you post. You may know already, but since you have quite a small post count I thought I'd mention it.
 
Last edited:

Theraze

Active member
Don't have to actually call 9 variable EatDrink, just define "SIM_CONSUME=false;" before you call EatDrink and it should work great. It's what I do in my aliases...
 

Banana Lord

Member
So I take it you think it's a good idea to streamline the process rather than force users to check their eatdrink settings before running Harvest too Theraze? Hmm, I'll think about it.
 

Theraze

Active member
Well, if you're going to call EatDrink, make it work. :) If calling EatDrink is the responsibility of the user, leave it the responsibility of the user.
 

Banana Lord

Member
Actually, would setting simConsume to false work? Let's assume a user of Harvest has never used ED before (because if they had then this wouldn't be a problem for them). Setting simConsume to false before calling the script won't do a thing because the zlib settings won't have been created yet. I could have Harvest run ED once filling to 0 of each fullstat before changing the setting, but that doesn't seem very elegant.

However, if I use the 9 parameter version with simConsume set to false and it's the first time a user has run ED it should work, yes?
 

Alhifar

Member
The SIM_CONSUME variable is set in the top level of ED. Therefore, by the time your script runs, the import will have set it (and set the default value of vars[simConsume], but that's another matter), so setting that will affect the rest of the script.
 

Theraze

Active member
Yeah... my 'regular' eatdrink alias is this:
eatdrink => ashq import <EatDrink.ash>; SIM_CONSUME=false; eatdrink(fullness_limit(), inebriety_limit(), spleen_limit(), false);
If someone else used it, regardless of what settings they have saved, that would actually (not simulated) eat and drink from empty to full using whatever they have set for VoA and the pricing limits and the rest of it. As a different example, my simulation alias is this:
seatdrink => ashq import <EatDrink.ash>; SIM_CONSUME=true; simfullness = my_fullness(); siminebriety = my_inebriety(); simspleen = my_spleen_use(); eatdrink(fullness_limit(), inebriety_limit(), spleen_limit(), false);
As you can see, I redefine simfulness, siminebriety, and simspleen as well as the SIM_CONSUME... this way they are properly set, but since I'm defining them after I've imported the script, I'm overwriting the script's defaults. :)
 

fronobulax

Developer
Staff member
When Theraze is happy with the EatDrink additions I expect to add a couple of things that make it easier to import and call EatDrink without making the user fiddle with everything.
 

Theraze

Active member
Yeah, still working on it... for example, found out yesterday that even though I have it auto-purchasing worthless items if you have the money for it and the painful penne pasta is a good choice, if you start with no worthless items, creatable_amount is 0 despite the NPC store setting, because it's not a 'standard' NPC store. Soon as you get a (or a bunch of) worthless item somehow, your creatable_amount is 1+, and you'll create the 3-5 you'd normally make. Somewhat bizarre. Anyways, the fix was to allow for people using EAT_ACCURATE (the default) to consider each item whether you have it officially creatable or not, and for people with EAT_ACCURATE off for speed to use creatable_amount, since that's what it'll use below to decide if it can make the item, similar to current EatDrink.

All that to say, working on it, I'll post a new version for people to test once I think we've got some actual improvements in there.
 

dangold

New member
Two things:

First, your call to eatdrink.ash fails on Linux. Author of that script calls it EatDrink.ash, and case is significant in Unices

Second, running the script yields an error message as follows:
Code:
Cannot store boolean in ocd_profit of type int (Harvest.ash, line 878)

Harvest.ash , line 878:
Code:
int ocd_profit = ocd_control(false);
 
Top