-
Bill D Cat
- Posts: 555
- Joined: Sat Aug 10, 2013 8:13 pm
- Location: Deep in the Heart of Texas
#1
Post
by Bill D Cat » Mon Dec 23, 2013 12:47 pm
I'm building my waypoint files for Sascilia Steppes and am attempting to gather Ash wood in order to ensure that my gathering skill level for wood is at least level 8 so that I can harvest Willow for a quest. I'm using a function in my onload section to locate and harvest the Ash only until I get the gathering skill to level 8, then it switches to gathering the Willow. My problem is, occasionally the bot will decide that there is no nearby Ash to gather when the node is exhausted and try to attack it!?! This usually ends up resulting in the bot becoming totally locked up and unresponsive. Any ideas why it tries to use combat skills on gathering nodes?
Code: Select all
function getWood()
local _isMounted = player.Mounted
woodSkill = player:getCraftLevel(CRAFT_WOODCUTTING)
if 8 > woodSkill then
repeat
ash = player:findNearestNameOrId(560018) -- Ash Wood
if ash and 250 > distance(ash, player) then
player:moveTo(CWaypoint(ash.X, ash.Z), true)
player:harvest(560018)
end
until ash == nil
else
repeat
willow = player:findNearestNameOrId(560019) -- Willow Wood
if willow and 250 > distance(willow, player) then
player:moveTo(CWaypoint(willow.X, willow.Z), true)
player:harvest(560019)
end
until willow == nil
end
if _isMounted then player:mount() end
end
-
Attachments
-
Last edited by
Bill D Cat on Tue Dec 24, 2013 1:26 pm, edited 1 time in total.
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#2
Post
by rock5 » Mon Dec 23, 2013 1:55 pm
It looks like it is trying to caste Forge between harvests.
I don't understand the problem. Instead of saying what the bot "decides" try describing exactly what happens. Is it failing to cast forge? Is casting Forge interrupting the harvest? Is forge a self cast or friendly cast skill?
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:
- “They say hard work never hurt anybody, but I figure, why take the chance.”
-
Bill D Cat
- Posts: 555
- Joined: Sat Aug 10, 2013 8:13 pm
- Location: Deep in the Heart of Texas
#3
Post
by Bill D Cat » Mon Dec 23, 2013 6:32 pm
Forge is a Champion's self buff. I was harvesting a node, collected two pieces of wood from it and it started fading. At that point the bot started to cast Forge while the node was still targeted. Then for some reason it just locked up and stopped responding. Pressing END would not pause the bot, though I could abort the script with CTRL-L or kill MM completely with CTRL-C still. No matter what I tried, the script would not resume execution, so I ended up aborting it and manually restarting it at the current waypoint.
I was just confused because of the way the log shows that the bot has found Ash Wood on one line, and on the next there is no harvestables found. Then it tries to cast Forge while targeting the Ash. Then the cycle repeats until the bot locks up.
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#4
Post
by rock5 » Mon Dec 23, 2013 9:26 pm
I'm assuming it's getting stuck in a loop somewhere but I'm having trouble figuring out where. It looks like it exits the harvest function so i don't think that is it. I've looked at your function carefully and I can't see how it could get stuck in that. You could double check that it's not your function by putting a print message in each repeat loop. If when it gets stuck it prints the message again and again then you know it's stuck there.
Is it possible it's getting stuck in some other part of the code?
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:
- “They say hard work never hurt anybody, but I figure, why take the chance.”
-
lisa
- Posts: 8332
- Joined: Tue Nov 09, 2010 11:46 pm
- Location: Australia
#5
Post
by lisa » Mon Dec 23, 2013 11:23 pm
I dunno I think it is kind of obvious.
Code: Select all
repeat
ash = player:findNearestNameOrId(560018) -- Ash Wood
if ash and 250 > distance(ash, player) then
player:moveTo(CWaypoint(ash.X, ash.Z), true)
player:harvest(560018)
end
until ash == nil
if it finds ash and it is within 250 to the ash then it will move to it and harvest it, what if it finds ash but ash is more than 250 away? it will just keep repeating the loop for ever and ever and ever. From memory the distance to objects in memory is 450, so a node 251-450 distance that is the closest to you of that type will infact put u in a never ending loop.
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#6
Post
by rock5 » Mon Dec 23, 2013 11:34 pm
Or it could be something really obvious.
I must be half asleep.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:
- “They say hard work never hurt anybody, but I figure, why take the chance.”
-
Bill D Cat
- Posts: 555
- Joined: Sat Aug 10, 2013 8:13 pm
- Location: Deep in the Heart of Texas
#7
Post
by Bill D Cat » Tue Dec 24, 2013 1:56 am
Thanks, I didn't realize the distance was quite that large. I've refined my function and it seems to be working fine now.
Code: Select all
function getWood()
player:update()
local _isMounted = player.Mounted
local woodSkill = player:getCraftLevel(CRAFT_WOODCUTTING)
local woodType = 560018 -- Ash Wood
if woodSkill > 8 then
woodType = 560019 -- Willow Wood
end
local wood = player:findNearestNameOrId(woodType)
if wood and 250 > distance(wood, player) then
player:moveTo(CWaypoint(wood.X, wood.Z), true)
player:harvest(woodType)
end
if _isMounted then player:mount() end
end
-
lisa
- Posts: 8332
- Joined: Tue Nov 09, 2010 11:46 pm
- Location: Australia
#8
Post
by lisa » Tue Dec 24, 2013 3:32 am
yeah I did some testing on it a long time ago (when I first started on GM detect), the memory distance for objects is roughly 450, Could write up a quite function to work it out easy enough. Just do through all objects and distance to object and "save" the largest distance and then print it. Run that a few times as you move around and you will get a good idea of memory max distance.
Code: Select all
function getmaxdistance(ID)
local biggestdist = 0
local biggestname = "NFI"
local objectList = CObjectList();
objectList:update();
local objSize = objectList:size()
for i = 0,objSize do
local obj = objectList:getObject(i);
if obj then
player:update()
local distt = distance(player.X,player.Z,obj.X,obj.Z)
if ID then
if obj.Id == ID and obj.X ~= 0 and distt > biggestdist then
biggestdist = distt
biggestname = obj.Name
end
else
if obj.X ~= 0 and distt > biggestdist then
biggestdist = distt
biggestname = obj.Name
end
end
end
end
print(biggestname.." : "..biggestdist)
end
very crude.
Code: Select all
Command> for i = 1,20 do getmaxdistance(560036) yrest(2000) end
Beetroot : 126.74964950122
Beetroot : 126.74964950122
Beetroot : 140.39763726016
Beetroot : 150.77740117873
Beetroot : 536.30074154124
Beetroot : 523.25221161962
Beetroot : 539.25868311131
Beetroot : 574.18289609459
Beetroot : 160.87849571858
Beetroot : 161.48928071738
Beetroot : 165.42705646769
Beetroot : 155.30046021061
Beetroot : 561.8466712678
Beetroot : 559.55259717484
Beetroot : 564.04493358956
Beetroot : 572.09828077326
Beetroot : 165.89135288464
Beetroot : 162.32728266977
Beetroot : 568.60617156103
Beetroot : 576.88728617999
so can get close to 600 distance for nodes, other objects were weird though.
Code: Select all
Flying Ship : 3874.2133801221
Tador's Stone Tablet : 12441.011306651
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#9
Post
by rock5 » Tue Dec 24, 2013 4:23 am
You know you could abbreviate this
Code: Select all
local wood = player:findNearestNameOrId(woodType)
if wood and 250 > distance(wood, player) then
player:moveTo(CWaypoint(wood.X, wood.Z), true)
player:harvest(woodType)
end
to
Code: Select all
settings.profile.options.HARVEST_DISTANCE=250
player:harvest(woodType)
Or you could put HARVEST_DISTANCE in your profile.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:
- “They say hard work never hurt anybody, but I figure, why take the chance.”
-
Bill D Cat
- Posts: 555
- Joined: Sat Aug 10, 2013 8:13 pm
- Location: Deep in the Heart of Texas
#10
Post
by Bill D Cat » Tue Dec 24, 2013 1:21 pm
What does the _second_try option do? It's referenced only in the function arguments, but nowhere else in the function itself. I was hoping it would be a true/false type argument to retry the harvest if it fails. Typically this happens when you reach a new gathering plateau and begin harvesting the next level of materials.
/classes/player.lua line 380:
Code: Select all
function CPlayer:harvest(_id, _second_try)
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#11
Post
by rock5 » Tue Dec 24, 2013 7:53 pm
Um... I think it does nothing. The variable isn't used anywhere. It probably did at some stage.
But I believe the harvest function is set up to recover from interruptions such as being attacked. I'm not sure it's set to recover when it just fails with no interruption. I guess that's why you had the repeat loop earlier. I thought that was a really rare occurrence in later leveling. I guess it would be an issue if you are botting new character harvest skills.
If you try adding the repeat loop again maybe this time add a pause to give the node time to fade so it doesn't try to harvest a fading node. I could probably add a 'fading' check.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:
- “They say hard work never hurt anybody, but I figure, why take the chance.”
-
Bill D Cat
- Posts: 555
- Joined: Sat Aug 10, 2013 8:13 pm
- Location: Deep in the Heart of Texas
#12
Post
by Bill D Cat » Wed Dec 25, 2013 12:07 pm
I was using the repeat loop in case the gathering failed on its own, and to automatically harvest other nearby nodes without needing to call the function again for each node. I've put the repeat loop back, and have other sanity checks now to exit the loop properly when all nearby nodes have been gathered.
-
Marlb0ro
- Posts: 51
- Joined: Sat Aug 13, 2011 2:52 am
- Location: Netherlands
#13
Post
by Marlb0ro » Fri Dec 27, 2013 1:49 pm
Harvesting something on a steep slope may cause your character to slide down a cm. or two when it reached the node, causing the first harvest to fail cause of movement. It always tries a second time before giving up and moving on with the waypoint. That's my thoughts about second_try anyway.
-
Bill D Cat
- Posts: 555
- Joined: Sat Aug 10, 2013 8:13 pm
- Location: Deep in the Heart of Texas
#14
Post
by Bill D Cat » Fri Dec 27, 2013 8:34 pm
I've noticed that as well. I try to put a yrest() between the movement and the gather command. Most of the time it fails for me is when I have reached a level where I can gather a new material. The failure rate isn't too bad but it does happen enough that I have to add extra code to catch it when it happens.
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#15
Post
by rock5 » Fri Dec 27, 2013 10:46 pm
You could also use the wall hack to reduce sliding.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:
- “They say hard work never hurt anybody, but I figure, why take the chance.”
Who is online
Users browsing this forum: Bing [Bot] and 9 guests