ldmud-3.2.9/doc/
ldmud-3.2.9/doc/efun/
ldmud-3.2.9/mud/
ldmud-3.2.9/mud/heaven7/
ldmud-3.2.9/mud/heaven7/lib/
ldmud-3.2.9/mud/lp-245/
ldmud-3.2.9/mud/lp-245/banish/
ldmud-3.2.9/mud/lp-245/doc/
ldmud-3.2.9/mud/lp-245/doc/examples/
ldmud-3.2.9/mud/lp-245/doc/sefun/
ldmud-3.2.9/mud/lp-245/log/
ldmud-3.2.9/mud/lp-245/obj/Go/
ldmud-3.2.9/mud/lp-245/players/lars/
ldmud-3.2.9/mud/lp-245/room/death/
ldmud-3.2.9/mud/lp-245/room/maze1/
ldmud-3.2.9/mud/lp-245/room/sub/
ldmud-3.2.9/mud/lp-245/secure/
ldmud-3.2.9/mud/morgengrauen/
ldmud-3.2.9/mud/morgengrauen/lib/
ldmud-3.2.9/mud/sticklib/
ldmud-3.2.9/mud/sticklib/src/
ldmud-3.2.9/mudlib/uni-crasher/
ldmud-3.2.9/pkg/
ldmud-3.2.9/pkg/debugger/
ldmud-3.2.9/pkg/diff/
ldmud-3.2.9/pkg/misc/
ldmud-3.2.9/src/autoconf/
ldmud-3.2.9/src/bugs/
ldmud-3.2.9/src/bugs/MudCompress/
ldmud-3.2.9/src/bugs/b-020916-files/
ldmud-3.2.9/src/bugs/doomdark/
ldmud-3.2.9/src/bugs/ferrycode/ferry/
ldmud-3.2.9/src/bugs/ferrycode/obj/
ldmud-3.2.9/src/bugs/psql/
ldmud-3.2.9/src/done/
ldmud-3.2.9/src/done/order_alist/
ldmud-3.2.9/src/done/order_alist/obj/
ldmud-3.2.9/src/done/order_alist/room/
ldmud-3.2.9/src/gcc/
ldmud-3.2.9/src/gcc/2.7.0/
ldmud-3.2.9/src/gcc/2.7.1/
ldmud-3.2.9/src/hosts/
ldmud-3.2.9/src/hosts/GnuWin32/
ldmud-3.2.9/src/hosts/amiga/NetIncl/
ldmud-3.2.9/src/hosts/amiga/NetIncl/netinet/
ldmud-3.2.9/src/hosts/amiga/NetIncl/sys/
ldmud-3.2.9/src/hosts/i386/
ldmud-3.2.9/src/hosts/msdos/byacc/
ldmud-3.2.9/src/hosts/msdos/doc/
ldmud-3.2.9/src/hosts/os2/
ldmud-3.2.9/src/hosts/win32/
ldmud-3.2.9/src/util/
ldmud-3.2.9/src/util/erq/
ldmud-3.2.9/src/util/indent/hosts/next/
ldmud-3.2.9/src/util/xerq/
ldmud-3.2.9/src/util/xerq/lpc/
ldmud-3.2.9/src/util/xerq/lpc/www/
#include <mudlib.h>
#include <ships.h>
#include <perms.h>

inherit NPC_SHIP;

string msFerryName;
mapping mmTripProgram;
int miTripCounter;
int miCurrentTrip;
string msCurrentDest;

void reset(int arg) {
    if(!is_clone(this_object())) return;
    ::reset(arg);
    if (arg) return;

    //Setup defaults in case vars don't restore
    set_name("a ferry");
    reset_short("mysterious ferry");
    set_main_long("\
This is a long a sleek cruiser. Two masts rise into the sky, the\n\
mizzenmast in the front and the mainmast in the center. Both masts\n\
are covered with square sails. The ship has a stearncastle with the\n\
bridge on top. Including the bowsprit, the ship is about 70 feet\n\
in length.\n");
    set_ship_name("ferry");
    set_enter_messages(({"You board the ferry","boards the ferry",
      "comes aboard the ferry"}));
    set_deboard_messages(({"You disembark the ferry","leaves the ferry",
      "disembarks from the ferry"}));
    set_docked(1,1);
    call_out("execute_program",6);
}

void set_ferry_name(string sArg) {
  msFerryName = sArg;
  set_enter_messages(({"You board the " + msFerryName,"boards the " + msFerryName,
      "comes aboard the " + msFerryName}));
  set_deboard_messages(({"You disembark the " + msFerryName,"leaves the " + msFerryName,
      "disembarks from the " + msFerryName}));
  set_name(msFerryName);
  set_ship_name(msFerryName);
}

void set_trip_program(mapping mProgram) { mmTripProgram = mProgram; }

//Overloads of virtual function in parent
string query_ship_class() { return "ferry";}
string query_ship_arrive() { return "sails in";}
string query_ship_depart() { return "sails swiftly";}

string get_destination() {
  if(msCurrentDest == "darkwind") return "the land of Darkwind";
  if(msCurrentDest == "souvrael") return "Souvrael, city of sand";
  if(msCurrentDest == "odako") return "the land of Odako in Kerei";
  if(msCurrentDest == "chimotage") return "the province of Chimotage in Kerei";
  if(msCurrentDest == "hyperborea") return "Grimsfjord, port of Hyperborea";
  return "parts unknown";
}

void execute_announce(string sArg) {
  string sDomain;
  string sWhat;
  string sMsg;

  if(sscanf(sArg,"%s %s",sWhat, sDomain) != 2) return;
  //Check for "local, to-ship only" msgs
  if(sWhat == "arrive") sMsg = "The " + msFerryName + " has arrived at " +
    capitalize(sDomain) + ". Its next destination is " + get_destination() + ".\n";
  else if(sWhat == "warning") sMsg = "The " + msFerryName +
    " will depart in 2 minutes, bound for " + get_destination() + ".\n";
  else if(sWhat == "leave") sMsg = "The " + msFerryName + " is now departing for "
    + get_destination() + ".\n";
  else sMsg = sArg;
  dshout(sDomain,wrap(sMsg),1);
}

void execute_program() {
  string * asCmds;
  string sCmd;
  int iAmt;
  string sRest;

  asCmds = mmTripProgram[miCurrentTrip];
  if(!asCmds) return;
  sCmd = asCmds[miTripCounter];
  if(!sCmd) return;

  miTripCounter++;
  if(miTripCounter >= sizeof(asCmds)) {
    miTripCounter = 0;
    miCurrentTrip ++;
    if(!member(mmTripProgram,miCurrentTrip))
      miCurrentTrip = 0;
  }
  if(sscanf(sCmd,"hold %d",iAmt)) {
    call_out("execute_program",iAmt * 60);
    return;
  }
  if(sscanf(sCmd,"announce %s",sRest)) {
    execute_announce(sRest);
    call_out("execute_program",0);
    return;
  }
  if(sscanf(sCmd,"nextdest %s",sRest)) {
    msCurrentDest = sRest;
    call_out("execute_program",0);
    return;
  }
  if(sCmd == "dock") set_docked(1);
  else if(sCmd == "push") set_docked(0);
  else if(sCmd == "hoist") set_sails(1);
  else if(sCmd == "furl") set_sails(0);

  else move_vehicle(sCmd,1);
  call_out("execute_program",2);
}

status enter_func(string str) {
  object o;

  if(!id(str)) return(0);
  if(IS_APPLICANT(this_player())) return ::enter_func(str);
  if(this_player()->query_sitting()) return ::enter_func(str);
  if(!(o = present("ferry_ticket",this_player()))) {
    notify_fail("The sailors won't let you on with no ticket.\n");
    return 0;
  }
  if(::enter_func(str)) {
    write("\
A sailor takes your ticket and warns you not to get off until you\n\
have reached your destination.\n");
    destruct(o);
    return 1;
  }
  return 0;
}