[EasyUO]KaianaBeeHarvester

If you make a Client-side script you can publish it here for other players to use
Locked
User avatar
Kaiana
Elder Scribe
Posts: 148
Joined: Mon Jul 13, 2009 3:07 pm

[EasyUO]KaianaBeeHarvester

Post by Kaiana »

I think you guys will like this one :)

This script serves a simple purpose - to prevent carpal tunnel due to harvesting bees. ;) Most scripts I make are for this reason, actually, but I digress. :p

The instructions are at the top of the script, but it's pretty simple. Let me know how it works!

Code: Select all

;Kaiana's Bee Harvester v1.0
;
;Thanks for using my scripts :)
;
;To use this script, either fill in the first two lines with the IDs of your choice or simply run the script with the X there
;to select them as the script starts.  Then, you simply need to move into range of some beehives and the script will detect
;their presence and loot all the resources from them if possible.  The script will halt if you run out of backpack space or
;bottles or hive tools.  I'd recommend having at least 150 stones (if not more) available in your pack when running this script.
;Once the script has looted all the beehives in range you can move on to the next set.  If the script detects no beehives for
;ten seconds it will ask if you are done harvesting; select Yes to have the script dump the remaining harvest into your drop bag
;and halt itself.  :)


set %mageKeys X ;put your mage keys ID here, or X to auto-detect at start
set %dropBag X ;put a bag's ID here where stuff will be dropped, or X to select at start
set %waitTime 10 ;default is usually fine on Ex, you can try faster if you want but it might glitch

if %mageKeys = X
{
   set %mageKeys N/A
   finditem NUI C_ , #BACKPACKID
   repeat
   {
      if #FINDKIND <> -1
      {
         event property #FINDID
         if Spell , #spc , Caster in #property && Keys in #property
            set %mageKeys #FINDID
         else
         {
            ignoreitem #FINDID 3
            finditem NUI C_ , #BACKPACKID
         }
      }
   }
   until %mageKeys <> N/A || #FINDKIND = -1
   ;keys found or all keys checked and none found
   ignoreitem reset 3
   if %mageKeys <> N/A
      display ok Spell Caster's Keys Found!
   else
   {
      display ok No Spell Caster's Keys Detected.$$You need Spell Caster's Keys in your main pack(for bottles) to use this script.  Halting script.
      halt
   }
}

if %dropBag = X
{
   display ok Please target the bag to drop harvested resources into.$$Holding bags work best, but you can also use a regular container on the ground and move it with you as you harvest.
   event macro 8 7 ;open backpack
   set #TARGCURS 1
   set #LTARGETID X
   repeat
   {
      sleep 1
   }
   until #LTARGETID <> X
   set %dropBag #LTARGETID
}

set %targetID X
set %targetType X
set %keysSize 505_475
set %savedPosX 0
set %savedPosY 0


event Macro 8 2 ;open status
display ok Please keep your status window open while running this script (to track weight).

set %lastFound #SCNT

loop1:
gosub CheckStatus
if #result <> #true
{
   wait %waitTime
   goto loop1
}
gosub LocateHive
if #result <> #true
{
   if #SCNT - %lastFound > 10
   {
      display yesno Are you done harvesting?
      if #dispres = yes
      {
         gosub DropStuff
         event SysMessage Halting script.
         halt
      }
      set %lastFound #SCNT
   }
   goto loop1
}
loop2:
gosub TakeStuff
if #result <> #true
  goto loop2
ignoreitem %targetID

goto loop1


sub LocateHive
{
   findItem OOD G_2
   if #FINDCNT > 0
   {
      ;hive found
      set %targetID #FINDID
      set %targetType #FINDTYPE
      set %lastFound #SCNT
      gosub OpenHive
      return #true
   }
   else
      return #false
}

sub TakeStuff
{
   set %clickLocX #CONTPOSX + 70
   set %clickLocY #CONTPOSY + 160
   beeswaxloop:
   set %jrnl #jindex
   scanjournal %jrnl
   click %clickLocX %clickLocY DMC
   wait %waitTime
   repeat
   {
      if #jindex > %jrnl
      {
         set %jrnl %jrnl + 1
         scanjournal %jrnl
      }
      else
         sleep 1
   }
   until collect_the_excess_beeswax_and_place_it_in_your_pack in #journal
   + || enough_excess_wax_in_the_hive in #journal
   + || room_in_your_backpack in #journal
   + || need_a_hive_tool_to_scrape in #journal
   
   if need_a_hive_tool_to_scrape in #journal
   {
      event SysMessage You need more hive tools.  Halting Script.
      halt
   }
   if room_in_your_backpack in #journal
   {
      gosub DropStuff
      if #result = #false
      {
         event SysMessage You need space in your backpack.  Halting Script.
         halt
      }
      goto beeswaxloop
   }
   if enough_excess_wax_in_the_hive in #journal
   {
      gosub OpenHive
   }
   honeyloop:
   set %clickLocX #CONTPOSX + 215
   set %clickLocY #CONTPOSY + 160
   set %jrnl #jindex
   scanjournal %jrnl
   click %clickLocX %clickLocY DMC
   wait 5
   repeat
   {
      if #jindex > %jrnl
      {
         set %jrnl %jrnl + 1
         scanjournal %jrnl
      }
      else
         sleep 1
   }
   until need_a_bottle in #journal || fill_a_bottle_with_golden_honey_and_place_it in #journal || enough_honey_in_the_hive in #journal || need_a_hive_tool_to_extract in #journal
   
   if need_a_hive_tool_to_extract in #journal
   {
      event SysMessage You need more hive tools.  Halting Script.
      halt
   }
   if need_a_bottle in #journal
   {
       gosub GetBottles
       goto honeyloop
   }
   if enough_honey_in_the_hive in #journal
   {
       goto endhoneypoint
   }
   repeat
   {
      sleep 1
   }
   until #CONTSIZE = 250_219
   goto honeyloop
   endhoneypoint:
   gosub WaitForGump 250_219 3
   click %clickLocX %clickLocY R DMC
   set %lastFound #SCNT
   return #true
}


sub GetBottles
{
   set %weight #WEIGHT
   if ( #WEIGHT + 100 ) > #MAXWEIGHT
   {
      event sysMessage You cannot hold 100 bottles.
      gosub DropStuff
      set %weight #WEIGHT
      if #result = #true && ( #WEIGHT + 100 ) < #MAXWEIGHT
      {
         ;move on
      }
      else
      {
         event SysMessage You cannot hold more bottles and have nothing collected to drop.  Reduce your pack weight.  Script Halted.
         halt
      }
   }
   set #LOBJECTID %mageKeys
   set #LOBJECTTYPE NUI
   event macro 17 0
   wait %waitTime
   repeat
   {
      sleep 1
   }
   until #CONTSIZE = %keysSize
   set %clickLocX #CONTPOSX + 290
   set %clickLocY #CONTPOSY + 160
   set %jrnl #jindex
   scanjournal %jrnl
   click %clickLocX %clickLocY DMC
   repeat
   {
      if #jindex > %jrnl
      {
         set %jrnl %jrnl + 1
         scanjournal %jrnl
      }
      else
         sleep 1
   }
   until ( #WEIGHT > %weight && #CONTSIZE = %keysSize ) || do_not_have_any_of_that_resource in #journal
   if do_not_have_any_of_that_resource in #journal
   {
      event SysMessage You need more bottles in your Spellcaster's Keys.  Script halted.
      halt
   }
   wait 10
   click %clickLocX %clickLocY R DMC
   return
}

sub DropStuff
{
   event SysMessage Attempting to drop collected stuff...
   set %weight #WEIGHT
   droploop:
   finditem KRD_ETH C_ , #BACKPACKID
   if #FINDCNT > 0
   {
      exevent Drag #FINDID #FINDSTACK
      exevent Dropc %dropBag
      wait %waitTime
      goto droploop
   }
   if #WEIGHT < %weight
      return #true
   else
      return #false
}

sub OpenHive
{
   set #LOBJECTID %targetID
   set #LOBJECTTYPE %targetType
   event macro 17 0 ;open hive
   wait %waitTime
   ;gosub WaitForGump 258_219 5
   ;if #result <> #true
   repeat
   {
      sleep 1
   }
   until #CONTSIZE = 258_219
   reopensecond:
   set %clickLocX #CONTPOSX + 70
   set %clickLocY #CONTPOSY + 60
   click %clickLocX %clickLocY DMC
   gosub WaitForGump 250_219 4
   if #result <> #true
      goto reopensecond
   return
}

sub WaitForGump ;%1 = contsize to wait for, %2 = waittime(seconds)
{
   set %gumpWaiting #SCNT
   repeat
   {
      sleep 1
   }
   until #CONTSIZE = %1 || #SCNT - %gumpWaiting > %2
   if #CONTSIZE = %1
      return #true ;gump has appeared
   else
      return #false ;hasn't shown up in allotted time
}

sub CheckStatus
{
   if #CHARPOSX <> %savedPosX || #CHARPOSY <> %savedPosY
   {
      set %savedPosX #CHARPOSX
      set %savedPosY #CHARPOSY
      return #false
   }
   else
      return #true
}
♥Kaiana♥ - Administrator of the Heart

Yay for scripting and programming! :)
public bool EasyUOMastery = true;
private double CSharpSkillz = 30.0; //and rising!
Fairis
Grandmaster Scribe
Posts: 83
Joined: Thu Sep 30, 2010 7:27 am

Re: [EasyUO]KaianaBeeHarvester

Post by Fairis »

Works great. :nod:
It is possible to make script for filling beehives from kegs ? :)
Penoxal.com
ticketguru
Grandmaster Scribe
Posts: 99
Joined: Fri Jun 12, 2009 11:25 pm

Re: [EasyUO]KaianaBeeHarvester

Post by ticketguru »

Bee hives are automatically done from kegs. You don't need to have the potions in bottles or even have an empty bottle with you to do your bees.

I wonder how difficult it would be to modify this script to put the correct amount of potions in each of the hives. I think it would be much more difficult to detect the current state of the hive to determine how many of each potion is needed for each hive.
User avatar
Kaiana
Elder Scribe
Posts: 148
Joined: Mon Jul 13, 2009 3:07 pm

Re: [EasyUO]KaianaBeeHarvester

Post by Kaiana »

Ticket I think that's what he meant too. :D

Already working on that ticket....although...I may need to ask Coli's permission to make bees completely easy to manage :p I don't know if he'd appreciate me making bees basically a matter of filling potion kegs and then standing there as my script does all the work...lol ;)
♥Kaiana♥ - Administrator of the Heart

Yay for scripting and programming! :)
public bool EasyUOMastery = true;
private double CSharpSkillz = 30.0; //and rising!
aaron
Grandmaster Scribe
Posts: 79
Joined: Wed Jul 18, 2012 2:28 pm

Re: [EasyUO]KaianaBeeHarvester

Post by aaron »

Kaiana, this script works great but it seems that no matter how much strength you have it won't be enough because eventually you will be overloaded. Lets say you pull out 255 bees wax from the hive, that's 255 stones already. Next you pull out 100 bottles, another 100 stones. Those bottles fill up but the hive isn't empty yet, so you pull out another 100 bottles and that puts you at 455 stones alone. When you pull out those bottles the second time, it makes you overweight and the script halts because you are now over the weight limit of your backpack (not necessarily because of your strength). I think this would all be avoided if the script dropped the wax into the container immediately after harvesting instead of when the hive is completely emptied. Otherwise, great script.
User avatar
Ironbender
Elder Scribe
Posts: 152
Joined: Wed Feb 23, 2011 2:02 pm
Location: Pennsburg, PA

Re: [EasyUO]KaianaBeeHarvester

Post by Ironbender »

I agree with Aaron. I think the best bet would be to make have a MOVE Resources command when it discovers your out of bottles also. (Therefore before it grabs 100 more.)

Pull wax - If wax would make you overweight... Move Resources
as well as
If no bottles present - Move Resources - Open Keys - Grab Bottles

This would prevent any possible Overweight issues.

Otherwise GREAT script.
Thank you
Image
Ernie
Apprentice Scribe
Posts: 19
Joined: Sun Jun 15, 2014 12:13 pm

Re: [EasyUO]KaianaBeeHarvester

Post by Ernie »

Kaiana, it is not a harvester that we need. UOSteam will do that quite well. What we need is something to click those red spots in the Honey Comb automatically, after we select the potion.
Ernie
Locked