Page 2 of 3

Re: Finding and looting dead bodies

Posted: Thu Oct 28, 2010 11:40 pm
by miximixi007
I changed player.lua :

Code: Select all

function CPlayer:findNearestNameOrId(_objnameorid, ignore)
	ignore = ignore or 0;
	local closestObject = 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 or obj.Type == PT_MONSTER) and obj.Address ~= ignore and (obj.Id == _objnameorid or string.find(obj.Name, _objnameorid) )) then  --**************
				local dist = distance(self.X, self.Z, obj.X, obj.Z);
				if( closestObject == nil ) then
					if( distance(self.X, self.Z, obj.X, obj.Z ) < settings.profile.options.HARVEST_DISTANCE ) then
						closestObject = obj;
					end
				else
					if( distance(self.X, self.Z, obj.X, obj.Z) <
						distance(self.X, self.Z, closestObject.X, closestObject.Z) ) then
						-- this node is closer
						closestObject = obj;
					end
				end
			end
		end
	end

   return closestObject;
end

function CPlayer:target_Object(_objname, _waittime, _harvestall, _donotignore)
	_waittime = _waittime or 0
	_harvestall = (_harvestall == true)
	_donotignore = (_donotignore == true)
	if( not _objname ) then
		cprintf(cli.yellow, language[181]);	-- Please give an Object name
		return
	end
	
	yrest(200); -- Make sure we come to a stop before attempting to harvest.
	local lastHarvestedNodeAddr = nil;
	local objFound = false;

	while(true) do
		obj = self:findNearestNameOrId(_objname, lastHarvestedNodeAddr)
		if obj then -- object found, target
			cprintf(cli.yellow, language[95], obj.Name);
			objFound = true
			memoryWriteInt(getProc(), self.Address + addresses.pawnTargetPtr_offset, obj.Address);
			yrest(100)

                        if obj.Type == PT_MONSTER then        --**************************
                        	local tmpTargetHP = memoryReadIntPtr(getProc(), self.Address + addresses.pawnTargetPtr_offset, addresses.pawnHP_offset);
                        	--printf(""..tmpTargetHP.."")
                        	if tmpTargetHP~=0 then
                              		printf("Found target,break loot and fight")                              		self:fight()
                                end
			end                                  --*************************


  			RoMScript("UseSkill(1,1)"); yrest(50); RoMScript("UseSkill(1,1)"); -- 'click' again to be sure
			yrest(_waittime);
		end

		if obj and _harvestall == true then -- harvest again
			if _donotignore ~= true then
				lastHarvestedNodeAddr = obj.Address -- Default ignore this address in next search
			end
		else -- No more harvesting
			if objFound == false then
				printf(language[79]); -- No harvestables found
			end
			
			return objFound
		end
	end
end


profiles file:

Code: Select all

	<onLeaveCombat>

               player:target_Object(""..target_Name.."",2000,true);--you need del the "local" in player.lua
               player:target_Object("Sick Ent",2000,true);	
               player:target_Object("monsterName2",2000,true);
              player:target_Object("monsterName3",2000,true);
</onLeaveCombat>

Re: Finding and looting dead bodies

Posted: Thu Oct 28, 2010 11:59 pm
by rock5
checkii wrote:
WhiteTiger wrote:instead of looting the nearby corpses, it targeted a new mob and started attack him (it was after I had left combat). then when he was dead the bot returned and looted the mob.
I had another post describing this situation however the bot doesn't always loot the mobs. So you loot some of the time, but not always.

The reason I ask if you use AOE was because the problem i experience, specifically applies to AOE spells/skill where your bot will sometimes skip lootable bodies and move on to the next target. As of right now I still don't have a solution to that. My current fix is to just stay with single target spells. It seems lootbodies() will always (for the most part) loot if your bot uses single target spells.

Ofcourse its not very ideal, since AoE is faster. If anyone has figure out a way for loot to work with AOE, please share :)
I believe it has something to do with where i stick lootbodies(), which may be as simple as putting a delay. I don't mind redundancy, any workable solution will be appreciated.
I'm not sure how anyone can help you if we don't know how your attack sequence works.

Re: Finding and looting dead bodies

Posted: Fri Oct 29, 2010 12:58 am
by checkii
Can we commit the above changes to the script? See how it works out?

The attack sequence I am using is mage purgatory fire range 50 (I edited skill.xml to reflect the 50 range).

To make the skill cast faster, onskillcast I would tell it to cast purgatory again. Although without onskillcast the bot still has same looting pattern (of missing loot sometimes).

I can take a wild guess that when I cast purgatory I may kill mobs that were not on my aggro list because they died too fast. Or they are on their way to me while I was in combat, but died before reaching me because of AE. Basically the bot did not pick up multiple aggro and therefore ignores the loot. This is also why single target spells do not have loot issues as the bot picked up each individual aggro, and thereby looting them individually.

On a side note, not sure if this is relevant. It seems that every time I overran a waypoint, looting will be ignored and he continues on his way. I dont know if that takes priority over looting.

i would love to have a script that loots indiscriminately even if the loot belongs to someone else. Though in this case, I did kill it.

Re: Finding and looting dead bodies

Posted: Fri Oct 29, 2010 6:45 am
by WhiteTiger
Holy shit, got mine to work now! Put a player:update(); before or inside the lootBodies()

Re: Finding and looting dead bodies

Posted: Fri Oct 29, 2010 6:53 pm
by rock5
checkii wrote:Can we commit the above changes to the script? See how it works out?

The attack sequence I am using is mage purgatory fire range 50 (I edited skill.xml to reflect the 50 range).

To make the skill cast faster, onskillcast I would tell it to cast purgatory again. Although without onskillcast the bot still has same looting pattern (of missing loot sometimes).

I can take a wild guess that when I cast purgatory I may kill mobs that were not on my aggro list because they died too fast. Or they are on their way to me while I was in combat, but died before reaching me because of AE. Basically the bot did not pick up multiple aggro and therefore ignores the loot. This is also why single target spells do not have loot issues as the bot picked up each individual aggro, and thereby looting them individually.

On a side note, not sure if this is relevant. It seems that every time I overran a waypoint, looting will be ignored and he continues on his way. I dont know if that takes priority over looting.

i would love to have a script that loots indiscriminately even if the loot belongs to someone else. Though in this case, I did kill it.
Which code are you talking about? The one from miximixi007? He doesn't say what it's supposed to do, what he's changed and it looks like he based it on an older version of rombot.

My lootBodies function doesn't rely on 'if it has aggro'ed you or not' so that shouldn't be a problem.

Have you tried WhiteTigers idea of adding a 'player:update()'?

Re: Finding and looting dead bodies

Posted: Fri Oct 29, 2010 7:02 pm
by WhiteTiger
Hmm, is there any way I can make the bot loot faster? e.g. make so he doesn't have to wait for the corpse to disapear before moving to the next?

Re: Finding and looting dead bodies

Posted: Fri Oct 29, 2010 8:31 pm
by rock5
WhiteTiger wrote:Hmm, is there any way I can make the bot loot faster? e.g. make so he doesn't have to wait for the corpse to disapear before moving to the next?
It doesn't wait for the corpse to disappear. The time it waits is a calculated time. I guess we could speed it up a tiny bit by having it stop waiting once the body is no longer lootable. I'll look into it.

Edit: changed revision 515 to stop waiting when the body is no longer lootable. Saves a tiny amount of time. :)

Re: Finding and looting dead bodies

Posted: Sat Oct 30, 2010 12:31 am
by miximixi007
rock5 wrote:Which code are you talking about? The one from miximixi007? He doesn't say what it's supposed to do, what he's changed and it looks like he based it on an older version of rombot.
I set to loot after combat every time.it will find near all object of you want:player:target_Object("monsterName",2000,true);
if u dont set any monster name,it`ll loot the monsterName with u just kill.you can use like:player:target_Object(""..target_Name.."",2000,true);but you need change "locan target_Name" to "target_Nmae" in player.lua

if( (obj.Type == PT_NODE or obj.Type == PT_MONSTER) and obj.Address ~= ignore and (obj.Id == _objnameorid or string.find(obj.Name, _objnameorid) )) then --here is add the type of monster



local occupiedSlots, totalSlots = sendMacro("GetBagCount()") --if bag is full
if occupiedSlots>=60 then --maybe occupiedSlots==totalSlots is better
return false
end;
if obj.Type == PT_MONSTER then
local tmpTargetHP = memoryReadIntPtr(getProc(), self.Address + addresses.pawnTargetPtr_offset, addresses.pawnHP_offset);
--printf(""..tmpTargetHP.."")
if tmpTargetHP~=0 then
printf("Found target,break loot and fight")
self:fight() --if the monster is live then fight when u wanna loot it.
end
end


I've tried many times,It run well.look for better way.

Re: Finding and looting dead bodies

Posted: Sat Oct 30, 2010 5:26 pm
by checkii
I tried player update, it works wonderfully as far as I can tell.

I ran few hours of testing and with player:update() in front of lootbodies() it seems to be able to loot everything in front of the bot. Especially useful during AoE attacks.

Everything is awesome fine now.

Re: Finding and looting dead bodies

Posted: Sat Oct 30, 2010 7:26 pm
by WhiteTiger
It doesn't wait for the corpse to disappear. The time it waits is a calculated time. I guess we could speed it up a tiny bit by having it stop waiting once the body is no longer lootable. I'll look into it.

Edit: changed revision 515 to stop waiting when the body is no longer lootable. Saves a tiny amount of time.
fucking awesome work man, youre one of the reasons why I still play RoM lol

Re: Finding and looting dead bodies

Posted: Tue Nov 02, 2010 5:52 am
by miximixi007
checkii wrote:To make the skill cast faster, onskillcast I would tell it to cast purgatory again.
How to do this?

Re: Finding and looting dead bodies

Posted: Thu Nov 04, 2010 8:32 am
by Starrider
is there now any final version maybe as addon file?

Re: Finding and looting dead bodies

Posted: Thu Nov 04, 2010 9:09 am
by jduartedj
Administrator wrote: I wouldn't have a problem with that, except for one thing: already looted corpses become a problem. If you've looted a corpse but use a loot filter or don't have space in your inventory for some items, the body stays on the ground and lootable for some time. This would cause the bot to continue to and loot it over and over again. One solution to this is holding a table of recently looted corpses, but this is far from a decent solution. Some corpses (such as bosses) last for a long time. However, using a long timer on removing a corpse from this list could cause the bot to not want to loot some fresh corpses that happen to have the same ID of corpses that have already disappeared.

Best way to do this, I think, would be to keep track of ID and the body's coordinates, right? What are the odds of getting the same body ID in the same exact spot! Just a though....

Re: Finding and looting dead bodies

Posted: Fri Nov 12, 2010 10:53 am
by checkii
miximixi007 wrote:
checkii wrote:To make the skill cast faster, onskillcast I would tell it to cast purgatory again.
How to do this?

Same way you do this

Code: Select all

		-- Additional Lua code to execute when casting a skill
		-- Note: arg1 contains the skill being used.
		-- i.e. arg1.Name will be the name of the skill being cast
		-- e.g.:
		--if( 15 > player.HP/player.MaxHP*100 ) then
		--    player:cast("PRIEST_SOUL_SOURCE");
		--elseif( 25 > player.HP/player.MaxHP*100 ) then
		--    player:cast("PRIEST_HOLY_AURA");
		--    player:cast("PRIEST_URGENT_HEAL");
		--    player:cast("PRIEST_URGENT_HEAL");
But use arg1.Name

Re: Finding and looting dead bodies

Posted: Sat Nov 13, 2010 10:31 am
by jduartedj
This may be a *LONG* shot but what if while engadging multiple mobs, the player would actually define multiple targets!
Then he'd define targets 1,2,3,4,etc and when all are dead he'd loot 1,2,3,4,etc in order so that none is missed or looted twice.

Aoe really helps in mass farming, so i guess getting to to work would be vgood.

Re: Finding and looting dead bodies

Posted: Sun Nov 14, 2010 3:44 am
by checkii
Its working, putting player:update() in front of, or inside lootbodies() forces the bot to loot everything within range no matter what, how, or when you kill the mobs. By calling this function he will loot everything. In fact he does it so well he won't let go of the corpses until he loots everything from it.

Unless a bug was introduced, your AOE farm will function.

Re: Finding and looting dead bodies

Posted: Mon Dec 13, 2010 6:56 pm
by Petzzz
after 2-3h of testing i found a bug. we need a skip loot and return to waypoint after 5 sec not moving/looting (sometimes bot didnt loot all mobs and get stucked by trying to loot mobs out of range or behind walls).
mfg Petz

Drücke MACRO: Plündere toten Mob. Entfernung 26.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 178.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Lösche Ziel.
Drücke MACRO: Plündere toten Mob. Entfernung 111.
Wir haben uns nicht zum Plündern bewegt!? Festgewurzelt? Option 'zum Bewegen kli
cken' aktiviert?
Drücke MACRO: Plündere toten Mob. Entfernung 111.
scripts/rom/classes/player.lua:1131: Fehler im Profile bei der Zeitpunktverarbei
ten: onLeaveCombat error scripts/rom/functions.lua:550: bad argument #1 to 'memo
ryReadByte' ((null))

Tue Dec 14 01:54:16 2010 : Error attempting to open process 0xBECC18. Error code: 87 (Falscher Parameter.).
In main thread:
stack traceback:
scripts/rom/classes/pawn.lua:182: in function 'update'
scripts/rom/classes/pawn.lua:156: in function 'ctor'
...ames/Gamelab/Rom/micromacro_new/lib/mods/classes.lua:25: in function 'CPawn'
scripts/rom/classes/player.lua:1338: in function 'evalFunc'
scripts/rom/classes/player.lua:221: in function 'findEnemy'
scripts/rom/classes/player.lua:1702: in function 'moveTo'
scripts/rom/bot.lua:641: in function 'foo'
C:\Games\Gamelab\Rom\micromacro_new\lib\lib.lua:538: in function <C:\Games\Gamelab\Rom\micromacro_new\lib\lib.lua:536>

Re: Finding and looting dead bodies

Posted: Mon Dec 13, 2010 8:49 pm
by rock5
Petzzz wrote:after 2-3h of testing i found a bug. we need a skip loot and return to waypoint after 5 sec not moving/looting (sometimes bot didnt loot all mobs and get stucked by trying to loot mobs out of range or behind walls).
If the mob is out of range then it shouldn't try to loot it. If you are botting in an area with walls and other obstacles that cause problems you should reduce the loot distance or not use lootbodies at all. You can't just put in a time limit because it may still end up trying to loot it again, maybe many times.

I'm not sure what an error has to do with getting stuck looting but I couldn't read it anyway because I only speak English.

Re: Finding and looting dead bodies

Posted: Mon Dec 13, 2010 9:29 pm
by Petzzz
request was not to skip a single corps. i mean skip the howl looting after 5 sec not moving/looting. why not add a timer after last try to loot and last loot done.
so if timer > 5 sec skip looting (so we cant get stucked by trying to loot the dead boddy again and again because the lootbodies will not be called again untill we killed the next mob) with lootbodies at onleavecombat.

Re: Finding and looting dead bodies

Posted: Mon Dec 13, 2010 10:08 pm
by rock5
Petzzz wrote:request was not to skip a single corps. i mean skip the howl looting after 5 sec not moving/looting. why not add a timer after last try to loot and last loot done.
so if timer > 5 sec skip looting (so we cant get stucked by trying to loot the dead boddy again and again because the lootbodies will not be called again untill we killed the next mob) with lootbodies at onleavecombat.
Yes, but every time you kill a mob near that body you can't loot you'll try to loot it again. The same problem happens if you can't loot something in the loot list, eg. something you've already collected the max number of. Putting a timer on it might alleviate it a little but wont solve the problem. You still need to adjust the settings to avoid those situations in those areas.

Still... maybe it's better than nothing. I'll think about it.