there was a bit of an annoying situation where the harvester would find a resource in the middle of a lot of mobs, and it would target the mob, try again, and give up (marking it as bad).
Not sure if we are supposed to post these kind changes here, or PM Wyv. But since i've been PMing him a lot, i don't want him to think i'm harrasing him, lol
I made a little change to the way that my version does this.
when it gets to the spot it's supposed to be, and starts targeting, it will keep trying until a variable # of times, then give up. Got this idea from the way i would normally harvest manually.. walk up to it, tab.. tab tab tab tab .. darn, why isnt it working.. screw it..
On my first attempt i had completely broke it

. lol.. but i guessing found out if was a simple syntax issue (i'm too used to non-script version's of vb's)
Seems to be working fine now though, Wyv might want to check it over to make sure i didn't break something in the process. I'm testing it as i'm typing this. It's gotten to 2 scenarios which would normally fail, and has worked fine.
I did however notice that in Wyv's remarks on my version, it's showing Version 1.1, so i might not have the lastest one.
(!empty($user->lang['QUOTE'])) ? $user->lang['QUOTE'] : ucwords(strtolower(str_replace('_', ' ', 'QUOTE'))):
'EQ2Harvest Bot. version 1.1
'By WyvernX
' Install Instructions
'1. You MUST install the EQ2Service plugin. Get it from the downloads on the web page.
'2. Configure your data below
'Various Varying Variables
Dim oServiceObject, File, temp, FTarget, TargetID
Dim ResourceIndex, SpawnID, Resources, MobName, ResourceName
Dim HarvestCounter, MaxHarvests, MaxWanderDistance
Dim bQuitOnMaxHarvests, WanderDistance, bIgnoreWanderDistanceIfResourceFound
Dim BadSpawnArray, NumberOfBadSpawns
Dim RX, RY, PX, PY, RH, PH, IX, IY 'Resource, Player, Initial X and Y values
Dim TabCount, MaxTabCount
'Notes: If using patrol route, use a tight/small WanderDistance. If using wander method, use a larger one. Just remember you will wander any where in a square - distance away from the origin!!!
bIgnoreWanderDistanceIfResourceFound = true 'If a resource is outside of our wander area, harvest it anyway. (This could cause to you to move FAR away from home point!)
WanderDistance = 100 'How far the char is allowed to wander around
MaxWanderDistance = 300 'How far to stray away from starting point (if bIgnoreWanderDistanceIfResourceFound is true)
MaxHarvests = 999 'Will attempt to harvest MaxHarvests times.
bQuitOnMaxHarvets = false 'Log out after MaxHarvests is reached.
MaxTabCount = 10 ' This could probably be renamed to make it more descriptive, but it's basically how many times the Harvester will attempt to retarget if it gets a wrong one the first time.
'Resources to look for. Syntax: HOTKEY, ResourceName
'Notice, last array has no trailing comma!
Resources = array( _
array("4", "wind felled tree"), _
array("3", "desert roots"), _
array("1", "wind swept rock"), _
array("1", "cloven ore") _
)
' array("3", "oasis shrubbery"), _
' array("3", "oasis fungi"), _
' array("2", "armadillo den"), _
' array("9", "?"), _
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
' DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!!!
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'Set the Log file for our output if necessary
logFilename = GetXUnleashedDirectory() + "\Scripts\EQ2Test.txt" 'debug log file
'Simple Log writing function
function writeLogLine (msg)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim FTarget, File, MyDate, MyTime, temp
MyDate = CStr (FormatDateTime (Date, 1))
MyTime = CStr (FormatDateTime (Time, 3))
Set FTarget = CreateObject("Scripting.FileSystemObject")
Set File = FTarget.OpenTextFile(logFilename, ForAppending, True)
temp = "[" & MyDate & " " & MyTime & "] " & msg & vbCrLf
File.Write temp
File.Close
end function
function WithinRoamArea()
'Check Distance
if (bIgnoreWanderDistanceIfResourceFound = true) then
if (distDiff(IX,RX) < MaxWanderDistance AND distDiff(IY,RY) < MaxWanderDistance) then
WithinRoamArea = true
else
WithinRoamArea = false
end if
else
if (distDiff(IX,RX) < WanderDistance AND distDiff(IY,RY) < WanderDistance) then
WithinRoamArea = true
else
WithinRoamArea = false
end if
end if
end function
sub HandleNoResourcesNearby
writeLogLine("No Resources in this area. Taking a nap!")
for s = 1 to 30
XUScriptPlugin.staStatus.Text = "No Resources nearby. Sleeping " & 30 - s
sleep 1000 'Sleep for 30 seconds.
next
XUScriptPlugin.staStatus.Text = "Going to random spot near origin"
NavigateXY oServiceObject, IX - WanderDistance + Random(0,WanderDistance * 2), IY - WanderDistance + Random(0,WanderDistance * 2)
end sub
sub HandleBadResource()
'This will take us back to "near" our starting point.
writeLogLine("HandleBadResource Called. Avoid that resource node.")
XUScriptPlugin.staStatus.Text = "Bad Resource/Target! Avoiding it for now. . ."
'NavigateXY oServiceObject, IX - WanderDistance + Random(0,WanderDistance * 2), IY - WanderDistance + Random(0,WanderDistance * 2)
BadSpawnArray(NumberOfBadSpawns) = SpawnID
NumberOfBadSpawns = NumberOfBadSpawns + 1
end sub
'How to find Resources.
'Note, it looks for preference items (lower index in the array) first.
'Might customize this later to look for nearest resources first.
sub FindResource()
writeLogLine("Finding Resource...")
XUScriptPlugin.staStatus.Text = "Looking. . ."
for i = LBound(Resources) to UBound(Resources)
SpawnID = findNearestMob(oServiceObject,Resources(i)(1))
for b = LBound(BadSpawnArray) to UBound(BadSpawnArray)
if (BadSpawnArray(b) = SpawnID) then
writeLogLine("Avoiding this resource, we couldnt get it last time!")
SpawnID = findNextNearestMob(oServiceObject)
if (SpawnID < 0) then 'No more of that type of resource!
exit for
end if
end if
next
if (SpawnID > -1) then
ResourceIndex = i
writeLogLine("Found Something...")
RX = getMobX(oServiceObject,SpawnID)
RY = getMobY(oServiceObject,SpawnID)
PX = getPlayerX(oServiceObject)
PY = getPlayerY(oServiceObject)
if (WithinRoamArea) then
writeLogLine("Woot! Found a " & Resources(i)(1))
XUScriptPlugin.staStatus.Text = "Found " & Resources(i)(1)
exit sub
else
writeLogLine("Nope, too far away!")
SpawnID = -1
end if
end if
next
if (SpawnID < 0) then
HandleNoResourcesNearby
end if
end sub
sub GotoResource()
writeLogLine("Moving to it...")
If (Index > -1) then
if (RX = 0 and RY = 0) then
writeLogLine("Bad location?")
XUScriptPlugin.staStatus.Text = "Skipping, bad location?"
Sleep 2000
else
NavigateXY oServiceObject, RX, RY
end if
end if
end sub
sub HarvestResource()
if (SpawnID > 0) then 'Make sure we still got a target
writeLogLine("Harvesting...")
XUScriptPlugin.staStatus.Text = "Harvesting. . .Only " & MaxHarvests - HarvestCounter & " more!!!"
SendKeys(Resources(ResourceIndex)(0))
HarvestCounter = HarvestCounter + 1 'One down!
sleep 5000 + Random(500,1500) 'Wait 5 seconds to harvest + a random delay of .5 to 1.5 seconds
end if
end sub
'Load in the helper functions
writeLogLine("Loading in Library: Navigator")
XUScriptPlugin.staStatus.Text = "Loading libraries... (EQ2Harvest-Navigator)"
XUScriptHost.ImportScript("EQ2Harvest\navigator.vbs")
writeLogLine("Loading in Library: EQ2Service")
XUScriptPlugin.staStatus.Text = "Loading libraries... (EQ2Harvest-EQ2Service)"
XUScriptHost.ImportScript("EQ2Harvest\EQ2Service.vbs")
writeLogLine("Creating EQ2Service Object")
XUScriptPlugin.staStatus.Text = "Loading EQ2Service..."
set oServiceObject = XUScriptPlugin.GetService("EQ2Service.Service")
if Err.Number <> 0 then
XUScriptPlugin.staStatus.Text = "EQ2Service Failed to load!"
Sleep 5000
else
writeLogLine("Doing 1 time init.")
'Any and All initialization
HarvestCounter = 0
IX = getPlayerX(oServiceObject)
IY = getPlayerY(oServiceObject)
NumberOfBadSpawns = 0
redim BadSpawnArray(MaxHarvests)
writeLogLine("Lets do this.")
'Heart of the Script.
Do while HarvestCounter < MaxHarvests
FindResource
if (SpawnID > 0) then
Sleep 2000
GotoResource
writeLogLine("Attempting to Target Resource")
For TabCount = 1 to MaxTabCount
SendKeys("{TAB}") 'To Target the Resource
TargetID = getTargetID(oServiceObject)
if (TargetID > 0) then
MobName = getMobName(oServiceObject, TargetID)
writeLogLine("Targeted Resource: " & MobName)
ResourceName = Resources(ResourceIndex)(1)
if (TargetID = SpawnID) Then
TargetID = getTargetID(oServiceObject)
if (TargetID = SpawnID) then HarvestResource
TargetID = getTargetID(oServiceObject)
if (TargetID = SpawnID) then HarvestResource
TargetID = getTargetID(oServiceObject)
if (TargetID = SpawnID) then HarvestResource
HarvestCounter = HarvestCounter + 1
TabCount = MaxTabCount + 2 'A cheat to exit the loop early
'NOTE: This adds +2, since a for-next loop will end with a +1 if it has reached the end of it
'This is how i am checking later to see if we EVER found a good one, Without having to
'completely restructure this whole section of code.
Else
'Try looking at a few more objects
writeLogLine("Wrong Target! Attempting " & MaxTabCount - TabCount & " more times.")
sleep 500
End If
End If
Next
ResourceName = Resources(ResourceIndex)(1)
If (TabCount = (MaxTabCount + 1)) then
HandleBadResource
writeLogLine("ARG!!! Still can't find it, giving up.")
End if
End if
sleep 200
loop
if (bQuitOnMaxHarvets = true) then
SendKeys("/quit{ENTER}")
end if
set File = Nothing
set FTarget = Nothing
set oServiceObject = Nothing
end if
Here's my version, to main changes... the declares at the top, setting the MaxTab to 10, and a semi re-write of the heart of it. (sorry Wyv, lol.. but had to in order to get the loop to do what i needed)
Like i said, it's got a different version number on it, but here it is for Wyvern's approval
~Shagz