Global Quest Variables

For all talk about quest development - creation, testing, and quest system.
Post Reply
User avatar
Kamer
Posts: 583
Joined: Mon Mar 05, 2018 9:26 pm

Global Quest Variables

Post by Kamer »

Are these available to use?

"The main quest uses 0-4, 6-9, 11-14, 16-18, 21, 23, 25, 28-29, 31, 33, 36, and 42-43 for global task numbers.
Presumably the residual numbers 5, 10, 15, 19, 20, 22, 24, 26, 27, 30, 32, 34, 35, 37-41 can be used by any quests you choose to create.

There are, in fact, 64 global variables."


That's what it talks about on the questing-source-docs. I tested it out and can't seem to get it to work. I just recently wanted to give them a go to see how they would work.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Global Quest Variables

Post by Interkarma »

There are 64 global variables in total. They can hold a state of either true/false. You can see these in the quest debugger on the right-hand side.

To set a global variable from quest system, use a variable mapping then set it. Here's a condensed example from _BRISIEN.

Code: Select all

MetLadyBrisienna _S.06_		// Declare mapping
start task _S.06_		// Sets the global var
The name of each global var are found in Quests-GlobalVars.txt table. I'll post here for convenience.

Code: Select all

-- There are a total of 64 global variables
-- Classic saves store global state in SAVEVARS.DAT
-- Known globals have strings matching output from Template 1.11

schema: id,*name

0,	LiftedCurse
1,	GothrydGotTotem
2,	KingOfWormsGotTotem
3,	GortwogGotTotem	
4,	AkorithiGotTotem
5,	Unused1
6,	UnderkingGotTotem
7,	EadwyreGotTotem
8,	BrisiennaGotTotem
9,	MedoraGotHorn
10,	Unused2
11,	GothrydEnding
12,	KingOfWormsEnding
13,	GortwogEnding
14,	AkorithiEnding
15,	Unused3
16,	UnderkingEnding
17,	EadwyreEnding
18,	BrisiennaEnding
19,	Unused4
20,	Unused5
21,	UnknownElysanna
22,	Unused6
23,	MorgiahSatisfied
24,	Unused7
25,	ElysannaSatisfied
26,	Unused8
27,	Unused9
28,	BarenziahSatisfied
29,	MyniseraSatisfied
30,	Unused10
31,	MetLadyBrisienna
32,	Unused11
33,	KingOfWormsSatisfied
34,	Unused12
35,	Unused13
36,	FinishedMantellanCrux
37,	Unused14
38,	Unused15
39,	Unused16
40,	Unused17
41,	Unused18
42,	UnknownHelseth
43,	LysandusSatisfied
44,	Unused19
45,	Unused20
46,	Unused21
47,	Unused22
48,	Unused23
49,	Unused24
50,	Unused25
51,	Unused26
52,	Unused27
53,	Unused28
54,	Unused29
55,	Unused30
56,	Unused31
57,	Unused32
58,	Unused33
59,	Unused34
60,	Unused35
61,	Unused36
62,	Unused37
63,	Unused38

-- Reused by Werefall

5,	TookTheCure
10,	OpenedShapeshifters
You can use any of the Unused# global vars for your own quests to coordinate shared state. The only time this might be an issue is if another quest author uses the same global var in their quests. So probably best to use them sparingly if possible.

Something I've considered is adding an secondary expanded quest variable system for better persistence of state between quests that won't have this limitation. But I'm not sure if I'll get to this any time soon.

User avatar
Kamer
Posts: 583
Joined: Mon Mar 05, 2018 9:26 pm

Re: Global Quest Variables

Post by Kamer »

I've already tried this method and it doesn't seem to work. What am I missing here? How do you set this up? I've been talking to Jay about it yesterday and I've been tying to get it to work for about 3 days straight. So I'm gonna break down what I'm doing into the simplest possible form in order to understand it. This is what I have for this particular example, whats wrong with it?
Spoiler!
Quest: Global Variable Example-1
-- Message panels
QRC:

QuestorOffer: [1000]

RefuseQuest: [1001]
<ce>

AcceptQuest: [1002]
<ce>

QuestFail: [1003]
<ce>

QuestComplete: [1004]
<ce>

Message: 1000
<ce> It works.

QBN:

-- Quest start-up:

Unused11 _S.32_

--------------------------------------------------------------------------


Quest: Global Variable Example-2
-- Message panels
QRC:

QuestorOffer: [1000]

RefuseQuest: [1001]
<ce>

AcceptQuest: [1002]
<ce>

QuestFail: [1003]
<ce>

QuestComplete: [1004]
<ce>

QBN:

-- Quest start-up:


_atCity_ task:
when pc enters city
start task _S.32_








User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Global Quest Variables

Post by Interkarma »

Your first quest is just doing the mapping and nothing else. Here's the simplest possible example:

Quest "GVAR01.txt"

Code: Select all

Quest: GVAR01
-- Message panels
QRC:

QBN:

--	Quest start-up:
-- This is where the task is started - but you can start from any other condition
start task _S.32_

-- This is where the var mapping is declared for this quest
Unused11 _S.32_
Quest "GVAR02.txt"

Code: Select all

Quest: GVAR02
-- Message panels
QRC:

Message: 1000
<ce> It works.

QBN:

--	Quest start-up:

-- Task to display success message based on shared mapping
when _S.32_
say 1000

-- This is where the var mapping is declared for this quest
Unused11 _S.32_
Save these to .txt files in your Quests folder and execute like so:
  1. startquest gvar02 (this will start watching the global var mapping for true state)
  2. startquest gvar01 (this actually sets the global var mapping to true)
If you have the quest debugger open, you'll see that Unused11 has become green (true).

User avatar
Kamer
Posts: 583
Joined: Mon Mar 05, 2018 9:26 pm

Re: Global Quest Variables

Post by Kamer »

I see, so Unused11 _S.32_ has to be placed in both quests so they recognize each other?

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Global Quest Variables

Post by Interkarma »

You got it. :) What it's doing is linking the global variable "Unused11" to a local variable "_S.32_" the local quest can interface with. Then anytime the local quest checks/sets/clears the local variable it will replicate to or from global.

User avatar
Jay_H
Posts: 4062
Joined: Tue Aug 25, 2015 1:54 am
Contact:

Re: Global Quest Variables

Post by Jay_H »

Hmm... The MQ backbone is permanent but not all our quests need to be. I'm wondering if it would be possible to recycle some global variables on a long-term chain if some only matter early on and others only matter later on.

Post Reply