Page 1 of 1

Quests

Posted: Sat Jul 12, 2014 1:40 am
by Jabantiz
Foof gave me the idea of saving a bit mask to characters quests so we can support these "dynamic" quests, figured it would be simple to implement so jumped in, I was wrong...

lua didn't start supporting bitwise operations until 5.2, we use 5.1, after searching around I did find some lua functions for basic functionality, at least good enough for my needs. The next issue was on a /reload quests it killed all the players quests and added new ones, so had to preserve the flag, that was the simplest of my problems.

Finally, and the reason why I am posting, upon logging in if no progress has been made in the quest reload is never called, so the main point of adding this bitmask would not work if no progress was made. I got around this by having reload being called if the bitmask has a value, will call reload with step = 0, not sure if that will be a problem for any scripts though. I have checked a lot of scripts and haven't seen an if/else in a reload function yet, most are just if's or if/elseif, but hesitate to commit this code unless others think it is ok to call reload with step = 0.

Re: Quests

Posted: Sat Jul 12, 2014 2:26 am
by Dello0000
Well I cant comment, that made 0 sense to me lol. :D

Re: Quests

Posted: Sat Jul 12, 2014 5:12 pm
by Jabantiz
Well I went through all the quests on content SVN and checked the reload function and these changes won't cause any issues so committed the code.

While I was messing around with the quest code I looked into the tracking issue, turns out the quest is sent with tracking disabled and then again right after with it enabled, we just sent it once with tracking enabled, changed it to match live and seems to be working, just did basic tests though.

Also noticed adding a new quest results in us sending the journal packet with all quests again, live just sends the packet with the new quest, so implemented that and it seem to work properly.

Re: Quests

Posted: Sun Jul 13, 2014 12:36 am
by Dello0000
Oh, that's good, i understood that lol, well done!

Re: Quests

Posted: Sun Jul 13, 2014 8:08 pm
by thefoof
Yeah, sorry for the delayed response. But, reloading at with 0 progress shouldn't hurt anything we've done, and not doing this removes some functionality. So I would definitely say go with reloading regardless of progress. We don't necessarily have to do the bit functions in LUA either (I haven't looked at your code for this). To make it simpler to read, we could just do flags 1-64 or whatever. Then get that variable in the server, and do quest_flags |= (1 << (lua_interface->GetInt8() - 1));

Just might make it easier for non programmers, because like you've said before bit math is hard to understand for the uninitiated. But we are initiated...aren't we bruce wayne.

Image

Re: Quests

Posted: Mon Jul 14, 2014 3:39 pm
by Jabantiz
A few examples that use this is The Wanderer's Three Meanings of Life (3 steps are random) and Hunting for Trapper Borgus (1 random step with random quantites), both are live on the server and function rather well. The main thing is I had to add a function to check the flags

Code: Select all

function hasflag(flags, flag)
	return flags % (2*flag) >= flag
end
To check a flag in the script would be

Code: Select all

local example_flag = 2
...
if hasflag(GetQuestFlags(Quest), example_flag) then
    Say(Player, "I have the example_flag")
end
Seems simple to me, mostly a bunch of checks for multiple flags which can't be avoided no matter how it is implemented, then again like you said I deal with it in c++ so we could change it to something simpler.


Also I finally figured out the bitmask for the quest display_status, should be able to implement everything, also figured out the timer but still debating how to best handle that, will probably have to add another field to the character_quest_progress field so the timer will persist through a zone and logging off.

Re: Quests

Posted: Sun Jul 20, 2014 7:44 pm
by Jabantiz
Identified the bitmask used for "display_status" and added support for the different values, basically it was just hidden quests and the check next to the quest name if it was tracked or not, hopefully the server will remember all the settings now.

I also added support for the quest timers and for a step to fail as well as 6 lua functions to support these features, info for these functions will be on the script forum tonight.