Page 1 of 1
Problems with quests with particular NPC
Posted: Tue Feb 19, 2013 10:44 pm
by noobbotter
NPC Shaman Fogg in Lyonsyde Tribe in CoO is giving me troubles. He won't let my bot turn in or accept quests. I'm using:
Code: Select all
player:target_NPC("Shaman Fogg");
CompleteQuestByName("Test Results");
yrest(1000);
AcceptQuestByName("Go to");
yrest(1000);
For some reason, when the bot targets him, he opens a dialog window with the only option being to Leave Conversation. It does this as well during the CompleteQuestByName and AcceptQuestByName. The weird thing is, if I stop the bot and manually click on him, he opens the dialog to turn in my quest and the next time he'll open the window for me to accept the next quest. These quests are part of the Line that starts with "The First Step" quest:
Quest "The First Step" given by Santenando and turned into Santenando - works fine
Quest "Hunting Trainee" given by Santenando and turned in to Village Hunter - works fine
Quest "Test Results" given by Village Hunter and turned in to Shaman Fogg - This is the only one I'm having issues with. Bot accepts it, runs the waypoints to gather the animals from traps and goes to Lyonsyde Tribe to turn it in, but Shaman Fogg doesn't cooperate unless I manually click him to turn it in. Also the following quest "Go to the Woodcutter's Camp" won't automatically accept from him either.
Are there certain NPCs that you have to do something different with to get certain quests to accept or turn in with?
Re: Problems with quests with particular NPC
Posted: Tue Feb 19, 2013 11:01 pm
by rock5
Yes. Sometimes there is more than one npc with the same name and the one that is visible depends on various things such as what quest you are up to. What you are doing is targeting the invisible Fogg that is for the earlier quests. You should be able to fix it by using 'rom/getid' and getting the id of that Fogg and using that id for that quest.
I wonder if we could get the bot to find the visible npc over the hidden one.
Re: Problems with quests with particular NPC
Posted: Wed Feb 20, 2013 8:27 am
by noobbotter
Thanks Rock. Getting the visible one's ID and use that in the script sounds like the easy way to go. Then again, thinking about it, it might not be too hard to implement something that would find the nearest NPC with that name, try to accept quest (or check to see if he has that quest), and if not, then target next NPC with that name, and keep doing that until the correct one is found? Of course, to avoid an endless loop you'd have to only loop through the NPCs once and if not found, either error out, or skip that quest. Maybe something like this?
Code: Select all
function findQuestNPC(npcname,questname)
local objectList = CObjectList();
objectList:update();
for i = 0,objectList:size() do
local obj = objectList:getObject(i);
if obj.Name == npcname then
player:target(obj);
yrest(100);
AcceptQuestByName(questname);
yrest(500);
curquest = questlog:getQuest(questname);
if curquest == true then
break;
end
end
end
if questlog:haveQuest(questname) ~= true then
error("Didn't find the quest");
end
end
You think that might work? I'm not home right now so I can't test it but it looks like it might work.
Edit: better yet, I made the function where it should work for either accepting or turning in a quest:
Code: Select all
function findQuestNPC(npcname,questname,AcceptorComplete)
local objectList = CObjectList();
objectList:update();
for i = 0,objectList:size() do
local obj = objectList:getObject(i);
if obj.Name == npcname then
player:target(obj);
yrest(100);
if AcceptorComplete == "Accept" then
AcceptQuestByName(questname);
yrest(500);
curquest = questlog:getQuest(questname);
if curquest == true then
break;
end
elseif AcceptorComplete == "Complete" then
CompleteQuestByName(questname,1);
yrest(500);
curquest = questlog:getQuest(questname);
if curquest == false then
break;
end
else
error("AcceptorComplete must be either 'Accept' or 'Complete'. Try again");
end
end
end
if AcceptorComplete == "Accept" then
if questlog:haveQuest(questname) ~= true then
error("Didn't find the quest");
end
elseif AcceptorComplete == "Complete" then
if questlog:haveQuest(questname) ~= false then
error("Didn't complete the quest");
end
end
end
Re: Problems with quests with particular NPC
Posted: Wed Feb 20, 2013 9:52 am
by rock5
Looks like it would work but it looks like you don't need to be using the questlog functions. Why not just use getQuestStatus?
Although I think it would be easier to just check if the npc is visible or not instead of trying to open a dialog with each. The visibility check in findEnemy would probably work.
Code: Select all
local inp = memoryReadRepeat("int", getProc(), obj.Address + addresses.pawnAttackable_offset) or 0;
if not bitAnd(inp,0x4000000) then -- Means is visible
Re: Problems with quests with particular NPC
Posted: Wed Feb 20, 2013 9:59 am
by noobbotter
That does look a lot better. I'll try the one for checking for invisibility. Thanks again.
edit:
Ok, how does this look? Of course, I can't test it until I get home later.
Code: Select all
function findQuestNPC(npcname,questname,AcceptorComplete)
curnpcid = 0;
local objectList = CObjectList();
objectList:update();
for i = 0,objectList:size() do
local obj = objectList:getObject(i);
if obj.Name == npcname then
local inp = memoryReadRepeat("int", getProc(), obj.Address + addresses.pawnAttackable_offset) or 0;
if not bitAnd(inp,0x4000000) then -- Means is visible
curnpcid = obj.Id
break;
end
end
end
if curnpcid == 0 then
cprintf(cli.yellow,"Could not find %s. You must %s the quest manually before continuing.\n", npcname, AcceptorComplete)
player:sleep()
else
player:target_NPC(curnpcid);
yrest(500);
if AcceptorComplete == "Accept" then
AcceptQuestByName(questname);
elseif AcceptorComplete == "Complete" then
CompleteQuestByName(questname,1);
end
end
end
Edit:
I implemented the code above and it appears to be working. Thanks Rock.
Re: Problems with quests with particular NPC
Posted: Wed Feb 20, 2013 10:53 pm
by noobbotter
Ok, new question. I had the above workign but ran into a new questing problem. On quests where you accept the quest, then you talk to that person, then turn in quest, I normally just use target NPC to talk to them. However, on this one, when you target them, it brings up the dialogue window containing 3 items:
Unfinished Quests:
Family Quarrel
Chat:
(Attempt to console the Shaman Fogg)
Leave Conversation
I'm not sure if there's a way to do this one. I've tried the sendMacro("ChoiceOption(2);"); method and that didn't work either. Any ideas? Thanks.
Re: Problems with quests with particular NPC
Posted: Thu Feb 21, 2013 2:18 am
by rock5
If it's the only "option" then it should be option 1. Have you tried 1?
Re: Problems with quests with particular NPC
Posted: Thu Feb 21, 2013 2:56 am
by rock5
noobbotter wrote:I had the above workign
So did the visibility flag work? Because I'm thinking of adding it to findnearestnameorid.
Re: Problems with quests with particular NPC
Posted: Thu Feb 21, 2013 6:48 am
by noobbotter
Well, initially, it seemed the visibility flag worked, but on a later quest at that same person, I found that even using that invisibility flag, it would find the NPC twice in one run through the loop, so I'm not really sure now if it's working or if I got lucky the first time I tried it. It will take more testing I think.
Re: Problems with quests with particular NPC
Posted: Thu Feb 21, 2013 11:39 pm
by noobbotter
It was having weird issues so I decided to revert to using the ID for targeting him. Once I did that, it cleared up any problems of completing that one quest. For anyone interested, here's how I finally got it to work. Very simple, actually.
Code: Select all
player:target_NPC(117632);
AcceptQuestByName("Family Quarrel");
yrest(500);
player:target_NPC(117632);
yrest(500);
ChoiceOptionByName("Attempt");
repeat
yrest(1000);
quest = questlog:getQuest("Family Quarrel");
until quest:isComplete() == true;
player:target_NPC(117632);
CompleteQuestByName("Family Quarrel",1);
I found that ChoiceOptionByName in another post and gave it a shot. it worked.
I need to keep this snippet of code handy so i can use it for any of those quests where you wait for people to finish talking.
Re: Problems with quests with particular NPC
Posted: Fri Feb 22, 2013 12:11 am
by rock5
The cool thing about ChoiceOptionByName is it tries 2 ways to choose the option so you don't have to try one way and then the other.