Alchemy
Your hero can learn to brew potions using a cauldron. This tutorial teaches the new API methods you'll need: finding world objects, placing items, and interacting with crafting stations.
Tip
This tutorial builds on Pick up & Equip Items. Make sure you're comfortable with FindNearestItemOnGround, PickUp, and Equip before continuing.
New Methods: Interactives and DropInto
Until now we've worked with items on the ground. Alchemy introduces two new concepts:
Finding World Objects
Campfires, cauldrons, shrines, and other world objects are interactives - things you can interact with, but not pick up like items. Use FindNearestInteractive to find them:
var campfire = Hero.FindNearestInteractive("Campfire");
var cauldron = Hero.FindNearestInteractive("Cauldron");
if (campfire != null)
{
Hero.Say("Found a campfire!");
}
This works just like FindNearestItemOnGround but searches for world objects instead of items.
Dropping Items Into Things
DropInto lets you place an item into or onto a target object. Your hero walks to the target and drops the item:
var item = Hero.FindNearestItemOnGround("Bucket");
var cauldron = Hero.FindNearestInteractive("Cauldron");
if (item != null && cauldron != null)
{
Hero.DropInto(item, cauldron); // Hero walks over and drops the bucket into the cauldron
}
DropInto is versatile - it works for placing crafting stations, adding ingredients, fueling fires, filling containers, and more. If the item is on the ground, the hero picks it up first automatically.
Interacting with Objects
InteractWith triggers a double-click interaction - reading a book, stirring a cauldron, opening a chest:
var book = Hero.FindNearestItemOnGround("Book of Alchemy");
if (book != null)
{
Hero.InteractWith(book); // Reads the skill book
}
Discovering the Brew Process
The Witch's Hut near the village contains everything you need to get started with alchemy. Explore it and experiment with the supplies you find there.
Here's what you'll need to figure out:
- What skill do you need, and how do you learn it?
- Where does the cauldron go?
- What goes into the cauldron, and in what order?
- What tool do you need equipped to brew?
- How do you get the finished potion out?
Tip
Try dragging items onto different objects and see what happens. Most crafting in GrindFest works by dropping items onto crafting stations.
Building an Alchemy Bot
Once you understand the process, you can automate it. Alchemy bots work best with the class-based approach using AutomaticHero, because the process has many steps.
A good alchemy bot follows a check -> try -> complain -> return pattern for every step:
using GrindFest;
class AlchemyBot : AutomaticHero
{
void Update()
{
if (!IsBotting) return;
// Step 1: Check if we need to do something
// Step 2: Try to do it
// Step 3: If we can't, complain
// Step 4: Return (stop here, retry next frame)
}
}
Here's the pattern for a single step:
// Do I have the skill I need?
if (Character.SkillUser.GetSkill<Alchemy>() == null)
{
// Try to fix it
var book = FindNearestItemOnGround("Book of Alchemy");
if (book != null) { InteractWith(book); return; }
// Can't fix it - complain and stop
Say("I need a skill book!");
return;
}
// Skill learned! Continue to next step...
The return at each step is crucial - it prevents the bot from trying later steps before earlier ones are complete. Each frame, the bot starts from the top and works its way down.
Useful Properties for Crafting Bots
When writing your bot, these properties on interactives will help you check the state of things:
cauldron.LiquidContainer- Check what liquid is in the cauldron and how muchcauldron.Container.Items- See what solid items are in the cauldroncampfire.FuelSystem- Check if the fire has fuel.
var cauldron = FindNearestInteractive("Cauldron");
if (cauldron != null && cauldron.LiquidContainer != null)
{
Say($"Cauldron has {cauldron.LiquidContainer.Contents.Sum(c => c.Amount)} liquid");
}
Tip
Use Say and Debug.Log() liberally while developing your bot. Alchemy has many steps and it's easy to get stuck on one without knowing why. See Debugging for more tips.
Key Methods Reference
| Method | Purpose |
|---|---|
| FindNearestItemOnGround | Find items lying on the ground |
| FindItem | Find items in inventory OR on ground |
| FindItemInInventory | Find items only in inventory |
| FindNearestInteractive | Find world objects (campfires, cauldrons, shrines) |
| PickUp | Pick up an item from the ground |
| DropInto | Drop an item into/onto a target |
| Equip | Equip an item |
| InteractWith | Double-click interaction (read book, stir cauldron) |
What to do next?
- Drink Potion - Use the potions you've brewed
- Classes - Understand the
AutomaticHeropattern used in the alchemy bot - Pick up & Equip Items - Master item management