Resetting variables to a different initial state than the one they originally had in a save file
Posted: Mon Sep 30, 2024 2:13 pm
[Unity 2021.3.42f1 - Articy v2 - AC v1.81.6 - DS v2.2.46.1]
Hi Tony,
To cater for the lack of string support in Articy v2 variables, I have been using ints with verbose names to track the quest progress in the game I'm working on.
As an example imagine a quest, "Open The Door", where the steps are to first find the key then open the door and leave.
I would lay it out in Articy like so:
q_OpenTheDoor.progress = -1 (this meaning the quest still has to start)
q_OpenTheDoor.START = 0
q_OpenTheDoor.GOT_KEY = 1
q_OpenTheDoor.LEFT_ROOM = 2
Then, when in DS I want to start specific conversations \ lines for specific quest states, I would write my conditions in Articy like so:
q_OpenTheDoor.progress == q_OpenTheDoor.GOT_KEY ---> "Nice! I wonder if this is the key to the door"
q_OpenTheDoor.progress == q_OpenTheDoor.LEFT_ROOM ---> "Ah, fresh air!"
and if the progress is different from any of the above ---> "I have to get out of here"
Now imagine the following procedure:
- I start this quest, progress correctly advances to the same value as q_OpenTheDoor.START
- I get the key, progress correctly advances to the same value as q_OpenTheDoor.GOT_KEY
- I save and exit. q_OpenTheDoor.progress value is correctly set to the same value as q_OpenTheDoor.GOT_KEY
- I get back in Articy and swap the values of q_OpenTheDoor.GOT_KEY and q_OpenTheDoor.LEFT_ROOM
- I write a small script that updates q_OpenTheDoor.GOT_KEY and q_OpenTheDoor.LEFT_ROOM to their *new* initial value, after restoring a previous save file:
- Reimport the Articy project into the game
When I run the game again I find out that everything is correct:
- q_OpenTheDoor.GOT_KEY is now set to 2
- q_OpenTheDoor.LEFT_ROOM is now set to 1
- q_OpenTheDoor.progress is still set to 1
But, when I play the conversation that checks for the q_OpenTheDoor.progress value I get the "I have to get out of here" response, even if the variables are correctly showing the correct values.
My question is, am I doing something wrong?
I hope I made everything clear! I'm considering this as a way to patch our game after launch if needed, and without breaking save games for our players.
Thanks a lot as always!
Hi Tony,
To cater for the lack of string support in Articy v2 variables, I have been using ints with verbose names to track the quest progress in the game I'm working on.
As an example imagine a quest, "Open The Door", where the steps are to first find the key then open the door and leave.
I would lay it out in Articy like so:
q_OpenTheDoor.progress = -1 (this meaning the quest still has to start)
q_OpenTheDoor.START = 0
q_OpenTheDoor.GOT_KEY = 1
q_OpenTheDoor.LEFT_ROOM = 2
Then, when in DS I want to start specific conversations \ lines for specific quest states, I would write my conditions in Articy like so:
q_OpenTheDoor.progress == q_OpenTheDoor.GOT_KEY ---> "Nice! I wonder if this is the key to the door"
q_OpenTheDoor.progress == q_OpenTheDoor.LEFT_ROOM ---> "Ah, fresh air!"
and if the progress is different from any of the above ---> "I have to get out of here"
Now imagine the following procedure:
- I start this quest, progress correctly advances to the same value as q_OpenTheDoor.START
- I get the key, progress correctly advances to the same value as q_OpenTheDoor.GOT_KEY
- I save and exit. q_OpenTheDoor.progress value is correctly set to the same value as q_OpenTheDoor.GOT_KEY
- I get back in Articy and swap the values of q_OpenTheDoor.GOT_KEY and q_OpenTheDoor.LEFT_ROOM
- I write a small script that updates q_OpenTheDoor.GOT_KEY and q_OpenTheDoor.LEFT_ROOM to their *new* initial value, after restoring a previous save file:
Code: Select all
string initialValue = DialogueManager.MasterDatabase.GetVariable("q_OpenTheDoor.GOT_KEY").InitialValue;
int currentValue = DialogueLua.GetVariable("q_OpenTheDoor.GOT_KEY").asInt;
DialogueLua.SetVariable("q_OpenTheDoor.GOT_KEY", initialValue);
initialValue = DialogueManager.MasterDatabase.GetVariable("q_OpenTheDoor.LEFT_ROOM").InitialValue;
currentValue = DialogueLua.GetVariable("q_OpenTheDoor.LEFT_ROOM").asInt;
DialogueLua.SetVariable("q_OpenTheDoor.LEFT_ROOM", initialValue);
When I run the game again I find out that everything is correct:
- q_OpenTheDoor.GOT_KEY is now set to 2
- q_OpenTheDoor.LEFT_ROOM is now set to 1
- q_OpenTheDoor.progress is still set to 1
But, when I play the conversation that checks for the q_OpenTheDoor.progress value I get the "I have to get out of here" response, even if the variables are correctly showing the correct values.
My question is, am I doing something wrong?
I hope I made everything clear! I'm considering this as a way to patch our game after launch if needed, and without breaking save games for our players.
Thanks a lot as always!