Problem while harvesting.
-
- Posts: 8
- Joined: Wed Jul 07, 2010 1:42 am
Problem while harvesting.
Hallo
I use this bot now for something about 1 year. At the beginning for harvesting ... later only for collecting daily-stuff.
Now after the new patch I want to harvest again and noticed a problem. In the profile I set my "level above" and "level below" to -1. So the bot will only attack aggressive mobs. Works fine. The problem is the moment the bot collect the herbs und a mob becomes aggressive. The bot stops harvesting and kills the mob. After killing he goes to the NEXT waypoint instead of start again harvesting. That way I miss nearly 1/3 of the stuff.
First I thought ... no problem ... I take it next round. But if the round is long enough, the mob respawns and ... hm ... you can imagine...
Is there any way to restart collecting after killing the mob?
Thx
I use this bot now for something about 1 year. At the beginning for harvesting ... later only for collecting daily-stuff.
Now after the new patch I want to harvest again and noticed a problem. In the profile I set my "level above" and "level below" to -1. So the bot will only attack aggressive mobs. Works fine. The problem is the moment the bot collect the herbs und a mob becomes aggressive. The bot stops harvesting and kills the mob. After killing he goes to the NEXT waypoint instead of start again harvesting. That way I miss nearly 1/3 of the stuff.
First I thought ... no problem ... I take it next round. But if the round is long enough, the mob respawns and ... hm ... you can imagine...
Is there any way to restart collecting after killing the mob?
Thx
- Administrator
- Site Admin
- Posts: 5330
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Problem while harvesting.
Yeah, this was something I had forgot to do when rewriting the new harvesting system. I'll be fixed.
-
- Posts: 8
- Joined: Wed Jul 07, 2010 1:42 am
Re: Problem while harvesting.
Thank you.
I really love this new harvesting system.
I really love this new harvesting system.
- Administrator
- Site Admin
- Posts: 5330
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Problem while harvesting.
Can you test the change for me? Open classes/player.lua in notepad, and find this line:
Should be around line 137 (CTRL+G).
Change it to this:
Save it. It *should* now fight all aggressive enemies then return to harvesting.
Code: Select all
lastHarvestedNodeAddr = closestHarvestable.Address;
Change it to this:
Code: Select all
self:update();
if( not self.Battling ) then
lastHarvestedNodeAddr = closestHarvestable.Address;
else
while( self.Battling ) do
self:target(self:findEnemy(true, nil, evalTargetDefault, self.IgnoreTarget));
self:update();
if( self:haveTarget() ) then
self:fight();
end
end
end
-
- Posts: 8
- Joined: Wed Jul 07, 2010 1:42 am
Re: Problem while harvesting.
dont seems to work. I tried 5 times.
on 2 of them the mob attacked .. the bot shortly started harvesting ... got interrupted ... killed the mob ... and went on to the next waypoint.
the other 3 tries ... the bot started harvesting ... mob got closer and attacked ... the bot killed the mob ... and went on to the next waypoint.
maybe Im to stupid to copy-paste
... here is the part in my player.lua I changed...
Anyway ... thanks for your fast response.
on 2 of them the mob attacked .. the bot shortly started harvesting ... got interrupted ... killed the mob ... and went on to the next waypoint.
the other 3 tries ... the bot started harvesting ... mob got closer and attacked ... the bot killed the mob ... and went on to the next waypoint.
maybe Im to stupid to copy-paste

Code: Select all
function CPlayer:harvest(_id, _second_try)
local function findNearestHarvestable(_id, ignore)
ignore = ignore or 0;
local closestHarvestable = nil;
local obj = nil;
local objectList = CObjectList();
objectList:update();
for i = 0,objectList:size() do
obj = objectList:getObject(i);
if( obj ~= nil ) then
if( obj.Type == PT_NODE and obj.Address ~= ignore and (_id == obj.Id or (not _id and database.nodes[obj.Id])) ) then
local dist = distance(self.X, self.Z, obj.X, obj.Z);
if( closestHarvestable == nil ) then
if( distance(self.X, self.Z, obj.X, obj.Z ) < settings.profile.options.HARVEST_DISTANCE ) then
closestHarvestable = obj;
end
else
if( distance(self.X, self.Z, obj.X, obj.Z) <
distance(self.X, self.Z, closestHarvestable.X, closestHarvestable.Z) ) then
-- this node is closer
closestHarvestable = obj;
end
end
end
end
end
return closestHarvestable;
end
local function nodeStillFound(node)
local closestHarvestable = nil;
local obj = nil;
local objectList = CObjectList();
objectList:update();
for i = 0,objectList:size() do
obj = objectList:getObject(i);
if( obj.Address == node.Address ) then
return true;
end
end
return false;
end
yrest(200); -- Make sure we come to a stop before attempting to harvest.
local lastHarvestedNodeAddr = nil;
while(true) do
self:update();
closestHarvestable = findNearestHarvestable(_id, lastHarvestedNodeAddr);
if( closestHarvestable == nil ) then
printf(language[79]);
return;
end
cprintf(cli.yellow, language[95], closestHarvestable.Name);
if( distance(self.X, self.Z, closestHarvestable.X, closestHarvestable.Z) > 80 ) then
self:moveTo(CWaypoint(closestHarvestable.X, closestHarvestable.Z), true);
end
memoryWriteInt(getProc(), self.Address + addresses.pawnTargetPtr_offset, closestHarvestable.Address);
RoMScript("UseSkill(1,1)");
if _id and not database.nodes[closestHarvestable.Id] then -- The rest is not needed if not resource node
return true
end
self:update();
local timeStart = getTime();
while( not self.Harvesting ) do
-- Wait to start harvesting
yrest(100);
self:update();
if( self.Battling ) then
printf(language[78]);
return;
end
if( deltaTime(getTime(), timeStart) > 3000 ) then
-- Maybe the command didn't go through. Try once more.
RoMScript("UseSkill(1,1)");
yrest(500);
break;
end
end
self:update();
timeStart = getTime();
while( self.Harvesting ) do
yrest(100);
self:update();
if( self.Battling ) then
printf(language[78]);
return;
end
if( not nodeStillFound(closestHarvestable) or self.TargetPtr ~= closestHarvestable.Address ) then
break;
end
if( deltaTime(getTime(), timeStart) > 45000 ) then
-- Taking too long. Drop out.
printf("Stop harvesting. Taking too long.\n");
break;
end
end
self:update();
if( not self.Battling ) then
lastHarvestedNodeAddr = closestHarvestable.Address;
else
while( self.Battling ) do
self:target(self:findEnemy(true, nil, evalTargetDefault, self.IgnoreTarget));
self:update();
if( self:haveTarget() ) then
self:fight();
end
end
end
end
end
- Administrator
- Site Admin
- Posts: 5330
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Problem while harvesting.
Ok, at around line 122, you'll see this:
Change the return line like so:
Now does it work?
Code: Select all
if( self.Battling ) then
printf(language[78]);
return;
end
Code: Select all
if( self.Battling ) then
printf(language[78]);
--return;
end
-
- Posts: 8
- Joined: Wed Jul 07, 2010 1:42 am
Re: Problem while harvesting.
didnt work.
this part you can find twice in player.lua
I tried 3 times ... changed first part ... changed second part ... changed both parts ... each change with one test ... all with the same result:
... the bot started harvesting ... mob came closer and attacked ... the bot got interrupted ... and didnt react...
the bot not targeted the mob ... the bot not attacked the mob ... the bot not started harvesting again ... just stand at the waypoint and took damage ... I waited for one minute ... thats it ...
here again the part of the player.lua I changed:
this part you can find twice in player.lua
Code: Select all
if( self.Battling ) then
printf(language[78]);
--return;
... the bot started harvesting ... mob came closer and attacked ... the bot got interrupted ... and didnt react...
the bot not targeted the mob ... the bot not attacked the mob ... the bot not started harvesting again ... just stand at the waypoint and took damage ... I waited for one minute ... thats it ...
here again the part of the player.lua I changed:
Code: Select all
while( not self.Harvesting ) do
-- Wait to start harvesting
yrest(100);
self:update();
if( self.Battling ) then
printf(language[78]);
--return;
end
if( deltaTime(getTime(), timeStart) > 3000 ) then
-- Maybe the command didn't go through. Try once more.
RoMScript("UseSkill(1,1)");
yrest(500);
break;
end
end
self:update();
timeStart = getTime();
while( self.Harvesting ) do
yrest(100);
self:update();
if( self.Battling ) then
printf(language[78]);
--return;
end
if( not nodeStillFound(closestHarvestable) or self.TargetPtr ~= closestHarvestable.Address ) then
break;
end
if( deltaTime(getTime(), timeStart) > 45000 ) then
-- Taking too long. Drop out.
printf("Stop harvesting. Taking too long.\n");
break;
end
end
Re: Problem while harvesting.
Will something like this work with player:target_Object()?Administrator wrote:Can you test the change for me? Open classes/player.lua in notepad, and find this line:Should be around line 137 (CTRL+G).Code: Select all
lastHarvestedNodeAddr = closestHarvestable.Address;
Change it to this:Save it. It *should* now fight all aggressive enemies then return to harvesting.Code: Select all
self:update(); if( not self.Battling ) then lastHarvestedNodeAddr = closestHarvestable.Address; else while( self.Battling ) do self:target(self:findEnemy(true, nil, evalTargetDefault, self.IgnoreTarget)); self:update(); if( self:haveTarget() ) then self:fight(); end end end
- 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.”
- Ronald Reagan
- Administrator
- Site Admin
- Posts: 5330
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Problem while harvesting.
I'm not sure what you're asking.rock5 wrote: Will something like this work with player:target_Object()?
Re: Problem while harvesting.
player:target_Object() needs to check for aggro too while collecting or it can get stuck trying to collect something but always getting interrupted by an aggressive mob. Don't worry I'm looking into it. I'm trying to design it so it will still harvest the item after it's killed the mob.Administrator wrote:I'm not sure what you're asking.rock5 wrote: Will something like this work with player:target_Object()?
- 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.”
- Ronald Reagan
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
Re: Problem while harvesting.
Too many posts, please delete this one.
Last edited by MiesterMan on Sun Aug 22, 2010 12:24 pm, edited 2 times in total.
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
Re: Problem while harvesting.
Too many posts, please delete this one.
Last edited by MiesterMan on Sun Aug 22, 2010 1:12 pm, edited 4 times in total.
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
Re: Problem while harvesting.
The edited code below includes:
- Fix for canceling harvesting from battle thus skipping node
- Fix for failing to harvest because character is still moving thus skipping node
- Fix for canceling harvesting from buffing while harvesting thus skipping node
CPlayer:cast(skill) before "-- Wait for casting to start (if it has a decent cast time)"
CPlayer:harvest from line 74 to the end of the function.
Edit: Tested final cut, working as intended.
New problem found. The harvest function will actually attempt to harvest all nearby harvestables but once the first node is down and it goes to the next it seems to have the same issue about character moving after harvesting starts. I will look into it.
More edited: After some thought using waypoints isn't the best option, saving a pointer and adding an additional condition to revisit the node after combat would be better. This way "hunting" nodes might be viable later on.
- Fix for canceling harvesting from battle thus skipping node
- Fix for failing to harvest because character is still moving thus skipping node
- Fix for canceling harvesting from buffing while harvesting thus skipping node
CPlayer:cast(skill) before "-- Wait for casting to start (if it has a decent cast time)"
Code: Select all
-- Check if harvesting and correct waypoint
if self.Harvesting then
if __WPL.Direction == 1 then __WPL:setWaypointIndex(__WPL.CurrentWaypoint - 1) end;
if __WPL.Direction == 2 then __WPL:setWaypointIndex(__WPL.CurrentWaypoint + 1) end;
end
CPlayer:harvest from line 74 to the end of the function.
Code: Select all
-- Make sure we come to a stop before attempting to harvest.
repeat
self:update();
local curX = self.X;
local curY = self.Y;
local curZ = self.Z;
yrest(200);
until curX == self.X and curY == self.Y and curZ == self.Z
local lastHarvestedNodeAddr = nil;
while(true) do
self:update();
closestHarvestable = findNearestHarvestable(_id, lastHarvestedNodeAddr);
if( closestHarvestable == nil ) then
printf(language[79]);
return;
end
cprintf(cli.yellow, language[95], closestHarvestable.Name);
if( distance(self.X, self.Z, closestHarvestable.X, closestHarvestable.Z) > 80 ) then
self:moveTo(CWaypoint(closestHarvestable.X, closestHarvestable.Z), true);
end
memoryWriteInt(getProc(), self.Address + addresses.pawnTargetPtr_offset, closestHarvestable.Address);
RoMScript("UseSkill(1,1)");
if _id and not database.nodes[closestHarvestable.Id] then -- The rest is not needed if not resource node
return true
end
self:update();
local timeStart = getTime();
-- Set repeat waypoint waypoint
local reWapt = 1;
if __WPL.Direction == 1 then reWapt = __WPL.CurrentWaypoint - 1 end;
if __WPL.Direction == 2 then reWapt = __WPL.CurrentWaypoint + 1 end;
while( not self.Harvesting ) do
-- Wait to start harvesting
yrest(100);
self:update();
if( self.Battling ) then
printf(language[78]);
__WPL:setWaypointIndex(reWapt);
return;
end
if( deltaTime(getTime(), timeStart) > 3000 ) then
-- Maybe the command didn't go through. Try once more.
RoMScript("UseSkill(1,1)");
yrest(500);
break;
end
end
self:update();
timeStart = getTime();
while( self.Harvesting ) do
yrest(100);
self:update();
if( self.Battling ) then
printf(language[78]);
__WPL:setWaypointIndex(reWapt);
return;
end
if( not nodeStillFound(closestHarvestable) or self.TargetPtr ~= closestHarvestable.Address ) then
break;
end
if( deltaTime(getTime(), timeStart) > 45000 ) then
-- Taking too long. Drop out.
printf("Stop harvesting. Taking too long.\n");
break;
end
end
lastHarvestedNodeAddr = closestHarvestable.Address;
end
New problem found. The harvest function will actually attempt to harvest all nearby harvestables but once the first node is down and it goes to the next it seems to have the same issue about character moving after harvesting starts. I will look into it.
More edited: After some thought using waypoints isn't the best option, saving a pointer and adding an additional condition to revisit the node after combat would be better. This way "hunting" nodes might be viable later on.
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
Who is online
Users browsing this forum: Google [Bot] and 0 guests