I have almost gotten eq2 harvester v. 146 working. I put in waypoints, told it what I wanted it to harvest and set up my keys. here is the problem that I am having though. when the harvester gets to a waypoint he does not wander or harvest. he just kind of stands there and twitches. I beleive that this is related to a problem with movment but I don't know enough about scripting to fix this or to find the problem. when I use my chat screen to see what keys the script is hitting virtually I see that it is spamming the "d" or "a" key to turn right or left but not moving forward. if I turn off the script then my toon will constantly turn in a circle in one direction or another without moveing until I close eq2 and restart the xunleashed client. below is my harvester ini file and vbs file. hope this helps for so much of a post
.INI file
[Harvester]
;Avoidplayers = True/False will ignore nodes with players nearby if true
;CampOnEnd = True/False if true will camp to desktop once harvesting ends
;QuitonTimeout = True/False End script if timout value reached since last harvested item
;Timeout = # Max time in minutes since last harvested item before causing a timeout and ending script
; if you get stuck or other unforseen event happens
;Hotbar = # number of the hotbar 0-9 that you have the harvesting hotkeys on
;defaultzone = zonename this is the zone the script will assume you are in ONLY if the zone detected
; is not defined in the script
;EQ2Path = directory directory where EQ2 is installed
;
AvoidPlayers = true
CampOnEnd = true
QuitonTimeout = false
Timeout = 15
Hotbar = 5
defaultzone = antonica
EQ2Path = d:\games\Everquest II\
[Resources]
;nodetype = #, #, true/false first number is Priority and is 0 based,
; second number is the hotkey to use,
; true/false harvest this type of node
COLLECT = 9, 4, false
MISC = 9, 3, false
ORE = 1, 1, true
STONE = 1, 1, true
FUNGI = 9, 2, false
SHRUB = 9, 2, false
WOOD = 2, 2, true
ROOTS = 7, 2, false
DEN = 3, 3, true
FISH = 9, 5, false
;This section is for defining the buffs for your characters. Set the section name to
;your characters first name ie [Johnydoe]
;NumofBuffs = # set this to the number of buffs you wish to cast
;Buff# = name, duration in min, cast time in seconds, hotbar, hotkey
[Johnydoe]
Numofbuffs = 2
buff1 = pathfinding, 14, 6, 2, =
buff2 = elise's ditty, 14, 6, 2, -
;Zone sections
;[zonename]
;maxwander = # this value is a radius around your starting point and is ONLY used if you
; do not use waypoints
;UseWaypoints = True/False set to true or false to use your starting point or a waypoint list
;NumofPoints = # set this to the number of waypoints you define for this zone
;Waypoint# = X, Y, R set this to the X, Y coordinates and a harvest radius around it set the radius
; to zero if you just wish to travel through this location
;nodetype = resource set the appropriate resource name for this type of node
[The Enchanted Lands]
MaxWander = 100
UseWaypoints = false
COLLECT = ?
ORE = residual ore
STONE = rhythmic stone
WOOD = wretched arbor
SHRUB = mystical natural garden
FUNGI = fairy ring
ROOTS = velvety roots
DEN = deer den
FISH = throng of fish
[The Commonlands]
Maxwander = 100
Usewaypoints = false
Collect = ?
ore = cloven ore
stone = wind swept rock
Fungi = oasis fungi
Shrub = oasis shrubbery
roots = desert roots
fish = band of fish
den = armadillo den
wood = wind felled tree
[The Thundering Steppes]
MaxWander = 100
UseWaypoints = False
NumOfPoints = 0
COLLECT = ?
ORE = stonecrest ore
STONE = wind swept stones
WOOD = felled high plains arbor
SHRUB = high plains shrubbery
FUNGI = high plains fungi
ROOTS = mesquite catch weed
DEN = badger den
FISH = mob of fish
[Zek, the Orcish Wastes]
Maxwander = 100
Usewaypoints = False
Collect = ?
Ore = ferric ore
Stone = mud stone
wood = marred arbor
Shrub = flattened bed of thistle
Fungi = flattened natural herb garden
Roots = vestigial roots
Den = lioness den
Fish = fury of fish
[Antonica]
maxwander = 200
UseWaypoints = true
Numofpoints = 15
waypoint1 = -552, 633, 135
waypoint2 = -592, 531, 135
waypoint3 = -613, 442, 145
waypoint4 = -557, 376, 110
waypoint5 = -483, 305, 0
waypoint6 = -511, 185, 0
waypoint7 = -907, 209, 140
waypoint8 = -947, 320, 100
waypoint9 = -1305, 199, 130
waypoint10 = -1401, 196, 100
waypoint11 = -1676, 177, 100
waypoint12 = -1829, 158, 150
waypoint13 = -1841, 9, 150
waypoint14 = -1750, -108, 50
waypoint15 = -1925, -231, 115
COLLECT = ?
ORE = callous ore
STONE = sandwashed rock
WOOD = wind felled tree
SHRUB = plains shrubbery
FUNGI = plains fungi
ROOTS = plains roots
DEN = critter den
FISH = shoal of fish
MISC = withered bones
.vbs file
'====================================================================================
'EQ2 Harvester ver 1.45
'====================================================================================
'4-19-05 Retsek Extensively modified version of WyvernX's harvester bot
' this version reads an .ini file for all the user defined
' information. Eliminating those annoying mystery failures
' of the script.
' Future enhancements in the works will be automatic buffing,
' and evading combat by camping or casting escape for higher
' level scouts.
'
'4-20-05 Retsek Added TEMPORARY fCenterX to the zone processing section. If
' the getzonename() function of eq2service fails it will read
' an ini entry in the [harvester] section key defaultzone to
' get the zone.
' So in the ini file section [Harvester] add the line
'
' DefaultZone = The Forest Ruins
'
' as an example. Once the eq2service is updated this will be
' ignored.
'
'4-22-05 Retsek Now resets bad node list whenever zero resources are located.
'
' Instead of using True/False in the waypoint list now using a
' radius value for harvesting. Set to 0 to treat as a travel
' only node. This allows for harvesting a larger open space
' say like in the dead river basin where it opens up a bit, then
' returning to tight radius for the narrower sections.
'
' If the current zone is undefined in the INI file it will now
' look for the "defaultzone" entry in the harvest section of
' the ini file.
'
' If no resources are defined or all have been set to not
' harvest the script will halt.
'
'4-24-05 Retsek Added a player section to the ini file where you can put in
' any buffs you wish to cast.
'
' Added player detection around the node and you can set an
' entry in the ini file which will allow you to choose to ignore
' a player within harvestable distance of the node or go ahead
' and whack it anyway
'
' Fixed a bug wherein the harvest area wasn't getting set on
' the first waypoint. It now correctly ignores the max_wander
' key if you use waypoints.
'
'4-27-05 Retsek Added a search of the EQ2 logfile for harvest successes. A
' timeout value in minutes since the last successful harvest is
' checked and the script will end if no activity happens during this
' period. The default is 5 minutes.
'
' If your inventory is full and your chat log is found then harvesting
' will end when it sees that message.
'
' The [HARVESTER] section of the INI file has changed!
' (See notes in the ini file for details)
'
' *************************** N O T E ******************************
' This means you need to have your logging turned on in the eq2 menu.
' It can be found under the options menu ALT-O in the user interface
' area under "Chat Window" turn on "log chat text". You will need
' to camp and then come back for this to properly activate but then
' eq2 will keep a chat log for all your characters.
' ******************************************************************
'
'4-28-05 Retsek Fixed minor bug in castbuffs ... wasn't targeting self for the
' buffs that required it.
'
' Reworked navigation to hopefully address a tighter path for where you
' really need it. As well as slightly improved handling of being stuck.
'
' When you start the script, if you have waypoints defined it will
' move to the nearest waypoint defined instead of the first one. Lets you
' interrupt the script to fight etc... then start it back up where you
' left off.
'
'====================================================================================
'You must have installed WyvernX's eq2service to use this script. Then simply
'unpack the archive into the scripts directory
'
'====================================================================================
' I M P O R T E D S C R I P T S
'====================================================================================
XUScriptHost.ImportScript("EQ2Harvest\EQ2Service.vbs")
'====================================================================================
' G L O B A L V A R I A B L E S
'====================================================================================
'Dimension global variables
Dim EQ2_SvcObj, TargetID
Dim SpawnID, SpawnName
Dim BadSpawnCount
Dim iCounter
Dim WaypointCount
Dim MaxWander
Dim CX, CY, RX, RY, CenterX, CenterY
Dim ResourceIDX, WaypointIDX
Dim Resources(10,3)
Dim Waypoints
Dim BadSpawns(1000)
Dim Buffs
Dim BuffCount
Dim PCName
Dim ZoneName, SectionName, Keyname, DefaultVal, KeyVal, TempSTR, Hotbar
Dim IniFileName, LogFileName, EQ2Logfilename, EQ2Path
Dim LastHarvestTime
Dim Timeout
Dim QuitOnTimeout, EQ2LogFound
Dim EQ2Chatlog
Dim FSObj
Dim CampOnEnd, UseWaypoints, OKtoContinue, ResourcesSelected, AvoidPlayers, SkipNode
Const ForReading = 1, ForWriting = 2, ForAppending = 8
'====================================================================================
' M A I N C O D E
'====================================================================================
set EQ2_SvcObj = XUScriptPlugin.GetService("EQ2Service.Service")
do until Err.number = 0
XUScriptPlugin.staStatus.Text = "EQ2Service failed to load"
Sleep 5000
set EQ2_SvcObj = XUScriptPlugin.GetService("EQ2Service.Service")
Loop
InitializeFiles
If OKtoContinue then
ProcessINIFile
EQ2LogFound = FindEq2Log()
If EQ2LogFound then
Set FSObj = CreateObject("Scripting.FileSystemObject")
set EQ2ChatLog = fsobj.opentextfile(EQ2Logfilename, forreading)
do while EQ2ChatLog.AtEndOfStream <> True
EQ2ChatLog.SkipLine
loop
lastharvesttime = now
writelogline("EQ2 Chat Log: " & EQ2Logfilename)
writelogline("*****************************************************")
End If
CastBuffs
If ResourcesSelected then
If usewaypoints then
GotoClosestWaypoint
else
xuscriptplugin.stastatus.text = "No waypoints defined using current loc"
writelogline("No Waypoints defined using current loc")
CenterX = getPlayerX(EQ2_SvcObj)
CenterY = getPlayerY(EQ2_SvcObj)
end if
BadSpawnCount = 0
Do while OKtoContinue
CastBuffs
FindResource
if (SpawnID > 0) then
GotoResource
If Playernearby() and AvoidPlayers = True then
xuscriptplugin.stastatus.text = "player too close!"
sleep 100
SkipNode = True
processunharvestablenode
Else
Skipnode = False
end if
If Skipnode = False then
SendKeys("{F1}")
sleep 100
iCounter = 0
targetid = -1
do until (TargetID = SpawnID) OR (iCounter = 10)
iCounter = iCounter + 1
SendKeys("{TAB}") 'To Target the Resource
TargetID = getTargetId(EQ2_SvcObj)
sleep 100
loop
if (TargetID <> SpawnID) then
writeLogLine("Untargetable node found!")
ProcessUnharvestableNode
Else
Spawnname = getmobname(eq2_svcobj,targetid)
XUScriptPlugin.staStatus.Text = "Targeted Resource: " & SpawnName
writeLogLine("Targeted Resource: " & SpawnName)
end if
icounter = 0
do while (TargetID = SpawnID) and icounter < 15 and OKtoContinue
HarvestResource
If EQ2LogFound then
ProcessChatlog
End If
TargetID = getTargetID(EQ2_SvcObj)
icounter = icounter + 1
if icounter = 15 then
writelogline("Unharvestable node found!")
ProcessUnharvestableNode
end if
loop
end if
end if
if QuitOnTimeout then
TimeSinceHarvest = datediff("s", lastharvesttime, now()) / 60
If TimeSinceharvest > Timeout then
OKtoContinue = False
writelogline("*****************************************************")
writelogline("*****************************************************")
writelogline("It has been " & formatnumber(timesinceharvest,1) & _
" minutes since last harvest activity.")
writelogline("Harvesting stopped.")
writelogline("*****************************************************")
writelogline("*****************************************************")
xuscriptplugin.stastatus.text = "Timeout reached: Ending Harvest"
sleep 5000
End if
end if
sleep 10
loop
if CampOnEnd And ResourcesSelected then
SendKeys("/camp desktop{ENTER}")
end if
else
xuscriptplugin.stastatus.text = "No resources selected - halting script"
writelogline("No resources selected - halting script")
sleep 5000
end if
end if
EQ2ChatLog.Close
set FSObj = Nothing
set EQ2_SvcObj = Nothing
'====================================================================================
' F I N D E Q 2 C H A T L O G
'====================================================================================
function FindEQ2Log()
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
EQ2Logfilename = EQ2Path & "logs\eq2log_" & PCName & ".txt"
If FSO.FileExists(EQ2LogFileName) then
FindEQ2Log = True
Else
FindEQ2Log = False
end if
Set FSO = Nothing
end function
'====================================================================================
' I N I T I A L I Z E F I L E S
'====================================================================================
sub InitializeFiles()
Dim FSO
XUScriptPlugin.staStatus.Text = "Initializing files"
OKtoContinue = True
Set FSO = CreateObject("Scripting.FileSystemObject")
LogFileName = GetXUnleashedDirectory() & "\Scripts\EQ2Test.txt"
If FSO.FileExists(LogFileName) then
FSO.DeleteFile(LogFileName)
end if
writelogline("Log File Created")
xuscriptplugin.stastatus.text = "Log File Created"
IniFileName = GetXUnleashedDirectory() & "\Scripts\EQ2Harvester.ini"
If FSO.FileExists(IniFileName) Then
xuscriptplugin.stastatus.text = "INI File found!"
writelogline("INI File Found")
Else
OKtoContinue = False
xuscriptplugin.stastatus.text = "INI File not found!"
writelogline("Missing INI File - Please unpack it from original RAR!")
end if
Set FSO = Nothing
end sub
'====================================================================================
' P R O C E S S I N I F I L E
'====================================================================================
sub ProcessIniFile()
XUScriptPlugin.staStatus.Text = "Processing INI File"
writelogline("Processing INI File")
ProcessHarvesterSection
ProcessPlayerSection
ProcessResourcesSection
ProcessZoneSection
End sub
'====================================================================================
' P R O C E S S H A R V E S T E R S E C T I O N
'====================================================================================
sub ProcessHarvesterSection
XUScriptPlugin.staStatus.Text = "Processing Harvester Section"
writelogline("Processing Harvester Section")
writelogline("*****************************************************")
writelogline("*****************************************************")
Tempstr = getini("harvester", "AvoidPlayers", "True", inifilename)
Avoidplayers = cbool(tempstr)
writelogline("Avoid players: " & AvoidPlayers)
Tempstr = GetINI("harvester", "CampOnEnd", "False", inifilename)
CampOnEnd = CBool(tempstr)
writelogline("CampOnEnd: " & CampOnEnd)
HotBar = GetINI("harvester", "hotbar", "", inifilename)
keydown(virtualkey.vk_shift)
sleep 100
SendKeys(HotBar)
sleep 100
keyup(virtualkey.vk_shift)
writelogline("Hotbar: " & hotbar)
tempstr = getini("harvester", "timeout", "5", inifilename)
Timeout = cint(tempstr)
writelogline("Timeout: " & timeout)
tempstr = getini("harvester", "quitontimeout", "True", inifilename)
QuitOnTimeout = CBool(tempstr)
writelogline("QuitonTimeout: " & quitontimeout)
EQ2Path = getini("harvester", "eq2path", "", inifilename)
If eq2path = "" then
quitontimeout = False
writelogline("EQ2 directory not defined in INI file QuitonTimeout disabled")
End If
writelogline("*****************************************************")
end sub
'====================================================================================
' P R O C E S S P L A Y E R S E C T I O N
'====================================================================================
sub ProcessPlayerSection
Dim i, buffidx
PCName = getplayername(eq2_svcobj)
Sectionname = PCName
keyname = "Numofbuffs"
defaultval = "0"
buffcount = cint(getini(sectionname, keyname, defaultval, inifilename))
if buffcount > 0 then
writelogline("Player: " & sectionname)
reDim buffs(buffcount, 6)
writelogline("Number of buffs: " & buffcount)
for i = 1 to buffcount
buffidx = i-1
keyname = "buff" & i
defaultval = ""
tempstr = getini(sectionname, keyname, defaultval, inifilename)
ParseBuffKey tempstr, buffidx
next
writelogline("*****************************************************")
end if
end sub
'====================================================================================
' P A R S E B U F F K E Y
'====================================================================================
sub ParseBuffKey(buffkey, buffidx)
Dim Pos1, Len1, TmpVal, TmpStr
buffs(buffidx, 0) = ""
buffs(buffidx, 1) = 0
buffs(buffidx, 2) = 0
buffs(buffidx, 3) = ""
buffs(buffidx, 4) = ""
buffs(buffidx, 5) = 0
'get buff name
pos1 = instr(1, buffkey, ",", vbtextcompare)
If Pos1 > 0 then
buffs(buffidx, 0) = Left(buffkey, pos1-1)
writelogline("Ability: " & buffs(buffidx, 0))
Len1 = len(buffkey) - Pos1 - 1
tmpval = right(buffkey, len1)
end if
'get duration
pos1 = instr(1, tmpval, ",", vbtextcompare)
If Pos1 > 0 then
buffs(buffidx, 1) = csng(left(tmpval, pos1-1))
writelogline("Duration in min: " & buffs(buffidx, 1))
Len1 = len(tmpval) - Pos1 - 1
tmpval = right(tmpval, len1)
end if
'get cast time
pos1 = instr(1, tmpval, ",", vbtextcompare)
If Pos1 > 0 then
buffs(buffidx, 2) = csng(left(tmpval, pos1-1))
writelogline("Cast time in seconds: " & buffs(buffidx, 2))
Len1 = len(tmpval) - Pos1 - 1
tmpval = right(tmpval, len1)
end if
'get hotbar
pos1 = instr(1, tmpval, ",", vbtextcompare)
If Pos1 > 0 then
buffs(buffidx, 3) = trim(left(tmpval, pos1-1))
writelogline("Hotbar: " & buffs(buffidx, 3))
Len1 = len(tmpval) - Pos1 - 1
tmpval = right(tmpval, len1)
end if
'get hotkey
buffs(buffidx, 4) = trim(tmpval)
writelogline("Hotkey: " & buffs(buffidx, 4))
end sub
'====================================================================================
' P R O C E S S R E S O U R C E S S E C T I O N
'====================================================================================
sub ProcessResourcesSection
XUScriptPlugin.staStatus.Text = "Processing Resources Section"
writelogline("Processing Resources Section")
keyname = "collect"
defaultval = "0, 6, True"
parseresourcekey
keyname = "ore"
defaultval = "1, 1, True"
parseresourcekey
keyname = "stone"
defaultval = "2, 1, True"
parseresourcekey
keyname = "wood"
defaultval = "3, 2, True"
parseresourcekey
keyname = "misc"
defaultval = "4, 2, True"
parseresourcekey
keyname = "den"
defaultval = "5, 3, True"
parseresourcekey
keyname = "roots"
defaultval = "6, 4, True"
parseresourcekey
keyname = "shrub"
defaultval = "7, 4, True"
parseresourcekey
keyname = "fungi"
defaultval = "8, 4, True"
parseresourcekey
keyname = "fish"
defaultval = "9, 5, True"
parseresourcekey
for i = 0 to 9
tempstr = " harvest: False"
if resources(i,2) then tempstr = " harvest: True"
writelogline(resources(i,1) & space(8-len(resources(i,1))) & " hotkey: " & resources(i,0) & tempstr)
next
writelogline("*****************************************************")
end sub
'====================================================================================
' P A R S E R E S O U R C E K E Y
'====================================================================================
sub parseresourcekey()
Dim Pos1, Len1, V1, V2, B1
tempstr = GetINI("resources", keyname, defaultval, inifilename)
pos1 = instr(1, tempstr, ",", vbtextcompare)
V1 = Cint(left(tempstr, pos1-1))
pos1 = pos1 + 1
len1 = len(tempstr) - pos1
tempstr = right(tempstr, len1)
pos1 = instr(1, tempstr, ",", vbtextcompare)
V2 = Cint(left(tempstr, pos1-1))
pos1 = pos1 + 1
len1 = len(tempstr) - pos1
tempstr = right(tempstr, len1)
B1 = Cbool(tempstr)
resources(v1, 0) = v2
resources(v1, 1) = keyname
resources(v1, 2) = b1
end sub
'====================================================================================
' P R O C E S S Z O N E S E C T I O N
'====================================================================================
sub ProcessZoneSection
XUScriptPlugin.staStatus.Text = "Processing Zone Section"
writelogline("Processing Zone Section")
'Get the zone name then trim any instance numbers from it
ZoneName = getzonename(EQ2_SvcObj)
z = instr(1, "0123456789", right(zonename,1), vbtextcompare)
If z > 0 then
zonename = left(zonename, len(zonename)-2)
end if
if NOT Findzone(zonename, inifilename) then
xuscriptplugin.stastatus.text = "Zone undefined: " & zonename
writelogline("")
writelogline("Zone undefined: " & zonename)
Zonename = getini("harvester", "defaultzone", "antonica", inifilename)
xuscriptplugin.stastatus.text = "Using defaultzone: " & zonename
writelogline("Using defaultzone: " & zonename)
writelogline("")
end if
writelogline("Zone: " + ZoneName)
TempSTR = GetINI(zonename, "maxwander", "100", IniFilename)
MaxWander = CInt(tempstr)
writelogline("MaxWander: " & MaxWander)
Tempstr = GetINI(zonename, "usewaypoints", "False", inifilename)
UseWayPoints = Cbool(tempstr)
If UseWayPoints then
writelogline("UseWaypoints: True")
tempstr = GetINI(zonename, "Numofpoints", "1", inifilename)
WayPointCount = Cint(tempstr)
writelogline("Number of Waypoints: " & WayPointCount)
ReDim Waypoints(WayPointCount, 3)
CX = getplayerx(EQ2_SvcObj)
CY = Getplayery(EQ2_SvcObj)
DefaultVal = formatnumber(cx,2) & ", " & formatnumber(cy,2) & ", True"
for z = 1 to WayPointCount
WaypointIDX = Z - 1 'arrays zero based so subtract 1 from count
keyname = "waypoint" & z 'set keyname to look for as waypoint1 ... waypoint2 etc...
tempstr = GetINI(zonename, keyname, defaultval, inifilename)
p1 = instr(1,tempstr,",",vbtextcompare) 'parse out the x coord of the key
keyval = left(tempstr,p1-1)
waypoints(waypointidx,0) = csng(keyval) 'store it in the waypoints array
p1 = p1+1 'cut string to remaining part of key
p2 = len(tempstr) - p1
tempstr = right(tempstr,p2)
p1 = instr(1,tempstr,",",vbtextcompare) 'parse out the y coord of the key
keyval = left(tempstr,p1-1)
waypoints(waypointidx,1) = Csng(keyval) 'store it in the waypoints array
p1 = p1+1 'cut string to remaining part of key
p2 = len(tempstr) - p1
tempstr = right(tempstr,p2)
waypoints(waypointidx,2) = csng(tempstr) 'remainder of key is the radius around loc for harvest
tempstr = formatnumber(waypoints(waypointidx, 0),2) & ", " & _
formatnumber(waypoints(waypointidx, 1),2) & ", " & _
formatnumber(waypoints(waypointidx,2),2)
writelogline("Waypoint: " & tempstr)
next
WaypointIDX = 0
writelogline("*****************************************************")
End if
icounter = 0
for z = 0 to 9
KeyName = Resources(z,1)
DefaultVal = Keyname & " undefined!"
Resources(z,1) = GetINI(zonename, keyname, defaultval, IniFileName)
If instr(1, Resources(z,1), "undefined", vbtextcompare) OR Resources(z,2) = False Then
writelogline("Ignoring: " + Resources(z,1))
Resources(z,2) = False
end if
if Resources(z,2) = True then
icounter = icounter + 1
writelogline("Harvesting: " + Resources(z,1))
end if
next
if icounter = 0 then
ResourcesSelected = False
writelogline("No resources selected to harvest")
else
ResourcesSelected = True
end if
writelogline("*****************************************************")
end sub
'====================================================================================
' G E T I N I E N T R Y
'====================================================================================
Function GetINI(Section, KeyName, Default, FileName)
Dim PosSection, PosKey
Dim KeyValue
Dim FSO, IniTextFile
Dim InSection, KeyFound
Set FSO = CreateObject("Scripting.FileSystemObject")
set IniTextFile = fso.opentextfile(filename, forreading)
InSection = False
KeyFound = False
Do until IniTextFile.atendofstream or keyfound
inicontents = IniTextFile.readline
PosSection = instr(1, inicontents, "[" & Section & "]", vbtextcompare)
If Possection <> 0 then
InSection = True
else
If InSection then
If left(inicontents,1) = "[" then
InSection = False
Else
If instr(1,left(inicontents,len(keyname)),keyname,vbtextcompare) > 0 then
KeyFound = True
PosKey = Instr(1, inicontents, "=", vbtextcompare) + 1
If Poskey > 1 Then
KeyValue = trim(Right(inicontents, Len(inicontents) - Poskey))
else
Keyvalue = ""
End if
End if
end if
end if
End if
Loop
If NOT KeyFound Then
KeyValue = Default
End If
IniTextFile.Close
Set FSO = Nothing
GetINI = KeyValue
End Function
'====================================================================================
' A P P E N D T E X T T O L O G
'====================================================================================
function writeLogLine (msg)
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
'====================================================================================
' C H E C K N O D E I D I N B A D S P A W N A R R A Y
'====================================================================================
function nodeisvalid()
Dim i
nodeisvalid = True
for i = lbound(BadSpawns) to ubound(BadSpawns)
if BadSpawns(i) = spawnid then
nodeisvalid = False
exit for
end if
next
end function
'====================================================================================
' C H E C K D I S T A N C E B E T W E E N 2 P O I N T S < L I M I T
'====================================================================================
function WithinRange(X1,Y1,X2,Y2,MaxDistance)
Dim Distance, DX, DY
DX = (x2-X1) * (X2-X1)
DY = (Y2-Y1) * (Y2-Y1)
Distance = SQR(DX+DY)
If distance > maxdistance then
WithinRange = False
else
WithinRange = True
End If
end function
'====================================================================================
' M o v e T o R a n d o m S p o t O r N e x t W a y p o i n t
'====================================================================================
sub ProcessNoResources()
Dim i, cx, cy, roam
writeLogLine("No Resource in this area.")
XUScriptPlugin.staStatus.Text = "No wanted resources nearby"
sleep 100
If UseWaypoints then
getnewlocation()
cx = CenterX
cy = CenterY
badspawncount = 0
xuscriptplugin.stastatus.text = "Loc " & waypointidx + 1 & ": " & cx & ", " & cy & " Range: " & maxwander
writelogline("Moving to loc " & waypointidx + 1 & ": " & cx & ", " & cy & " Range: " & maxwander)
else
roam = MaxWander / 3
cx = round(getplayerx(EQ2_SvcObj) - roam + random(1,roam*2),1)
cy = round(getplayery(EQ2_SvcObj) - roam + random(1,roam*2),1)
if NOT WithinRange(cx,cy,CenterX,CenterY,MaxWander) then
cx = CenterX
cy = CenterY
badspawncount = 0
end if
xuscriptplugin.stastatus.text = "Loc: " & cx & ", " & cy & " Range: " & maxwander
writelogline("Moving to loc: " & cx & ", " & cy & " Range: " & maxwander)
end if
NavigateXY cx, cy
end sub
'====================================================================================
' A D D N O D E T O B A D S P A W N A R R A Y
'====================================================================================
sub ProcessUnharvestableNode()
Dim cx, cy, roam
BadSpawns(BadSpawnCount) = SpawnID
BadSpawnCount = BadSpawnCount + 1
end sub
'====================================================================================
' F I N D W A N T E D N O D E S I N P R E F E R R E D P R I O R I T Y
'====================================================================================
sub FindResource()
Dim i
spawnid = -1
for i = 0 to 9
if resources(i,2) = True then
ResourceIDX = i
findnode(resources(i,1))
if spawnid > -1 then
exit for
end if
end if
next
if spawnid < 0 then
ProcessNoResources
end if
end sub
'====================================================================================
' L O C A T E N E A R E S T N O D E B Y N A M E
'====================================================================================
sub findnode(node)
xuscriptplugin.stastatus.text = "Looking for: " & node
spawnid = findnearestmob(EQ2_SvcObj, node)
if spawnid > -1 then
do until nodeisvalid() or spawnid < 0
spawnid = findnextnearestmob(EQ2_SvcObj)
loop
rx = getmobx(EQ2_SvcObj,spawnid)
ry = getmoby(EQ2_SvcObj,spawnid)
if NOT WithinRange(rx,ry,CenterX,CenterY,MaxWander) then
spawnid = -1
end if
end if
end sub
'====================================================================================
' M O V E P C T O L O C A T I O N O F N O D E
'====================================================================================
sub GotoResource()
writeLogLine("Moving to " & resources(ResourceIDX,1))
xuscriptplugin.stastatus.text = "Moving to " & resources(ResourceIDX,1)
NavigateXY RX, RY
end sub
'====================================================================================
' H A R V E S T T A R G E T E D N O D E
'====================================================================================
sub HarvestResource()
if (SpawnID > 0) then
XUScriptPlugin.staStatus.Text = "Harvesting... "
writelogline("Harvesting...")
SendKeys(Resources(ResourceIDX,0))
sleep 6000
end if
end sub
'====================================================================================
' S E T W A Y P O I N T I N D E X T O N E X T I N L I S T
'====================================================================================
sub GetNewLocation()
WaypointIDX = WaypointIDX + 1
If WaypointIDX >= WaypointCount then
WaypointIDX = 0
End if
CenterX = waypoints(waypointidx,0)
CenterY = waypoints(waypointidx,1)
MaxWander = waypoints(waypointidx,2)
end sub
'====================================================================================
' L O O K F O R Z O N E I N I N I F I L E
'====================================================================================
Function FindZone(Section, FileName)
Dim PosSection
Dim FSO, TextFile
Dim InSection
Dim IniContents
Set FSO = CreateObject("Scripting.FileSystemObject")
set TextFile = fso.opentextfile(filename, forreading)
InSection = False
Do until TextFile.atendofstream or InSection
inicontents = TextFile.readline
PosSection = instr(1, inicontents, "[" & Section & "]", vbtextcompare)
If Possection <> 0 then
InSection = True
End if
Loop
Findzone = InSection
End Function
'====================================================================================
' C A S T B U F F S
'====================================================================================
sub Castbuffs()
Dim i, j, ElapsedTime
sendkeys("{F1}")
sleep 100
For i = 0 to buffcount - 1
ElapsedTime = datediff("s", buffs(i,5), now) / 60
If ElapsedTime < 0 or ElapsedTime > buffs(i,1) or buffs(i,5) = 0 then
writelogline("Casting: " & buffs(i,0))
xuscriptplugin.stastatus.text = "Casting: " & buffs(i,0)
keydown(virtualkey.vk_shift)
sleep 100
SendKeys(buffs(i,3))
sleep 100
keyup(virtualkey.vk_shift)
sleep 100
sendkeys(buffs(i,4))
sleep 1000 * buffs(i,2)
buffs(i,5) = now
end if
next
keydown(virtualkey.vk_shift)
sleep 100
SendKeys(HotBar)
sleep 100
keyup(virtualkey.vk_shift)
sleep 100
end sub
'====================================================================================
' C H E C K F O R P L A Y E R A T R E S O U R C E
'====================================================================================
function playernearby()
Dim tx, ty, tmpbool
sendkeys("{F1}") 'First target self
sleep 100
sendkeys("{F7}") 'Target nearest PC
sleep 100
targetid = gettargetid(eq2_svcobj)
'if player targeted then check for proximity to resource
if targetid > 0 then
sleep 100
tx = getmobx(eq2_svcobj,targetid)
ty = getmoby(eq2_svcobj,targetid)
tmpbool = withinrange(tx,ty,rx,ry,7)
If tmpbool then
xuscriptplugin.stastatus.text = "PLayer within 7 of resource"
sleep 100
end if
playernearby = tmpbool
else
xuscriptplugin.stastatus.text = "No Player Found"
sleep 100
playernearby = False
end if
end function
'====================================================================================
' P R O C E S S C H A T L O G
'====================================================================================
sub ProcessChatLog()
Dim ChatText
Dim HarvestResults
Dim i, p, l
HarvestResults = Array( _
"You failed to", _
"You mine", _
"You gather", _
"You forest", _
"You acquire", _
"You found", _
"You fish" _
)
Do while EQ2Chatlog.AtEndofStream <> True
ChatText = EQ2ChatLog.Readline
For i = lbound(harvestresults) to ubound(harvestresults)
p = instr(1, chattext, harvestresults(i), vbtextcompare)
If p <> 0 then
l = len(chattext) - p + 1
writelogline(right(chattext, l))
LastHarvestTime = now()
exit for
end if
next
if instr(1, chattext, "SYSTEM MESSAGE", vbtextcompare) <> 0 and instr(1, chattext, "camp out", vbtextcompare) <> 0 then
OKtoContinue = False
writelogline("*****************************************************")
writelogline("*****************************************************")
writelogline("SYSTEM MESSAGE: Zone coming down")
writelogline("*****************************************************")
writelogline("*****************************************************")
xuscriptplugin.stastatus.text = "Zone coming down!"
sleep 5000
end if
if instr(1, chattext, "Your inventory is currently full", vbtextcompare) <> 0 then
OKtoContinue = False
writelogline("*****************************************************")
writelogline("*****************************************************")
writelogline("Your inventory is full! Harvesting stopped.")
writelogline("*****************************************************")
writelogline("*****************************************************")
xuscriptplugin.stastatus.text = "Inventory full: Ending Harvest"
sleep 5000
end if
loop
end sub
'====================================================================================
' G O T O C L O S E S T W A Y P O I N T
'====================================================================================
sub GotoClosestWaypoint()
Dim ClosestWP, ClosestDistance, Distance, DX, DY
ClosestWP = 0
ClosestDistance = 9999
For WaypointIDX = lbound(waypoints) to ubound(waypoints)
CenterX = getplayerx(eq2_svcobj)
Centery = getplayery(eq2_svcobj)
DX = (CenterX - waypoints(waypointidx, 0)) * (CenterX - waypoints(waypointidx, 0))
DY = (Centery - waypoints(waypointidx, 1)) * (Centery - waypoints(waypointidx, 1))
distance = SQR(DX + DY)
If distance < closestdistance then
Closestdistance = distance
Closestwp = waypointidx
end if
next
Waypointidx = ClosestWP
CenterX = Waypoints(waypointidx, 0)
Centery = Waypoints(waypointidx, 1)
MaxWander = Waypoints(waypointidx, 2)
xuscriptplugin.stastatus.text = "Loc " & waypointidx + 1 & ": " & centerx & ", " & centery & " Range: " & maxwander
writelogline("Moving to loc " & waypointidx + 1 & ": " & centerx & ", " & centery & " Range: " & maxwander)
NavigateXY Centerx, Centery
End sub
'====================================================================================
' N A V I G A T I O N R O U T I N E S
'====================================================================================
function RunForward
KeyDown(VirtualKey.VK_W)
Sleep 100
end function
function StopRunning
KeyUp(VirtualKey.VK_W)
end function
function RunBackward(time)
KeyDown(VirtualKey.VK_S)
Sleep time
Keyup(VirtualKey.VK_S)
end function
function TurnLeft(time)
KeyDown(VirtualKey.VK_A)
Sleep time
KeyUp(VirtualKey.VK_A)
end function
function TurnRight(time)
KeyDown(VirtualKey.VK_D)
Sleep time
KeyUp(VirtualKey.VK_D)
end function
function Jump(time)
KeyDown(VirtualKey.VK_SPACE)
Sleep time
KeyUp(VirtualKey.VK_SPACE)
end function
function FindHeading (byval x2, byval y2, byval x1, byval y1)
dim x, y, angle, pi
pi = 3.141592
x = (x1 - x2)
y = (y1 - y2)
if x = 0 then
if y < 0 then
angle = 90
else
angle = -90
end if
else
angle = ((Atn(y/x) / pi) * 180)
if x > 0 then
angle = (angle + 180)
end if
end if
angle = ((360-Int(angle))+90) mod 360
FindHeading = angle
end function
function angleDiff(a, b)
Dim temp
temp = a - b
if temp > 180 then
temp = temp - 360
end if
if temp < -180 then
temp = 360 + temp
end if
angleDiff = temp
end function
function distDiff(a, b)
distDiff = Abs(a - b)
end function
Sub navigateXY(Target_X, Target_Y)
Dim Running, AreWeThereYet
Dim Hdg, NewHdg, HdgDiff
Dim current_x, current_y
Dim old_x, old_y
Dim TurnCount, toggleTurn, turntime
Running = false
Turncount = 0
maxTries = 3
toggleTurn = False
do
Hdg = GetPlayerHeading(EQ2_SVCOBJ)
current_x = GetPlayerX(EQ2_svcobj)
current_y = getplayery(eq2_svcobj)
newhdg = FindHeading(current_x, current_y, target_x, target_y)
Hdgdiff = angleDiff(NewHdg, Hdg)
turntime = abs(hdgdiff) / 10 * 75
If turntime < 20 then
turntime = 20
end if
if Abs(HdgDiff) >= 90 then
if running then
StopRunning
running = false
end if
end if
if Running and withinrange(current_x, current_y, old_x, old_y, .25) then
stoprunning
runbackward(500)
if toggleTurn then
TurnLeft(300)
else
TurnRight(300)
end if
runforward
TurnCount = TurnCount + 1
if TurnCount > 3 then
maxTries = maxTries - 1
toggleTurn = not toggleTurn
Jump(50)
end if
lastmovecheck = now
elseif round(HdgDiff) <= -1 then
turnleft(turntime)
elseif round(HdgDiff) >= 1 then
turnright(turntime)
else
TurnCount = 0
if not running then
RunForward
running = true
end if
end if
AreWeThereYet = withinrange(current_x, current_y, target_x, target_y, 3)
If running and NOT arewethereyet then
Sleep 200
old_x = current_x
old_y = current_y
Else
sleep 10
end if
loop until AreWeThereYet or (TurnCount > 6) or (maxTries < 1)
StopRunning
end sub
|