Page 3 of 3
Re: Player Sequencor After Alert
Posted: Wed Jun 10, 2015 11:18 am
by Tony Li
Hi,
I'll take a look at this and reply later today. I'll try to post instructions for how to keep it in the Dialogue state during alerts. If that doesn't work out, I'll post instructions for opening an invisible dummy AC menu during alerts that blocks input to AC.
What version of AC are you using? I ran basic functionality tests with the newly-released AC 1.46, and the Dialogue System integration seems to be fine, but I haven't exhaustively tested all menu and input combinations.
Re: Player Sequencor After Alert
Posted: Wed Jun 10, 2015 11:28 am
by Rocco
We are using V1.45. The other thing that I thought was what if in the custom action instead of returning 0.0 we don't kill the action until the alert has been dismissed.
Re: Player Sequencor After Alert
Posted: Wed Jun 10, 2015 11:19 pm
by Tony Li
Alright, it took some digging into Adventure Creator, but this customized subclass of UnityUIDialogueUI seems to work reliably. It makes AC think it's running an AC conversation while the alert is visible.
Code: Select all
using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem.AdventureCreator;
namespace PixelCrushers.DialogueSystem {
public class MySpecialUnityUIDialogueUI : UnityUIDialogueUI {
private AC.Conversation dummyConversation;
public override void Start() {
base.Start();
dummyConversation = gameObject.AddComponent<AC.Conversation>();
}
public override void ShowAlert(string message, float duration) {
SetDialogState();
base.ShowAlert(message, duration);
}
public override void HideAlert() {
base.HideAlert();
StartCoroutine(UnsetDialogStateCoroutine());
}
public void SetDialogState() {
AC.KickStarter.stateHandler.gameState = AC.GameState.DialogOptions;
AC.KickStarter.playerInput.activeConversation = dummyConversation;
}
public IEnumerator UnsetDialogStateCoroutine() {
yield return null; // Wait 1 frame so AC doesn't also handle the click.
AC.KickStarter.playerInput.activeConversation = null;
AC.KickStarter.stateHandler.gameState = AC.GameState.Normal;
}
}
}
Sorry about the lack of syntax highlighting. I'll install a mod next week that should highlight syntax in code blocks.
Re: Player Sequencor After Alert
Posted: Fri Jun 12, 2015 6:26 pm
by Rocco
This worked like a charm! Funny enough, I was very close to the solution. I basically had your implementation but the part I didn't get around to figuring out was the dummy conversation. Nice trick Tony.
With a couple extra tweaks I was able to get it working to what we need!
Re: Player Sequencor After Alert
Posted: Fri Jun 12, 2015 9:43 pm
by Tony Li
Great! Any extra tweaks that I should be aware of for other people who are using the Dialogue System with Adventure Creator?
Re: Player Sequencor After Alert
Posted: Sat Jun 13, 2015 11:04 am
by Rocco
Tony,
Unfortunately I am not at work right now to check the extra tweaks we made but off the top of my head here's what I remember. (We are actually still in the process of fixing some stuff).
So switching the game state back to Normal works just fine if the Alert is always the LAST thing shown after dialogue or simply the only thing shown period. However in a situation where the Alert is shown MID dialogue then it breaks the conversation state. Another scenario was when an alert leads into a cut scene using the Post Alert Sequence variable we spoke about earlier. Unfortunately the cut scene or follow up dialogue states get cut off and the game resumes to Normal state.
Playing alerts during cut scenes also breaks cut scenes simple because we switch the state back. We are in the process of restructuring where our alerts pop up anyway in order to make some more sense for the game itself. After that we are going to evaluate any extra changes we need to make the code regarding state swapping for alerts.
Re: Player Sequencor After Alert
Posted: Sat Jun 13, 2015 2:49 pm
by Tony Li
My initial version of the script saved the game state in ShowAlert and restored the saved game state in HideAlert. I took it out for clarity, but it might be helpful in your situation to put that back in.
Re: Player Sequencor After Alert
Posted: Mon Jun 15, 2015 3:21 pm
by Rocco
I was doing something similar as well. I cached the AC Game State prior to changing it and then restored it to that state as opposed to GameState.Normal. The only problem with that was something like the following example.
A cutscene prompts a conversation with an Action. State is cached as GameState.DialogOptions. Alert pops up, changes state to DialogOptions if not already. If the alert is the last thing that shows you would want to go back to GameState.Normal in this case. However it would return to DialogOptions which would get the player stuck.
This also happens when playing alerts from Cutscenes and them being the last thing that happens. You get stuck in Cutscene mode. The solution really depends on when and where you pop up an alert.
Re: Player Sequencor After Alert
Posted: Mon Jun 15, 2015 3:39 pm
by Tony Li
Sounds like you have a handle on it. I've added this to my list to look at. If I can implement a tidy way to handle the different situations, I'll include it in the AC support package and let you know.
Re: Player Sequencor After Alert
Posted: Tue Jun 16, 2015 9:30 am
by Rocco
Sounds great. After some back and forth with my co-worker we have come up with a very rough implementation. It is fairly messy and could definitely use some more polish. If you do get around to it in the near future I would love to hear what your solution was. Thanks for all the help.