player:target_Object() problem

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
Ego95
Posts: 564
Joined: Tue Feb 28, 2012 12:38 pm
Contact:

player:target_Object() problem

#1 Post by Ego95 » Sat Apr 25, 2015 6:59 am

Hi,

I got some problems with the player:target_Object() function. Like you know we need a minimal distance to objects, to harvest them. The problem is, that the library in the guild castle is so huge, that the center point is too far away.

In player.lua I found (lines 3741-3747)

Code: Select all

				if( distance(self.X, self.Z, obj.X, obj.Z) > 39 ) then
					self:moveInRange(CWaypoint(obj.X, obj.Z), 39, true);
					repeat
						yrest(50)
						self:updateActualSpeed()
					until not self.Moving
				end
I needed to change the distance from 39 to 50, so that the player can click the library. Better would be 75. The thing is, that this affects harvesting materials and other things too. Is there no way to check via memory, from which distance an object is clickable? Or could there be an other workaround for this?

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: player:target_Object() problem

#2 Post by BlubBlab » Sat Apr 25, 2015 12:01 pm

Perhaps make change of the distance optional as an extra argument ?
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: player:target_Object() problem

#3 Post by lisa » Sat Apr 25, 2015 7:04 pm

If the library is the only Object with this issue then I would just not use player:target_Object() for the library.

You could make up a user function to click library which uses the code in target_Object but with a distance of 50.
If there was more objects with the issue then I would look at adding in another argument to target_Object for distance and just do default at 39 if the argument isn't used.

Just my 2 cents
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
Ego95
Posts: 564
Joined: Tue Feb 28, 2012 12:38 pm
Contact:

Re: player:target_Object() problem

#4 Post by Ego95 » Sun Apr 26, 2015 3:27 pm

Okay, thanks for your answers =) I took BlubBlabs idea and added an extra argument. I dont know, if the code can be made cleaner, this is, how I did it:

Code: Select all

function CPlayer:target_Object(_objname, _waittime, _harvestall, _donotignore, _objdistance, evalFunc)
(line 3705)

and

Code: Select all

				if( distance(self.X, self.Z, obj.X, obj.Z) > 39 ) and _objdistance == nil then
					self:moveInRange(CWaypoint(obj.X, obj.Z), 39, true);
					repeat
						yrest(50)
						self:updateActualSpeed()
					until not self.Moving
				else
					self:moveInRange(CWaypoint(obj.X, obj.Z), _objdistance, true);
					repeat
						yrest(50)
						self:updateActualSpeed()
					until not self.Moving
				end
(from line 3741)

The repeat-part is double, but but works =)

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: player:target_Object() problem

#5 Post by lisa » Sun Apr 26, 2015 6:11 pm

Probably not the way I would do it but this is a neater version of what you posted.

--=== Untested ===--

Code: Select all

function CPlayer:target_Object(_objname, _waittime, _harvestall, _donotignore, _objdistance, evalFunc)
if  type(_objdistance) ~= "number" then  _objdistance = 39 end


           if( distance(self.X, self.Z, obj.X, obj.Z) > _objdistance ) then
               self:moveInRange(CWaypoint(obj.X, obj.Z), _objdistance, true);
               repeat
                  yrest(50)
                  self:updateActualSpeed()
               until not self.Moving
            end
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: player:target_Object() problem

#6 Post by rock5 » Sun Apr 26, 2015 9:55 pm

Basically player:targetObject is a complicated special targeting function that has arguments to help target harvestable type items. That's items that have collect time or you need to collect until it disappears or you need to ignore it after using it, etc.

If all you want to do is click something then I would use target_NPC but unfortunately that also has a distance check.

Honestly, in this case, I would just use the more basic commands.

Code: Select all

lib = player:findNearestNameOrId("Library")
player:target(lib)
Attack()
I think the reason this hasn't come up before because usually you would use the Library manually when needed.
  • 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

User avatar
Ego95
Posts: 564
Joined: Tue Feb 28, 2012 12:38 pm
Contact:

Re: player:target_Object() problem

#7 Post by Ego95 » Mon Apr 27, 2015 2:43 am

The thing is, that I used target_Object because I need the waittime. For a special reason I need to click the library once until the castingbar has been full, then go on.
The library is a complicated thing, maybe I should change it to target_NPC. But I think I already tried that, but my character tried to get to the center point of the building again.

I will test your idea, with findNearestNameOrId, rock =)

Edit: Just read the thing with the distance check of target_NPC...yes, this is why it didn't work either

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: player:target_Object() problem

#8 Post by rock5 » Mon Apr 27, 2015 4:16 am

You can probably use player.Casting to make sure you are casting and player:waitTillCastingEnds() to wait until the castbar goes away, eg.

Code: Select all

repeat
   Attack()
   yrest(500)
   player:updateCasting()
until player.Casting == true
player:waitTillCastingEnds()
  • 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

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: player:target_Object() problem

#9 Post by rock5 » Mon Apr 27, 2015 4:43 am

Looks like player:waitTillCastingEnds() wont work with that. Instead you can use player.Casting again.

Code: Select all

repeat
   yrest(500)
   player:updateCasting()
until player.Casting == false
  • 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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 94 guests