Kingdom Come: Deliverance II

Kingdom Come: Deliverance II

View Stats:
spels47 Feb 17 @ 12:17am
AutoBrew AutoHotKey Script
Automated Potion Brewing Script

Overview
This script automates potion brewing in Kingdom Come: Deliverance by navigating the recipe book and performing brewing steps.

Important Considerations
1. Recipe Book Order Matters
  • Your recipe book must match the script's expected order exactly.
  • The script assumes a total of 21 recipes in your book.
  • If any recipe is missing or in a different position, the script will not work correctly.
  • Example: If Aqua Vitalis is 14 page turns from the first page on my setup but 12 or 15 on yours, the script will fail to find it.

2. Mouse and Screen Sensitivity
  • Mouse movement is scripted based on my machine’s settings.
  • Differences in mouse sensitivity, screen resolution, or aspect ratio may cause incorrect cursor positioning.
  • Adjust these settings manually if needed.

3. Key Mapping
  • The script uses Numpad keys by default.
  • If your keyboard lacks a numpad, you must remap the keys accordingly.

4. Startup Behavior
  • At the start of a recipe, Henry will appear to stop and stare at the first recipe.
  • This is normal! The script is ensuring it starts from the first page.
  • It presses the A button 21 times (with a 2-second delay per press) to guarantee it's at the first page.
  • Only then does it navigate to the correct recipe.
  • If you see Henry staring at the book for ~40 seconds, don't worry—the script is just running its normal setup process.

5. Looping Multiple Recipes
  • The script is designed for one hotkey = one recipe.
  • However, you can modify it to brew multiple recipes in a loop (e.g., Marigold, Saviour Schnapps, Aqua Vitalis, then repeat).
  • You'll need to set up the loop yourself based on your preferences.

Default Key Bindings
  • Numpad 1 - Marigold Decoction
  • Numpad 2 - Saviour Schnapps
  • Numpad 3 - Bane Poison
  • Numpad 4 - Aqua Vitalis
  • Numpad 5 - Bowman's Brew
  • Numpad 6 - Artemesia Potion
  • Numpad 7 - Digestive Potion
  • Numpad 8 - Hair Of The Dog
  • Numpad 9 - Painkiller Brew
  • Numpad 0 - Moonshine
  • Shift + Numpad 1 - Buck's Blood
  • Shift + Numpad 2 - Embrocation
  • Shift + Numpad 3 - Night Hawk
  • Shift + Numpad 4 - Soap (henry is a dirty boy)
  • Shift + Numpad 5 - Lead Shot Gunpowder
  • Shift + Numpad 6 - Scattershot Gunpowder
  • Shift + Numpad 7 - Fox
  • Shift + Numpad 8 - Cockerel

Usage
  1. Ensure your recipe book matches the expected order.
  2. Start the script.
  3. Walk up to alchemy station and enter alchemy mode.
  4. Wait for animation to finish, do not move mouse or touch any keyboard inputs
  5. Henry should now be staring into the fire beneath the cauldron, this is position zero for the script, and its dependant on this position in order for the mouse movements to successfully navigate to the different objects henry needs to interact with.
  6. Press the assigned hotkey to brew the desired potion.
  7. Wait for the script to complete the process automatically.
  8. When you want to end the loop, hold CTRL(Control) during the end part of the potion making, for this script that means when the potion result window pops up, gets closed automatically, and henry looks down on the cauldron, thats the end of one potion recipe, if you held CTRL(Control) during this time, henry should not start to cook up another batch like he is Jesse Pinkman afraid his methlamine is going to expire.

Troubleshooting
  • Script doesn’t find the right recipe → Check your recipe book order.
  • Mouse clicks in the wrong spot → Adjust screen resolution or mouse sensitivity.
  • Keyboard input doesn’t work → Ensure you have a numpad or remap keys.
  • Henry stares at the book for a long time → Normal behavior at startup, wait for it to proceed.

This script is designed primarily for my setup, but with tweaking, you can adjust it for your system.

#IfWinActive Kingdom Come: Deliverance II Numpad1:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ MarigoldDecoctionRecipe() } return Numpad2:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ SaviourSchnappsRecipe() } return Numpad3:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ BanePoisonRecipe() } return Numpad4:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ AquaVitalisRecipe() } return Numpad5:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ BowmansBrewRecipe() } return Numpad6:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ ArtemesiaPotionRecipe() } return Numpad7:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ DigestivePotionRecipe() } return Numpad8:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ HairOfTheDogRecipe() } return Numpad9:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ PainKillerBrewRecipe() } return Numpad0:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ MoonshineRecipe() } return +Numpad1:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ BucksBloodRecipe() } return +Numpad2:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ EmbrocationRecipe() } return +Numpad3:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ NightHawkPotionRecipe() } return +Numpad4:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ SoapRecipe() } return +Numpad5:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ LeadShotGunpowderRecipe() } return +Numpad6:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ ScattershotGunpowderRecipe() } return +Numpad7:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ FoxRecipe() } return +Numpad8:: StartAlchemyFindCauldron() while not(GetKeyState("Control")){ CockerelRecipe() } return MarigoldDecoctionRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(8) AfterBookFindCauldron() PourWater() TakeFirstHerb() AddToCauldron() Boil(2) TakeSecondHerb() AddToMortar() TakeSecondHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 PreparePhial() Pour() } SaviourSchnappsRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(7) AfterBookFindCauldron() PourWine() TakeFirstHerb() AddToCauldron() Boil(2) TakeSecondHerb() AddToMortar() TakeSecondHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 PreparePhial() Pour() } BanePoisonRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(4) AfterBookFindCauldron() PourWine() TakeFirstHerb() AddToCauldron() Boil(2) TakeSecondHerb() AddToMortar() TakeSecondHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 BoilWithBellows(1) TakeFirstSpecialIngredient() AddToCauldron() PreparePhial() Distill() } AquaVitalisRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(14) AfterBookFindCauldron() PourWater() TakeFirstHerb() AddToCauldron() TakeFirstHerb() AddToCauldron() Boil(1) TakeSecondHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 Boil(2) PreparePhial() Distill() } BowmansBrewRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(3) AfterBookFindCauldron() PourSpirits() TakeFirstHerb() AddToCauldron() TakeFirstHerb() AddToCauldron() Boil(3) TakeSecondHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 BoilWithBellows(1) PreparePhial() Distill() } ArtemesiaPotionRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(1) AfterBookFindCauldron() PourSpirits() TakeSecondHerb() AddToCauldron() Boil(1) TakeFirstHerb() AddToMortar() TakeFirstHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 Boil(2) PreparePhial() Distill() } DigestivePotionRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(2) AfterBookFindCauldron() PourWater() TakeSecondHerb() AddToCauldron() TakeSecondHerb() AddToCauldron() Boil(2) TakeFirstHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 Boil(1) TakeFirstSpecialIngredient() AddToMortar() Grind() AddToCauldron() Sleep 5000 PreparePhial() Pour() } HairOfTheDogRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(0) AfterBookFindCauldron() PourWater() TakeFirstHerb() AddToCauldron() TakeSecondHerb() AddToCauldron() Boil(3) TakeThirdHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 PreparePhial() Pour() } PainKillerBrewRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(16) AfterBookFindCauldron() PourSpirits() TakeFirstHerb() AddToMortar() TakeFirstHerb() AddToMortar() TakeFirstHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 TakeThirdHerb() AddToCauldron() BoilWithBellows(1) TakeSecondHerb() AddToCauldron() Boil(2) PreparePhial() Distill() } MoonshineRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(9) AfterBookFindCauldron() PourSpirits() TakeSecondHerb() AddToCauldron() TakeSecondHerb() AddToCauldron() Boil(2) TakeFirstHerb() AddToMortar() TakeFirstHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 Boil(1) PreparePhial() Distill() } BucksBloodRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(13) AfterBookFindCauldron() PourOil() TakeFirstHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 TakeThirdHerb() AddToCauldron() Boil(1) TakeSecondHerb() AddToCauldron() BoilWithBellows(1) PreparePhial() Pour() } EmbrocationRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(10) AfterBookFindCauldron() PourOil() TakeSecondHerb() AddToCauldron() TakeThirdHerb() AddToCauldron() Boil(2) TakeFirstHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 TakeFirstSpecialIngredient() AddToCauldron() Boil(1) PreparePhial() Pour() } NightHawkPotionRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(11) AfterBookFindCauldron() PourWater() TakeFirstHerb() AddToMortar() TakeFirstHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 TakeSecondHerb() AddToCauldron() Boil(3) TakeThirdHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 PreparePhial() Pour() } SoapRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(21) AfterBookFindCauldron() PourOil() TakeFirstHerb() AddToMortar() TakeFirstHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 Boil(2) TakeSecondHerb() AddToCauldron() Boil(1) TakeFirstSpecialIngredient() AddToMortar() Grind() AddToCauldron() Sleep 5000 PreparePhial() Pour() } LeadShotGunpowderRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(19) AfterBookFindCauldron() PourWater() TakeFirstSpecialIngredient() AddToMortar() TakeSecondSpecialIngredient() AddToMortar() Grind() AddToCauldron() Sleep 5000 Boil(2) TakeThirdSpecialIngredient() AddToMortar() Grind() AddToCauldron() Sleep 5000 Boil(2) GrindFinish() } ScattershotGunpowderRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(20) AfterBookFindCauldron() PourWater() TakeFirstSpecialIngredient() AddToMortar() TakeSecondSpecialIngredient() AddToMortar() Grind() AddToCauldron() Sleep 5000 Boil(3) TakeThirdSpecialIngredient() AddToMortar() Grind() AddToCauldron() Sleep 5000 Boil(1) GrindFinish() } FoxRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(5) AfterBookFindCauldron() PourOil() TakeSecondHerb() AddToMortar() TakeFirstHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 Boil(2) TakeFirstSpecialIngredient() AddToMortar() Grind() AddToCauldron() Sleep 5000 TakeThirdHerb() AddToCauldron() Boil(1) PreparePhial() Pour() } CockerelRecipe() { GoToRecipeBook() ResetRecipeBookToFirstRecipe() SelectRecipe(6) AfterBookFindCauldron() PourSpirits() TakeSecondHerb() AddToMortar() TakeSecondHerb() AddToMortar() Grind() AddToCauldron() Sleep 5000 Boil(1) TakeFirstHerb() AddToCauldron() Boil(2) PreparePhial() Distill() } StartAlchemyFindCauldron() { UltraMoveMouse(-10, -22) } AfterBookFindCauldron(){ UltraMoveMouse(-17, -40) } GoToRecipeBook() { UltraMoveMouse(200, 0) Send e Sleep 3000 } ResetRecipeBookToFirstRecipe(){ Loop 21 { Send a Sleep 2000 } } SelectRecipe(number){ iteration := 0 while (iteration < number) { iteration := iteration + 1 Send d Sleep 2000 } Send {e down} Sleep 1000 Send {e up} Sleep 3000 } TakeFirstHerb() { UltraMoveMouse(86, -15) Send e Sleep 3000 UltraMoveMouse(-86, 15) } TakeSecondHerb() { UltraMoveMouse(69, -15) Send e Sleep 3000 UltraMoveMouse(-69, 15) } TakeThirdHerb() { UltraMoveMouse(55, -10) Send e Sleep 3000 UltraMoveMouse(-55, 10) } TakeFirstSpecialIngredient() { UltraMoveMouse(87, 15) Send e Sleep 3000 UltraMoveMouse(-87, -15) } TakeSecondSpecialIngredient() { UltraMoveMouse(74, 18) Send e Sleep 3000 UltraMoveMouse(-74, -18) } TakeThirdSpecialIngredient() { UltraMoveMouse(62, 20) Send e Sleep 3000 UltraMoveMouse(-62, -20) } AddToCauldron() { Send e Sleep 3000 } BoilWithBellows(turns) { Send e Sleep 4000 Sleep 1400 totalTime := turns * 10000 bellowTime := 3750 endTime := A_TickCount + totalTime - 4000 while (A_TickCount < endTime) { Send q Sleep 100 } Sleep bellowTime Send e Sleep 4000 } Boil(turns) { Send e Sleep 4000 Sleep 1400 Sleep (turns * 10000) Send e Sleep 4000 } AddToMortar() { UltraMoveMouse(55, 45) Send e Sleep 3000 UltraMoveMouse(-55, -45) } Grind() { UltraMoveMouse(55, 45) Send e Sleep 10000 UltraMoveMouse(-55, -45) } PreparePhial() { UltraMoveMouse(-71, 15) Sleep 2000 Send e Sleep 2000 UltraMoveMouse(71, -15) } Pour() { Send {e down} Sleep 1000 Send {e up} Sleep 10000 Send {Escape} } Distill() { UltraMoveMouse(-74, 30) Send {e down} Sleep 1000 Send {e up} Sleep 20000 Send {Escape} Sleep 100 UltraMoveMouse(-8, 12) } GrindFinish() { UltraMoveMouse(55, 45) Send {e down} Sleep 1000 Send {e up} Sleep 20000 Send {Escape} } PourWater() { UltraMoveMouse(-88, -20) Send e Sleep 8500 UltraMoveMouse(88, 20) } PourWine() { UltraMoveMouse(-72, -20) Send e Sleep 8000 UltraMoveMouse(72, 20) } PourOil() { UltraMoveMouse(-55, -20) Send e Sleep 8000 UltraMoveMouse(55, 20) } PourSpirits() { UltraMoveMouse(-37, -20) Send e Sleep 7000 UltraMoveMouse(37, 20) } UltraMoveMouse(xAxis, yAxis) { Loop 10 { DllCall("mouse_event", uint, 1, int, xAxis, int, yAxis, uint, 0, int, 0) Sleep 10 } Sleep 100 }
Last edited by spels47; Feb 17 @ 1:08am
< >
Showing 1-15 of 17 comments
Gravora Feb 21 @ 2:30pm 
How do I change the order?
spels47 Feb 21 @ 3:22pm 
Originally posted by Gravora:
How do I change the order?
the order of what?
spels47 Feb 21 @ 3:23pm 
Originally posted by Gravora:
How do I change the order?
btw i moved the script to a guide, updates to it and a more thorough documentation will be posted there https://steamcommunity.com/sharedfiles/filedetails/?id=3429740275
Gravora Feb 21 @ 4:01pm 
The order of the recipes. And thank you.
Raynar Mar 7 @ 7:14am 
arigoldDecoctionRecipe() {
GoToRecipeBook()
ResetRecipeBookToFirstRecipe()
SelectRecipe(8)<-----------------0 would be page 1
AfterBookFindCauldron()

PourWater()
TakeFirstHerb()
AddToCauldron()
Boil(2)
TakeSecondHerb()
AddToMortar()
TakeSecondHerb()
AddToMortar()
Grind()
AddToCauldron()
Sleep 5000
PreparePhial()
Pour()
}
if you are going to cheat, why not use consol commands and simply add the potions you need?
spels47 Mar 7 @ 11:49am 
Originally posted by Bernstorff:
if you are going to cheat, why not use consol commands and simply add the potions you need?
because i want a thing that exists in the middle between the minigame that becomes tedious after the first 3 times and just spawning the items i want in my inventory, i would have preferred to have something like the AutoBrew perk that existed in the first game but thats not available, that was a perk where you still spent the herbs to create the potion, but you didnt have to make the thing by hand, since that doesnt exist, a script that just follows the steps is the next best thing. ofcourse if you are a person that either prefers to use console commands, or enjoys spending hours cooking up potions by hand, then by all means, but i prefer this way.
Autobrew should exist by default as a mid to early perk.

Wasting 10+ minutes per in-game day is just disrespectful of player time.

If you have a 2 hour play session, spending 30 minutes of it on maintenance and crafting instead of advancing the story and exploring hampers the best part of the game.
KynQ Mar 7 @ 11:57am 
I found alchemy not tedious enough to use AHK for it, getting 6 henry potions per brew is good enough and it is kinda satisfying while listening to podcast or something. I use AHK for autorun and on my second playthrough to skip dialogues and cutscenes. Cool to see someone putting the effort into this though.
You can make 6 potions at a time... I also find the minigame boring, but If you know what you are doing you can make the needed potions in a few minutes.
spels47 Mar 8 @ 8:05am 
Originally posted by Bernstorff:
You can make 6 potions at a time... I also find the minigame boring, but If you know what you are doing you can make the needed potions in a few minutes.
depends how many you need, i burn through potions in almost every combat encounter i have, and thats my preferred way of playing, so for me, producing 6 potions is nice, but i need closer to 30 of each combat recipe before i leave so thats 5 repetitions per potion recipe, and there is like 7 ish recipes? so for me to have enough potions for my use would come to making potions 35 times.

if you are satisfied with 6, then good for you, go out there and slay some dragons, make daddy radzig proud.
Kabirbd Mar 8 @ 8:11am 
Originally posted by spels47:
Originally posted by Bernstorff:
You can make 6 potions at a time... I also find the minigame boring, but If you know what you are doing you can make the needed potions in a few minutes.
depends how many you need, i burn through potions in almost every combat encounter i have, and thats my preferred way of playing, so for me, producing 6 potions is nice, but i need closer to 30 of each combat recipe before i leave so thats 5 repetitions per potion recipe, and there is like 7 ish recipes? so for me to have enough potions for my use would come to making potions 35 times.

if you are satisfied with 6, then good for you, go out there and slay some dragons, make daddy radzig proud.
Bruh. That sounds more of an OCD than anything. No need to be passive aggressive about it with others.
You are probably over encumbered from dried herbs. Let alone gear.
Last edited by Kabirbd; Mar 8 @ 8:11am
spels47 Mar 8 @ 9:36am 
Originally posted by Kabirbd:
Originally posted by spels47:
depends how many you need, i burn through potions in almost every combat encounter i have, and thats my preferred way of playing, so for me, producing 6 potions is nice, but i need closer to 30 of each combat recipe before i leave so thats 5 repetitions per potion recipe, and there is like 7 ish recipes? so for me to have enough potions for my use would come to making potions 35 times.

if you are satisfied with 6, then good for you, go out there and slay some dragons, make daddy radzig proud.
Bruh. That sounds more of an OCD than anything. No need to be passive aggressive about it with others.
You are probably over encumbered from dried herbs. Let alone gear.
actually no, when im not brewing potions i keep all my materials in my personal chest, although i am overencumbered, but im fine with that, and im not passive aggressive im explaining my use case for it, you are the one feeling the need to comment that you are fine with doing it by hand since you dont need that many, and thats fine, enjoy your playstyle, i have mine, and i prefer using a script in order to get the quantity of potions i need in order to restock that quantity from time to time.
tiehu Apr 5 @ 5:14pm 
Hey, could you check the “controls_sensitivity” item in the file “C:\Users\YourUserName\Saved Games\kingdomcome2\profiles\defaul\attributes.xml”? This is where the game saves your configuration settings, and it records the specific mouse sensitivity value, which is very helpful for others using the script.

Also, could you tell me at which alchemy station you created and tested this script? Although visually all the alchemy stations in the game appear identical, my tests indicate that the script behaves inconsistently across different alchemy stations, though it might just be a measurement error.

Furthermore, here’s a small suggestion: You don’t need the script to flip through the recipe book on every cycle; it only needs to flip to the correct page on the first pass. After that, simply look at the book and hold down the E key, which will significantly reduce the cycle time.

Regarding the recipe book page order issue, my suggestion is to have the player manually flip to the corresponding potion page the first time. You can use the Pause function to wait for the player to complete the action, and then bind a hotkey so that when the player reaches the correct page, they can press that hotkey to manually unpause the script. The subsequent process will then be fully automated, eliminating the need for the recipe book to be in the correct order.
Great work, but why is this not in the guide section?
< >
Showing 1-15 of 17 comments
Per page: 1530 50