Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Idle intelligence  (Read 4093 times)

0 Members and 1 Guest are viewing this topic.

kypho

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 33
    • View Profile
Idle intelligence
« 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
Logged

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Idle intelligence
« Reply #1 on: October 23, 2008, 08:42:24 PM »

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.
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Idle intelligence
« Reply #2 on: October 23, 2008, 08:56:38 PM »

where do you define the variable actor.IsTalking?
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

kypho

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 33
    • View Profile
Re: Idle intelligence
« Reply #3 on: October 24, 2008, 08:48:17 AM »

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
Logged

kypho

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 33
    • View Profile
Re: Idle intelligence
« Reply #4 on: October 24, 2008, 08:54:19 AM »

Hey Catacomber!

Thanks, I think it works with this new piece of script :)

Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Idle intelligence
« Reply #5 on: October 24, 2008, 12:24:34 PM »

it's why I asked. The correct code would look like:

Code: WME Script
  1. if (actor.IsTalking())
  2. {
  3.    // actor is now talking
  4.  
  5. }
  6.  
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet
 

Page created in 0.092 seconds with 25 queries.