Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Pages: 1 2 [3]  All

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

0 Members and 1 Guest are viewing this topic.

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.038 seconds with 21 queries.