-Iago
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
}