Path: news.larc.nasa.gov!amiga-request
From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
Subject: v91i160: Larn 12.3 - dungeon type adventure game, Part16/17
Reply-To: Sie <S.Raybould@fulcrum.bt.co.uk>
Newsgroups: comp.sources.amiga
Message-ID: <comp.sources.amiga.v91i160@ab20.larc.nasa.gov>
References: <comp.sources.amiga.v91i145@ab20.larc.nasa.gov>
Date: 30 Aug 91 10:10:32 GMT
Approved: tadguy@uunet.UU.NET (Tad Guy)
X-Mail-Submissions-To: amiga@uunet.uu.net
X-Post-Discussions-To: comp.sys.amiga.misc

Submitted-by: Sie <S.Raybould@fulcrum.bt.co.uk>
Posting-number: Volume 91, Issue 160
Archive-name: games/larn-12.3/part16

#!/bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 16 (of 17)."
# Contents:  object.c
# Wrapped by tadguy@ab20 on Mon Aug 26 21:51:55 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'object.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'object.c'\"
else
echo shar: Extracting \"'object.c'\" \(33382 characters\)
sed "s/^X//" >'object.c' <<'END_OF_FILE'
X/* object.c */
X#include "header.h"
X#include "larndefs.h"
X#include "monsters.h"
X#include "objects.h"
X#include "player.h"
X
X#define min(x,y) (((x)>(y))?(y):(x))
X#define max(x,y) (((x)>(y))?(x):(y))
X
X/* LOOK_FOR_OBJECT
X subroutine to look for an object and give the player his options if an object
X was found.
X*/
Xlookforobject(do_ident, do_pickup, do_action)
X    char            do_ident;   /* identify item: T/F */
X    char            do_pickup;  /* pickup item:   T/F */
X    char            do_action;  /* prompt for actions on object: T/F */
X{
X    register int    i, j;
X
X    /* can't find objects if time is stopped    */
X    if (c[TIMESTOP])
X        return;
X    i = item[playerx][playery];
X    if (i == 0)
X        return;
X    j = iarg[playerx][playery];
X    showcell(playerx, playery);
X    cursors();
X    yrepcount = 0;
X    switch (i)
X    {
X    case OGOLDPILE:
X    case OMAXGOLD:
X    case OKGOLD:
X    case ODGOLD:
X        lprcat("\n\nYou have found some gold!");
X        ogold(i);
X        break;
X
X    case OPOTION:
X        if (do_ident)
X        {
X            lprcat("\n\nYou have found a magic potion");
X            if (potionname[j][0])
X                lprintf(" of %s", &potionname[j][1]);
X        }
X        if (do_pickup)
X            if (take(OPOTION, j) == 0)
X                forget();
X        if (do_action)
X            opotion(j);
X        break;
X
X    case OSCROLL:
X        if (do_ident)
X        {
X            lprcat("\n\nYou have found a magic scroll");
X            if (scrollname[j][0])
X                lprintf(" of %s", &scrollname[j][1]);
X        }
X        if (do_pickup)
X            if (take(OSCROLL, j) == 0)
X                forget();
X        if (do_action)
X            oscroll(j);
X        break;
X
X    case OALTAR:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\n\nThere is a Holy Altar here!");
X        if (do_action)
X            oaltar();
X        break;
X
X    case OBOOK:
X        if (do_ident)
X            lprcat("\n\nYou have found a book.");
X        if (do_pickup)
X            if (take(OBOOK, j) == 0)
X                forget();
X        if (do_action)
X            obook();
X        break;
X
X    case OCOOKIE:
X        if (do_ident)
X            lprcat("\n\nYou have found a fortune cookie.");
X        if (do_pickup)
X            if (take(OCOOKIE, 0) == 0)
X                forget();
X        if (do_action)
X            ocookie();
X        break;
X
X    case OTHRONE:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprintf("\n\nThere is %s here!", objectname[i]);
X        if (do_action)
X            othrone(0);
X        break;
X
X    case OTHRONE2:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprintf("\n\nThere is %s here!", objectname[i]);
X        if (do_action)
X            othrone(1);
X        break;
X
X    case ODEADTHRONE:
X        if (do_ident)
X            lprintf("\n\nThere is %s here!", objectname[i]);
X        if (do_action)
X            odeadthrone();
X        break;
X
X    case OPIT:
X        /* always perform these actions. */
X        lprcat("\n\nYou're standing at the top of a pit.");
X        opit();
X        break;
X
X    case OSTAIRSUP: /* up */
X        if (do_ident)
X            lprcat("\n\nThere is a circular staircase here");
X        if (do_action)
X            ostairs(1);
X        break;
X
X    case OFOUNTAIN:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\n\nThere is a fountain here");
X        if (do_action)
X            ofountain();
X        break;
X
X    case OSTATUE:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\n\nYou are standing in front of a statue");
X        if (do_action)
X            ostatue();
X        break;
X
X    case OCHEST:
X        if (do_ident)
X            lprcat("\n\nThere is a chest here");
X        if (do_pickup)
X            if (take(OCHEST, j) == 0)
X                forget();
X        if (do_action)
X            ochest();
X        break;
X
X    case OSCHOOL:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\n\nYou have found the College of Larn.");
X        if (do_action)
X            prompt_enter();
X        break;
X
X    case OMIRROR:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\n\nThere is a mirror here");
X        if (do_action)
X            omirror();
X        break;
X
X    case OBANK2:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\n\nYou have found a branch office of the bank of Larn.");
X        if (do_action)
X            prompt_enter();
X        break;
X
X    case OBANK:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\n\nYou have found the bank of Larn.");
X        if (do_action)
X            prompt_enter();
X        break;
X
X    case ODEADFOUNTAIN:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\n\nThere is a dead fountain here");
X        break;
X
X    case ODNDSTORE:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\n\nThere is a DND store here.");
X        if (do_action)
X            prompt_enter();
X        break;
X
X    case OSTAIRSDOWN:   /* down */
X        if (do_ident)
X            lprcat("\n\nThere is a circular staircase here");
X        if (do_action)
X            ostairs(-1);
X        break;
X
X    case OOPENDOOR:
X        if (do_ident)
X            lprintf("\n\nYou have found %s", objectname[i]);
X        if (do_action)
X            o_open_door();
X        break;
X
X    case OCLOSEDDOOR:
X        if (do_ident)
X            lprintf("\n\nYou have found %s", objectname[i]);
X        if (do_action)
X            o_closed_door();
X        break;
X
X    case OENTRANCE:
X        if (do_ident)
X            lprcat("\nYou have found ");
X        lprcat(objectname[i]);
X        if (do_action)
X            prompt_enter();
X        break;
X
X    case OVOLDOWN:
X        if (do_ident)
X            lprcat("\nYou have found ");
X        lprcat(objectname[i]);
X        if (do_action)
X            prompt_volshaft(-1);
X        break;
X
X    case OVOLUP:
X        if (do_ident)
X            lprcat("\nYou have found ");
X        lprcat(objectname[i]);
X        if (do_action)
X            prompt_volshaft(1);
X        break;
X
X    case OIVTELETRAP:
X        if (rnd(11) < 6)
X            return;
X        item[playerx][playery] = OTELEPORTER;
X        know[playerx][playery] = KNOWALL;
X        /* fall through to OTELEPORTER case below!!! */
X
X    case OTELEPORTER:
X        lprcat("\nZaaaappp!  You've been teleported!\n");
X        beep();
X        nap(3000);
X        oteleport(0);
X        break;
X
X    case OTRAPARROWIV:  /* for an arrow trap */
X        if (rnd(17) < 13)
X            return;
X        item[playerx][playery] = OTRAPARROW;
X        know[playerx][playery] = 0;
X        /* fall through to OTRAPARROW case below!!! */
X
X    case OTRAPARROW:
X        lprcat("\nYou are hit by an arrow");
X        beep();
X        lastnum = 259;
X        losehp(rnd(10) + level);
X        bottomhp();
X        return;
X
X    case OIVDARTRAP:    /* for a dart trap */
X        if (rnd(17) < 13)
X            return;
X        item[playerx][playery] = ODARTRAP;
X        know[playerx][playery] = 0;
X        /* fall through to ODARTTRAP case below!!! */
X
X    case ODARTRAP:
X        lprcat("\nYou are hit by a dart");
X        beep();     /* for a dart trap */
X        lastnum = 260;
X        losehp(rnd(5));
X        if ((--c[STRENGTH]) < 3)
X            c[STRENGTH] = 3;
X        bottomline();
X        return;
X
X    case OIVTRAPDOOR:   /* for a trap door */
X        if (rnd(17) < 13)
X            return;
X        item[playerx][playery] = OTRAPDOOR;
X        know[playerx][playery] = KNOWALL;
X        /* fall through to OTRAPDOOR case below!!! */
X
X    case OTRAPDOOR:
X        lastnum = 272;  /* a trap door */
X        if ((level == MAXLEVEL - 1) || (level == MAXLEVEL + MAXVLEVEL - 1))
X        {
X            lprcat("\nYou fell through a bottomless trap door!");
X            beep();
X            nap(3000);
X            died(271);
X        }
X        i = rnd(5 + level);
X        lprintf("\nYou fall through a trap door!  You lose %d hit points.", (long) i);
X        beep();
X        losehp(i);
X        nap(2000);
X        newcavelevel(level + 1);
X        draws(0, MAXX, 0, MAXY);
X        bot_linex();
X        return;
X
X    case OTRADEPOST:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\nYou have found the Larn trading Post.");
X        if (do_action)
X            prompt_enter();
X        return;
X
X    case OHOME:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\nYou have found your way home.");
X        if (do_action)
X            prompt_enter();
X        return;
X
X    case OWALL:
X        break;
X
X    case OANNIHILATION:
X        died(283);  /* annihilated by sphere of annihilation */
X        return;
X
X    case OLRS:
X        if (nearbymonst())
X            return;
X        if (do_ident)
X            lprcat("\n\nThere is an LRS office here.");
X        if (do_action)
X            prompt_enter();
X        break;
X
X    default:
X        if (do_ident)
X        {
X            lprintf("\n\nYou have found %s ", objectname[i]);
X            switch (i)
X            {
X            case ODIAMOND:
X            case ORUBY:
X            case OEMERALD:
X            case OSAPPHIRE:
X            case OSPIRITSCARAB:
X            case OORBOFDRAGON:
X            case OCUBEofUNDEAD:
X            case ONOTHEFT:
X                break;
X
X            default:
X                if (j > 0)
X                    lprintf("+ %d", (long) j);
X                else
X                if (j < 0)
X                    lprintf(" %d", (long) j);
X                break;
X            }
X        }
X        if (do_pickup)
X            if (take(i, j) == 0)
X                forget();
X        if (do_action)
X        {
X            char            tempc = 0;
X
X            lprcat("\nDo you want to (t) take it");
X            iopts();
X            while (tempc != 't' && tempc != 'i' && tempc != '\33')
X                tempc = ttgetch();
X            if (tempc == 't')
X            {
X                lprcat("take");
X                if (take(i, j) == 0)
X                    forget();
X                return;
X            }
X            ignore();
X        }
X        break;
X    };
X}
X
X
X/*
X * subroutine to process the stair cases if dir > 0 the up else down 
X */
Xstatic ostairs(dir)
X    int             dir;
X{
X    register int    k;
X    lprcat("\nDo you (s) stay here ");
X    if (dir > 0)
X        lprcat("or (u) go up? ");
X    else
X        lprcat("or (d) go down? ");
X
X    while (1)
X        switch (ttgetch())
X        {
X        case '\33':
X        case 's':
X        case 'i':
X            lprcat("stay here");
X            return;
X
X        case 'u':
X            lprcat("go up");
X            act_up_stairs();
X            return;
X
X        case 'd':
X            lprcat("go down");
X            act_down_stairs();
X            return;
X        };
X}
X
X
X
X/*
X * subroutine to handle a teleport trap +/- 1 level maximum 
X */
Xoteleport(err)
X    int             err;
X{
X    register int    tmp;
X    if (err)
X        if (rnd(151) < 3)
X            died(264);  /* stuck in a rock */
X    c[TELEFLAG] = 1;    /* show ?? on bottomline if been teleported    */
X    if (level == 0)
X        tmp = 0;
X    else
X    if (level < MAXLEVEL)
X    {
X        tmp = rnd(5) + level - 3;
X        if (tmp >= MAXLEVEL)
X            tmp = MAXLEVEL - 1;
X        if (tmp < 1)
X            tmp = 1;
X    } else
X    {
X        tmp = rnd(3) + level - 2;
X        if (tmp >= MAXLEVEL + MAXVLEVEL)
X            tmp = MAXLEVEL + MAXVLEVEL - 1;
X        if (tmp < MAXLEVEL)
X            tmp = MAXLEVEL;
X    }
X    playerx = rnd(MAXX - 2);
X    playery = rnd(MAXY - 2);
X    if (level != tmp)
X        newcavelevel(tmp);
X    positionplayer();
X    draws(0, MAXX, 0, MAXY);
X    bot_linex();
X}
X
X
X/*
X * function to process a potion 
X */
Xstatic opotion(pot)
X    int             pot;
X{
X    lprcat("\nDo you (d) drink it, (t) take it");
X    iopts();
X    while (1)
X        switch (ttgetch())
X        {
X        case '\33':
X        case 'i':
X            ignore();
X            return;
X
X        case 'd':
X            lprcat("drink\n");
X            forget();   /* destroy potion  */
X            quaffpotion(pot, TRUE);
X            return;
X
X        case 't':
X            lprcat("take\n");
X            if (take(OPOTION, pot) == 0)
X                forget();
X            return;
X        };
X}
X
X/*
X * function to drink a potion 
X *
X * Also used to perform the action of a potion without quaffing a potion (see
X * invisible capability when drinking from a fountain). 
X */
Xquaffpotion(pot, set_known)
X    int             pot;
X    int             set_known;
X{
X    register int    i, j, k;
X
X    /* check for within bounds */
X    if (pot < 0 || pot >= MAXPOTION)
X        return;
X
X    /*
X     * if player is to know this potion (really quaffing one), make it
X     * known 
X     */
X    if (set_known)
X        potionname[pot][0] = ' ';
X
X    switch (pot)
X    {
X    case 0:
X        lprcat("\nYou fall asleep. . .");
X        i = rnd(11) - (c[CONSTITUTION] >> 2) + 2;
X        while (--i > 0)
X        {
X            parse2();
X            nap(1000);
X        }
X        cursors();
X        lprcat("\nYou woke up!");
X        return;
X
X    case 1:
X        lprcat("\nYou feel better");
X        if (c[HP] == c[HPMAX])
X            raisemhp(1);
X        else
X        if ((c[HP] += rnd(20) + 20 + c[LEVEL]) > c[HPMAX])
X            c[HP] = c[HPMAX];
X        break;
X
X    case 2:
X        lprcat("\nSuddenly, you feel much more skillful!");
X        raiselevel();
X        raisemhp(1);
X        return;
X
X    case 3:
X        lprcat("\nYou feel strange for a moment");
X        c[rund(6)]++;
X        break;
X
X    case 4:
X        lprcat("\nYou feel more self confident!");
X        c[WISDOM] += rnd(2);
X        break;
X
X    case 5:
X        lprcat("\nWow!  You feel great!");
X        if (c[STRENGTH] < 12)
X            c[STRENGTH] = 12;
X        else
X            c[STRENGTH]++;
X        break;
X
X    case 6:
X        lprcat("\nYour charm went up by one!");
X        c[CHARISMA]++;
X        break;
X
X    case 7:
X        lprcat("\nYou become dizzy!");
X        if (--c[STRENGTH] < 3)
X            c[STRENGTH] = 3;
X        break;
X
X    case 8:
X        lprcat("\nYour intelligence went up by one!");
X        c[INTELLIGENCE]++;
X        break;
X
X    case 9:
X        lprcat("\nYou sense the presence of objects!");
X        nap(1000);
X        if (c[BLINDCOUNT])
X            return;
X        for (i = 0; i < MAXY; i++)
X            for (j = 0; j < MAXX; j++)
X                switch (item[j][i])
X                    {
X                    case OPLATE:
X                    case OCHAIN:
X                    case OLEATHER:
X                    case ORING:
X                    case OSTUDLEATHER:
X                    case OSPLINT:
X                    case OPLATEARMOR:
X                    case OSSPLATE:
X                    case OSHIELD:
X                    case OSWORDofSLASHING:
X                    case OHAMMER:
X                    case OSWORD:
X                    case O2SWORD:
X                    case OSPEAR:
X                    case ODAGGER:
X                    case OBATTLEAXE:
X                    case OLONGSWORD:
X                    case OFLAIL:
X                    case OLANCE:
X                    case ORINGOFEXTRA:
X                    case OREGENRING:
X                    case OPROTRING:
X                    case OENERGYRING:
X                    case ODEXRING:
X                    case OSTRRING:
X                    case OCLEVERRING:
X                    case ODAMRING:
X                    case OBELT:
X                    case OSCROLL:
X                    case OPOTION:
X                    case OBOOK:
X                    case OCHEST:
X                    case OAMULET:
X                    case OORBOFDRAGON:
X                    case OSPIRITSCARAB:
X                    case OCUBEofUNDEAD:
X                    case ONOTHEFT:
X                    case OCOOKIE:
X                        know[j][i] = HAVESEEN;
X                        show1cell(j, i);
X                        break;
X                    }
X        showplayer();
X        return;
X
X    case 10:        /* monster detection */
X        lprcat("\nYou detect the presence of monsters!");
X        nap(1000);
X        if (c[BLINDCOUNT])
X            return;
X        for (i = 0; i < MAXY; i++)
X            for (j = 0; j < MAXX; j++)
X                if (mitem[j][i] && (monstnamelist[mitem[j][i]] != floorc))
X                {
X                    know[j][i] = HAVESEEN;
X                    show1cell(j, i);
X                }
X        return;
X
X    case 11:
X        lprcat("\nYou stagger for a moment . .");
X        for (i = 0; i < MAXY; i++)
X            for (j = 0; j < MAXX; j++)
X                know[j][i] = 0;
X        nap(1000);
X        draws(0, MAXX, 0, MAXY);    /* potion of forgetfulness */
X        return;
X
X    case 12:
X        lprcat("\nThis potion has no taste to it");
X        return;
X
X    case 13:
X        lprcat("\nYou can't see anything!");    /* blindness */
X        c[BLINDCOUNT] += 500;
X        return;
X
X    case 14:
X        lprcat("\nYou feel confused");
X        c[CONFUSE] += 20 + rnd(9);
X        return;
X
X    case 15:
X        lprcat("\nWOW!!!  You feel Super-fantastic!!!");
X        if (c[HERO] == 0)
X            for (i = 0; i < 6; i++)
X                c[i] += 11;
X        c[HERO] += 250;
X        break;
X
X    case 16:
X        lprcat("\nYou have a greater intestinal constitude!");
X        c[CONSTITUTION]++;
X        break;
X
X    case 17:
X        lprcat("\nYou now have incredibly bulging muscles!!!");
X        if (c[GIANTSTR] == 0)
X            c[STREXTRA] += 21;
X        c[GIANTSTR] += 700;
X        break;
X
X    case 18:
X        lprcat("\nYou feel a chill run up your spine!");
X        c[FIRERESISTANCE] += 1000;
X        break;
X
X    case 19:
X        lprcat("\nYou feel greedy . . .");
X        nap(1000);
X        if (c[BLINDCOUNT])
X            return;
X        for (i = 0; i < MAXY; i++)
X            for (j = 0; j < MAXX; j++)
X            {
X                k = item[j][i];
X                if ((k == ODIAMOND)  ||
X                    (k == ORUBY)     ||
X                    (k == OEMERALD)  ||
X                    (k == OMAXGOLD)  ||
X                    (k == OSAPPHIRE) ||
X                    (k == OLARNEYE)  ||
X                    (k == OGOLDPILE))
X                {
X                    know[j][i] = HAVESEEN;
X                    show1cell(j, i);
X                }
X            }
X        showplayer();
X        return;
X
X    case 20:
X        c[HP] = c[HPMAX];
X        break;      /* instant healing */
X
X    case 21:
X        lprcat("\nYou don't seem to be affected");
X        return;     /* cure dianthroritis */
X
X    case 22:
X        lprcat("\nYou feel a sickness engulf you"); /* poison */
X        c[HALFDAM] += 200 + rnd(200);
X        return;
X
X    case 23:
X        lprcat("\nYou feel your vision sharpen");   /* see invisible */
X        c[SEEINVISIBLE] += rnd(1000) + 400;
X        monstnamelist[INVISIBLESTALKER] = 'I';
X        return;
X    };
X    bottomline();       /* show new stats      */
X    return;
X}
X
X
X/*
X * function to process a magic scroll 
X */
Xstatic oscroll(typ)
X    int             typ;
X{
X    lprcat("\nDo you ");
X    if (c[BLINDCOUNT] == 0)
X        lprcat("(r) read it, ");
X    lprcat("(t) take it");
X    iopts();
X    while (1)
X        switch (ttgetch())
X        {
X        case '\33':
X        case 'i':
X            ignore();
X            return;
X
X        case 'r':
X            if (c[BLINDCOUNT])
X                break;
X            lprcat("read");
X            forget();
X            if (typ == 2 || typ == 15)
X            {
X                show1cell(playerx, playery);
X                cursors();
X            }
X             /* destroy it  */ read_scroll(typ);
X            return;
X
X        case 't':
X            lprcat("take");
X            if (take(OSCROLL, typ) == 0)
X                forget();   /* destroy it  */
X            return;
X        };
X}
X
X/*
X * data for the function to read a scroll 
X */
Xstatic int   xh, yh, yl, xl;
Xstatic char  curse[] = {BLINDCOUNT, CONFUSE, AGGRAVATE, HASTEMONST, ITCHING,
X                        LAUGHING, DRAINSTRENGTH, CLUMSINESS, INFEEBLEMENT, 
X                        HALFDAM};
Xstatic char  exten[] = {PROTECTIONTIME, DEXCOUNT, STRCOUNT, CHARMCOUNT,
X                        INVISIBILITY, CANCELLATION, HASTESELF, GLOBE,
X                        SCAREMONST, HOLDMONST, TIMESTOP};
Xstatic char  time_change[] = {HASTESELF, HERO, ALTPRO, PROTECTIONTIME, DEXCOUNT,
X                              STRCOUNT, GIANTSTR, CHARMCOUNT, INVISIBILITY,
X                              CANCELLATION,HASTESELF, AGGRAVATE, SCAREMONST,
X                              STEALTH, AWARENESS, HOLDMONST, HASTEMONST,
X                              FIRERESISTANCE, GLOBE, SPIRITPRO, UNDEADPRO,
X                              HALFDAM, SEEINVISIBLE, ITCHING, CLUMSINESS, WTW};
X/*
X * function to adjust time when time warping and taking courses in school
X */
Xadjtime(tim)
X    register long   tim;
X{
X    register int    j;
X    for (j = 0; j < 26; j++)/* adjust time related parameters */
X        if (c[time_change[j]])
X            if ((c[time_change[j]] -= tim) < 1)
X                c[time_change[j]] = 1;
X    regen();
X}
X
X/*
X * function to read a scroll 
X */
Xread_scroll(typ)
X    int             typ;
X{
X    register int    i, j;
X    if (typ < 0 || typ >= MAXSCROLL)
X        return;     /* be sure we are within bounds */
X    scrollname[typ][0] = ' ';
X    switch (typ)
X    {
X    case 0:
X        lprcat("\nYour armor glows for a moment");
X        enchantarmor();
X        return;
X
X    case 1:
X        lprcat("\nYour weapon glows for a moment");
X        enchweapon();
X        return;     /* enchant weapon */
X
X    case 2:
X        lprcat("\nYou have been granted enlightenment!");
X        yh = min(playery + 7, MAXY);
X        xh = min(playerx + 25, MAXX);
X        yl = max(playery - 7, 0);
X        xl = max(playerx - 25, 0);
X        for (i = yl; i < yh; i++)
X            for (j = xl; j < xh; j++)
X                know[j][i] = KNOWALL;
X        draws(xl, xh, yl, yh);
X        return;
X
X    case 3:
X        lprcat("\nThis scroll seems to be blank");
X        return;
X
X    case 4:
X        createmonster(makemonst(level + 1));
X        return;     /* this one creates a monster  */
X
X    case 5:
X        something(level);   /* create artifact     */
X        return;
X
X    case 6:
X        c[AGGRAVATE] += 800;
X        return;     /* aggravate monsters */
X
X    case 7:
X        gtime += (i = rnd(1000) - 850); /* time warp */
X        if (i >= 0)
X            lprintf("\nYou went forward in time by %d mobuls", (long) ((i + 99) / 100));
X        else
X            lprintf("\nYou went backward in time by %d mobuls", (long) (-(i + 99) / 100));
X        adjtime((long) i);  /* adjust time for time warping */
X        return;
X
X    case 8:
X        oteleport(0);
X        return;     /* teleportation */
X
X    case 9:
X        c[AWARENESS] += 1800;
X        return;     /* expanded awareness   */
X
X    case 10:
X        c[HASTEMONST] += rnd(55) + 12;
X        return;     /* haste monster */
X
X    case 11:
X        for (i = 0; i < MAXY; i++)
X            for (j = 0; j < MAXX; j++)
X                if (mitem[j][i])
X                    hitp[j][i] = monster[mitem[j][i]].hitpoints;
X        return;     /* monster healing */
X    case 12:
X        c[SPIRITPRO] += 300 + rnd(200);
X        bottomline();
X        return;     /* spirit protection */
X
X    case 13:
X        c[UNDEADPRO] += 300 + rnd(200);
X        bottomline();
X        return;     /* undead protection */
X
X    case 14:
X        c[STEALTH] += 250 + rnd(250);
X        bottomline();
X        return;     /* stealth */
X
X    case 15:
X        lprcat("\nYou have been granted enlightenment!");   /* magic mapping */
X        for (i = 0; i < MAXY; i++)
X            for (j = 0; j < MAXX; j++)
X                know[j][i] = KNOWALL;
X        draws(0, MAXX, 0, MAXY);
X        return;
X
X    case 16:
X        c[HOLDMONST] += 30;
X        bottomline();
X        return;     /* hold monster */
X
X    case 17:
X        for (i = 0; i < 26; i++)    /* gem perfection */
X            switch (iven[i])
X            {
X            case ODIAMOND:
X            case ORUBY:
X            case OEMERALD:
X            case OSAPPHIRE:
X                j = ivenarg[i];
X                j &= 255;
X                j <<= 1;
X                if (j > 255)
X                    j = 255;    /* double value */
X                ivenarg[i] = j;
X                break;
X            }
X        break;
X
X    case 18:
X        for (i = 0; i < 11; i++)
X            c[exten[i]] <<= 1;  /* spell extension */
X        break;
X
X    case 19:
X        for (i = 0; i < 26; i++)    /* identify */
X        {
X            if (iven[i] == OPOTION)
X                potionname[ivenarg[i]][0] = ' ';
X            if (iven[i] == OSCROLL)
X                scrollname[ivenarg[i]][0] = ' ';
X        }
X        break;
X
X    case 20:
X        for (i = 0; i < 10; i++)    /* remove curse */
X            if (c[curse[i]])
X                c[curse[i]] = 1;
X        break;
X
X    case 21:
X        annihilate();
X        break;      /* scroll of annihilation */
X
X    case 22:
X        godirect(22, 150, "The ray hits the %s", 0, ' ');   /* pulverization */
X        break;
X    case 23:
X        c[LIFEPROT]++;
X        break;      /* life protection */
X    };
X}
X
Xstatic opit()
X{
X    register int    i;
X    if (rnd(101) < 81)
X        if (rnd(70) > 9 * c[DEXTERITY] - packweight() || rnd(101) < 5)
X            if (level == MAXLEVEL - 1)
X                obottomless();
X            else
X            if (level == MAXLEVEL + MAXVLEVEL - 1)
X                obottomless();
X            else
X            {
X                if (rnd(101) < 20)
X                {
X                    i = 0;
X                    lprcat("\nYou fell into a pit!  Your fall is cushioned by an unknown force\n");
X                } else
X                {
X                    i = rnd(level * 3 + 3);
X                    lprintf("\nYou fell into a pit!  You suffer %d hit points damage", (long) i);
X                    lastnum = 261;  /* if he dies scoreboard
X                             * will say so */
X                }
X                losehp(i);
X                nap(2000);
X                newcavelevel(level + 1);
X                draws(0, MAXX, 0, MAXY);
X            }
X}
X
Xstatic obottomless()
X{
X    lprcat("\nYou fell into a bottomless pit!");
X    beep();
X    nap(3000);
X    died(262);
X}
X
Xstatic ostatue()
X{
X}
X
Xstatic omirror()
X{
X}
X
Xstatic obook()
X{
X    lprcat("\nDo you ");
X    if (c[BLINDCOUNT] == 0)
X        lprcat("(r) read it, ");
X    lprcat("(t) take it");
X    iopts();
X    while (1)
X        switch (ttgetch())
X        {
X        case '\33':
X        case 'i':
X            ignore();
X            return;
X
X        case 'r':
X            if (c[BLINDCOUNT])
X                break;
X            lprcat("read");
X             /* no more book */ readbook(iarg[playerx][playery]);
X            forget();
X            return;
X
X        case 't':
X            lprcat("take");
X            if (take(OBOOK, iarg[playerx][playery]) == 0)
X                forget();   /* no more book */
X            return;
X        };
X}
X
X/*
X * function to read a book 
X */
Xreadbook(lev)
X    register int    lev;
X{
X    register int    i, tmp;
X    if (lev <= 3)
X        i = rund((tmp = splev[lev]) ? tmp : 1);
X    else
X        i = rnd((tmp = splev[lev] - 9) ? tmp : 1) + 9;
X    spelknow[i] = 1;
X    lprintf("\nSpell \"%s\":  %s\n%s", spelcode[i], spelname[i], speldescript[i]);
X    if (rnd(10) == 4)
X    {
X        lprcat("\nYour int went up by one!");
X        c[INTELLIGENCE]++;
X        bottomline();
X    }
X}
X
Xstatic ocookie()
X{
X    char           *p;
X    lprcat("\nDo you (e) eat it, (t) take it");
X    iopts();
X    while (1)
X        switch (ttgetch())
X        {
X        case '\33':
X        case 'i':
X            ignore();
X            return;
X
X        case 'e':
X            lprcat("eat");
X            forget();   /* no more cookie */
X            outfortune();
X            return;
X
X        case 't':
X            lprcat("take");
X            if (take(OCOOKIE, 0) == 0)
X                forget();   /* no more book */
X            return;
X        };
X}
X
X/*
X * routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth
X * 100* the argument
X */
Xstatic ogold(arg)
X    int             arg;
X{
X    register long   i;
X    i = iarg[playerx][playery];
X    if (arg == OMAXGOLD)
X        i *= 100;
X    else
X    if (arg == OKGOLD)
X        i *= 1000;
X    else
X    if (arg == ODGOLD)
X        i *= 10;
X    lprintf("\nIt is worth %d!", (long) i);
X    c[GOLD] += i;
X    bottomgold();
X    item[playerx][playery] = know[playerx][playery] = 0;    /* destroy gold    */
X}
X
Xohome()
X{
X    register int    i;
X    nosignal = 1;       /* disable signals */
X    for (i = 0; i < 26; i++)
X        if (iven[i] == OPOTION)
X            if (ivenarg[i] == 21)
X            {
X                iven[i] = 0;    /* remove the potion of cure
X                         * dianthroritis from
X                         * inventory */
X                clear();
X                lprcat("Congratulations.  You found a potion of cure dianthroritis.\n");
X                lprcat("\nFrankly, No one thought you could do it.  Boy!  Did you surprise them!\n");
X                if (gtime > TIMELIMIT)
X                {
X                    lprcat("\nThe doctor has the sad duty to inform you that your daughter died");
X                    lprcat("\nbefore your return.  There was nothing he could do without the potion.\n");
X                    nap(5000);
X                    died(269);
X                } else
X                {
X                    lprcat("\nThe doctor is now administering the potion, and in a few moments\n");
X                    lprcat("your daughter should be well on her way to recovery.\n");
X                    nap(6000);
X                    lprcat("\nThe potion is");
X                    nap(3000);
X                    lprcat(" working!  The doctor thinks that\n");
X                    lprcat("your daughter will recover in a few days.  Congratulations!\n");
X                    beep();
X                    nap(5000);
X                    died(263);
X                }
X            }
X    while (1)
X    {
X        clear();
X        lprintf("Welcome home %s.  Latest word from the doctor is not good.\n", logname);
X
X        if (gtime > TIMELIMIT)
X        {
X            lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
X            lprcat("You didn't make it in time.  There was nothing he could do without the potion.\n");
X            nap(5000);
X            died(269);
X        }
X        lprcat("\nThe diagnosis is confirmed as dianthroritis.  He guesses that\n");
X        lprintf("your daughter has only %d mobuls left in this world.  It's up to you,\n", (long) ((TIMELIMIT - gtime + 99) / 100));
X        lprintf("%s, to find the only hope for your daughter, the very rare\n", logname);
X        lprcat("potion of cure dianthroritis.  It is rumored that only deep in the\n");
X        lprcat("depths of the caves can this potion be found.\n\n\n");
X        lprcat("\n     ----- press ");
X        standout("return");
X        lprcat(" to continue, ");
X        standout("escape");
X        lprcat(" to leave ----- ");
X        i = ttgetch();
X        while (i != '\33' && i != '\n')
X            i = ttgetch();
X        if (i == '\33')
X        {
X            drawscreen();
X            nosignal = 0;   /* enable signals */
X            return;
X        }
X    }
X}
X
X/* routine to save program space   */
Xiopts()
X{
X    lprcat(", or (i) ignore it? ");
X}
Xignore()
X{
X    lprcat("ignore\n");
X}
X
X/*
X * For prompt mode, prompt for entering a building.
X */
Xstatic prompt_enter()
X{
X    char            i;
X
X    lprcat("\nDo you (g) go inside, or (i) stay here? ");
X    i = 0;
X    while ((i != 'g') && (i != 'i') && (i != '\33'))
X        i = ttgetch();
X    if (i == 'g')
X        enter();
X    else
X        lprcat(" stay here");
X}
X
X/*
X * For prompt mode, prompt for climbing up/down the volcanic shaft. 
X *
X * Takes one parameter: if it is negative, going down the shaft, otherwise,
X * going up the shaft. 
X */
Xstatic prompt_volshaft(dir)
X    int             dir;
X{
X    char            i;
X
X    lprcat("\nDo you (c) climb ");
X    if (dir > 0)
X        lprcat("up");
X    else
X        lprcat("down");
X    iopts();
X
X    i = 0;
X    while ((i != 'c') && (i != 'i') && (i != '\33'))
X        i = ttgetch();
X
X    if ((i == '\33') || (i == 'i'))
X    {
X        ignore();
X        return;
X    }
X    if (dir > 0)
X        act_up_shaft();
X    else
X        act_down_shaft();
X}
X
Xstatic o_open_door()
X{
X    char            i;
X    lprcat("\nDo you (c) close it");
X    iopts();
X    i = 0;
X    while ((i != 'c') && (i != 'i') && (i != '\33'))
X        i = ttgetch();
X    if ((i == '\33') || (i == 'i'))
X    {
X        ignore();
X        return;
X    }
X    lprcat("close");
X    forget();
X    item[playerx][playery] = OCLOSEDDOOR;
X    iarg[playerx][playery] = 0;
X    playerx = lastpx;
X    playery = lastpy;
X}
X
Xstatic o_closed_door()
X{
X    char            i;
X    lprcat("\nDo you (o) try to open it");
X    iopts();
X    i = 0;
X    while ((i != 'o') && (i != 'i') && (i != '\33'))
X        i = ttgetch();
X    if ((i == '\33') || (i == 'i'))
X    {
X        ignore();
X        playerx = lastpx;
X        playery = lastpy;
X        return;
X    } else
X    {
X        lprcat("open");
X        /*
X         * if he failed to open the door ... 
X         */
X        if (!act_open_door(playerx, playery))
X        {
X            playerx = lastpx;
X            playery = lastpy;
X        }
X    }
X}
END_OF_FILE
if test 33382 -ne `wc -c <'object.c'`; then
    echo shar: \"'object.c'\" unpacked with wrong size!
fi
# end of 'object.c'
fi
echo shar: End of archive 16 \(of 17\).
cp /dev/null ark16isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 17 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
Mail comments to the moderator at <amiga-request@uunet.uu.net>.
Post requests for sources, and general discussion to comp.sys.amiga.misc.
