Back to "snippet" tags

Brewing-Bro by nev0r

////////////////////////////// // // Brewing-Bot for UO Outlands // - Processes kettles and casks within range // - No mandatory setup, an optional setup section can be found below // - Make sure to carry all items you want to be added to your kettles and casks in your backpack // - WARNING: server system messages are needed to determine necessary actions, make sure they are not filtered for scripts: // Razor -> Filters -> Text&Messages -> // - Uncheck "Filter repeating system messages" // - "Enable text filter" and "Filter system messages" (list entry sub-menu) can be checked, however "Ignore filtered messages in overhead and scripts" (list entry sub-menu) has to be unchecked // ////////////////////////////// ######## MANUAL SETUP ######## # brewingRange: 1 - 18 # Amout of tiles around character that will be searched for brewing equipment. If there are no unprocessed items left within this range the script will terminate. # Note: to actually work the kettle and cask you need to be in a range of 2 tiles, maximal visual range is 18 tiles setvar! brewingRange 2 # brewingSkipOverheadInfo: 0 ... Overhead On, 1 ... Overhead Off # Display status information above kettles and casks setvar! brewingSkipOverheadInfo 0 # brewingDebugMode: 0 ... Off, 1 ... On # Display additional status information in our journal for easier debugging setvar! brewingDebugMode 0 ###### END MANUAL SETUP ###### ////////////////////////////// // // Changelog: // - 09-Dec-2024: Added overhead info above unprocessed kettles and casks outside 2 tiles range, and possibility to continue brewing session in case script did not finish // ////////////////////////////// if timerexists brewingRestartTimer if timer brewingRestartTimer < 10000 unsetvar brewingDone endif removetimer brewingRestartTimer endif if not varexist brewingDone or brewingDone = 1 setvar! brewingDone 0 @clearignore clearsysmsg else settimer brewingRestartTimer 0 overhead "|* Resuming brewing *|" cBeer sysmsg "|* Resuming brewing *|" cBeer overhead "|* Replay to start fresh *|" cLightOrange sysmsg "|* Replay within 10s to start fresh *|" cLightOrange endif setvar! brewingMinWaitForServerResponse 200 setvar! brewingMaxWaitForServerResponse 1000 setvar! brewingWaitForObjectDelay 600 if not timerexists brewingObjectDelayTimer settimer brewingObjectDelayTimer brewingWaitForObjectDelay endif setvar! brewingKettleGumpID 2803256377 setvar! brewingCaskGumpID 2874981722 setvar! cBeer 1720 setvar! cGreen 68 setvar! cLightBlue 100 setvar! cLightOrange 145 setvar! cRed 33 setvar! cWhite 1150 removelist brewingEmptyCaskList createlist brewingEmptyCaskList while findtype "brewing kettle|brewing barrel" ground -1 -1 brewingRange //World save if insysmsg "world is saving" sysmsg "Waiting for world save ..." settimer globalWorldSaveTimer 0 while timer globalWorldSaveTimer < 10000 if insysmsg "save complete" sysmsg "The world has been saved!" settimer brewingWaitTimer 0 getlabel backpack pingCheck while timer brewingWaitTimer < brewingMinWaitForServerResponse endwhile break endif endwhile endif if targetexists target cancel endif if brewingDebugMode > 0 settimer brewingDebugTimer 0 endif if not timerexists brewingOverheadTimer overhead "|* Brewing *|" cBeer settimer brewingOverheadTimer 0 elseif not findtype "brewing kettle|brewing barrel" ground -1 -1 2 and timer brewingOverheadTimer > 2000 overhead "|* Searching equipment *|" cBeer if brewingSkipOverheadInfo = 0 createlist brewingUnfinishedEquipmentList while 10 > index and findtype "brewing kettle|brewing barrel" ground -1 -1 brewingRange as localEquipment overhead "Pending" cLightOrange localEquipment overhead " ▼ " cLightOrange localEquipment pushlist brewingUnfinishedEquipmentList localEquipment @ignore localEquipment endwhile @unignore brewingUnfinishedEquipmentList removelist brewingUnfinishedEquipmentList endif settimer brewingOverheadTimer 0 continue elseif timer brewingOverheadTimer > 2000 overhead "|* Brewing *|" cBeer settimer brewingOverheadTimer 0 endif //Refill water containers in proximity if we are next to a water tile (currently once per script execution) if findtype "water" ground -1 -1 2 while findtype "water" ground -1 -1 2 and findtype 3703|3707|3715|4090|5344|5453 ground -1 -1 2 as localWaterContainer while timer brewingObjectDelayTimer < brewingWaitForObjectDelay endwhile dclick localWaterContainer if brewingDebugMode > 0 sysmsg "[Brewing] Trying to refill water containers (Timer: {{brewingDebugTimer}} ms)" cLightBlue endif settimer brewingObjectDelayTimer 0 @ignore localWaterContainer endwhile while findtype "water" ground -1 -1 2 and findtype 3703|3707|3715|4090|5344|5453 backpack as localWaterContainer while timer brewingObjectDelayTimer < brewingWaitForObjectDelay endwhile dclick localWaterContainer if brewingDebugMode > 0 sysmsg "[Brewing] Trying to refill water containers (Timer: {{brewingDebugTimer}} ms)" cLightBlue endif settimer brewingObjectDelayTimer 0 @ignore localWaterContainer endwhile endif //Casks if findtype "brewing barrel" ground -1 -1 2 as localCask and not inlist brewingEmptyCaskList localCask getlabel localCask localCaskLabel if "%)" in localCaskLabel @ignore localCask elseif "(needs mixture)" in localCaskLabel pushlist brewingEmptyCaskList localCask else gumpclose brewingCaskGumpID while timer brewingObjectDelayTimer < brewingWaitForObjectDelay endwhile dclick localCask settimer brewingObjectDelayTimer 0 waitforgump brewingCaskGumpID brewingMaxWaitForServerResponse if not gumpexists brewingCaskGumpID wait brewingMaxWaitForServerResponse if not gumpexists brewingCaskGumpID continue endif endif if gumpexists brewingCaskGumpID and "complete)" in localCaskLabel if insysmsg "You collect 10 cleansing brew from the brewing cask." endif gumpresponse 13 brewingCaskGumpID settimer brewingWaitTimer 0 waitforgump brewingCaskGumpID brewingMaxWaitForServerResponse getlabel backpack pingCheck pushlist brewingEmptyCaskList localCask while timer brewingWaitTimer < brewingMinWaitForServerResponse endwhile if brewingDebugMode > 0 if insysmsg "You collect 10 cleansing brew from the brewing cask." sysmsg "[Brewing] Cleansing brew collected (Cask: {{localCask}}, Timer: {{brewingDebugTimer}} ms)" cLightBlue else sysmsg "[Brewing] Cleansing brew pickup failed (Cask: {{localCask}}, Timer: {{brewingDebugTimer}} ms)" cLightBlue endif endif //Refill cask else //Hops if gumpexists brewingCaskGumpID and ingump "Add Hops (0/1)" 2874981722 and not ingump "Add Kettle Mixture (0/1)" 2874981722 if findtype 6818 backpack as localHops if insysmsg "This cask does not currently require hops." or insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." endif while not targetexists gumpresponse 11 brewingCaskGumpID waitforgump brewingCaskGumpID brewingMaxWaitForServerResponse if insysmsg "This cask does not currently require hops." or insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." break endif endwhile if targetexists target localHops settimer brewingWaitTimer 0 waitforgump brewingCaskGumpID brewingMaxWaitForServerResponse getlabel backpack pingCheck while timer brewingWaitTimer < brewingMinWaitForServerResponse endwhile if brewingDebugMode > 0 overhead "Hops" cGreen localCask sysmsg "[Brewing] Adding hops" cLightBlue endif endif else overhead "|* Not enough hops *|" cRed endif endif //Jar of Honey if gumpexists brewingCaskGumpID and counttype 2540 backpack >= 10 and not ingump "Add Jar of Honey (10/10)" 2874981722 and not ingump "Add Hops (0/1)" 2874981722 while not ingump "Add Jar of Honey (10/10)" 2874981722 and findtype 2540 backpack as localJarOfHoney if insysmsg "This cask does not currently require jars of honey." or insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." endif while not targetexists gumpresponse 12 brewingCaskGumpID waitforgump brewingCaskGumpID brewingMaxWaitForServerResponse if insysmsg "This cask does not currently require jars of honey." or insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." break endif endwhile if targetexists target localJarOfHoney settimer brewingWaitTimer 0 waitforgump brewingCaskGumpID brewingMaxWaitForServerResponse while find localJarOfHoney backpack and timer brewingWaitTimer < brewingMaxWaitForServerResponse endwhile else break endif endwhile if brewingDebugMode > 0 and not ingump "Add Jar of Honey (10/10)" 2874981722 sysmsg "[Brewing] Honey failed" cRed elseif brewingDebugMode > 0 overhead "Honey" cBeer localCask sysmsg "[Brewing] Honey added" cLightBlue endif elseif counttype 2540 backpack < 10 overhead "|* Not enough honey *|" cRed endif if brewingDebugMode > 0 and ingump "Add Jar of Honey (10/10)" 2874981722 overhead "Done" cGreen localCask overhead " ▼ " cGreen localCask sysmsg "[Brewing] Cask done (Serial: {{localCask}}, Timer: {{brewingDebugTimer}})" cLightBlue elseif brewingDebugMode > 0 overhead "Fail" cRed localCask overhead " ▼ " cRed localCask sysmsg "[Brewing] Cask refill failed (Serial: {{localCask}}, Timer: {{brewingDebugTimer}})" cLightBlue endif @ignore localCask endif endif //Kettle elseif findtype "brewing kettle" ground -1 -1 2 as localKettle getlabel localKettle localKettleLabel if "%)" in localKettleLabel @ignore localKettle else gumpclose brewingKettleGumpID while timer brewingObjectDelayTimer < brewingWaitForObjectDelay endwhile dclick localKettle settimer brewingObjectDelayTimer 0 waitforgump brewingKettleGumpID brewingMaxWaitForServerResponse if not gumpexists brewingKettleGumpID wait brewingMaxWaitForServerResponse if not gumpexists brewingKettleGumpID continue endif endif //Transfer mixture to cask if gumpexists brewingKettleGumpID and "complete)" in localKettleLabel and list brewingEmptyCaskList > 0 if poplist brewingEmptyCaskList front as localEmptyCask if insysmsg "You transfer the mixture to a brewing cask." or insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." endif while not targetexists gumpresponse 13 brewingKettleGumpID waitforgump brewingKettleGumpID brewingMaxWaitForServerResponse if insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." break endif endwhile if targetexists target localEmptyCask settimer brewingWaitTimer 0 waitforgump brewingKettleGumpID brewingMaxWaitForServerResponse getlabel backpack pingCheck while timer brewingWaitTimer < brewingMinWaitForServerResponse endwhile if insysmsg "You transfer the mixture to a brewing cask." @unignore localEmptyCask if brewingDebugMode > 0 overhead "Mixture" cWhite localEmptyCask sysmsg "[Brewing] Adding mixture (Cask: {{localEmptyCask}}, Timer: {{brewingDebugTimer}} ms)" cLightBlue endif else pushlist brewingEmptyCaskList localEmptyCask front endif endif endif endif //Refill kettle if gumpexists brewingKettleGumpID and ingump "(0.0% Complete)" 2803256377 //Barley if gumpexists brewingKettleGumpID and ingump "Add Barley (0/1)" 2803256377 if findtype 49557 backpack as localBarley if insysmsg "This kettle does not currently require barley." or insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." endif while not targetexists gumpresponse 10 brewingKettleGumpID waitforgump brewingKettleGumpID brewingMaxWaitForServerResponse if insysmsg "This kettle does not currently require barley." or insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." break endif endwhile if targetexists target localBarley settimer brewingWaitTimer 0 waitforgump brewingKettleGumpID brewingMaxWaitForServerResponse getlabel backpack pingCheck while timer brewingWaitTimer < brewingMinWaitForServerResponse endwhile if brewingDebugMode > 0 overhead "Barley" cGreen localKettle sysmsg "[Brewing] Adding barley" cLightBlue endif endif else overhead "|* Not enough barley *|" cRed endif endif //Water if gumpexists brewingKettleGumpID and ingump "Add Water (0/250)" 2803256377 and not ingump "Add Barley (0/1)" 2803256377 createlist brewingFullWateringCanList if insysmsg "You do not see any nearby water containers to fill this from." endif while findtype 25570|56416|56417 backpack as localWateringCan getlabel localWateringCan localWateringCanLabel if "250/250" in localWateringCanLabel pushlist brewingFullWateringCanList localWateringCan @ignore localWateringCan else while timer brewingObjectDelayTimer < brewingWaitForObjectDelay endwhile dclick localWateringCan settimer brewingWaitTimer 0 settimer brewingObjectDelayTimer 0 getlabel backpack pingCheck while timer brewingWaitTimer < brewingMinWaitForServerResponse if insysmsg "You completely fill the watering can." break elseif insysmsg "You do not see any nearby water containers to fill this from." @ignore localWateringCan break endif endwhile endif endwhile @unignore brewingFullWateringCanList if list brewingFullWateringCanList = 0 overhead "|* No water supply *|" cRed elseif poplist brewingFullWateringCanList front as localFullWateringCan if insysmsg "This kettle does not currently require water." or insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." endif while find localFullWateringCan backpack and not targetexists gumpresponse 11 brewingKettleGumpID waitforgump brewingKettleGumpID brewingMaxWaitForServerResponse if insysmsg "This kettle does not currently require water." or insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." break endif endwhile if targetexists and find localFullWateringCan backpack target localFullWateringCan settimer brewingWaitTimer 0 waitforgump brewingKettleGumpID brewingMaxWaitForServerResponse getlabel backpack pingCheck while timer brewingWaitTimer < brewingMinWaitForServerResponse endwhile if brewingDebugMode > 0 overhead "Water" cLightBlue localKettle sysmsg "[Brewing] Adding water" cLightBlue endif endif endif removelist brewingFullWateringCanList endif //Garlic if gumpexists brewingKettleGumpID and counttype 3972 self >= 10 and not ingump "Add Garlic (10/10)" 2803256377 and not ingump "Add Water (0/250)" 2803256377 if not findtype 3972 backpack 0 10 and findtype 3972 self 0 10 as localGarlic while timer brewingObjectDelayTimer < brewingWaitForObjectDelay endwhile @drop backpack -1 -1 -1 lift localGarlic 10 settimer brewingObjectDelayTimer 0 @drop backpack -1 -1 -1 settimer brewingWaitTimer 0 while not find localGarlic backpack 0 10 and timer brewingWaitTimer < brewingMaxWaitForServerResponse endwhile endif while not ingump "Add Garlic (10/10)" 2803256377 and findtype 3972 backpack as localGarlic if insysmsg "This kettle does not currently require garlic." or insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." or insysmsg "That item must be in your backpack in order to be used." endif while not targetexists gumpresponse 12 brewingKettleGumpID waitforgump brewingKettleGumpID brewingMaxWaitForServerResponse if insysmsg "This kettle does not currently require garlic." or insysmsg "You must wait for this to finish brewing." or insysmsg "You are too far away to use that item." or insysmsg "That item must be in your backpack in order to be used." break endif endwhile if targetexists target localGarlic settimer brewingWaitTimer 0 waitforgump brewingKettleGumpID brewingMaxWaitForServerResponse while find localGarlic backpack and timer brewingWaitTimer < brewingMaxWaitForServerResponse endwhile else break endif endwhile if brewingDebugMode > 0 and not ingump "Add Garlic (10/10)" 2803256377 sysmsg "[Brewing] Garlic failed" cRed elseif brewingDebugMode > 0 overhead "Garlic" cWhite localKettle sysmsg "[Brewing] Garlic added" cLightBlue endif elseif counttype 3972 self < 10 overhead "|* Not enough garlic *|" cRed endif if brewingDebugMode > 0 and ingump "Add Garlic (10/10)" 2803256377 overhead "Done" cGreen localKettle overhead " ▼ " cGreen localKettle sysmsg "[Brewing] Kettle done (Serial: {{localKettle}}, Timer: {{brewingDebugTimer}})" cLightBlue elseif brewingDebugMode > 0 overhead "Fail" cRed localKettle overhead " ▼ " cRed localKettle sysmsg "[Brewing] Kettle refill failed (Serial: {{localKettle}}, Timer: {{brewingDebugTimer}})" cLightBlue endif endif @ignore localKettle endif endif if list brewingEmptyCaskList > 0 and not findtype "brewing kettle" ground -1 -1 brewingRange overhead "|* Not enough mixtures *|" cRed @ignore brewingEmptyCaskList endif endwhile gumpclose brewingKettleGumpID gumpclose brewingCaskGumpID removetimer brewingDebugTimer removetimer brewingOverheadTimer removetimer brewingWaitTimer removetimer globalWorldSaveTimer removelist brewingEmptyCaskList @clearignore setvar! brewingDone 1 overhead "|* Brewing Done *|" cBeer