Ok, I have one that has worked for me thus far...
I added the following variables:
Dim SpawnHarvestCounter, MaxSpawnHarvests
initialized them as follows:
SpawnHarvestCounter = 0
MaxSpawnHarvests = 12 (should be able to lower it to 8 or so with no ill effects)
Changed the Harvesting subroutine to look like this:
Code: Select all
sub HarvestResource()
if (SpawnID > 0) then 'Make sure we still got a target
writeLogLine("Harvesting...")
XUScriptPlugin.staStatus.Text = "Harvesting. . .Attempt " & SpawnHarvestCounter + 1 & " of " & MaxSpawnHarvests
SendKeys(Resources(ResourceIndex)(0))
HarvestCounter = HarvestCounter + 1 'One down!
SpawnHarvestCounter = SpawnHarvestCounter + 1
sleep 5000 + Random(500,1500) 'Wait 5 seconds to harvest + a random delay of .5 to 1.5 seconds
end if
end sub
and changed the end of the big "if" statement in the main script to look like this:
Code: Select all
do while (TargetID = SpawnID)
HarvestResource
TargetID = getTargetID(oServiceObject)
if (SpawnHarvestCounter = MaxSpawnHarvests) then
HandleBadResource
SpawnHarvestCounter = 0
TargetID = 0
end if
loop
SpawnHarvestCounter = 0
I'm not sure if that's the right way to clear out the targetId, but it seems to work.