Quests in SugarCube

Twine Version: 2.3.16
Story Format: 2.36.1

I simply do not understand how to add quests. I have seen a few ‘answers’ from general browser searches on other sites, but I do not understand a word that they say. It is always phrased in a far too complicated manner for me to grasp. I suspect they might be forums for those all know more than I do.

However, every question I have asked here so far has been clear, concise and simple, so this is it…


My story is a mystery/adventure with adult themes. Initially the player must discover where their parents have gone, so this would be the first quest. Other quests will be added later as discoveries are made, new people are met etc, and added to a quest log.

I have created a passage called Quests to which I added this, (simply so it had some content):

<div id="questdiv" style="padding-left: 10px; color: black; background-image: url('img/bg/old paper.jpg');">''You currently have no quests''
</div>

In StoryCaption, I added this, thanks to @pbparjeter

<<link "Quests">>
<<script>>
Dialog.setup("Quests");
Dialog.wiki(Story.get("Quests").processText());
Dialog.open();
<</script>>
<</link>>

I can access this from the sidebar, as well as other tabs, and I believe this is good for the questlog passage, to store the quests, but that’s as far as my inexperience takes me.

From another game, I copied this to StoryInit, but as you can see, I turned it off, because it wasn’t part of the original code, and I didn’t fully understand it. But it looked like it might be useful (I try to collect useful code and adapt it where possible):

/*<<set $questdone to 'false'>>*/

I haven’t added anything yet like:

<<set $missingparents is true>>

although I believe bits like that will be needed as the story progresses, and as quests get ticked off.


So simply put, how do I make something into a quest, and how do I keep track of whether it is active, completed or failed? Also, there is no doubt I have missed some element to all this that will be necessary in this project, so please feel free to point out anything that I have missed.

There isn’t any built in way to make quests. The most straightforward way is just to hide links behind variables

For example, in the last page of your first quest

<<set $quest1 to "complete">>
<<set $missingparents to true>>

Then on your start page (or wherever)

<<link "Start Quest 1>><<goto "quest1">><<set $active_quest to "1">><</link>>
<<if $quest1 eq complete>><<link "Start Quest 2">><<goto "quest2">><<set $active_quest to 2>><<endif>>

This assumes that quests are linear chapters, though. If you have a different approach, things could get complicated fast, to say the least.

Edit: To elaborate a bit more, the goal is just to set different variables for different contexts. There are no hard and fast rules here, but

<<if $quest1 eq “complete”>> is used to open access to the next quest
<<if $active_quest eq “1”>> can be used in passages to display certain relevant text, hints, etc.
<<if $missingparents eq true>> can be used for anything else

1 Like

Though it is not working code, you should be aware of this rule

<<set $questdone to 'false'>>
should be
<<set $questdone to false>>.

Logical values such as true, false, numbers, etc. should not be in quotation marks…a full list of values is here.

Other values should go in quotation marks though.

2 Likes

I think quests as story variables. I would set any quest in my StoryInit passage

<<set $Quest1 to 0>>
<<set $Quest2 to 0>>
...

Under circumstances quests will progress.

<<set $Quest1 to 2>>

This will change future passages.

<<if $Quest2 == 0>>something happens
<<elseif $Quest == 1>>something else happens<</if>>

At some point the quest will reach its conclusions, success, or failure, you may want to give a different value if further needed, or even <<unset>> the variable altogether.

1 Like

If in StoryInit, I add

<<set $Quest1 to false>>
<<set $Quest2 to false>>
<<set $Quest3 to false>>
<<set $Quest4 to false>>
<<set $Quest5 to false>>

and in my Quests passage I add:

<<if $Quest1 is true>> "name of quest"<</if>>
<<if $Quest2 is true>> "name of quest"<</if>>
<<if $Quest3 is true>> "name of quest"<</if>>
<<if $Quest4 is true>> "name of quest"<</if>>
<<if $Quest5 is true>> "name of quest"<</if>>

This would give me a list of quests, even if it is simply a list, which would update as each quest gets activated by:

<<set $Quest1 to true>>

and if a quest is completed, could be removed from the list with another:

<<set $Quest1 to false>>

once more. This would give the player an active list that they could check.

Not perfect, not particularly eloquent, but it should work. Shouldn’t it? Can anyone see any potential issues with this?

1 Like

It looks good and solid, McFluff.

Just one thing:

<<if $Quest1>>

is a shortcut for

<<if $Quest1 is true>>

The less characters, the fewer the chances of a silly mistake!

2 Likes

For the Quest list you can use else so that there is unclickable text when false. For example

<<if $Quest1 is true>> [[Name of Quest]] <<else>> Name of Quest  <</if>>
1 Like

I dont know if this will help, but Ill try my best!

How I usually set a Quest System is the Following:
‘’’
StoryInit

<<set $quest = “”>>
<<set $quest1 = “Incomplete”>>
<<set $questInfo = “Quest Name”>>
<<set $questDescription = “Add Description here”>>
<<set $questProgress = “Current Progress”>>

‘’’
Once you have all of that Code set up, go into your Quest Section that you’ve set up and use the Following Code:

‘’’
Quest

<<if $quest eq “Quest Name” and $quest1 eq “Incomplete”>>
$questInfo

$questDescription
$questProgress

<>
‘’’

And After everything is set up, just set a Complete Objective and a set of Code that checks if $quest1 = “Complete”

[necro thread, but…]
It depends how you use your variables.

You can have $quest1 = true when active and false when not accepted or completed…

Or you can use a numerical scale:

<<set $quest1 = 0>>
And then determine for each quest something like if the variable is:
0 = The quest has not been discovered.
1 = The quest has been accepted but not completed.
2 = The quest has a new factor involved that updates its status.
3 = The quest is complete but the player hasn’t formally turned it in yet.
4 = Quest Completed

So in the quest log, you’d have something like (quests by default set to 0 don’t show and are a mystery…):
<<if $quest1 eq 1>>The baker asked you to find some flour.<<elseif $quest1 eq 2>>The flour mill has been raided by goblins! You'll need to seek out the cave to recover the stolen flour for the baker!<<elseif $quest1 eq 3>>You managed to invade the goblin cave and recover flour for the baker. Now you just need to get it back to the bakery.<elseif $quest1 eq 4>>COMPLETED: Baker's Quest. The baker will now supply you with free bread.<</if>>

So after the Baker tells their tale of woe, the $quest1 variable is set to 1. Discovering the mill sets it to 2. Obtaining the flour in the cave sets it to 3. Reporting to the Baker and getting the quest completed speech sets it to 4.

This has the advantage that you can use the quest markers to affect other things, such as in the Baker’s dialogue:

<<if $quest1 neq 4>>[[Buy some bread.|buybread]]<<else>>[[Hey Baker, can I have more free bread since I've completed your quest?|freebread]]<</if>>

The Array is a useful data-type when it comes to tracking things that can / have / haven’t occur(ed).

<<set $possible to ["visit-grandma", "make-lunch"]>>
<<set $doing to []>>
<<set $done to []>>

Can I visit Grandma? <<if $possible.includes("visit-grandma")>>YES<<else>>NO<</if>>

Am I currently visiting Grandma? <<if $doing.includes("visit-grandma")>>YES<<else>>NO<</if>>

/* Decided to visit Grandma */
<<run $possible.delete("visit-grandma"); $doing.push("visit-grandma");>>

Have I finished visiting Grandma? <<if $done.includes("visit-grandma")>>YES<<else>>NO<</if>>

/* Finish visiting Grandma */
<<run $doing.delete("visit-grandma"); $done.push("visit-grandma")>>

Did I visit Grandma? <<if $done.includes("visit-grandma")>>YES<<else>>NO<</if>>

How you use the Array is up to you.