/*
       -= SEER - C-Scripting engine v 0.94a =-
State      : under implementation
Author     : Przemyslaw Podsiadly
             email: ppodsiad@elka.pw.edu.pl
             WWW:   http://home.elka.pw.edu.pl/~ppodsiad/seer
File:exlsam.sc
Desc:character script for Sam, Merry and Pippin
*/

#title SamMerryPippin
#author Theur

#include "exlotr.sh"

string goal="wait";

void handleEvent(Event& e)
{
 switch(e.nr)
 {
  case evUnable:
       say("What am I to do? I can't %s!",goal);break;
  case evNotice:
       say("I have noticed something. I'll leave it where it lies.\n");break;
  case evHear:
       say("I have heard something");break;
  case evAttacked:
       say("I've been suddenly attacked");break;
  case evMeet:
       say((rnd(2))? "Oh, hi %s! And you are here?":
                     "Well, even %s my eyes have met!",
            evMeetWhom(e)->name);
       break;
  default:say("What am I doing here?(%d)",e.nr);
 }
}


void followFrodo()
{Event e;
 goal="with Frodo reach Rivendell";
 while(1)
 {act(e,actFollow,getCharacter("Frodo"));
  if (e==evTold)
  {if (string(evToldWhat(e))=="Go rest!")
        return;
   say("I don't understand '%s'!",evToldWhat(e));
  }
  if (e!=evSuccess)//so what, I'm always with Frodo!
    handleEvent(e);
 }
}

void goToFrodo()
{Event e;

 goal="reach Frodo";

 while (goToCharacter(e,"Frodo"),e!=evSuccess)
 {handleEvent(e);
 }

 say("Hi, Frodo!");

}

void live()
{
 goToFrodo();
 followFrodo();
 say("Right, Frodo. I'm tired and very hungry. I'll go.");
}
