The alchemy script is getting to be near complete. The old alchemy script has been renamed to alchemy-old on the repository, and alchemy-new is renamed to just alchemy.
How the script works:
Everything is a recipe. In addition to the 190 recipes that give ranks, there are 428 support recipes. Many of these are one-step recipes for buying, foraging, grinding, extracting, distilling, or killing (either for skins or things like essence of fire).
The script makes recipes recursively. When it can't find an ingredient on you, it looks for recipes to make that ingredient. For example, if a recipe requires ground tkaro and you don't have any, it will find the recipe for making ground tkaro, which requires tkaro root. If you don't have any tkaro root, it looks for a recipe for tkaro root, which is a simple forage recipe. Or, if you're making something that requires an ayanad crystal, and you only have a n'ayanad crystal, it will break the n'ayanad crystal down into a t'ayanad crystal, s'ayanad crystal, and two ayanad crystals, and then do the original recipe.
The script attempts to find cheapest/fastest combination of recipes to do a task. The estimated cost is the cost of whatever needs to be bought, plus the cost of the pawnshop-style ingredients at the alchemist. If you have an ingredient on you, its cost is zero, unless it's a pawnshop-style ingredient. The time estimate includes travel time to and from forage locations, hunting grounds, and shops, the roundtime for all the alchemy commands, and an estimated time needed to forage or hunt.
The script learns how long it takes you to forage or hunt for each ingredient by keeping track of the total time spent foraging or hunting, and the total number of ingredients found for each ingredient. By default, everything is set to 1 second and 1 ingredient, which encourages the script to try new things and find out what is really the fastest.
The cost-per-second setting is used to combine the estimated cost and time into a value it can compare against other recipes to pick the best recipe (;alchemy set cost-per-second 15). The default value is 15, meaning the script would rather spend 899 silvers to buy an ingredient than spend 60 seconds foraging or hunting for it, and it would rather spend 60 seconds foraging or hunting than spend 901 silvers to buy.
How to get started:
The script does not buy alchemy equipment. So if you haven't already, go buy a cauldron, mortar, pestle (put the pestle inside the mortar), small crystal flask, and (clouded|warped|chipped|tapered|smoky|thick|slende r) glass vial. Also, get a large bank note and put it in one of your containers.
The script uses three containers. Set them up with:
;set change alchemysack <container>
;set change lootsack <container>
;set change herbsack <container>
The script will look in all three containers for anything it needs. It will put away herbs in your herbsack; alchemy equipment, reagents, and bank notes in your alchemysack; and alchemy products that can't be used as an ingredient in your lootsack.
If you want the script to collect skins or hunt for other ingredients, you need to set up an attack script (;alchemy set attack-script <scriptname>). The attack script is given the ids of any npcs in the room that are supposed to have the ingredient you're looking for. The attack script needs to kill them, handle looting, and exit. There are a couple global variables that the attack script can set.
$alchemy_abort_room = true
If the attack script does this, the alchemy script will ignore any npcs in the room and move to the next.
$alchemy_abort_hunt = true
If the attack script does this, the alchemy script will end the hunt.
You can also set before-hunt-script, after-hunt-script, before-forage-script, and after-forage-script.
“;alchemy help” should be pretty self-explanatory, except maybe a couple things.
;alchemy need – This finds every ingredient that can be used in any recipe you can get ranks for, and creates a regex that can be accessed with UserVars.needed_reagents or viewed with “;set list”. This regex is used by loot-be-gone to automatically exclude reagents you need from being sold, and by “;alchemy buy” to know what to buy.
;alchemy buy – This buys pawnshop-style reagents from the alchemist. It buys at most 20 of each reagent you need and puts them in jars if you have them.
If you're using “;alchemy auto”, then needed_reagents is automatically set if it's missing and each time the script gains a ranks for you.
What's left to do:
Many recipes are untested. There are likely errors and typos somewhere. Some recipes did not have the last rank it would give ranks on virilneus.com and krakiipedia.com. Pretty much any recipe with a range of 10 ranks is not correct.
The script knows that it should forage every ingredient that is foragable, and it knows what npc to kill for every skin, but it doesn't necessarily know where to find those things. It relies on tags in the map database. Likewise, it knows the full inventory for every guild shop. It knows if something is only available in certain towns and/or to certain professions. However, it doesn't know where every guild shop is, or every training cauldron, workshop, training administrator, etc. until the map database is fixed up.
Refract code was added, but not really tested. Also, I had to guess which time you can refract sunlight and moonlight.
The buy-crap, throw-away-crap, and sell-crap settings are only used in auto mode. Use throw-away-crap and sell-crap at your own risk. They pretty much only throw away and sell the stuff I needed them to, and it's possible it'll throw away something you don't want it to. It could be fixed up slightly by editing the script, but I plan on moving this function out of the alchemy script and into loot-be-gone.
If any recipe is missing from the script, I don't know what it is.