Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Pages: 1 [2] 3  All

Author Topic: actors as NPC's  (Read 14954 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!!
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!!!
Pages: 1 [2] 3  All
 

Page created in 0.084 seconds with 23 queries.