Hey,
I'm trying to figure out what's the best way to code a background conversation for two characters, like we did with Abbie and The Watcher in the forest of Pizza Morgana Episode 1.
My current architechture includes using a deamon script that runs in the background.
This sort of works in my Episode 2 code, up until when i try to change scenes, and it causes WME to crash (i susptect because two scripts might be calling the same entity's talk function while one is already running, i don't know why it causes WME to crash, though, i'll also mention that the talk function is overriden because of our baloon system, which might cause the crash)
The method is as follows (slight Episode2 spoilres included) :
Create a script called TinyTalkConvDaemon :
#include "scripts\base.inc"
on "StartDaemon"
{
Sleep(2000); // sleep for safely
TalkCycle();
}
method TalkCycle()
{
var TalkCount = 1;
while (GameState.AngryWatcherStage < 6) {
if (Scene.Name != "DoubleDep") // quit daemon if we're not in the scene.
return;
Sleep(1500);
// can we talk? if not wait until we can.
while (!CanTalk()) {
Sleep(2000);
}
// altrenate between the two characters's lines.
if (TalkCount % 2 == 0) {
//Watcher1.TurnTo(ClerkConvince);
Watcher1.TinyTalk("/DIALOG_DOUBLEDEP_TINYTALK_WATCHER1_CLERKCONVINCE_0" + TalkCount + "/MISSING TEXT DIALOG_DOUBLEDEP_TINYTALK_WATCHER1_CLERKCONVINCE_0" + TalkCount);
} else {
//ClerkConvince.TurnTo(Watcher1);
ClerkConvince.TinyTalk("/DIALOG_DOUBLEDEP_TINYTALK_CLERKCONVINCE_WATCHER1_0" + TalkCount + "/MISSING TEXT DIALOG_DOUBLEDEP_TINYTALK_CLERKCONVINCE_WATCHER1_0" + TalkCount);
}
if (TalkCount < 8) {
TalkCount = TalkCount + 1;
} else {
TalkCount = 1;
}
}
}
function CanTalk()
{
if (Scene.InConversation == true)
return false;
if (Game.Interactive != true)
return false;
if (Scene.Name != "DoubleDep")
return false;
if (actor != Watcher)
return false;
return true;
}
Generatit if the first time in Scene_Init:
///////////////////////////////////////////////////////////////////////////////
if(!StateDoubleDep.Visited)
{
StateDoubleDep.Visited = true;
// this is our first visit in this scene...
global TurnCycleDaemon;
global TinyTalkConvDaemon;
if (TinyTalkConvDaemon == null)
TinyTalkConvDaemon = new Object("scenes\DoubleDep\scr\TinyTalkConvDaemon.script");
call it from scene init whenerver we enter the scene, using an event so it won't cause the scene init script to wait for it to end and runs in a new thread:
if (TinyTalkConvDaemon.CanHandleEvent("StartDaemon"))
TinyTalkConvDaemon.ApplyEvent("StartDaemon");
some questions and discussions :
1. is this the best way to do it?
2. IN the episode 1 deamons, i didn't use the events, but instead i just called TalkCycle() from the script's own code which is executed when the script is loaded.
3. We also used to keep it as a scene_init this.variable instead of a global, and unload it when leaving or entering the scene . is it the right way to do it ?
4. are there any posibilities for zombie daemons still running when you exit or re-enter the scene?
5. do many scripts of this type causes the engine to run slower (we have unresolved performance issues with EPisode 1 which we don't understand)
Oded