taultunleashed logoHarvest Bot : EverQuest 2 Premium Discussions - Page 8
newtopic  postreply
 [ 244 posts ]  Previous  1 ... 5, 6, 7, 8, 9, 10, 11 ... 17  Next
blue large dot

Harvest Bot : EverQuest 2 Premium Discussions - Page 8

Posted: February 23rd, 2005, 2:14 pm
 
wyvernx

Total Posts: 6718
Joined: May 1st, 2004, 4:00 am
wyvernx's Reps: 21
User avatar
administrator
premium
scrollpt, no andyes. See some of the previous replys for how to setup ?'s.

_________________
Use Search first, ask questions later!


Reply with quote
Posted: February 23rd, 2005, 6:41 pm
 
drakkiss
drakkiss's Reps:
User avatar
Update. I was using the player start instead of player current location to calculate distance to the resource. Sorry. This fixes it.


(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
'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, NothingClose
Dim ClosestResourceDist, ClosestSpawnID, CurrentResourceDist
Dim HarvestCounter, MaxHarvests, MaxWanderDistance
Dim bQuitOnMaxHarvests, WanderDistance, bIgnoreWanderDistanceIfResourceFound
Dim BadSpawnArray, NumberOfBadSpawns
Dim RX, RY, PX, PY, RH, PH, IX, IY, ClosestSpawnRX, ClosestSpawnRY 'Resource, Player, Initial X and Y values
Dim Xsq, YSq
XUScriptHost.ImportScript "MessageBoxLibrary.vbl"
Dim MessageBoxSample
Set MessageBoxSample = New MessageBoxClass

'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 = false '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 = 250 'How far the char is allowed to wander around
MaxWanderDistance = 300 'How far to stray away from starting point (if bIgnoreWanderDistanceIfResourceFound is true)
MaxHarvests = 200 'Will attempt to harvest MaxHarvests times.
bQuitOnMaxHarvets = false 'Log out after MaxHarvests is reached.

'Resources to look for.  Syntax:  HOTKEY, ResourceName
'Notice, last array has no trailing comma!
Resources = array( _
   array("1", "cloven ore"), _
   array("1", "wind swept rock"), _
   array("4", "wind felled tree"), _
   array("2", "armadillo den"), _
   array("3", "desert roots"), _
   array("3", "oasis fungi"), _
   array("3", "oasis shrubbery") _
)
ClosestResources = array( _
   array("0", "NULL") _
)


'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'    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()
  NothingClose = "TRUE"
  ClosestResourceDist = 9999
  writeLogLine("Finding Resource...")
  XUScriptPlugin.staStatus.Text = "Looking. . ."
  for i = LBound(Resources) to UBound(Resources)
     'XUScriptPlugin.staStatus.Text = "Looking for: " & Resources(i)(1) & ", Best: " & ClosestResourceDist
     'Sleep 1000
     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    '****************************MODIFIED***************************
       ResourceIndex = i
       writeLogLine("Found Something...")
      RX = getMobX(oServiceObject,SpawnID)
      RY = getMobY(oServiceObject,SpawnID)
      PX = getPlayerX(oServiceObject)
      PY = getPlayerY(oServiceObject)
      if (WithinRoamArea) then
         writeLogLine("Found a " & Resources(i)(1))
         XSq = ((distDiff(PX,RX))*(distDiff(PX,RX)))
         YSq = ((distDiff(PY,RY))*(distDiff(PY,RY)))
         CurrentResourceDist=(Sqr(XSq+YSq))
         'The goto & harvesting functions will now reference the 'ClosestOLDSTRINGNAME' version of the
         'variables as they should always point to the closest resource in the array.
         if ClosestResourceDist > CurrentResourceDist then
            ClosestResourceDist = CurrentResourceDist
            ClosestSpawnRX = RX
            ClosestSpawnRY = RY
            ClosestResources(0)(0) = Resources(i)(0)
            ClosestResources(0)(1) = Resources(i)(1)
            ClosestSpawnID = SpawnID
            XUScriptPlugin.staStatus.Text = "Found " & Resources(i)(1) & ", " & CurrentResourceDist
            'Sleep 2000
         end if
      NothingClose = "FALSE"
      else
         XUScriptPlugin.staStatus.Text = "Found " & Resources(i)(1) & " but it's too far away!"
         'Sleep 2000
         writeLogLine("Nope, too far away!")
         SpawnID = -1
        end if
     end if
 
  next

   if NothingClose = "TRUE" then    '****************************END MODIFIED***************************
      HandleNoResourcesNearby
   else
      SpawnID = ClosestSpawnID
      XUScriptPlugin.staStatus.Text = "Found " & ClosestResources(0)(1) & ", " & ClosestResourceDist
   end if 
end sub

sub GotoResource()
   writeLogLine("Moving to it...")
  If (Index > -1) then
   if (ClosestSpawnRX = 0 and ClosestSpawnRY = 0) then    '*************  MODIFIED
      writeLogLine("Bad location?")
      XUScriptPlugin.staStatus.Text = "Skipping, bad location?"
      'Sleep 2000
   else
      NavigateXY oServiceObject, ClosestSpawnRX, ClosestSpawnRY    '*************  MODIFIED
   end if
  end if
end sub

sub HarvestResource()
    if (ClosestSpawnID > 0) then 'Make sure we still got a target    '*************  MODIFIED
      writeLogLine("Harvesting...")
      XUScriptPlugin.staStatus.Text = "Harvesting. . .Only " & MaxHarvests - HarvestCounter & " more!!!"
       SendKeys(ClosestResources(0)(0))    '*************  MODIFIED
      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("Targeting Resource")      
      SendKeys("{TAB}") 'To Target the Resource
      TargetID = getTargetID(oServiceObject)      
      if (TargetID > 0) then
         MobName = getMobName(oServiceObject, TargetID)
         writeLogLine("Targeted Resource:  " & MobName)
      end if
      ResourceName = ClosestResources(0)(1)   '*************  MODIFIED
      if (TargetID <> ClosestSpawnID) then    '*************  MODIFIED
         'Try backing up a little and try again:
         writeLogLine("Wrong Target!  Trying to back up a little...")         
         RunBackward
         StopRunningBackward
         SendKeys("{ESCAPE}")
         SendKeys("{TAB}") 'To Target the Resource
         TargetID = getTargetId(oServiceObject)      
         if (TargetID > 0) then
            MobName = getMobName(oServiceObject, TargetIndex)
            writeLogLine("Targeted Resource:  " & MobName)
         end if
         ResourceName = ClosestResources(0)(1)   '*************  MODIFIED
         if (TargetID <> ClosestSpawnID) then   '*************  MODIFIED
             HandleBadResource
             writeLogLine("ARG!!! Could not target the resource!!!")
         end if
      end if
      TargetID = getTargetID(oServiceObject)   
      if (TargetID = ClosestSpawnID) then HarvestResource   '*************  MODIFIED
      TargetID = getTargetID(oServiceObject)   
      if (TargetID = ClosestSpawnID) then HarvestResource   '*************  MODIFIED
      TargetID = getTargetID(oServiceObject)   
      if (TargetID = ClosestSpawnID) then HarvestResource   '*************  MODIFIED
  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


Reply with quote
Posted: February 23rd, 2005, 6:43 pm
 
redneckbubba
redneckbubba's Reps:
User avatar
Heh - I was just going to come back and post that I found myself passing a lot of resources. But that makes sense, as I was always wandering back to near the start point.


Reply with quote
Posted: February 23rd, 2005, 8:28 pm
 
drakkiss
drakkiss's Reps:
User avatar
redneckbubba";p="56308 (!empty($user->lang['WROTE'])) ? $user->lang['WROTE'] : ucwords(strtolower(str_replace('_', ' ', 'WROTE'))):
Heh - I was just going to come back and post that I found myself passing a lot of resources. But that makes sense, as I was always wandering back to near the start point.


It still isn't perfect becuase the original function to calculate if a resource is too far away isn't accurate. I think the BadSpawn array is messing things up also.

I just haven't gotten around to that yet.


Reply with quote
Posted: February 23rd, 2005, 9:27 pm
 
drakkiss
drakkiss's Reps:
User avatar
Ok. Fixed all the problems I mentioned.

(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
'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, NothingClose
Dim ClosestResourceDist, ClosestSpawnID, CurrentResourceDist
Dim HarvestCounter, MaxHarvests, MaxWanderDistance
Dim bQuitOnMaxHarvests, WanderDistance, bIgnoreWanderDistanceIfResourceFound
Dim BadSpawnArray, NumberOfBadSpawns
Dim RX, RY, PX, PY, RH, PH, IX, IY, ClosestSpawnRX, ClosestSpawnRY 'Resource, Player, Initial X and Y values
Dim Xsq, YSq
XUScriptHost.ImportScript "MessageBoxLibrary.vbl"
Dim MessageBoxSample
Set MessageBoxSample = New MessageBoxClass

'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 = false '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 = 250 'How far the char is allowed to wander around
MaxWanderDistance = 300 'How far to stray away from starting point (if bIgnoreWanderDistanceIfResourceFound is true)
MaxHarvests = 200 'Will attempt to harvest MaxHarvests times.
bQuitOnMaxHarvets = false 'Log out after MaxHarvests is reached.

'Resources to look for.  Syntax:  HOTKEY, ResourceName
'Notice, last array has no trailing comma!
Resources = array( _
   array("1", "cloven ore"), _
   array("1", "wind swept rock"), _
   array("4", "wind felled tree"), _
   array("2", "armadillo den"), _
   array("3", "desert roots"), _
   array("3", "oasis fungi"), _
   array("3", "oasis shrubbery") _
)
ClosestResources = array( _
   array("0", "NULL") _
)


'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'    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
   XSq = ((distDiff(IX,RX))*(distDiff(IX,RX)))
   YSq = ((distDiff(IY,RY))*(distDiff(IY,RY)))
   CurrentResourceDist=(Sqr(XSq+YSq))
   if (bIgnoreWanderDistanceIfResourceFound = true) then
      if CurrentResourceDist < MaxWanderDistance then
         WithinRoamArea = true
      else
         WithinRoamArea = false
      end if
   else
      if CurrentResourceDist < 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()
  NothingClose = "TRUE"
  ClosestResourceDist = 9999
  writeLogLine("Finding Resource...")
  XUScriptPlugin.staStatus.Text = "Looking. . ."
  for i = LBound(Resources) to UBound(Resources)
     XUScriptPlugin.staStatus.Text = "Looking for: " & Resources(i)(1) & ", Best: " & ClosestResourceDist
     'Sleep 1500
     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)
         SpawnID = -1
         if (SpawnID < 0) then 'No more of that type of resource!
            exit for
         end if
      end if         
     next
     if (SpawnID > -1) then    '****************************MODIFIED***************************
       ResourceIndex = i
       writeLogLine("Found Something...")
      RX = getMobX(oServiceObject,SpawnID)
      RY = getMobY(oServiceObject,SpawnID)
      PX = getPlayerX(oServiceObject)
      PY = getPlayerY(oServiceObject)
      if (WithinRoamArea) then
         writeLogLine("Found a " & Resources(i)(1))
         XSq = ((distDiff(PX,RX))*(distDiff(PX,RX)))
         YSq = ((distDiff(PY,RY))*(distDiff(PY,RY)))
         CurrentResourceDist=(Sqr(XSq+YSq))
         'The goto & harvesting functions will now reference the 'ClosestOLDSTRINGNAME' version of the
         'variables as they should always point to the closest resource in the array.
         if ClosestResourceDist > CurrentResourceDist then
            ClosestResourceDist = CurrentResourceDist
            ClosestSpawnRX = RX
            ClosestSpawnRY = RY
            ClosestResources(0)(0) = Resources(i)(0)
            ClosestResources(0)(1) = Resources(i)(1)
            ClosestSpawnID = SpawnID
            XUScriptPlugin.staStatus.Text = "Found " & Resources(i)(1) & ", " & CurrentResourceDist
            'Sleep 2000
         end if
      NothingClose = "FALSE"
      else
         XUScriptPlugin.staStatus.Text = "Found " & Resources(i)(1) & " but it's too far away!"
         'Sleep 2000
         writeLogLine("Nope, too far away!")
         SpawnID = -1
        end if
     end if
 
  next

   if NothingClose = "TRUE" then    '****************************END MODIFIED***************************
      HandleNoResourcesNearby
   else
      SpawnID = ClosestSpawnID
      XUScriptPlugin.staStatus.Text = "Found " & ClosestResources(0)(1) & ", " & ClosestResourceDist
   end if 
end sub

sub GotoResource()
   writeLogLine("Moving to it...")
  If (Index > -1) then
   if (ClosestSpawnRX = 0 and ClosestSpawnRY = 0) then    '*************  MODIFIED
      writeLogLine("Bad location?")
      XUScriptPlugin.staStatus.Text = "Skipping, bad location?"
      'Sleep 2000
   else
      NavigateXY oServiceObject, ClosestSpawnRX, ClosestSpawnRY    '*************  MODIFIED
   end if
  end if
end sub

sub HarvestResource()
    if (ClosestSpawnID > 0) then 'Make sure we still got a target    '*************  MODIFIED
      writeLogLine("Harvesting...")
      XUScriptPlugin.staStatus.Text = "Harvesting. . .Only " & MaxHarvests - HarvestCounter & " more!!!"
       SendKeys(ClosestResources(0)(0))    '*************  MODIFIED
      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("Targeting Resource")      
      SendKeys("{TAB}") 'To Target the Resource
      TargetID = getTargetID(oServiceObject)      
      if (TargetID > 0) then
         MobName = getMobName(oServiceObject, TargetID)
         writeLogLine("Targeted Resource:  " & MobName)
      end if
      ResourceName = ClosestResources(0)(1)   '*************  MODIFIED
      if (TargetID <> ClosestSpawnID) then    '*************  MODIFIED
         'Try backing up a little and try again:
         writeLogLine("Wrong Target!  Trying to back up a little...")         
         RunBackward
         StopRunningBackward
         SendKeys("{ESCAPE}")
         SendKeys("{TAB}") 'To Target the Resource
         TargetID = getTargetId(oServiceObject)      
         if (TargetID > 0) then
            MobName = getMobName(oServiceObject, TargetIndex)
            writeLogLine("Targeted Resource:  " & MobName)
         end if
         ResourceName = ClosestResources(0)(1)   '*************  MODIFIED
         if (TargetID <> ClosestSpawnID) then   '*************  MODIFIED
             HandleBadResource
             writeLogLine("ARG!!! Could not target the resource!!!")
         end if
      end if
      TargetID = getTargetID(oServiceObject)   
      if (TargetID = ClosestSpawnID) then HarvestResource   '*************  MODIFIED
      TargetID = getTargetID(oServiceObject)   
      if (TargetID = ClosestSpawnID) then HarvestResource   '*************  MODIFIED
      TargetID = getTargetID(oServiceObject)   
      if (TargetID = ClosestSpawnID) then HarvestResource   '*************  MODIFIED
  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


Reply with quote
Posted: February 24th, 2005, 10:13 am
 
blueknight

Total Posts: 136
Location: So Cal.
Joined: January 24th, 2005, 2:06 pm
blueknight's Reps: 2
User avatar
Active User > 50 Posts
premium
Thanks for the changed Drak. I have one suggestion though ... use some sort of version control so that it does not say 'EQ2Harvest Bot. version 1.1. Unless I read all of the posts (which I do actually) it would be quite confusing to see files with each verson and try to figure out which was the latest.


I am still looking forward to someone adding a stuck resolution. Something to the effect of ... If I have not moved more then 5 feet in the last 30 sec, back up 20 feet and go somewhere else.or turn 90deg and move a bit then try again.


Reply with quote
Posted: February 24th, 2005, 11:00 am
 
betathings
betathings's Reps:
User avatar
Ok..
I'm a ranger in game, so running this script for any duration let's my pathfinding run out. Thats abnormal for any scout class, and would be obvious to me (as a scout) that something was up...at least, more obvious on top of the way the toon turns and runs 200 yards to something most people don't have the pc to see...anyway, I am digressing.

I have attempted to add a buff structure to the harvest bot script.
Follows the same resource array principle, grabs the time at the begging of the harvest script, compares the current time with the origin time once a new node has been targetted, then runs a compare in the diff in time vs a user defined frequency value. Then it casts buffs and sets the current time as the origin time.

Btw, I know nothing about vb, I simply read your script and did a bit of googling this past hour to find the date function. I have no idea if this works, as I am at work...

Point out where I mess up, or I won't learn much ;)

Hope this helps someone IF it does work...


You do not have the required permissions to view the files attached to this post.


Reply with quote
Posted: February 24th, 2005, 11:21 am
 
betathings
betathings's Reps:
User avatar
crud...realized (even if it works) that there needs to be a sleep statement added after each buff to allow them to complete (if more then two).
Added that...


Reply with quote
Posted: February 24th, 2005, 12:44 pm
 
betathings
betathings's Reps:
User avatar
bleh I write crap code...fixing it now


Reply with quote
Posted: February 24th, 2005, 12:57 pm
 
betathings
betathings's Reps:
User avatar
(!empty($user->lang['QUOTE'])) ? $user->lang['QUOTE'] : ucwords(strtolower(str_replace('_', ' ', 'QUOTE'))):
'EQ2Harvest Bot. version 1.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, Buffs
Dim OriginTimeH, OriginTimeM, CurrentTimeH, CurrentTimeM, BuffFreq
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


'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 = 60 'Will attempt to harvest MaxHarvests times.
bQuitOnMaxHarvets = false 'Log out after MaxHarvests is reached.

'Resources to look for. Syntax: HOTKEY, ResourceName
'Notice, last array has no trailing comma!
Resources = array( _
array("1", "cloven ore"), _
array("1", "wind swept rock"), _
array("2", "armadillo den"), _
array("3", "desert roots"), _
array("3", "oasis shrubbery") _
)
'Buffs to use (hotkey, name)
Buffs = array( _
array("6", "pathfinding"), _
array("7", "agility buff") _
)
BuffFreq = 15 'Duration in minutes that you want to cast your buffs

'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////////////////
' 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
GetTime 'Establishes time script began for buff purposes

'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 - Wander Distance + 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

sub CastBuffs()
OriginTimeH = CurrentTimeH
OriginTimeM = CurrentTimeM
for i = LBound(Buffs) to UBound(Buffs)
SendKeys(Buffs(i)(0))
sleep 10000
next
end sub

sub GetTime()
OriginTimeM = DatePart("n", Now)
OriginTimeH = DatePart("h", Now)

end sub

sub CheckTime()
CurrentTimeM = DatePart("n", Now)
CurrentTimeH = DatePart("h", Now)
if CurrentTimeH = OriginTimeH then
if (CurrentTimeM - OriginTime) > BuffFreq then
CastBuffs
else
end if
else
delta = (60 - OriginTimeM)
if (CurrentTimeM + delta) > BuffFreq then
CastBuffs
else
end if
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
CheckTime
if (SpawnID > 0) then
Sleep 2000
GotoResource
writeLogLine("Targeting Resource")
SendKeys("{TAB}") 'To Target the Resource
TargetID = getTargetID(oServiceObject)
if (TargetID > 0) then
MobName = getMobName(oServiceObject, TargetID)
writeLogLine("Targeted Resource: " & MobName)
end if
ResourceName = Resources(ResourceIndex)(1)
if (TargetID <> SpawnID) then
'Try backing up a little and try again:
writeLogLine("Wrong Target! Trying to back up a little...")
RunBackward
StopRunningBackward
SendKeys("{ESCAPE}")
SendKeys("{TAB}") 'To Target the Resource
TargetID = getTargetId(oServiceObject)
if (TargetID > 0) then
MobName = getMobName(oServiceObject, TargetIndex)
writeLogLine("Targeted Resource: " & MobName)
end if
ResourceName = Resources(ResourceIndex)(1)
if (TargetID <> SpawnID) then
HandleBadResource
writeLogLine("ARG!!! Could not target the resource!!!")
end if
end if
TargetID = getTargetID(oServiceObject)
if (TargetID = SpawnID) then HarvestResource
TargetID = getTargetID(oServiceObject)
if (TargetID = SpawnID) then HarvestResource
TargetID = getTargetID(oServiceObject)
if (TargetID = SpawnID) then HarvestResource
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


Ok, this actually passes debug, and includes the sleep value in between buffs....someone give it a try and tell me if it even works :)


Reply with quote
Posted: February 24th, 2005, 1:52 pm
 
wyvernx

Total Posts: 6718
Joined: May 1st, 2004, 4:00 am
wyvernx's Reps: 21
User avatar
administrator
premium
blueknight, it does have stuck code in it.

It will attempt to turn and even jump around obsticals. If it doesnt make any progress after a few tries, it flags that resource as unreachable, and tries to get a new one.

_________________
Use Search first, ask questions later!


Reply with quote
Posted: February 24th, 2005, 2:52 pm
 
betathings
betathings's Reps:
User avatar
perhaps he was talking abou the random location from origin part.. I've noticed that if you have your wander turned well up, and the toon runs towards a zone boundry, it will continue to try and get to a spot it cannot ever reach forever. This is one of the mods I was going to attempt once I got my feet wet with the buffs thing..


Reply with quote
Posted: February 24th, 2005, 3:20 pm
 
wyvernx

Total Posts: 6718
Joined: May 1st, 2004, 4:00 am
wyvernx's Reps: 21
User avatar
administrator
premium
betathings, again, it is supposed to stop after a few tries, and try another spot.

_________________
Use Search first, ask questions later!


Reply with quote
Posted: February 24th, 2005, 8:40 pm
 
gzformula
gzformula's Reps:
User avatar
as far as I can tell it doesn't stop trying to go through a wall...ever..
I've never seen it try to move after being stuck in an obsticle...never seen it try to jump...and if it runs to a zoneline it will sit there forever trying to run through it.


Reply with quote
Posted: February 25th, 2005, 12:08 am
 
zippoman
zippoman's Reps:
User avatar
Here's a scenario i've noticed happenning:

I'll harvest until no other resources are up and it'll tell me "sleeping 30 seconds" and then it'll "Going to random spot near origin". If my character gets stuck running into a wall or tree when trying to reach this "random spot near origin" it will not attempt to find a new location to run to. My suggestion is to make some sort of fail-safe to catch this. There could be a timer as long as 4 or 5 minutes at which point it'll pick a different location, or perhaps do a 180 degree turn and run for a few seconds (if this is possible). Just thought I'd share, hopefully this can be incorporated into an updated version.


Reply with quote
Want Advertisements After The Last Post Removed? Create A Free Account!

blue large dot Who is online
Users browsing this forum: No registered users and 74 guests

Popular Sections
SWTOR Cheats
Guild Wars 2 Cheats
Guild Wars 2 Hacks
Guild Wars 2 Bots
Diablo 3 Cheats
Guild Wars 2 Mods

Popular Sections
WoW Cataclysm Cheats & Exploits
WoW Cataclysm Hacks & Bots
Star Wars The Old Republic Cheats
SWTOR Mods
Torchlight 2 Cheats
SWTOR Space Mission Bots
Site Nav and RSS
RSS Feed of EverQuest 2 Premium Discussions RSS Feed 
Sitemap of EverQuest 2 Premium Discussions Sitemap 
SitemapIndex SitemapIndex
RSS Feed RSS Feed
Channel list Channel list
left bottom corner Site and Contents Copyright 2001-2012 All Rights Reserved TaultUnleashed.com bottom corner
top left
top right
createaccount
Username:   Password:   Remember Me?