Wintermute Engine Forum
Wintermute Engine => Technical forum => Topic started by: kypho on October 23, 2008, 07:55:35 PM
-
Hi everybody on this Forum!
I have a very very veeery basic problem. My actor goes to idle state when he is talking with another character/npc. How to prevent this from happen? I have tried different things but all the time idle state turns on and the talking starts. I have tried with the following idle code (the same as in tutorial):
include "scripts\base.inc"
var IsIdle = false;
var IdleStartTime = 0;
while(true) // endless loop
{
if(actor.Ready) // is the actor doing something
{
if(!IsIdle)
{
// actor enters idle state
IsIdle = true;
IdleStartTime = Game.CurrentTime;
}
else if(Game.CurrentTime - IdleStartTime > 5000) // is the actor idle for 5 seconds
{
IdleStartTime = Game.CurrentTime;
actor.ApplyEvent("idle");
}
}
else IsIdle = false; // actor is busy; set IsIdle to false
Sleep(100); // wait for 100 milliseconds
}
////////////////////////////////////////////////////////////////////////////////
on "idle"
{
// do some idle processing here
actor.Talk("ZzzZZz...Yawn!");
Sleep(1000);
actor.Talk("Huoh!");
Sleep(1500);
actor.GoTo(Random(0, 1000), Random(0, 600));
}
////////////////////////////////////////////////////////////////////////////////
I have tried to put something like this:
if(!IsIdle && !actor.IsTalking)
to make the if sentence have AND operator...but unfortenately this doesn't work...I have also tried to make boolean variable for contain the true/false value when the actor is talking/not talking and then use that variable in that if statement, but can't get it rolling yet... ::)
So if somebody has solved a problem like this before please help, cos I don't want my actor say zzz when talking to some npc.
Thanks :)
- Kypho the beginner
-
This is just a guess from another beginner but it seems to me that idle state is very low---5 seconds--maybe changing it to something longer timewise might help? I'm sure you'll get a better answer but looking at your script I just noticed that seems low. : )
Also, doing a search here, I found slightly different script---
in place of the line that says
if(actor.Ready)
it had
if(Game.Interactive == true)
now I don't know the difference yet between those 2 things but it might work. Then again, it might not.
-
where do you define the variable actor.IsTalking?
-
Hi Folks, thanks for your quick response!
Hmm...the actor.IsTalking thing is something I just tried to fix it, actually I guess it should be actor.IsTalking(true) or something cos it's a game's basic functions (or is it?). This function as read in help file should return true value if actor is talking. But again I am not sure. So should I try to make a variable which contains the information about talking (true/false) in my npc script and then somehow use it in actor script. Of course I should also initialize that global variable in script_init? I tried this before, but I couldn't do it right :/
- Kypho the beginner
-
Hey Catacomber!
Thanks, I think it works with this new piece of script :)
-
it's why I asked. The correct code would look like:
{
// actor is now talking
}