New Quest functions?

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

New Quest functions?

#1 Post by rock5 »

Id like to add my quest function to the in-game-functions. I wasn't too satisfied with the way it worked originally but recently (about a patch or 2 back), I discovered a new command that gives you the status of the quests. I've since rewrote it and am quite happy with it.

Code: Select all

-- questname = name of quest
-- returns 'true' if quest complete 'false' if not and nil if not accepted
function igf_questStatus(_questname)
	local lowername=string.gsub(string.lower(_questname),"'","")
	local c = 1
	local getname = GetQuestRequest(c,-2)
	while getname ~= nil do
		getname=string.gsub(getname,"'","")
		if string.find(string.lower(getname), lowername) then -- Quest exists
			for i = 1, GetQuestRequest(c,-1) do -- for each goal
				__,getstatus = GetQuestRequest(c,i)
				if getstatus == 0 then -- check if not complete
					return false
				end
			end
			return true
        end
		c = c + 1
		getname = GetQuestRequest(c,-2)
	end
	return
end
I'd then add some functions to function.lua that would simplify using it, like so.

Code: Select all

function isQuestComplete(_questname)
	-- Do I need to turn in my quest?
	if (bot.IgfAddon == false) then
		error(language[1004], 0)	-- Ingamefunctions addon (igf) is not installed
	end
	
	local queststate = RoMScript("igf_questStatus(\"".._questname.."\")")
	if queststate == true then
		return true
	else
		return false
	end
end

function isQuestAccepted(_questname)
	-- Do I need to go an get the quest?
	if (bot.IgfAddon == false) then
		error(language[1004], 0)	-- Ingamefunctions addon (igf) is not installed
	end
	
	local queststate = RoMScript("igf_questStatus(\"".._questname.."\")")
	if (queststate == true) or (queststate == false) then
		return true
	else
		return false
	end
end

function getQuestStatus(_questname)
	-- Used when you need to make 3 way decision, get quest, complete quest or gather quest items.
	if (bot.IgfAddon == false) then
		error(language[1004], 0)	-- Ingamefunctions addon (igf) is not installed
	end
	
	return RoMScript("igf_questStatus(\"".._questname.."\")")
end
Any objections?
  • 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
Administrator
Site Admin
Posts: 5353
Joined: Sat Jan 05, 2008 4:21 pm

Re: New Quest functions?

#2 Post by Administrator »

I don't see any problems with it. If it works, go ahead and include it. It certainly looks cleaner than the original code.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: New Quest functions?

#3 Post by rock5 »

Administrator wrote:I don't see any problems with it. If it works, go ahead and include it. It certainly looks cleaner than the original code.
You didn't mention the returned variables. I'm not really happy the in-game function returning true, false or nil to mean Complete, Accepted but not Complete and Not Accepted respectively. Seems cumbersome to explain and understand.

I thought maybe I should return 0, 1 or 2 instead. Then define some static variables;
COMPLETE = 2
NOT_COMPLETE = 1
NOT_ACCEPTED = 0

So in users script they can do something like this;

Code: Select all

if getQuestStatus(questname) == COMPLETE then
Would that be better?
  • 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
Administrator
Site Admin
Posts: 5353
Joined: Sat Jan 05, 2008 4:21 pm

Re: New Quest functions?

#4 Post by Administrator »

A string value being returned might be the best option. Then you can just check against "complete", "incomplete", or "not accepted" instead of defining those variables. As this isn't a very time critical or expensive function, it's fine to make use of strings here.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: New Quest functions?

#5 Post by rock5 »

Administrator wrote:A string value being returned might be the best option. Then you can just check against "complete", "incomplete", or "not accepted" instead of defining those variables. As this isn't a very time critical or expensive function, it's fine to make use of strings here.
Bit late, I've already committed it. Do you want me to change it?
  • 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
Administrator
Site Admin
Posts: 5353
Joined: Sat Jan 05, 2008 4:21 pm

Re: New Quest functions?

#6 Post by Administrator »

It's up to you. I think the strings would be easier to use. Integers aren't so bad, though. If it's not too much trouble, I'd say change it.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: New Quest functions?

#7 Post by rock5 »

Administrator wrote:It's up to you. I think the strings would be easier to use. Integers aren't so bad, though. If it's not too much trouble, I'd say change it.
ok I'll add it in the next commit. I doubt anyone has started using it yet.
  • 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