Please login or register.

Login with username, password and session length
Advanced search  

News:

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

Pages: 1 2 3 [All]

Author Topic: actors as NPC's  (Read 14956 times)

0 Members and 1 Guest are viewing this topic.

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
actors as NPC's
« on: August 21, 2006, 04:08:22 AM »

I have read a few threads around here on actors used as NPC entities and was wondering how can i accomplish that.

In my game my character is being detained in a prison and my idea is that of having a few guards patrolling the area (walking randomly around) and a few inmates who also walk up and down the place. Of course since they would be walking around randomly i feel i am bound to using actors as NPC's. I had a look at the manual and there is indeed mention of instances in which it is possible to use actors as NPC's but i could not find any tutoriial or anything that would explain how to do it...

Also should i be able to do that, is there a way not to make the NPC's walk through each other?

Thank you and btw, WINTERMUTE ROCKS!!! ::rock

P.S.

Mnemonic you are truly a king among men!  ::rock
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

Altsaxofon

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: actors as NPC's
« Reply #1 on: August 21, 2006, 01:04:24 PM »

It's quite easy to use a actor as a NPC actually,

Just create your new actor with walking animations and all that,
and then load it into yor scene, in scene_init.script with

Code: [Select]
var NPC = Scene.LoadActor("actors\NPC\NPC.actor");
then you can let your NCP walk with the regular GoTo command.

Code: [Select]
NPC.GoTo( X, Y );
or talk, och play an animation or do anything else an actor can do
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: actors as NPC's
« Reply #2 on: August 21, 2006, 01:27:27 PM »

I would add a couple of things:

usually you should use this:

Code: [Select]
var NPC = Scene.LoadActor("your new actor there"); // or Scene.LoadActor3D(); for 3d actors
NPC.SkipTo(x,y); // some position on the hidden geometry so your NPC can also walk
NPC.Active = true; // this should show your actor in the scene. Depends on settings in act3d file;

Also if you note slowdowns on the scene entering it usually pays off to use zone based actor loading. This means
that you make the actor variables global and load actors through Game.LoadActor().

At the end of the zone you simply unload all NPC's used in current zone and load set of new. This way you cut the loading times for screens which significantly smoothes the gameplay. (the zone loading time will be longer though so you should divide the game space accordingly).

Hope that helps.



Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #3 on: August 21, 2006, 08:45:56 PM »

Thanks guys! I'll try that,

Also i just opened my own website now and i'll be uploading all the updates on Shelter at www.fabiobasile.com under "projects". Hopefully it will be faster to download my demos than googlepages has been so far!  :)
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: actors as NPC's
« Reply #4 on: August 21, 2006, 09:35:52 PM »

Also should i be able to do that, is there a way not to make the NPC's walk through each other?
There is a still-undocumented way of doing that, see this post.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #5 on: August 21, 2006, 10:53:46 PM »

mmh... i have managed to successfully insert an NPC in the scene but that's about it. I tried to paste the blocked region code in the NPC's script but it does nothing, the character walks through the NPC like a ghost... also i am quite confused on how to make the NPC clickable for interaction... :'(
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #6 on: August 22, 2006, 03:38:21 AM »

Ok i better clarify what my intentions are: what i want to accomplish is to have my NPC's doing the following:

Guards:

- turning automaticallly in the direction of the actor
- walking randomly withing a region
- saying random sentences (text only)

Prisoners:

- walking around within a region
- saying random sentences (text only)
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: actors as NPC's
« Reply #7 on: August 22, 2006, 07:14:35 PM »

I tried to paste the blocked region code in the NPC's script but it does nothing, the character walks through the NPC like a ghost...
Not in script, it has to be added to the .actor definition file.


also i am quite confused on how to make the NPC clickable for interaction... :'(
Add:

  INTERACTIVE = TRUE

to the .actor file.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #8 on: August 23, 2006, 08:10:54 AM »

Sorry to bother you still, lol i know i'm being a horrible nag  :P

everything works except for the interactivity... i tried to use the Take, Talk and LookAt codes in the NPC.script but nothing happens, and when i try to put that in the NPC.actor it gives an error and doesn't even load the NPC... How do i specify mouse actions on the actor entity (NPC)?

Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: actors as NPC's
« Reply #9 on: August 23, 2006, 08:24:56 AM »

basically you should put into NPC.script

on "LeftClick"
{
}

on "RightClick"
{
}

etc. depending on the action you're performing. Inside of those actions you will then (for example based on some internal global variables or object attributes decide what to do with the actor upon clicking on him). I fear that you're approaching this problem the other way around, but there is no way how could WME pair those events unless you script them in LeftClick or RightClick event defintions in game.script which would be too complicated and meaningless IMO.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: actors as NPC's
« Reply #10 on: August 23, 2006, 04:25:02 PM »

By specifying INTERACTIVE = TRUE you make the actor "clickable", i.e. it can receive mouse events. If your problem is the action menu isn't shown when you right click the actor, it's because its script doesn't contain neither of the on "Talk", on "LookAt" and on "Take" event handlers. If you add one of those to the actor's script, the menu will pop up on right click.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #11 on: August 23, 2006, 09:39:24 PM »

ok here is what i included in the NPC script "prisoner.script"

Code: [Select]
#include "scripts\base.inc"


////////////////////////////////////////////////////////////////////////////////
on "LookAt"

{
  NPC.Talk("you got a quarter, my friend?");
}

////////////////////////////////////////////////////////////////////////////////
on "Take"

{
NPC.Talk("wuzzaaaaaap!!!");
}

////////////////////////////////////////////////////////////////////////////////
on "Talk"

{
NPC.Talk("hey my man...");
}

it gives me 1 compiler error and one runtime error but nothing shows in any of the log files, the view of the scene is stuck in the upper left corner and nothing responds.

same thing if i put the code in the main actor's script "player.script". :'(
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #12 on: August 23, 2006, 11:38:34 PM »

ok i think i'm getting it...

Now the NPC can be clicked and spoken to, metamorphium you are actually right, the reason i was stuck was that i started with the idea that the NPC should speak first by using NPC.Talk instead of actor.Talk, which i can only assume is the reason why i kept getting those errors, i guess i must have broken a few laws without noticing lol :)


Just another thing i tried to implement and modify the code for the random actor actions on the NPC but it lead me nowhere...

Is there a way to modify this code and insert it somewhere so that the NPC will say random sentences every 15 seconds and walk around  at random, making a stop every 15 seconds?

Code: [Select]
#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 > 10000) // 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("dude... are we going to do *something* anytime soon?");
//  actor.GoTo(Random(800, 1000), Random(400, 600), Random(500, 1000));
}
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: actors as NPC's
« Reply #13 on: August 24, 2006, 07:41:27 PM »

Perhaps it would be easier to prepare several "actions" for the NPC, and execute them randomly?

Code: [Select]
// endless loop
while(true)
{
  // choose a random action
  switch(Random(0, 3))
  {
    case 0:
      // say something and wait
      this.Talk("Damn, I'm so bored.");
      Sleep(2000);
      break;
     
     
    case 1:
      // walk around
      this.GoTo(100, 200);
      Sleep(2000);
      this.GoTo(300, 400);
      Sleep(2000);
      this.GoTo(100, 200);
      break;
     
    case 2:
      // play some animation
      this.PlayAnim("smoke_cigarette.sprite");
      break;

    case 3:
      // do nothing for a while
      Sleep(3000);
      break; 
  }
}
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: actors as NPC's
« Reply #14 on: August 24, 2006, 07:44:33 PM »

it gives me 1 compiler error and one runtime error but nothing shows in any of the log files, the view of the scene is stuck in the upper left corner and nothing responds.
If you're getting compile and runtime errors, they have to be logged in the log file. UNLESS you disabled "debug mode" in ProjectMan. It's definitely worth enabling the debug mode while developing the game, really :)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #15 on: August 24, 2006, 08:09:04 PM »

i don't know why, but nothing shows in the logs, i have the debug mode enabled at all times because i need to monitor FPS and other information. Anyhow about those errors i think i figured that out and fixed it.

Anyway i've tried to implement the conversation script between the character and the NPC from the demo and it works GREAT, also the Talk, Take, and Look codes work well, the only problem is with the GoTo code. It simply doesn't work either ways.

I tried to do something like that:

Code: [Select]
actor.GoTo("NPC")
or

Code: [Select]
NPC.GoTo(actor)
and neither of them make one single step towards each other, they do all the conversation and interaction from afar...
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: actors as NPC's
« Reply #16 on: August 24, 2006, 08:32:56 PM »

i don't know why, but nothing shows in the logs, i have the debug mode enabled at all times because i need to monitor FPS and other information. Anyhow about those errors i think i figured that out and fixed it.
Then you must be looking at wrong logs... ???

I tried to do something like that:

Code: [Select]
actor.GoTo("NPC")
or

Code: [Select]
NPC.GoTo(actor)
and neither of them make one single step towards each other, they do all the conversation and interaction from afar...

The GoTo() method only accepts coordinates, so you'd have to do something like:

Code: [Select]
actor.GoTo(NPC.X, NPC.Y);
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #17 on: August 24, 2006, 10:15:50 PM »

Quote
Then you must be looking at wrong logs... Huh
lol my pc must be hunted :P I searched anything that had a .log extension and i swear nothing shown...

To think of it thou... does WME automatically re-creates the log files normally once they are erased? Coz a few days ago i erased all the log files and re-run WME and worked normally and all the logs were re-generated again and worked fine for a while until i guess... yesterday?


Anyhow for now i'm relying on the syntax checker which seems pretty accurate. I'll try reinstalling WME and see if something changes.

meanwhile apparently
Code: [Select]
actor.GoTo(NPC.X, NPC.Y); doesn't seem to work, well i know it should but the syntax error checker says that variable NPC is referenced but not defined... how do i define NPC?

here is the entire script of "NPC" prisoner.script

Code: [Select]
#include "scripts\base.inc"

///////////////////////////////////////////////////////////////////////////////

global StateRoom;

////////////////////////////////////////////////////////////////////////////////

on "Talk"
{
actor.GoTo(NPC.X, NPC.Y);
  actor.TurnTo(this);
  Game.Interactive = false;

  // greetings
  if(!StateRoom.TalkedToNPC) actor.Talk("how are you doing my man...");
  else actor.Talk("hey, man...");
  this.Talk("What's up kiddo?");

  // set the flag, so that we know we've already talked to him
  StateRoom.TalkedToNPC = true;

  // and let the dialogue begin
  NPCDialogue();

  // restore interactivity
  Game.Interactive = true;
}


////////////////////////////////////////////////////////////////////////////////

function NPCDialogue()
{
  var Responses;
  var Selected;

  var Loop = true;

  while(Loop)
  {
    // prepare the sentences
    Responses[0] = "What's goin on, old man?";
    Responses[1] = "What are you doing here?";
    Responses[2] = "I heard they caught another one";
    Responses[3] = "hey, old man, always a pleasure to chatter with ya!";

    // fill the response box
    Game.AddResponse(0, Responses[0]);
    Game.AddResponse(1, Responses[1]);
    Game.AddResponse(2, Responses[2]);
    Game.AddResponse(3, Responses[3]);

    // let the player choose one
    Selected = Game.GetResponse();

    // let the actor say the selected sentence
    // (that's why I use the array for storing the sentences)
    actor.Talk(Responses[Selected]);

    // now let the Old Guy reply depending on the selected sentence
    if(Selected==0)
    {
      this.Talk("Same as usual, my back hurts.");
      actor.Talk("life's a bitch, huh");
    }
    else if(Selected==1) this.Talk("Can't sleep, those damn dogs outside they are barking at every damn tree!");
    else if(Selected==2)
    {
      this.Talk("yeah, every now and then they do... not as often as before thou");
      // go to the second branch of dialogue
      NPCDialogue2();
    }
    else if(Selected==3)
    {
      this.Talk("Anytime kiddo. Remember stay clean...");
      Loop = false; // we want to end the dialogue
    }
  }
}



////////////////////////////////////////////////////////////////////////////////

function NPCDialogue2()
{
  var Responses;
  var Selected;
  var Loop = true;

  while(Loop)
  {
    // prepare the sentences
    Responses[0] = "you sound like you know him...?";
    Responses[1] = "What's his called?";
    Responses[2] = "so is he a subhuman or just another weird guy?";
    Responses[3] = "*Some* news is supposed to be good news around here...";

    // fill the response box
    Game.AddResponse(0, Responses[0]);
    Game.AddResponse(1, Responses[1]);
    Game.AddResponse(2, Responses[2]);
    Game.AddResponse(3, Responses[3]);

    // let the player choose one
    Selected = Game.GetResponse();

    // let the actor say the selected sentence
    // (that's why I use the array for storing the sentences)
    actor.Talk(Responses[Selected]);

    // now let the NPC reply depending on the selected sentence
    if(Selected==0)
    {
      this.Talk("Hardly... but i heard he escaped from another camp.");
      this.Talk("Weird kinda fellow.");
      actor.Talk("why?");
    }
    else if(Selected==1)
    {
      this.Talk("No idea... no one is allowed to talk to him. They put him in Isolation.");
      actor.Talk("I see.");
    }
    else if(Selected==2)
    {
      this.Talk("Well I don't know for sure...");
      this.Talk("who knows, right?.");
      actor.Talk("You got that figured out...");
    }
    else if(Selected==3) Loop = false;
  }
}


////////////////////////////////////////////////////////////////////////////////
on "LookAt"
{
actor.GoTo(NPC.X, NPC.Y);
  actor.TurnTo(this);
  if(!StateRoom.TalkedToNPC) actor.Talk("Look who's here. I was just in the mood for a chat.");
  else actor.Talk("Old guy Martin.. what a surprise...");
}

////////////////////////////////////////////////////////////////////////////////
on "Take"
{
actor.GoTo(NPC.X, NPC.Y);
  actor.TurnTo(this);
  this.Talk("Hey, youngster! I'm a little old for a piggy back ride...!");
}

////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
actor.GoTo(NPC.X, NPC.Y);
  actor.TurnTo(this);
}


////////////////////////////////////////////////////////////////////////////////
« Last Edit: August 24, 2006, 10:19:27 PM by fabiobasile »
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: actors as NPC's
« Reply #18 on: August 24, 2006, 10:26:43 PM »

log is always created in the root of the project tree of your game. there is a file called wme.log. (providing you're not running compiled version)
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: actors as NPC's
« Reply #19 on: August 24, 2006, 10:30:26 PM »

Replace NPC with "this".

actor.GoTo(this.X, this.Y);

"this" points to the object which owns the script, in this case it's your NPC.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #20 on: August 24, 2006, 10:36:46 PM »

i tried to put "this" instead of "NPC" and the error was gone but still the actor doesn't move... also i put
Code: [Select]
var NPC; after
Code: [Select]
Global StateRoom;again the error disappears but still the actor doesn't move at all... :'(
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #21 on: August 25, 2006, 12:45:26 AM »

Quote
log is always created in the root of the project tree of your game. there is a file called wme.log. (providing you're not running compiled version)

I'm running always in debug mode, i compile only when i'm at a point in which everything works the way i want it... this is my wme.log:

Quote
16:41: ********** DEBUG LOG OPENED 24-08-2006 (Release Build) *****************
16:41: Wintermute Engine ver 1.6.2 work, Compiled on Jun 20 2006, 22:45:48
16:41: Platform: Windows Server 2003 Service Pack 1 (Build 3790)
16:41: DirectX version: 9.0

Also i have noticed that even by adding another simple entity to the scene using the exact same way i added the NPC actor, the result is the same. The entity works in every other way except when using actor.GoTo(this) or any other variation of it.
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #22 on: August 25, 2006, 01:10:40 AM »

Ok i have reinstalled WME and it seems to be working now, i don't know for some reason it just couldn't write anything in the wme.log, but now it works.

unfoortunately actor.GoTo(this) still doesn't have any effect on the scene... :'(
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
I FIGURED IT OUT!!
« Reply #23 on: August 25, 2006, 02:47:55 AM »

It was so easy i can't believe it...

All i had to do was to use the simplest function in WME!
Code: [Select]
  actor.GoTo(Scene.MouseX, Scene.MouseY);by implementing it into the NPC script it doesn't actually affect the NPC in anyway but it allows the actor to be tricked into walking up to the NPC, by simply walking wherever the mouse clicked!

Well of course this trick solves the problem... but i just wonder if i really HAVE to use this trick or if i can actually use the more logical principle which i tried before...

For example if i want an NPC to follow the actor around, in case for example of a party member, a combat enemy or a stalker, how do i do that? Obviously NPC.GoTo(actor); has shown ineffective...
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: actors as NPC's
« Reply #24 on: August 25, 2006, 08:05:06 AM »

well, as Mnemonic already wrote, you should use

NPC.GoTo(actor.X,actor.Y); which works.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #25 on: August 25, 2006, 04:33:11 PM »

i know it should work, which means that there must be something else in the way... whenever i use that code the NPC simply refuses to walk anywhere... i'm really confused on this one... ???
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: actors as NPC's
« Reply #26 on: August 25, 2006, 09:18:45 PM »

Keep in mind the NPC variable has to be defined and it has to have some value assigned. The simplest way would be to store your NPC actor in a global variable. When you're loading the NPC actor, do something like:

  global CampGuard = Game.LoadActor("actors\guard\guard.actor");

The variable CampGuard now contains a reference to the guard actor.
Now, whenever you need to manipulate the guard from other script, you can do something like:

  global CampGuard;
  CampGuard.Talk("Blag blah.");

To follow the main hero you'd do:

  global CampGuard;
  CampGuard.GoTo(actor.X, actor.Y);

This *should* work. If it doesn't, check the wme.log file for runtime errors.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #27 on: August 25, 2006, 10:31:12 PM »

turns out it still not working and nothing abnormal shows in the logs... the NPC just won't move at all when GoTo is pointing at the actor or any other entity in the scene. It only works with coordinates...
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: actors as NPC's
« Reply #28 on: August 26, 2006, 09:15:35 AM »

Ok, then there's probably no valid path from the NPC to your actor. Try adding some waypoints to the scene.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #29 on: August 26, 2006, 10:04:37 PM »

well the scene is not very cluttered at all and there is nothing wrong with the waypoints otherwise the acor wouldn't be able to walk up to the NPC...
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: actors as NPC's
« Reply #30 on: August 27, 2006, 11:42:48 AM »

Oops, you're right. It indeed doesn't work. You could either use something like:

  global CampGuard;
  CampGuard.GoTo(actor.X + 80, actor.Y);

to position the NPC 80 pixels to the right of the actor (or X - 80, or Y + 80 etc.). That way you can even control the direction you want the NPC approach the actor from.

Or you can download the latest build of WME here, which corrects the problem (hopefully).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #31 on: August 27, 2006, 05:05:19 PM »

Mnemonic you are the man!! :-)

Now it works perfectly!

Now i have inserted another NPC, i call it "guard1" coz it's going to be one of the guards, and whenever the main actor gets too close to the exit of the camp, guard 1 says "YOU DON'T WANNA GO THAT WAY, PAL..." and then walks up to where the actor is.

The problem is that after guard1 reached the actor for some reason he repeats again his line and the both of them seem to be stuck in their Talk animation forever and the main actor is unable to move. Also for some reason when that happens, guard1 is on the foreground of everything...

lol sorry man, looks like i'm monopolizing you!  ;D


here is guard1 script:

Code: [Select]
#include "scripts\base.inc"

///////////////////////////////////////////////////////////////////////////////

global StateRoom;
global guard1;
global Idle;
////////////////////////////////////////////////////////////////////////////////

on "Talk"
{
  actor.GoTo(Scene.MouseX, Scene.MouseY);
  actor.TurnTo(this);
  this.TurnTo(actor);

  Game.Interactive = false;

  // greetings
  if(!StateRoom.TalkedToNPC) actor.Talk("*stares*");
  else actor.Talk("...");
  this.Talk("what are you staring at?");

  // set the flag, so that we know we've already talked to him
  StateRoom.TalkedToNPC = true;

  // and let the dialogue begin
  NPCDialogue();

  // restore interactivity
  Game.Interactive = true;
}


////////////////////////////////////////////////////////////////////////////////

function NPCDialogue()
{
  var Responses;
  var Selected;

  var Loop = true;

  while(Loop)
  {
    // prepare the sentences
    Responses[0] = "just wondering what's up...";
    Responses[1] = "What are you doing here?";
    Responses[2] = "i hear we have a new guest around here...";
    Responses[3] = "yeah... see ya.";

    // fill the response box
    Game.AddResponse(0, Responses[0]);
    Game.AddResponse(1, Responses[1]);
    Game.AddResponse(2, Responses[2]);
    Game.AddResponse(3, Responses[3]);

    // let the player choose one
    Selected = Game.GetResponse();

    // let the actor say the selected sentence
    // (that's why I use the array for storing the sentences)
    actor.Talk(Responses[Selected]);

// this.GoTo(1000, 500);
// this.TurnTo(actor);

    // now let the guard reply depending on the selected sentence
    if(Selected==0)
    {
      this.Talk("mind your business, pal.");
      actor.Talk("...");
    }
    else if(Selected==1) this.Talk("Look i'm working here, beat it.");
    else if(Selected==2)
    {
      this.Talk("news get around quickly... yeah we got another one of those animals in the wastes around here.");
      // go to the second branch of dialogue
      NPCDialogue2();
    }
    else if(Selected==3)
    {
      this.Talk("don't make any trouble, pal, i'm watching you.");
      Loop = false; // we want to end the dialogue
    }
  }
}



////////////////////////////////////////////////////////////////////////////////

function NPCDialogue2()
{
  var Responses;
  var Selected;
  var Loop = true;

  while(Loop)
  {
    // prepare the sentences
    Responses[0] = "so...?";
    Responses[1] = "What's he's called?";
    Responses[2] = "i see..";
    Responses[3] = "mmh...";

    // fill the response box
    Game.AddResponse(0, Responses[0]);
    Game.AddResponse(1, Responses[1]);
    Game.AddResponse(2, Responses[2]);
    Game.AddResponse(3, Responses[3]);

    // let the player choose one
    Selected = Game.GetResponse();

    // let the actor say the selected sentence
    // (that's why I use the array for storing the sentences)
    actor.Talk(Responses[Selected]);

    // now let the NPC reply depending on the selected sentence
    if(Selected==0)
    {
      this.Talk("What's it it to you?.");

//this.GoTo(990, 600);
//this.TurnTo(actor);

      this.Talk("you all look alike, you damn mutants, how the hell am i supposed to know?");
      actor.Talk("*right...*");
    }
    else if(Selected==1)
    {
      this.Talk("No one is allowed near him for now, we have reason to believe he's infected.");
      actor.Talk("I see.");
    }
    else if(Selected==2)
    {
      this.Talk("i don't know.");
      this.Talk("Are we done with the questioning?");
      actor.Talk("sure...");
    }
    else if(Selected==3) Loop = false;
  }
}


////////////////////////////////////////////////////////////////////////////////
on "LookAt"
{
  actor.GoTo(Scene.MouseX, Scene.MouseY);
  actor.TurnTo(this);
  this.TurnTo(actor);
  if(!StateRoom.TalkedToguard1) actor.Talk("A guard, i wonder if he knows what's going on with the new guy.");
  else actor.Talk("One of those dumb guards.");
}

////////////////////////////////////////////////////////////////////////////////
on "Take"
{
  actor.GoTo(Scene.MouseX, Scene.MouseY);
  actor.TurnTo(this);
  this.TurnTo(actor);
  this.Talk("Try anything funny and i'll open a can of whoop on your ass.");
}

////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
  actor.GoTo(Scene.MouseX, Scene.MouseY);
  actor.TurnTo(this);
  this.TurnTo(actor);
}



////////////////////////////////////////////////////////////////////////////////


and here is the redzone script (the region that triggers guard1's behavior):

Code: [Select]
#include "scripts\base.inc"

global NPC;
global guard1;
////////////////////////////////////////////////////////////////////////////////
on "ActorEntry"
{
  actor.Talk("...whistles...*");
  guard1.TurnTo(actor);
  guard1.GoTo(actor.X,actor.Y);
  guard1.Talk("YOU DON'T WANNA GO THAT WAY, PAL");
}
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!

fabiobasile

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
    • View Profile
    • my brand new website!!
Re: actors as NPC's
« Reply #32 on: August 27, 2006, 05:26:05 PM »

ok i think i figurerd it out :)

for some reason the guard1 gets the actor stuck in an endless loop of Talk animation, so what i did was to add an extra line to make the guard1 walk somewhere else after he's done with his lines.  :P

lol i feel more relaxed right now  ::rock
Logged
What would i do with a million dollar? I'd give it to what's left of Black Isle/Interplay and tell them to finish the damn game!!!
Pages: 1 2 3 [All]
 

Page created in 0.058 seconds with 23 queries.