help with waiting for items to appear before clicking it
Posted: Thu Dec 05, 2013 12:56 pm
I was wondering if someone could tell me if there's a simpler way to do this? I have an area where I need to wait for an item to appear and then I can click on it. I need to do this several times before turning in the quest. Initially I would just have the bot run between the 2 or 3 areas where the item appears and do a rest for a certain amount of time before trying to click it to ensure enough time goes by for it to appear. The problems with this would be that if someone else were there, that would completely mess up the bot and the waypoints.
So to fix this issue I thought about having the bot wait in one spot between two of the locations where the item appears, and once an item appears, i clcik it (gather it) then go back to my waiting spot. I keep doing this until the quest is complete.
Another problem I'm faced with is that if I pick the first 2 and they are not available, it will see a third one and if it goes to pick it and the quest is complete, it will try to run through an obstacle and look too much like a bot. With that, I want to put a distance limit on the objects I'm watching for. and only click the ones that are within 200 units (Feet?) from me.
Here's the code I came up with:
I'm about 80% sure there's a much more efficient way to do this same thing but I can't figure out what it is. Can anyone provide some thoughts? Thanks.
So to fix this issue I thought about having the bot wait in one spot between two of the locations where the item appears, and once an item appears, i clcik it (gather it) then go back to my waiting spot. I keep doing this until the quest is complete.
Another problem I'm faced with is that if I pick the first 2 and they are not available, it will see a third one and if it goes to pick it and the quest is complete, it will try to run through an obstacle and look too much like a bot. With that, I want to put a distance limit on the objects I'm watching for. and only click the ones that are within 200 units (Feet?) from me.
Here's the code I came up with:
Code: Select all
<!-- # 9 --><waypoint x="11111" z="2222" y="33" tag="finditem">
local myitem = player:findNearestNameOrId(123456)
if not myitem then -- if it doesn't find one at all, then wait for one
repeat
yrest(500)
local myitem = player:findNearestNameOrId(118052)
until 200 > distance(player.X, player.Z, myitem.X, myitem.Z) -- resting until there's one within range
player:target_Object(myitem)
mycheckQuest(987654) -- my custom function to check my quest status and return the done variable
if done == "true" then
__WPL:setWaypointIndex(__WPL:findWaypointTag("continue")) --quest done, continue to turn in quest
end
else -- this is run if it did find one
if distance(player.X, player.Z, myitem.X, myitem.Z) > 200 then -- if not within range:
repeat
yrest(500)
local myitem = player:findNearestNameOrId(118052)
until 200 > distance(player.X, player.Z, myitem.X, myitem.Z) -- wait for one in range
player:target_Object(myitem)
mycheckQuest(987654) -- check quest
if done == "true" then
__WPL:setWaypointIndex(__WPL:findWaypointTag("continue")) --quest done, continue to turn in quest
end
else -- if it is in range:
player:target_Object(myitem)
mycheckQuest(987654) -- check quest
if done == "true" then
__WPL:setWaypointIndex(__WPL:findWaypointTag("continue")) --quest done, continue to turn in quest
end
end
end
__WPL:setWaypointIndex(__WPL:findWaypointTag("finditem")) -- at this point it gathered an item but quest isn't done so return to spot to wait for another
</waypoint>