To see this problem in action, accept quests from the Fighters Guild then immediately speak to the quest giver once again. Many of their scripts will immediately give player a reward, even though you haven't moved from the spot. Not all quests have this problem, but many of the Fighters Guild quests do experience it.
So I thought I'd put together a quick tutorial on how to properly script quest completion. Let's start with an example of a bad quest script from M0B00Y06.
Code: Select all
clicked npc _qgiver_
give pc _gold_
when _S.02_ and not _S.01_
clear _S.02_ _clearclick_
The error is happening in S.02, which has a single trigger condition "clicked npc _qgiver_". The moment you click on the quest giver, this task will be executed whether you've completed the quest or not.
You'll note there's a _clearclick_ task which is supposed to be checking for quest completion and clearing the click, but it doesn't matter because S.02 has already been executed.
Here's the correct way to script a quest ending, from CUSTOM01.
Code: Select all
clicked npc _questgiver_
when _questorClicked_ and not _necromancerDead_
clear _questorClicked_ _clearclick_
when _questorClicked_ and _necromancerDead_
give pc _reward_
There are three parts to this:
- _questorClicked_ task picks up the click on quest giver.
- _clearclick_ task checks the quest ending condition(s) and clears both _questorClicked_ and itself when quest not completed.
- _rewardPlayer_ task will check both _questorClicked_ and quest ending condition(s) and only then gives player their reward and end quest.
All of these parts are important. If you didn't clear the click in step 2, player would get the reward as soon as the necromancer was killed later, instead of when returning to quest giver. If you don't separate out the click check and the reward process, then both of these things happen at the same time. If _clearclick_ doesn't also clear itself, then it won't be rearmed for next time.
Many of these quest scripts will need to be fixed eventually. Fortunately this is an easier job now everything is in plain text and people can send a PR.
For now though, I'm happy to have the same bugs as classic Daggerfall because these problems actually help me confirm my quest engine is properly emulating classic - because the same bad script behaviours are present in both.