a better option than yrest/npc search distance

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
883Dman
Posts: 90
Joined: Sat Dec 08, 2012 9:25 pm

a better option than yrest/npc search distance

#1 Post by 883Dman »

This is what i have been able to make to grind heffner dailies: (sorry, I don't know how to make a scroll box in here)

<!-- # 1 --><waypoint x="-7093" z="-4147" y="172" tag="npc">
player:target_NPC("Hugope");
CompleteQuestByName("Earn a Reputation");
local dqCount, dqPerDay = RoMScript("Daily_count()");
if dqCount == 10 then

loadPaths("andor1");
end
</waypoint>
<!-- # 2 --><waypoint x="-7042" z="-4231" y="173"> </waypoint>
<!-- # 3 --><waypoint x="-6999" z="-4414" y="172">
queststate = getQuestStatus("Earn a Reputation");
while queststate == "incomplete" do
yrest(100);player:target_NPC("Uncomfortable Adventurer");
sendMacro("ChoiceOption(1);");yrest(200);
queststate = getQuestStatus("Earn a Reputation");
sendMacro("ChoiceOption(1);");yrest(20000);
queststate = getQuestStatus("Earn a Reputation");
end

</waypoint>

<!-- # 12 --><waypoint x="-7043" z="-4311" y="172"> </waypoint>
<!-- # 13 --><waypoint x="-7096" z="-4141" y="172">
__WPL:setWaypointIndex(__WPL:findWaypointTag("npc"));
</waypoint>

* This works but is not efficient since it does the 20 second yrest to wait for the npc to respawn before checking completion status and doing the turn in. The other problem is that if it looks for the npc but does not find it (due to another bot having caused it to disappear) it automatically runs toward another viable npc that is within its radar range which of course is behind walls, buildings etc. SO:

1. How can I get my bot to stand the *&^% still and just wait for the npc to respawn without using yrest OR
2. change the distance the bot will look for another npc?
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: a better option than yrest/npc search distance

#2 Post by rock5 »

target_NPC has no distance check so you could "find" the npc first and check it's distance first. Eg.

Code: Select all

queststate = getQuestStatus("Earn a Reputation");
while queststate == "incomplete" do
	yrest(100);
	local npc = player:findNearestNameOrId("Uncomfortable Adventurer");
	if 100 > distance(player, npc) then
		player:target(npc.Address)
		Attack(); yrest(50); Attack(); -- twice to be sure
		yrest(500);

		sendMacro("ChoiceOption(1);");yrest(200);
		queststate = getQuestStatus("Earn a Reputation");
		sendMacro("ChoiceOption(1);");yrest(20000);
	end
	queststate = getQuestStatus("Earn a Reputation");
end 
Also, to put code into a box, select the code and click the 'code' button at the top of the edit box.
  • 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
883Dman
Posts: 90
Joined: Sat Dec 08, 2012 9:25 pm

Re: a better option than yrest/npc search distance

#3 Post by 883Dman »

not liking the distance value

[string " ..."]:6: Error: nil value passed to distance<>

Do I need to specify character name in: if 100 > distance(player, npc) then
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: a better option than yrest/npc search distance

#4 Post by rock5 »

npc might be nil if there is no adventurer. Try changing

Code: Select all

   if 100 > distance(player, npc) then
to

Code: Select all

   if npc and 100 > distance(player, npc) then
  • 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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: a better option than yrest/npc search distance

#5 Post by lisa »

On occasion I have thought that the findnearestnameorid could benefit from a distance check.

Code: Select all

function CPlayer:findNearestNameOrId(_objtable, ignore, evalFunc, dist)

dist = dist or 300


if( obj.Address ~= ignore and obj.Address ~= player.Address and dist > distance(player,obj) and (obj.Id == tonumber(_objnameorid) or string.find(obj.Name, _objnameorid, 1, true) )) then
Changes like that might do the trick?

Now i am looking at it there is a distance value created but it is never used, should just delete it, around line 3612

Code: Select all

local dist = distance(self.X, self.Z, self.Y, obj.X, obj.Z, obj.Y);
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
883Dman
Posts: 90
Joined: Sat Dec 08, 2012 9:25 pm

Re: a better option than yrest/npc search distance

#6 Post by 883Dman »

I'll poke around with it, but it seems like Rock's code is working. I'll know for sure tomorrow. Thanks a bunch.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: a better option than yrest/npc search distance

#7 Post by rock5 »

lisa wrote:On occasion I have thought that the findnearestnameorid could benefit from a distance check.
I think it may have originally had a default distance check but it was removed. I think the logic was that any function that needs a distance check, eg. harvest or target_Object, can just check the distance of the returned object. And seeing as each function has different distance requirements, it makes sense that those functions do the check. It then makes no sense for findnearestnameorid and those functions to both do distance checks. findnearestnameorid, as a general purpose function, should have no limitations. Of course findnearestnameorid could have accepted a distance argument that defaulted to unlimited but this is just the way it ended up. Of course it wouldn't hurt to add it as long as it's unlimited by default so it doesn't conflict with the other functions own distance checks.
lisa wrote:Now i am looking at it there is a distance value created but it is never used, should just delete it, around line 3612
Yeah, I just noticed one in harvest too.
  • 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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: a better option than yrest/npc search distance

#8 Post by lisa »

rock5 wrote:Of course it wouldn't hurt to add it as long as it's unlimited by default
Pretty sure the testing I did had the max memory range at 450 for objects, so if set to 500 it should be safely out of that max range of memory.
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
Bot_romka
Posts: 96
Joined: Tue Apr 05, 2011 2:59 am
Location: Russia

Re: a better option than yrest/npc search distance

#9 Post by Bot_romka »

Don`t use NPC name "Uncomfortable Adventurer" because there to different NPC with same name. One of them which appears after complete dialog not clicable and bot can crush client when try target not clicable NPC. Try to use NPC Id.
McGuffin
Posts: 46
Joined: Sat Mar 16, 2013 6:14 am

Re: a better option than yrest/npc search distance

#10 Post by McGuffin »

rock5 wrote:
lisa wrote:On occasion I have thought that the findnearestnameorid could benefit from a distance check.
I think it may have originally had a default distance check but it was removed. I think the logic was that any function that needs a distance check, eg. harvest or target_Object, can just check the distance of the returned object. And seeing as each function has different distance requirements, it makes sense that those functions do the check. It then makes no sense for findnearestnameorid and those functions to both do distance checks. findnearestnameorid, as a general purpose function, should have no limitations. Of course findnearestnameorid could have accepted a distance argument that defaulted to unlimited but this is just the way it ended up. Of course it wouldn't hurt to add it as long as it's unlimited by default so it doesn't conflict with the other functions own distance checks.
lisa wrote:Now i am looking at it there is a distance value created but it is never used, should just delete it, around line 3612
Yeah, I just noticed one in harvest too.
Came across this a couple of hours ago while looking for something else... weird.

http://www.solarstrike.net/phpBB3/viewt ... =21&t=2676
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: a better option than yrest/npc search distance

#11 Post by rock5 »

Yeah, that's probably when I changed it. Good to see I remembered correctly after 2 years. :)
  • 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