Page 1 of 2
Quest Problem, ChoiceOption not an option for completing
Posted: Tue Feb 19, 2013 11:24 pm
by Buster99
I am trying to script completing a lvl 43 quest in Xaviera called, "Real and Fake."
Quest flow is:
Accept quest
Pick Energy Stones off ground
Use Energy Stones in inventory a number of times until it spawns a "Magic Energy Pouch"
Use "Magical Energy Pouch"
Dialogue appears with two choices
Fake Ancient coin appears if you choose either option
3 Fake Ancient coins complete quest
Problem is:
When the dialogue appears, with two options, ChoiceOption does not work. Using:
Is there another way to select a dialogue box option? No idea why this won't work as it does in all other dialogue options I have used it for.
Thanks in advance for help.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 20, 2013 12:15 am
by rock5
I think you get the Energy Stones off the Stone Protectors and I think you have to select a particular option to get the fake coin, I think the first one.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 20, 2013 12:32 am
by kenzu38
Hmm, how about if you try this code:
Code: Select all
sendMacro("SpeakFrame_ListDialogOption(1, 1)")
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 20, 2013 1:05 am
by rock5
That quest seems to be disabled on the servers I play so I can't check it but it's possible the a dialog opened from an object is different than a dialog opened from an npc, just like a quest from an object is different than a quest from an npc.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 20, 2013 1:10 am
by lisa
rock5 wrote:That quest seems to be disabled on the servers I play so I can't check it but it's possible the a dialog opened from an object is different than a dialog opened from an npc, just like a quest from an object is different than a quest from an npc.
You need to do the lead up quests first, starts at the camp as you enter that zone and then you kill some wolves and mushrooms, then the blood test quest then down to that camp and do the quest in question, done it many times on rom4u. Never bothered to bot it though.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 20, 2013 1:14 am
by rock5
I thought there might be a lead up quest but I even checked with my main characters that have done all the quests in the zone and they don't have access to it either. I'm still looking into it though.
Edit: Oops I thought it was a daily. I have a character here now that can do it. I'll check it out.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 20, 2013 1:31 am
by rock5
Looks like SpeakFrame_ListDialogOption(1, 1) does work.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 20, 2013 4:36 am
by Buster99
Once again, you all are awesome and quick to respond.
Question: I am trying to learn the Repeat ... Until scripting options. I have read quite a few examples of its use. On this particular quest would I be able to:
Repeat
Use Energy Stones
Until
Magic Energy Pouch appears in Inventory
So far I haven't been able to get it to work but first wanted to know if this is even within the scope of its use.
Related question: Can you put as much code as you want between Repeat...Until? Limits?
Again, thanks
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 20, 2013 4:54 am
by lisa
Buster99 wrote:So far I haven't been able to get it to work but first wanted to know if this is even within the scope of its use.
You could do that but I would probably not do it that way, the item in question uses a random number of items in order to do what it is trying to do, so you might have 7 items but it might take 8 items to get what you want. So if you did a loop like you are suguesting it would get stuck in that loop forever because the item you want might never appear.
I am a bit pressed for time at the moment so I can't really go in to much detail of how I would handle it but I will say you need to be careful with the "repeat ... until" loops
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 20, 2013 6:19 am
by rock5
Well you could do
Code: Select all
repeat
...
until Magic Energy Pouch appears in Inventory or energy stone count = 0
Then follow it with a
Code: Select all
if Magic Energy Pouch is in Inventory then
get fake coin from it
end
then
Code: Select all
if fake coin count >=3 then
head back to npc
end
You could also use the stones every time you get one instead of waiting until you have a few.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 20, 2013 1:58 pm
by Buster99
Ok, I am really enjoying learning this stuff. I am trying to script 40-50 in Xaviera using quests. I know there are are other scipts out there but they use grinding and don't use quests, except dailies. It is a slow go but I am doing it mainly for the challenge and for learning.
The following works but it requires having 6 of the Energy Stones before advancing:
Code: Select all
<!-- # 10 --><waypoint x="2940" z="11504" y="137" tag="stonemore">
inventory:update();
if inventory:getItemCount("Energy Stone") >=6 then
repeat
inventory:useItem("Energy Stone");
yrest (2500)
until
inventory:useItem("Magic Energy Pouch");
yrest (1000)
sendMacro("SpeakFrame_ListDialogOption(1, 1)")
yrest (1200)
end
if getQuestStatus("Real and Fake") == "complete" then
__WPL:setWaypointIndex(__WPL:findWaypointTag("stonedone"));
else
__WPL:setWaypointIndex(__WPL:findWaypointTag("stonemore"));
end
</waypoint>
But I wanted to learn the "or" option and cannot get it to work. I know the error is in the syntax of how I am using it but cannot figure it out. Here it is:
Code: Select all
<!-- # 10 --><waypoint x="2940" z="11504" y="137" tag="stonemore">
inventory:update();
repeat
inventory:useItem("Energy Stone");
yrest (2500)
until
inventory:getItemCount("Energy Stone") = 0
or
inventory:useItem("Magic Energy Pouch");
yrest (1000)
sendMacro("SpeakFrame_ListDialogOption(1, 1)")
yrest (1200)
if getQuestStatus("Real and Fake") == "complete" then
__WPL:setWaypointIndex(__WPL:findWaypointTag("stonedone"));
else
__WPL:setWaypointIndex(__WPL:findWaypointTag("stonemore"));
end
</waypoint>
Also, I am sure there are more "clean" ways of writing and ANY tips or suggestions are appreciated.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 20, 2013 3:22 pm
by rock5
What you are doing is trying to use the magic pouch after every stone use. That might work but it's a bit messy. You should do one step at a time. First use the stones until you have a pouch or run out of stones. Then use the pouch if you got one.
You don't need to do inventory:update() before an itemTotalCount because it is done in itemTotalCount.
'=' means assign a value to. '==' means compare 2 values.
Also if you are going to put the code in a waypoint so it runs whenever it reaches that waypoint, why limit it to only run when you have more than 6? I would just run it anyway each time. Also you have it looping back to the same waypoint which means if it didn't have enough Stones to complete the quest then it would get stuck in a loop. It should instead go and kill more Stone Protectors. So the 'stonemore' tag should be at a waypoint that would take you around again to kill more mobs and get more stones.
There are certain rules about how you can split lines. I'm not sure but I don't think you can change
to
So, thinking it though, I would use stones until I get a pouch or run out of stones, use the pouch if I have one. If the quest is complete then continue to the 'stonedone' tag. Otherwise repeat until the stones are used up then go kill more mobs.
I was going to give you my complete version but you sound like you're enjoying doing it so I'll just give you the break down.
Code: Select all
repeat
-- Use stones until you get a pounch or run out
-- If I have a pouch, use it
-- if quest is finished then set waypoint to tag 'stonedone' and 'return' to exit waypoint
until inventory:getItemCount("Energy Stone") == 0
-- At this point quest not done and out of stones. Set tag 'stonemore' and go get some.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Thu Feb 21, 2013 1:11 pm
by Buster99
Thank you for not just giving me the answer. I am very close, I think, to having this work but I am stuck at one place and I think it is easy fix but don't know how to script it. After I use stones and use pouch, if a pouch is in inventory, and quest is NOT completed, I simply want to loop back and do again (like an old-time "goto" option)(or should I be trying to use a Repeat/Until?). I don't want to kill more mobs to get stones if I have more stones in backpack. I tried to insert two comments in the code below to show what I am trying to accomplish:
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>
settings.profile.options.COMBAT_DISTANCE = 130
settings.profile.mobs = {"Stone Protector"}
function usestones()
repeat
inventory:useItem("Energy Stone");
yrest (2500)
until inventory:getItemCount("Energy Stone") == 0 or inventory:getItemCount("Magic Energy Pouch") >= 1;
yrest (1000)
end
function pouchcheck()
if inventory:getItemCount("Magic Energy Pouch") >= 1 then
inventory:useItem("Magic Energy Pouch");
sendMacro("SpeakFrame_ListDialogOption(1, 1)")
yrest (1200)
end
end
</onLoad>
<!-- # 1 --><waypoint x="2703" z="11036" y="138"> </waypoint>
<!-- # 2 --><waypoint x="2802" z="11349" y="148"> </waypoint>
<!-- # 3 --><waypoint x="2699" z="11367" y="157" tag="stonemore"> </waypoint>
<!-- # 4 --><waypoint x="2755" z="11452" y="145"> </waypoint>
<!-- # 5 --><waypoint x="2575" z="11876" y="133"> </waypoint>
<!-- # 6 --><waypoint x="2854" z="12233" y="134"> </waypoint>
<!-- # 7 --><waypoint x="3020" z="12183" y="139"> </waypoint>
<!-- # 8 --><waypoint x="3246" z="11981" y="142"> </waypoint>
<!-- # 9 --><waypoint x="3145" z="11665" y="140"> </waypoint>
<!-- # 10 --><waypoint x="2940" z="11504" y="137">
-----> Want to start loop beginning here
usestones()
pouchcheck()
if getQuestStatus("Real and Fake") == "complete" then
__WPL:setWaypointIndex(__WPL:findWaypointTag("stonedone"));
else
if inventory:getItemCount("Energy Stone") >= 1 then
-----> I want to loop up so that it will do more stones AND check if quest is complete again
end
__WPL:setWaypointIndex(__WPL:findWaypointTag("stonemore"));
end
</waypoint>
<!-- # 10 --><waypoint x="2940" z="11504" y="137" tag="stonedone">
player:sleep() -- code for going to NPC and completing quest will go here
</waypoint>
I appreciate ALL feedback from anyone. If you have time and see teaching opportunities I would appreciate it very much. Is the rest of script written succinctly and well?
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Thu Feb 21, 2013 10:59 pm
by rock5
That is what the
Code: Select all
repeat
...
until inventory:getItemCount("Energy Stone") == 0
I posted, is for.
So basically you would do
Code: Select all
repeat
usestones()
pouchcheck()
if getQuestStatus("Real and Fake") == "complete" then
__WPL:setWaypointIndex(__WPL:findWaypointTag("stonedone"));
return
end
until inventory:getItemCount("Energy Stone") == 0
__WPL:setWaypointIndex(__WPL:findWaypointTag("stonemore"));
If you want me to explain anything, let me know.
Yes, I like your code. Nice and neat. I think that is a prerequisite of a good future programmer. Keep it up.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Tue Feb 26, 2013 11:08 pm
by Buster99
Thanks Rock, that script worked great for that quest. I had to learn the hard way what the "Return" was for. At first I took it out thinking it was a mistake by you only to learn I could not leave the Repeat/Until loop and advance to a WP tag without using Return. At least, I think that is what the "Return" does.
I have finised about 25 quests now and still enjoying it alot. I do have a couple questions and am going to ask it in this thread. If you think it is better to start a brand new thread for each quest question I can do that instead of continuing here.
I have a quest which seems super simple. It is called "Seal". I accept quest, tell NPC I am ready, am teleported to another location where I simply have to stand sill and kill three waves of easy mobs that attack me. Then the quest completes and it teleports me back by NPC to turn in.
1) Is there a way to stand in same spot and simply attack mobs advancing at me? I cannot figure out how to:
Repeat
Kill Mobs aggroing me
Until Quest Completes
2) (Related question) I tried to use createpath and simply make a few WPs to move between until quest is complete. The problem is the WPs do not match the location. I tried to use createpath at beginning of quest before being teleported by NPC and I also tried to use createpath after I was alread at the new location after teleport. It tries to move me somewhere else. I am guessing the problem is when I am trasnported to this "cutscene" the location varies? Just curious, why this is or how to "fix" so that I could actually move around in this new location.
Thanks again for help in advance.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 27, 2013 12:40 am
by rock5
1. I guess if the quest becomes complete when you have killed all the waves then, yes, you could do a
repeat ... until getQuestStatus("Seal") == "complete". All you want it to do in the loop is look for aggroed enemies and attack them. You should be able to just do
Code: Select all
local mob = player:findEnemy(true)
if mob then
player:target(mob)
player:fight()
end
yrest(100)
2. I never noticed it myself but then I never botted it. If there is more than one location that the quest is completed at, you can add each of the locations. Then add this after talking with the npc and waiting for the teleport to complete.
Code: Select all
__WPL:setWaypointIndex( __WPL:getNearestWaypoint(player.X, player.Z, player.Y ) );
This will go to the nearest waypoint.
Then at each of those waypoints you set the next waypoint using a tag. eg.
Code: Select all
Accept quest from npc. wait for teleport. Go to nearest waypoint.
First quest location. Fight mobs. Wait for teleport. Go to tagged waypoint.
Second quest location. Fight mobs. Wait for teleport. Go to tagged waypoint.
Third quest location. Fight mobs. Wait for teleport. Goto tagged waypoint.
Tagged waypoint. Talk to npc and complete quest.
Each of those lines is pseudo code for one waypoint.
See what you can do with that. Let me know if you need more help.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 27, 2013 1:36 pm
by Buster99
Rock, that code worked perfect! I can see other uses for that as well on some other things I have come across. Thanks much.
As I continue having quest questions with my project, is it fine for me to keep posting them in this thread or should I start a new one each time?
Thanks again
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Feb 27, 2013 2:10 pm
by rock5
I'd find your posts either way so it wouldn't really matter to me but I guess, because it's your topic and basically the topic is about you asking questions to help you learn, then I guess it's ok to keep posting them here.
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Mar 06, 2013 12:23 pm
by Buster99
Is there an editor I can use that will give me line numbers? There are times I get errors that give me a line number where the error occured but I have to manually count down to find the error. I am using Notepad.
Scripts are going well.
Thanks
Re: Quest Problem, ChoiceOption not an option for completing
Posted: Wed Mar 06, 2013 1:11 pm
by rock5
Notepad++ is usually recommended.
http://notepad-plus-plus.org/