Пример #1
0
markmissingrooms ()
{ register rm,i,j;
  for (rm=0; rm<9; ++rm)
  { room[rm]=0;
    for (i=bounds[rm].top; i<=bounds[rm].bot; ++i)
      for (j=bounds[rm].left; j<=bounds[rm].right; ++j)
	if (onrc(ROOM,i,j)) { room[rm]=ROOM; goto nextroom; }
	else if (onrc(BEEN,i,j)) { room[rm]=BEEN; goto nextroom; }
    nextroom: ;
  }
}
Пример #2
0
int   fightmonster ()
{   register int i, rr, cc, mdir = NONE, mbad  = NONE, danger = 0;
    int  melee = 0, adjacent = 0, alertmonster = 0;
    int  wanddir = NONE, m = NONE, howmean;
    char mon, monc = ':', *monster;

    /* Check for adjacent monsters */
    for (i = 0; i < mlistlen; i++)
    {   rr = mlist[i].mrow;
        cc = mlist[i].mcol;
        if (max (abs (atrow-rr), abs (atcol-cc)) == 1)
        {   if (mlist[i].q != ASLEEP)
            {   if (mlist[i].q != HELD || Hp >= Hpmax || !havefood (1))
                {   melee = 1;
                    if (mlist[i].q == AWAKE) alertmonster = 1;
                }
            }
        }
    }

    if (!melee) return (0);               /* No one to fight */

    /* Loop to find worst monster and tally danger & number adjacent */
    for (i = 0; i < mlistlen; i++)
    {   rr = mlist[i].mrow;
        cc = mlist[i].mcol;	/* Monster position */

        /*
         * If the monster is adjacent and is either awake or
         * we dont know yet whether he is asleep, but we havent
         * see any alert monsters yet.
         */

        if (max (abs (atrow-rr), abs (atcol-cc)) == 1 &&
                (alertmonster ? mlist[i].q == AWAKE :
                 mlist[i].q != ASLEEP)) /* DR Utexas 26 Jan 84 */
        {   mon = mlist[i].chr;		/* Record the monster type */
            monster = monname (mon);		/* Record the monster name */
            danger += maxhitchar(mon);	/* Add to the danger */

            /* If he is adjacent, add to the adj count */
            if (onrc (CANGO, rr, atcol) && onrc (CANGO, atrow, cc))
            {   adjacent++;
                howmean = isholder (monster) ? 10000 : avghit(i);

                /* If he is adjacent and the worst monster yet, save him */
                if ((howmean > mbad) || (mdir < 0))
                {   wanddir = mdir = direc (rr-atrow, cc-atcol);
                    monc = mon;
                    m = i;
                    mbad = howmean;
                }
            }

            /* If we havent yet a line of sight, check this guy out */
            else if (wanddir == NONE)
            {
                wanddir = direc (rr-atrow, cc-atcol);
            }

            /* Debugging breakpoint */
            dwait (D_BATTLE, "%c <%d,%d>, danger %d, worst %c(%d,%d), total %d",
                   screen[rr][cc], rr-atrow, cc-atcol,
                   danger, monc, mdir, mbad, adjacent);
        }
    }

    /*
     * The following variables have now been set:
     *
     * monc:      The letter of the worst monster we can hit
     * mbad:      Relative scale 0 to 26, how bad is (s)he
     * mdir:      Which direction to him/her
     * danger:    How many hit points can (s)he/they do this round?
     * wanddir:   Direction of worst monster, even if we cant move to it.
     */

    /*
     * Check whether the battlestations expert has a suggested action.
     */

    monster = monname (monc);
    if (battlestations (m, monster, mbad, danger, adjacent ? mdir : wanddir,
                        adjacent ? 1 : 2, alertmonster, max (1, adjacent)))
    {
        foughtmonster = DIDFIGHT;
        return (1);
    }

    /*
     * If we did not wait for him last turn, and he is not adjacent,
     * let him move to us (otherwise, he gets to hits us first).
     */

    if (!lyinginwait && !adjacent)
    {   command (T_FIGHTING, "s");
        dwait (D_BATTLE, "Lying in wait...");
        lyinginwait = 1;
        foughtmonster = DIDFIGHT;
        return (1);
    }

    /* If we are here but have no direction, there was a bug somewhere */
    if (mdir < 0)
    {   dwait (D_BATTLE, "Adjacent, but no direction known!");
        return (0);
    }

    /* If we could die this round, tell the user about it */
    if (danger >= Hp) display ("In trouble...");

    /* Well, nothing better than to hit the beast! Tell dwait about it */
    dwait (D_BATTLE, "Attacking %s(%d) direction %d (total danger %d)...",
           monster, mbad, mdir, danger);

    /* Record the monster type */
    lastmonster = monc-'A'+1;

    /* Move towards the monster (this causes us to hit him) */
    rmove (1, mdir, T_FIGHTING);
    lyinginwait = 0;
    foughtmonster = DIDFIGHT;
    return (1);
}