Example #1
0
int   strategize ()
{
    dwait (D_CONTROL, "Strategizing...");

    /* If replaying, instead of making an action, return the old one */
    if (replaying) return (replaycommand ());

    /* Clear any messages we printed last turn */
    if (msgonscreen) {
        at (0,0);
        clrtoeol ();
        msgonscreen = 0;
        at (row,col);
    }


    /* ----------------------- Production Rules --------------------------- */


    if (fightmonster ())          /* We are under attack! */
        return (1);

    if (fightinvisible ())        /* Claude Raines! */
        return (1);

    if (tomonster ())             /* Go play with the pretty monster */
        return (1);

    if (shootindark ())           /* Shoot arrows in dark rooms */
        return (1);

    if (handleweapon ())		/* Play with the nice sword */
    {
        dwait (D_BATTLE, "Switching to sword [1]");
        return (1);
    }

    if (light ())			/* Fiat lux! Especially if we lost */
        return (1);			/* a monster from view.		   */

    if (dinnertime ())            /* Soups on! */
        return (1);

    /*
     * These variables are short term memory.  Slowed and
     * cancelled are fuses which are disabled after a small
     * number of turns.
     */

    lyinginwait = 0;			/* No more monsters to wait for */
    if (foughtmonster) foughtmonster--;	/* Turns since fought monster */
    if (slowed) slowed--; 	        /* Turns since we slowed a monster */
    if (cancelled) cancelled--;		/* Turns since we zapped 'cancel' */
    if (beingheld) beingheld--;		/* Turns since held by a fungus */

    /* ---- End of short term memory modification ---- */

    if (dropjunk ())		/* Send it back */
        return (1);

    if (readscroll ())		/* Get out the reading glasses */
        return (1);			  /* Must come before handlearmor() */

    if (handlearmor ())		/* Play dressup */
        return (1);

    if (quaffpotion ())		/* Glug glug glug ... */
        return (1);			  /* Must come before handlering() */

    if (handlering ())		/* We are engaged! */
        return (1);

    if (blinded && grope (50))	/* Who turned out the lights */
    {
        display ("Blinded, groping...");
        return (1);
    }

    if (aftermelee ())		/* Wait for lingering monsters */
        return (1);

    if (tostuff ())		/* Pick up the play pretty */
        return (1);

    if (restup ())		/* Yawn! */
        return (1);

    if (goupstairs (NOTRUNNING))	/* Up we go! Make sure that we get */
        return (1);			  /* a better rank on the board. */

    if (trywand ())		/* Try to use a wand */
        return (1);

    if (gotowardsgoal ())		/* Keep on trucking */
        return (1);

    if (exploreroom ())		/* Search the room */
        return (1);

    if (archery ())		/* Try to position for fight */
        return (1);

    if (pickupafter ())		/* Look for stuff dropped by arched mon */
        return (1);

    if (plunge ())		/* Plunge mode */
        return (1);

    if (findarrow ())		/* Do we have an unitialized arrow? */
        return (1);

    if (findroom ())		/* Look for another room */
        return (1);

    /*
     * 'attempt' records the number of times we have completely searched
     * this level for secret doors.  If attempt is greater than 0, then we
     * have failed once to find the stairs and go down.  If this happens
     * three times, there could be amonster sleeping on the stairs.  We set
     * the SLEEPER bit for each square with a sleeping monster.  Go find
     * such a monster and kill it to see whether (s)he was on the stairs).
     */

    if (attempt > 4 && makemove (ATTACKSLEEP, genericinit, sleepvalue, REUSE))
    {   display ("No stairs, attacking sleeping monster...");
        return (1);
    }

    if (Level>1 && larder>0 && doorexplore ())	/* Grub around */
        return (1);

    if (godownstairs (NOTRUNNING))		/* Down we go! */
        return (1);

    if ((Level<2 || larder<1) && doorexplore())   /* Grub around anyway */
        return (1);

    /*
     * If we think we are on the stairs, but arent, maybe they were moved
     * (ie we were hallucinating when we saw them last time).
     */

    if (on (STAIRS) && (atrow != stairrow || atcol != staircol))
    {
        dwait (D_ERROR, "Stairs moved!");
        findstairs (NONE, NONE);
        return (1);
    }

    /*
     * If we failed to find the stairs, explore each possible secret door
     * another ten times.
     */

    while (attempt++ < MAXATTEMPTS)
    {   timestosearch += max (3, k_door / 5);
        foundnew ();
        if (doorexplore ()) return (1);
    }

    /*
     * Don't give up, start all over!
     */

    newlevel ();
    display ("I would give up, but I am too stubborn, starting over...");
    return (grope (10));
}
Example #2
0
void
bbsstart(void)
{
unsigned char stdinbuf[STDINBUFSIZ];
long    uglastmsg;	/* last msg seen in prev. rm */
long    ugtemp = TWILIGHTZONE;
short   prev_rm = TWILIGHTZONE;
char    cit_cmd;
char    bueller = 0;

  room = &sroom;
  setvbuf(stdin, (char *)stdinbuf, _IOFBF, STDINBUFSIZ);
  setvbuf(stdout, (char *)stdoutbuf, _IOFBF, STDOUTBUFSIZ);

  init_system();
  /* Putty.exe is obstinate */
  /* IAC WILL SGA */
  putchar(IAC); putchar(WILL); putchar(TELOPT_SGA);
  /* magic to set telnet into character mode */
  /* IAC  DO LINEMODE, IAC WILL ECHO */
  write(1,"\377\375\042\377\373\001",6);
  /* let window sizes come through */
  /* IAC DO NAWS */
  write(1,"\377\375\037",3);

  reserve_slot();
  do_login();

  colorize("\n@G");

  curr = LOBBY_RM_NBR;
  inituser();

  openroom();
  storeug(&uglastmsg, &ugtemp);

  /* The first thing we do is make the user read the lobby */
  cit_cmd = 'N';

  readroom(cit_cmd);


  for(;;)
  {
    /*
     * check if user has been kicked out of this room while they were in it,
     * or if room was deleted
     */
    if (ouruser->generation[curr] < 0 || !msg->room[curr].flags)
    {
      curr = LOBBY_RM_NBR;
      openroom();
      storeug(&uglastmsg, &ugtemp);
    }

    if (cit_cmd)
      colorize("\n@Y%s>@G ", msg->room[curr].name);

    checkx(0);

    if (ouruser->f_prog)
      cit_cmd = get_single_quiet("ABCD\005eEFGHIJKLNOpPqQRsSTUvVwWxX\027\030yYZ /?#%@-\"");
    else if (ouruser->f_aide)
      cit_cmd = get_single_quiet("ABC\005eEFGHIJKLNOpPqQRsSTUvVwWxX\027\030yYZ /?#%@-\"");
    else if (ouruser->usernum == msg->room[curr].roomaide && !ouruser->f_twit)
      cit_cmd = get_single_quiet("ABC\005eEFGHIJKLNOpPqQRsSTUwWxX\027\030yYZ /?#%-\"");
    else
      cit_cmd = get_single_quiet("BCeEFGHIJKLNOpPqQRsSTUwWxX\027\030yYZ /?#%-\"");

    if (cit_cmd == SP)
      cit_cmd = 'N';

    if (guest && !strchr("BFGHIJKLNOpPRsSTUwWyY/?#-", cit_cmd))
    {
      colorize("\n\n@RThe Guest user cannot do that.@G\n");
      continue;
    }

    if (curr == LOBBY_RM_NBR && strchr("DGNqsTU\027X\030Z% ", cit_cmd))
    {
      if (bueller++ >= 12)
        flush_input(bueller / 25);
      if (bueller >= 100)
      {
        colorize("@R\n\n\nGo away until you have something useful to do!\n\n\n@G");
        my_exit(10);
      }
    }
    else
      bueller = 0;

    if (strchr("AC\005eEHJpPQSvVx\030yYZ#-\"", cit_cmd))
      mybtmp->nox = 1;

    switch (cit_cmd)
    {

      case 'A':
	printf("Sysop commands (%s)\n", msg->room[curr].name);
	aide_menu();
	break;

      case 'R':
      case 'B':
	cit_cmd = 'R';
	printf("Read Reverse\n");
	readroom(cit_cmd);
	break;

      case 'C':
        printf("Change config\n");
        change_setup(NULL);
	break;

      case 'D':
	printf("Debug\n");
	debug();
	break;

      case '\005':
	if (ouruser->usernum == msg->room[curr].roomaide)
	{
	  printf("Enter Forum Moderator message\n\nAre you sure you want to enter a message as Forum Moderator? (Y/N) -> ");
	  if (!yesno(-1))
	    break;
	  sysopflags |= SYSOP_FROM_FM;
	}
	else if (ouruser->f_admin)
        {
	  printf("Enter Sysop message\n\nNOTE: You are entering this message as Sysop!\n\n");
	  sysopflags |= SYSOP_FROM_SYSOP;
        }
	/* FALL THRU */

      case 'e':
      case 'E':
	{
	  char work[20];

	  if (ouruser->f_newbie && (curr == MAIL_RM_NBR || curr > 4))
	    help("newuseraccess", NO);
	  else
	  {
	    if (cit_cmd == 'E')
	      printf("Upload message\n\n");
	    else if (cit_cmd == 'e')
	      printf("Enter message\n\n");
	    *work = 0;
	    (void)entermessage(curr, work, cit_cmd == 'e' ? 0 : 2);
	    sysopflags &= ~(SYSOP_FROM_SYSOP | SYSOP_FROM_FM);
	  }
	}
	break;

      case 'F':
	printf("Read Forward\n");
	readroom(cit_cmd);
	break;

      case 'G':
	printf("Goto ");
	updatels(&prev_rm);
	/* find next room with unread msgs and open it */
	nextroom();
	openroom();
	storeug(&uglastmsg, &ugtemp);
	break;

      case 'H':
	printf("Help!\n");
	help("topics", YES);
	break;

      case 'q':
      case 'Q':
        get_syself_help(cit_cmd);
        break;

      case 'I':
	printf("Forum Info\n");
	readdesc();
	break;

      case 'J':
	{
	  int old_rm;

	  printf("Jump to ");
	  old_rm = curr;
	  if (findroom() == YES)
	  {
	    int save_rm;
  
            mybtmp->nox = 0;
	    save_rm = curr;
	    curr = old_rm;
	    updatels(&prev_rm);
	    curr = save_rm;
	    openroom();
	    storeug(&uglastmsg, &ugtemp);
	  }
	}
	break;

      case 'K':
	printf("Known forums and zapped list\n");
	knrooms();
	break;

      case 'L':
        dologout();
	break;

      case 'N':
	if (ouruser->lastseen[curr] < room->num[MSGSPERRM - 1])
	{
	  printf("Read New\n");
	  readroom(cit_cmd);
	}
	else
	{			/* No new notes so just do a Goto now */
	  printf("Goto ");
	  updatels(&prev_rm);
	  /* find next room with unread msgs and open it */
	  nextroom();
	  openroom();
	  storeug(&uglastmsg, &ugtemp);
	}
	break;

      case 'O':
	printf("Read Old messages reverse\n");
	readroom(cit_cmd);
	break;

      case 'p':
      case 'P':
	profile_user(cit_cmd == 'P');
	break;

      case 's':		/* don't update lastseen, you're skipping the room */
	printf("Skip %s\n", msg->room[curr].name);
	skipping[curr >> 3] |= 1 << (curr & 7);
	/* after skipping a room, find the next unread room (not a goto) */
	nextroom();
	openroom();
	ugtemp = ouruser->lastseen[curr];
	break;

      case 'S':
	{
	  int old_rm;

	  printf("Skip %s to ", msg->room[curr].name);
	  old_rm = curr;
	  if (findroom() == YES)
	  {
            mybtmp->nox = 0;
	    skipping[old_rm >> 3] |= 1 << (old_rm & 7);
	    openroom();
	    ugtemp = ouruser->lastseen[curr];
	  }
	}
	break;

      case 'T':
	printdate("Time\n\n%s");
	break;

      case 'U':
	printf("Ungoto\n");
	ungoto(prev_rm, &uglastmsg, &ugtemp);
	break;

      case 'v':
	cit_cmd = 0;
	break;

      case 'V':
	printf("Validate new users\n");
	validate_users(1);
	break;

      case '\027':
	if (client)
	  clientwho();
	else
	  cit_cmd = 0;
	break;

      case 'w':		/* Short form of who's online */
	show_online(3);
	break;

      case 'W':		/* Who's online */
	show_online(0);
	break;

      case 'x':
	express();
	break;

      case 'X':
	change_express(1);
	break;

      case CTRL_X:
	old_express();
	break;

      case 'y':
      case 'Y':
        if (!wanttoyell(cit_cmd))
          break;
	(void)entermessage(-1, "", cit_cmd == 'y' ? 0 : 2);
	break;

      case 'Z':
	printf("Zap forum\n");
	if (forgetroom())
        {
	  nextroom();
	  openroom();
	  ugtemp = ouruser->lastseen[curr];
        }
	break;

      case '?':
      case '/':
	if (guest)
	  help("guestforumlevel", NO);
	else
	  help("doccmd", NO);
	break;

      case '#':
	readroom(cit_cmd);
	break;

      case '%':
	if (ouruser->f_elf && !ouruser->f_restricted && !ouruser->f_twit)
          if (mybtmp->xstat && !mybtmp->elf)
            printf("\n\nYou can't enable yourself as a guide while your X's are disabled.\n");
	  else if ((mybtmp->elf = !mybtmp->elf))
	    printf("\n\nYou are now marked as being available to help others.\n");
	  else
	    printf("\n\nYou are no longer marked as being available to help others.\n");
	else
	  cit_cmd = 0;
	break;

      case '-':
	readroom(cit_cmd);
	break;

      case '@':
	printf("Sysops, programmers, and forum moderators\n");
	more(AIDELIST, 0);
	break;

      case '"':
	{
	  char work[20];

	  printf("Quote X messages to Sysop\n");
          *work = 0;
          (void)entermessage(-1, work, -1);
	}
	break;

      default:
	break;
    }				/* switch */

  }