Player Sequencor After Alert
Player Sequencor After Alert
So I have some dialogue set up where the last node prompts an alert and also plays an Adventure Creator cutscene through the sequence command AC(MyCutscene); Is there any way to have that cutscene player AFTER an alert has either been dismissed or goes away on it's own? Currently I have the code in there to dismiss an alert on click and it's timer is set to 5 second should you not click. Is that all possible?
Player Sequencor After Alert
Hi,
You could create a subclass of your dialogue UI class (e.g., UnityUIDialogueUI) and override the HideAlert() method:
public override void HideAlert() {
base.HideAlert();
var sequence = DialogueLua.GetVariable("PostAlertSequence").AsString;
if (!string.IsNullOrEmpty(sequence)) {
DialogueManager.PlaySequence(sequence);
DialogueLua.SetVariable("PostAlertSequence", string.Empty);
}
}
In your last node, remove "AC(MyCutscene)" from the Sequence field. Instead, set the Script field to something like:
Variable[Alert] = "This is my alert.";
Variable[PostAlertSequence] = "AC(MySequence)"
What this does:
1. The last node sets a Lua variable ("PostAlertSequence").
2. When the dialogue UI hides the alert, it checks this Lua variable and runs it as a sequence.
You could create a subclass of your dialogue UI class (e.g., UnityUIDialogueUI) and override the HideAlert() method:
public override void HideAlert() {
base.HideAlert();
var sequence = DialogueLua.GetVariable("PostAlertSequence").AsString;
if (!string.IsNullOrEmpty(sequence)) {
DialogueManager.PlaySequence(sequence);
DialogueLua.SetVariable("PostAlertSequence", string.Empty);
}
}
In your last node, remove "AC(MyCutscene)" from the Sequence field. Instead, set the Script field to something like:
Variable[Alert] = "This is my alert.";
Variable[PostAlertSequence] = "AC(MySequence)"
What this does:
1. The last node sets a Lua variable ("PostAlertSequence").
2. When the dialogue UI hides the alert, it checks this Lua variable and runs it as a sequence.
Player Sequencor After Alert
Looks great Tony. I will definitely give that a try tomorrow. Additionally, is it possible to somehow access the Quest database variables through code?
I'm currently testing my game with over 20 quests and I would like to just create a custom AC Action that runs on start that allows my to skip to Quest X. Ideally I would set all the appropriate variables in AC to their values as if they were on that quest, but additionally to control the dialogue I would need to set the Quest variables to the appropriate values.
Example:
I want to skip to Quest 3.
Custom action loops through all variables in Quest 1 and 2 and sets the appropriately.
Custom action goes through Quest 1 and 2 States and Entry States and sets them to success (or their appropriate value).
Thanks again for all your help. The game is turning out great with DS thus far!
I'm currently testing my game with over 20 quests and I would like to just create a custom AC Action that runs on start that allows my to skip to Quest X. Ideally I would set all the appropriate variables in AC to their values as if they were on that quest, but additionally to control the dialogue I would need to set the Quest variables to the appropriate values.
Example:
I want to skip to Quest 3.
Custom action loops through all variables in Quest 1 and 2 and sets the appropriately.
Custom action goes through Quest 1 and 2 States and Entry States and sets them to success (or their appropriate value).
Thanks again for all your help. The game is turning out great with DS thus far!
Player Sequencor After Alert
I'm really glad the Dialogue System is helping out your game!
Someone just asked a question similar to yours on the Unity forum thread, so I'm going to be lazy and repost here:
The easiest way to work with quests in code is the QuestLog static class. It uses an enum QuestState:
// Activate a quest:
if (QuestLog.GetQuestState("My Quest") == QuestState.Unassigned) {
QuestLog.SetQuestState("My Quest", QuestState.Active);
}
Under the hood, the Dialogue System uses Lua to track runtime quest states. The Lua table Quest[] contains subtables, one per quest. Each subtable contains an index "State" -- for example: Quest[My_Quest].State. Lua doesn't do enums, so State is a string:
Quest[My_Quest].State = "active"
One other peculiarity: The Dialogue System uses the data model defined in Urban Brain's Chat Mapper. Chat Mapper replaces space characters with underscores in indices. If you end up digging into Lua this deep, you'll want to read the sections Important Note About Table Indices and Lua Examples (which includes a short table of syntax differences between Lua and C#).
The QuestLog class doesn't provide special methods for custom variables, so in C#/UnityScript you'll need to use the somewhat lower-level DialogueLua class. For example, say you've defined a custom field named "XP Reward":
// Get the quest's XP reward:
var xpReward = DialogueLua.GetQuestField("My Quest", "XP Reward").AsInt;
Or in Lua:
Variable[Alert] = Quest[My_Quest].XP_Reward .. " XP gained!"
If that doesn't answer your question, please let me know.
Someone just asked a question similar to yours on the Unity forum thread, so I'm going to be lazy and repost here:
The easiest way to work with quests in code is the QuestLog static class. It uses an enum QuestState:
// Activate a quest:
if (QuestLog.GetQuestState("My Quest") == QuestState.Unassigned) {
QuestLog.SetQuestState("My Quest", QuestState.Active);
}
Under the hood, the Dialogue System uses Lua to track runtime quest states. The Lua table Quest[] contains subtables, one per quest. Each subtable contains an index "State" -- for example: Quest[My_Quest].State. Lua doesn't do enums, so State is a string:
Quest[My_Quest].State = "active"
One other peculiarity: The Dialogue System uses the data model defined in Urban Brain's Chat Mapper. Chat Mapper replaces space characters with underscores in indices. If you end up digging into Lua this deep, you'll want to read the sections Important Note About Table Indices and Lua Examples (which includes a short table of syntax differences between Lua and C#).
The QuestLog class doesn't provide special methods for custom variables, so in C#/UnityScript you'll need to use the somewhat lower-level DialogueLua class. For example, say you've defined a custom field named "XP Reward":
// Get the quest's XP reward:
var xpReward = DialogueLua.GetQuestField("My Quest", "XP Reward").AsInt;
Or in Lua:
Variable[Alert] = Quest[My_Quest].XP_Reward .. " XP gained!"
If that doesn't answer your question, please let me know.
Player Sequencor After Alert
Tony,
So I used
QuestLog.GetAllQuests(QuestState.Unassigned);
And it returns an array of all my quests, which is great! However they are a sorted list! I was really hoping to get them in order of what they were in the database (by ID perhaps). Is there another way I can grab all the quests in the order that I have placed them in? Do you suggest another way to get quests in order that they appear in the game?
So I used
QuestLog.GetAllQuests(QuestState.Unassigned);
And it returns an array of all my quests, which is great! However they are a sorted list! I was really hoping to get them in order of what they were in the database (by ID perhaps). Is there another way I can grab all the quests in the order that I have placed them in? Do you suggest another way to get quests in order that they appear in the game?
Player Sequencor After Alert
So I dug around a bit and I came across the source access to the Quest Log class. I simply commented out the line that sorts the array. I'm not sure if that functionality is there for a specific reason, but I suppose I'll find out when I test the quests.
Additionally if it is not there for any specific reason perhaps it could be a good idea to leave sorting up to the user if they prefer the array sorted as it is more difficult to unsort the list then it is to sort it. Just a suggestion!
Additionally if it is not there for any specific reason perhaps it could be a good idea to leave sorting up to the user if they prefer the array sorted as it is more difficult to unsort the list then it is to sort it. Just a suggestion!
Player Sequencor After Alert
Suggestion taken! The next version (scheduled for early next week), will have an optional parameter to control sorting. (Sorting was added in v1.3.4 by customer request.)
Player Sequencor After Alert
Tony,
Awesome! So previously I asked if it's possible to play a AC Cutscene Sequencor after the alert. Is it possible to have the sequencor play after the line of dialogue ends? Would that be the same principle as what you showed me before but instead the logic handled in the HideSubtitle override function?
Awesome! So previously I asked if it's possible to play a AC Cutscene Sequencor after the alert. Is it possible to have the sequencor play after the line of dialogue ends? Would that be the same principle as what you showed me before but instead the logic handled in the HideSubtitle override function?
Player Sequencor After Alert
Hi,
Yes, you can handle it in HideSubtitle(), but there's an easier way. You don't need to touch any scripts or make any subclasses. Just set your Sequence field to something like:
required AC(MySequence, nowait)@{{end}}
The "{{end}}" keyword runs the AC() command at the end of the wait period. The "required" keyword ensures that it runs even if the player clicks continue and doesn't get to the end of the regular wait period. The "nowait" parameter starts the AC cutscene and lets it run without waiting for it to finish.
Yes, you can handle it in HideSubtitle(), but there's an easier way. You don't need to touch any scripts or make any subclasses. Just set your Sequence field to something like:
required AC(MySequence, nowait)@{{end}}
The "{{end}}" keyword runs the AC() command at the end of the wait period. The "required" keyword ensures that it runs even if the player clicks continue and doesn't get to the end of the regular wait period. The "nowait" parameter starts the AC cutscene and lets it run without waiting for it to finish.
Player Sequencor After Alert
Awesome! That worked! Although I am bit confused about how this works.
So you said the {{end}} keyword runs at the end of the wait period. In this scenario, is the end of the wait period when the player clicks continue to continue/end the conversation? Also the required makes it run presumably even if the player attempts to skip past the dialogue by maybe clicking fast?
Also nowait makes the cutscene run without waiting for it to finish. So say I had another cutscene run right after I would simply switch nowait to wait in order for the second cutscene to wait for the first one to finish?
So you said the {{end}} keyword runs at the end of the wait period. In this scenario, is the end of the wait period when the player clicks continue to continue/end the conversation? Also the required makes it run presumably even if the player attempts to skip past the dialogue by maybe clicking fast?
Also nowait makes the cutscene run without waiting for it to finish. So say I had another cutscene run right after I would simply switch nowait to wait in order for the second cutscene to wait for the first one to finish?