Quest Script readable by mere mortals?

For all talk about quests. Creating, testing, bugs, and development progress.
User avatar
JorisVanEijden
Posts: 64
Joined: Mon Aug 12, 2019 5:02 pm

Re: Quest Script readable by mere mortals?

Post by JorisVanEijden » Sun Sep 22, 2019 6:43 pm

BansheeXYZ wrote:
Sun Sep 22, 2019 3:28 pm
I like how terminology changes between sections. Clock becomes timer... Person becomes npc...
I hate it. Since there is is no source code for daggerfall available a lot of different people have worked on figuring stuff out about it and they used different words for the same things and the same words for different things. There have also been mistakes made along they way and there is still quite a bit unknown.
BansheeXYZ wrote:
Sun Sep 22, 2019 3:28 pm
and what's with this "start up task" in A0C01Y01?
A "start up task" is identical to any other task, except it doesn't have a name and it always runs.
BansheeXYZ wrote:
Sun Sep 22, 2019 3:28 pm
Translated:

Code: Select all

If player goes inside this place WELL AFTER THE QUEST HAS STARTED, start this nameless task and mark as completed, which if you scroll down, is a single action to say something that can't directly go here for some reason.
That is not a very good translation.
Better would be: "Set up a trigger that sets state _S.05_ to TRUE whenever the player enters this location"

The original daggerfall code for that "action" is:

Code: Select all

0000002B000000030000FF0900000900FFFFFFFFF244000600050900000900050000000E000000000004000004000000000000C8F2440041CB430003C14300000000001277430000000000000000000000008B02F5036F
and my interpretation is

Code: Select all

opCode : 43
argCount : 3
arguments:
  0: _
    type : State
    value : -1
    not : False
    index : 255
    unknown1 : 100680946 [0x060044F2]
  1: s_000033d7
    type : State
    value : 5
    not : False
    index : 5
    unknown1 : 14 [0x0000000E]
  2: l_qgiverhome
    type : Location
    value : 0
    not : False
    index : 0
    unknown1 : 1156761600 [0x44F2C800]
messageId : 1013
flags : 0 [0x0000]
lastUpdate : 111
from which I arrive at this decompilation:

Code: Select all

WhenAtLocation (l_qgiverhome): set s_000033d7 [Msg 1013]
and Tipton's decompilation is

Code: Select all

pc at _qgiverhome_ do _S.05_ saying 1013
BansheeXYZ wrote:
Sun Sep 22, 2019 3:28 pm
In other words, I don't get why a conditional thing is in the start-up section, or why a message has to act as a trigger for the spawn code instead of what the game should already know directly (whether the player is inside or outside of a predefined place).
Maybe if you had read the pages I linked you you would have a better idea of where this came from.

There's some things in Tipton's Template decompiler that can be hard to grasp.
He merged all opcodes together that depended on the same state, he merged some opcodes together and split others apart.
For reference, this is a representation of that quest in a format a lot closer to what the actual daggerfall classic engine uses:

Code: Select all

>> StartTimer (t_000343a8); When it expires: set s_000343a8
=> EnsureNpcLocation (l_qgiverhome)
>> IfTimeOfDayBetween (21:00:00, 1.00:00:00): set s_0000d703
>> WhenAtLocation (l_qgiverhome): set s_000033d7 [Msg 1013]
>> If (s_000033d7 and s_0000d703): set s_00068f54
if s_00068f54 => CreateFoe(m_00006f7b, 10, 25%, 1)
>> IfMobsKilled (m_00006f7b, 2): set s_0006fd8a
if s_0000d703 => PlaceNpcAt (n_qgiver, l_qgiverhome)
>> IfMobHurtByPlayer (m_00006f7b): set s_0001aa84 [Msg 1011]
>> IfNpcClicked (n_qgiver): set s_0000d194
>> If (s_0000d194 and s_0006fd8a): set s_questdone
>> If (not s_0006fd8a and s_0000d194): set s_clearclick
if s_clearclick => Unset (s_0000d194, s_clearclick)
if s_questdone => QuestSuccess (i_gold)
>> If (s_questdone and not s_000033d7): set s_0000064e
if s_0000064e => EndQuest ()
if s_000343a8 => EndQuest ()
=> CreateLogEntry (1010, 0)
There are no "tasks" and "actions" in there. Only "states", also know as "flags" (in my example denoted with a "s_" prefix).
The engine runs through this whole stack on every tick.
Every line is a command and all of them are always run, except the ones with an if s_tate in front of them, those only run when that flag is set to TRUE.
Some commands only run once (like StartTime and CreateLogEntry), others all the time.

Because this format is hard to read Tipton created a decompiler that created a much more readable output and he called it Template.
Template became used by many modders and questwriters and so was a logical choice for DFU to implement.
The current questmachine that runs on this has has hundreds of hours of writing and testing and bugfixing done on it.
It is not going to be rewritten or replaced.

I get that you don't understand a lot of things, but the solution is not to complain about that here, but to educate yourself. It took me just a few hours of reading to get to the bottom of this.

So unless you create a script language that compiles to Template or you have an addition that is well thought out and requires no rewriting of any existing quest, there is not much sense in complaining here.
I also really really want a better quest writing script. And trust me, writing a tool that translates to Template is by far the easiest solution. So if you want to help, please come up with a readable script and a way to translate it to Template. If you're not a coder I or someone else can do the implementation for you.

BansheeXYZ
Posts: 508
Joined: Fri Oct 23, 2015 8:19 pm

Re: Quest Script readable by mere mortals?

Post by BansheeXYZ » Mon Sep 23, 2019 8:14 am

JorisVanEijden wrote:
Sun Sep 22, 2019 6:43 pm
I hate it.
Yeah I was being sarcastic. I obviously find it strange.
A "start up task" is identical to any other task, except it doesn't have a name and it always runs.
I know they're the same functionally. But up to this point, I've only seen that area used to run tasks that needed to be performed immediately. To me, there's no logical reason for a condition to be in this area, unless there's some shortcoming in the format.
requires no rewriting of any existing quest, there is not much sense in complaining here.
I also really really want a better quest writing script. And trust me, writing a tool that translates to Template is by far the easiest solution. So if you want to help, please come up with a readable script and a way to translate it to Template. If you're not a coder I or someone else can do the implementation for you.
What I'd do to flesh out a new format is to rewrite most quest files. Documentation is nice, but implementation can do things you don't expect, so I would honestly prefer doing it that way myself. It's clear that Tipton's main goal wasn't to facilitate new quest creation, he was just trying to patch bugs here and there, so it's understandable that it kind of sucks.

I'm going to try converting an entire guild's quests over to my format, just to see how long it takes.

User avatar
JorisVanEijden
Posts: 64
Joined: Mon Aug 12, 2019 5:02 pm

Re: Quest Script readable by mere mortals?

Post by JorisVanEijden » Mon Sep 23, 2019 12:11 pm

BansheeXYZ wrote:
Mon Sep 23, 2019 8:14 am
I'm going to try converting an entire guild's quests over to my format, just to see how long it takes.
Doesn't really matter how long it takes.
Rewriting the current QuestMachine to parse your format would take hundreds of hours of building, testing and fixing.
That is not going to happen.

But I guess if it helps you come up with good ways to convert your script to Template, then that would be helpful.

Post Reply