Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: background conversation demon - best practice?  (Read 3653 times)

0 Members and 1 Guest are viewing this topic.

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
background conversation demon - best practice?
« on: December 16, 2009, 10:18:05 PM »

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 :


Code: [Select]
#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:

Code: [Select]
///////////////////////////////////////////////////////////////////////////////
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:
Code: [Select]

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
Logged

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
Re: background conversation demon - best practice?
« Reply #1 on: December 16, 2009, 10:35:27 PM »

i just found a bug which i'm not sure how to solve -
if you enter the scene , leave the scene  quicly, and renter - WME crashes, since its trying to call to the already running method in the tiny talk script, which is already running and sleeping.
Logged

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
Re: background conversation demon - best practice?
« Reply #2 on: December 16, 2009, 10:35:42 PM »

(using WME 1.8.10 btw)
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5681
    • View Profile
    • Dead:Code Site
Re: background conversation demon - best practice?
« Reply #3 on: December 16, 2009, 10:39:25 PM »

Please provide a minimal repro project so that the crash can be fixed.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
Re: background conversation demon - best practice?
« Reply #4 on: December 16, 2009, 11:00:27 PM »

i'll try.


Oded
Logged

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
Re: background conversation demon - best practice?
« Reply #5 on: December 17, 2009, 12:25:47 AM »

i've spent a while now trying to create a clean environment to reproduce it using WME_DEMO_3D but i can't .
any chance you'd figure it out by looking at the crash reports or something?
or at least give me some hint to what it is i might be needing to look for ?
Logged

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1455
  • Lamp dog!
    • View Profile
Re: background conversation demon - best practice?
« Reply #6 on: December 17, 2009, 08:22:48 AM »

How about a minimal repro project of your game send only to mnemonic? ;)
Logged
fl*p

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
Re: background conversation demon - best practice?
« Reply #7 on: December 17, 2009, 01:54:22 PM »

i'll see how i can do it minimal.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5681
    • View Profile
    • Dead:Code Site
Re: background conversation demon - best practice?
« Reply #8 on: December 18, 2009, 07:56:35 AM »

I identified and fixed the bug.
As a workaround, I believe you can evade the crash by calling this.Reset() immediately before calling this.SetTalkSprite().
« Last Edit: December 18, 2009, 08:04:28 AM by Mnemonic »
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
Re: background conversation demon - best practice?
« Reply #9 on: December 18, 2009, 08:04:48 AM »

...

Code: [Select]

this.Reset();

bebore:
Code: [Select]
if (Game.Subtitles == false)
this.SetTalkSprite("actors\NullAct\null.sprite");
else
this.SetTalkSprite("interface\system\tinybaloon.sprite");

it still crashes.
the fix will be in 1.9.1 i assume?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5681
    • View Profile
    • Dead:Code Site
Re: background conversation demon - best practice?
« Reply #10 on: December 18, 2009, 08:38:18 AM »

the fix will be in 1.9.1 i assume?
That's right.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
Re: background conversation demon - best practice?
« Reply #11 on: December 18, 2009, 07:51:38 PM »

right. crash bug solved  - now back to my original questions, about background deamons.


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. what's better - callinng event for a script that's already loaded, or relaoding the script every time from scratch?

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)

Logged
 

Page created in 0.612 seconds with 24 queries.