a better option than yrest/npc search distance
a better option than yrest/npc search distance
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?
<!-- # 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?
Re: a better option than yrest/npc search distance
target_NPC has no distance check so you could "find" the npc first and check it's distance first. Eg.
Also, to put code into a box, select the code and click the 'code' button at the top of the edit box.
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 - 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
Re: a better option than yrest/npc search distance
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
[string " ..."]:6: Error: nil value passed to distance<>
Do I need to specify character name in: if 100 > distance(player, npc) then
Re: a better option than yrest/npc search distance
npc might be nil if there is no adventurer. Try changing
to
Code: Select all
if 100 > distance(player, npc) thenCode: 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
Re: a better option than yrest/npc search distance
On occasion I have thought that the findnearestnameorid could benefit from a distance check.
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
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
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: a better option than yrest/npc search distance
I'll poke around with it, but it seems like Rock's code is working. I'll know for sure tomorrow. Thanks a bunch.
Re: a better option than yrest/npc search distance
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:On occasion I have thought that the findnearestnameorid could benefit from a distance check.
Yeah, I just noticed one in harvest too.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
- 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
Re: a better option than yrest/npc search distance
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.rock5 wrote:Of course it wouldn't hurt to add it as long as it's unlimited by default
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: a better option than yrest/npc search distance
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.
Re: a better option than yrest/npc search distance
Came across this a couple of hours ago while looking for something else... weird.rock5 wrote: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:On occasion I have thought that the findnearestnameorid could benefit from a distance check.
Yeah, I just noticed one in harvest too.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
http://www.solarstrike.net/phpBB3/viewt ... =21&t=2676
Re: a better option than yrest/npc search distance
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