[comp.sources.games] v12i057: larn2 - dungeon type adventure game

billr@saab.CNA.TEK.COM (Bill Randle) (04/24/91)

Submitted-by: routley@tle.ENET.DEC.COM (Kevin Routley)
Posting-number: Volume 12, Issue 57
Archive-name: larn2/Part04
Supersedes: larn: Volume 11, Issue 84-94
Environment: Unix, VMS, MS-DOS, OS/2, termcap



#! /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 4 (of 12)."
# Contents:  data.c movem.c os2larn.lnk tlink.rsp
# Wrapped by billr@saab on Tue Apr 23 13:50:29 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'data.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'data.c'\"
else
echo shar: Extracting \"'data.c'\" \(31296 characters\)
sed "s/^X//" >'data.c' <<'END_OF_FILE'
X#include "header.h"
X#include "monsters.h"
X#include "objects.h"
X
X#define VER    12
X#define SUBVER  3
X
X/*
X    class[c[LEVEL]-1] gives the correct name of the players experience level
X*/
Xstatic char aa1[] = " mighty evil master";
Xstatic char aa2[] = "apprentice demi-god";
Xstatic char aa3[] = "  minor demi-god   ";
Xstatic char aa4[] = "  major demi-god   ";
Xstatic char aa5[] = "    minor deity    ";
Xstatic char aa6[] = "    major deity    ";
Xstatic char aa7[] = "  novice guardian  ";
Xstatic char aa8[] = "apprentice guardian";
Xstatic char aa9[] = "    The Creator    ";
Xchar *class[]=
X{   "  novice explorer  ", "apprentice explorer", " practiced explorer",/*  -3*/
X    "   expert explorer ", "  novice adventurer", "     adventurer    ",/*  -6*/
X    "apprentice conjurer", "     conjurer      ", "  master conjurer  ",/*  -9*/
X    "  apprentice mage  ", "        mage       ", "  experienced mage ",/* -12*/
X    "     master mage   ", " apprentice warlord", "   novice warlord  ",/* -15*/
X    "   expert warlord  ", "   master warlord  ", " apprentice gorgon ",/* -18*/
X    "       gorgon      ", "  practiced gorgon ", "   master gorgon   ",/* -21*/
X    "    demi-gorgon    ", "    evil master    ", " great evil master ",/* -24*/
X      aa1       ,   aa1       ,   aa1       ,/* -27*/
X      aa1       ,   aa1       ,   aa1       ,/* -30*/
X      aa1       ,   aa1       ,   aa1       ,/* -33*/
X      aa1       ,   aa1       ,   aa1       ,/* -36*/
X      aa1       ,   aa1       ,   aa1       ,/* -39*/
X      aa2       ,   aa2       ,   aa2       ,/* -42*/
X      aa2       ,   aa2       ,   aa2       ,/* -45*/
X      aa2       ,   aa2       ,   aa2       ,/* -48*/
X      aa3       ,   aa3       ,   aa3       ,/* -51*/
X      aa3       ,   aa3       ,   aa3       ,/* -54*/
X      aa3       ,   aa3       ,   aa3       ,/* -57*/
X      aa4       ,   aa4       ,   aa4       ,/* -60*/
X      aa4       ,   aa4       ,   aa4       ,/* -63*/
X      aa4       ,   aa4       ,   aa4       ,/* -66*/
X      aa5       ,   aa5       ,   aa5       ,/* -69*/
X      aa5       ,   aa5       ,   aa5       ,/* -72*/
X      aa5       ,   aa5       ,   aa5       ,/* -75*/
X      aa6       ,   aa6       ,   aa6       ,/* -78*/
X      aa6       ,   aa6       ,   aa6       ,/* -81*/
X      aa6       ,   aa6       ,   aa6       ,/* -84*/
X      aa7       ,   aa7       ,   aa7       ,/* -87*/
X      aa8       ,   aa8       ,   aa8       ,/* -90*/
X      aa8       ,   aa8       ,   aa8       ,/* -93*/
X    "  earth guardian   ", "   air guardian    ", "   fire guardian   ",/* -96*/
X    "  water guardian   ", "  time guardian    ", " ethereal guardian ",/* -99*/
X      aa9       ,   aa9       ,   aa9       ,/* -102*/
X};
X
X/*
X    table of experience needed to be a certain level of player
X    skill[c[LEVEL]] is the experience required to attain the next level
X */
X#define MEG 1000000
Xlong skill[] = {
X0, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120,                  /*  1-11 */
X10240, 20480, 40960, 100000, 200000, 400000, 700000, 1*MEG,          /* 12-19 */
X2*MEG,3*MEG,4*MEG,5*MEG,6*MEG,8*MEG,10*MEG,                          /* 20-26 */
X12*MEG,14*MEG,16*MEG,18*MEG,20*MEG,22*MEG,24*MEG,26*MEG,28*MEG,      /* 27-35 */
X30*MEG,32*MEG,34*MEG,36*MEG,38*MEG,40*MEG,42*MEG,44*MEG,46*MEG,      /* 36-44 */
X48*MEG,50*MEG,52*MEG,54*MEG,56*MEG,58*MEG,60*MEG,62*MEG,64*MEG,      /* 45-53 */
X66*MEG,68*MEG,70*MEG,72*MEG,74*MEG,76*MEG,78*MEG,80*MEG,82*MEG,      /* 54-62 */
X84*MEG,86*MEG,88*MEG,90*MEG,92*MEG,94*MEG,96*MEG,98*MEG,100*MEG,     /* 63-71 */
X105*MEG,110*MEG,115*MEG,120*MEG, 125*MEG, 130*MEG, 135*MEG, 140*MEG, /* 72-79 */
X145*MEG,150*MEG,155*MEG,160*MEG, 165*MEG, 170*MEG, 175*MEG, 180*MEG, /* 80-87 */
X185*MEG,190*MEG,195*MEG,200*MEG, 210*MEG, 220*MEG, 230*MEG, 240*MEG, /* 88-95 */
X250*MEG,260*MEG,270*MEG,280*MEG, 290*MEG, 300*MEG                    /* 96-101*/
X};
X#undef MEG
X
Xchar *lpbuf,*lpnt,*inbuffer,*lpend; /* input/output pointers to the buffers */
X# ifdef MSDOS
XRAMBLOCK *ramblks;
XDISKBLOCK *diskblks;
X# else
Xstruct cel *cell;   /*  pointer to the dungeon storage  */
X# endif
Xshort hitp[MAXX][MAXY];     /*  monster hp on level     */
Xshort iarg[MAXX][MAXY]; /*  arg for the item array  */
Xchar item[MAXX][MAXY];  /*  objects in maze if any  */
Xchar know[MAXX][MAXY];  /*  1 or 0 if here before   */
Xchar mitem[MAXX][MAXY]; /*  monster item array      */
Xchar stealth[MAXX][MAXY];   /*  0=sleeping 1=awake monst*/
Xchar lastmonst[40];     /*  this has the name of the current monster    */
Xchar beenhere[MAXLEVEL+MAXVLEVEL];  /*  1 if have been on this level */
Xchar VERSION=VER;   /*  this is the present version # of the program    */
Xchar SUBVERSION=SUBVER;
Xchar nosignal=0;    /* set to 1 to disable the signals from doing anything */
Xchar predostuff=0;  /*  2 means that the trap handling routines must do a
X                        showplayer() after a trap.  0 means don't showplayer()
X                        0 - we are in create player screen
X                        1 - we are in welcome screen
X                        2 - we are in the normal game   */
Xchar loginname[20];     /* players login name */
Xchar logname[LOGNAMESIZE];  /* players name storage for scoring             */
Xchar sex=1;             /*  default is a man  0=woman                       */
Xchar boldon=1;          /*  1=bold objects  0=inverse objects               */
Xchar ckpflag=0;         /*  1 if want checkpointing of game, 0 otherwise    */
Xchar cheat=0;           /*  1 if the player has fudged save file            */
Xchar level=0;           /*  cavelevel player is on = c[CAVELEVEL]           */
Xchar wizard=0;          /*  the wizard mode flag                            */
Xshort lastnum=0;        /* the number of the monster last hitting player    */
Xshort hitflag=0;        /*  flag for if player has been hit when running    */
Xshort hit2flag=0;       /*  flag for if player has been hit when running    */
Xshort hit3flag=0;       /*  flag for if player has been hit flush input     */
Xshort playerx,playery;  /*  the room on the present level of the player     */
Xshort lastpx,lastpy;    /*  0 --- MAXX-1  or  0 --- MAXY-1                  */
Xshort oldx,oldy;
Xchar  prayed = 1;       /* did player pray at an altar (command mode)? needs
X                           to be saved, but I don't want to add incompatibility
X                           right now.  KBR 1/11/90 */
Xshort lasthx=0,lasthy=0;/* location of monster last hit by player       */
Xshort nobeep=0;         /* true if program is not to beep                   */
Xunsigned long lrandx=33601;  /*  the random number seed                      */
Xlong initialtime=0;         /* time playing began                           */
Xlong gtime=0;               /*  the clock for the game                      */
Xlong outstanding_taxes=0;   /* present tax bill from score file             */
Xlong c[100],cbak[100];      /*  the character description arrays            */
Xint enable_scroll=0;        /* constant for enabled/disabled scrolling regn */
Xchar aborted[] = " aborted";
Xstruct sphere *spheres=0; /*pointer to linked list for spheres of annihilation*/
Xchar *levelname[]=
X{ " H"," 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9","10","V1","V2","V3" };
X
Xchar original_objnamelist[]=".AT_P<_F&^+M=>_$$f*OD#~][[)))(((||||||||{?!BC}o:;,@@@@EVV))([[]]](^.[H***.^^.S.tsTLc_____________________________________________";
Xchar hacklike_objnamelist[]=".:\\_^<_{%^6|2>_55}$'+#~[[[))))))========-?!?&~~~~~****899)))[[[[[)^.[1$$$.^^.3./0\\4,____________________________________________";
Xchar objnamelist[MAXOBJECT+1];
Xchar monstnamelist[]=".BGHJKOScjtAELNQRZabhiCTYdegmvzFWflorXV.pqsyUkMwDDPxnDDuD........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,";
Xchar floorc = '.';
Xchar wallc  = '#';
Xchar boldobjects = FALSE ;
Xchar auto_pickup = FALSE ;
X
X# ifdef MSDOS
X  int DECRainbow, keypad;
X# endif
X
Xchar *objectname[]=
X{ 0,"a holy altar","a handsome jewel encrusted throne","the orb","a pit",
X  "a staircase leading upwards","an elevator going up","a bubbling fountain",
X  "a great marble statue","a teleport trap","the college of Larn",
X  "a mirror","the DND store","a staircase going down","an elevator going down",
X  "the bank of Larn","the 5th branch of the Bank of Larn",
X  "a dead fountain","gold","an open door","a closed door",
X  "a wall","The Eye of Larn","plate mail","chain mail","leather armor",
X  "a sword of slashing","Bessman's flailing hammer","a sunsword",
X  "a two handed sword","a spear","a dagger",
X  "ring of extra regeneration","a ring of regeneration","a ring of protection",
X  "an energy ring","a ring of dexterity","a ring of strength",
X  "a ring of cleverness","a ring of increase damage","a belt of striking",
X  "a magic scroll","a magic potion","a book","a chest",
X  "an amulet of invisibility","an orb of dragon slaying",
X  "a scarab of negate spirit","a cube of undead control",
X  "device of theft prevention","a brilliant diamond","a ruby",
X  "an enchanting emerald","a sparkling sapphire","the dungeon entrance",
X  "a volcanic shaft leaning downward","the base of a volcanic shaft",
X  "a battle axe","a longsword","a flail","ring mail","studded leather armor",
X  "splint mail","plate armor","stainless plate armor","a lance of death",
X  "an arrow trap","an arrow trap","a shield","your home",
X  "gold","gold","gold","a dart trap",
X  "a dart trap","a trapdoor","a trapdoor","the local trading post",
X  "a teleport trap", "a massive throne",
X  "a sphere of annihilation","a handsome jewel encrusted throne",
X  "the Larn Revenue Service","a fortune cookie","","","","","","",
X  "","","","","","","","","","","","","","","","","","","",""
X };
X
X
X/*
X *  for the monster data
X *
X *  array to do rnd() to create monsters <= a given level
X */
Xchar monstlevel[] = { 5, 11, 17, 22, 27, 33, 39, 42, 46, 50, 53, 56, 59 };
X
Xstruct monst monster[] = {
X/*  NAME            LV  AC  DAM ATT DEF GEN INT GOLD    HP  EXP
X----------------------------------------------------------------- */
X{ "",               0,  0,  0,  0,  0,   0,  3,   0,    0,  0   },
X{ "bat",            1,  0,  1,  0,  0,   0,  3,   0,    1,  1   },
X{ "gnome",          1,  10, 1,  0,  0,   0,  8,  30,    2,  2   },
X{ "hobgoblin",      1,  14, 2,  0,  0,   0,  5,  25,    3,  2   },
X{ "jackal",         1,  17, 1,  0,  0,   0,  4,   0,    1,  1   },
X{ "kobold",         1,  20, 1,  0,  0,   0,  7,  10,    1,  1   },
X
X{ "orc",            2,  12, 1,  0,  0,   0,  9,  40,    4,  2   },
X{ "snake",          2,  15, 1,  0,  0,   0,  3,   0,    3,  1   },
X{ "giant centipede",2,  14, 0,  4,  0,   0,  3,   0,    1,  2   },
X{ "jaculi",         2,  20, 1,  0,  0,   0,  3,   0,    2,  1   },
X{ "troglodyte",     2,  10, 2,  0,  0,   0,  5,  80,    4,  3   },
X{ "giant ant",      2,  8,  1,  4,  0,   0,  4,   0,    5,  5   },
X
X/*  NAME            LV  AC  DAM ATT DEF GEN INT GOLD    HP  EXP
X----------------------------------------------------------------- */
X
X{ "floating eye",   3,  8,  1,  0,  0,   0,  3,   0,     5,  2  },
X{ "leprechaun",     3,  3,  0,  8,  0,   0,  3,1500,    13, 45  },
X{ "nymph",          3,  3,  0,  14, 0,   0,  9,   0,    18, 45  },
X{ "quasit",         3,  5,  3,  0,  0,   0,  3,   0,    10, 15  },
X{ "rust monster",   3,  4,  0,  1,  0,   0,  3,   0,    18, 25  },
X{ "zombie",         3,  12, 2,  0,  0,   0,  3,   0,     6,  7  },
X
X{ "assassin bug",   4,  9,  3,  0,  0,   0,  3,   0,    20, 15  },
X{ "bugbear",        4,  5,  4,  15, 0,   0,  5,  40,    20, 35  },
X{ "hell hound",     4,  5,  2,  2,  0,   0,  6,   0,    16, 35  },
X{ "ice lizard",     4,  11, 2,  10, 0,   0,  6,  50,    16, 25  },
X{ "centaur",        4,  6,  4,  0,  0,   0, 10,  40,    24, 45  },
X
X/*  NAME            LV  AC  DAM ATT DEF GEN INT GOLD    HP  EXP
X----------------------------------------------------------------- */
X
X{ "troll",          5,  4,  5,  0,  0,   0,  9,  80,    50, 300 },
X{ "yeti",           5,  6,  4,  0,  0,   0,  5,  50,    35, 100 },
X{ "white dragon",   5,  2,  4,  5,  0,   0, 16, 500,    55, 1000},
X{ "elf",            5,  8,  1,  0,  0,   0, 15,  50,    22, 35  },
X{ "gelatinous cube",5,  9,  1,  0,  0,   0,  3,   0,    22, 45  },
X
X{ "metamorph",      6,  7,  3,  0,  0,   0,  3,  0,     30, 40  },
X{ "vortex",         6,  4,  3,  0,  0,   0,  3,  0,     30, 55  },
X{ "ziller",         6,  15, 3,  0,  0,   0,  3,  0,     30, 35  },
X{ "violet fungi",   6,  12, 3,  0,  0,   0,  3,  0,     38, 100 },
X{ "wraith",         6,  3,  1,  6,  0,   0,  3,  0,     30, 325 },
X{ "forvalaka",      6,  2,  5,  0,  0,   0,  7,  0,     50, 280 },
X
X/*  NAME            LV  AC  DAM ATT DEF GEN INT GOLD    HP  EXP
X----------------------------------------------------------------- */
X
X{ "lama nobe",      7,  7,  3,  0,  0,   0,  6,  0,     35, 80  },
X{ "osequip",        7,  4,  3,  16, 0,   0,  4,  0,     35, 100 },
X{ "rothe",          7,  15, 5,  0,  0,   0,  3,  100,   50, 250 },
X{ "xorn",           7,  0,  6,  0,  0,   0, 13,  0,     60, 300 },
X{ "vampire",        7,  3,  4,  6,  0,   0, 17,  0,     50, 1000},
X{ "invisible stalker",7,3,  6,  0,  0,   0,  5,  0,     50, 350 },
X
X{ "poltergeist",    8,  1,  4,  0,  0,   0,  3,  0,     50, 450 },
X{ "disenchantress", 8,  3,  0,  9,  0,   0,  3,  0,     50, 500 },
X{ "shambling mound",8,  2,  5,  0,  0,   0,  6,  0,     45, 400 },
X{ "yellow mold",    8,  12, 4,  0,  0,   0,  3,  0,     35, 250 },
X{ "umber hulk",     8,  3,  7,  11, 0,   0, 14,  0,     65, 600 },
X
X/*  NAME            LV  AC  DAM ATT DEF GEN INT GOLD    HP  EXP
X----------------------------------------------------------------- */
X
X{ "gnome king",     9,  -1, 10, 0,  0,   0, 18,  2000,  100,3000    },
X{ "mimic",          9,   5, 6,  0,  0,   0,  8,  0,     55, 99      },
X{ "water lord",     9, -10, 15, 7,  0,   0, 20,  0,     150,15000   },
X{ "bronze dragon",  9,   2, 9,  3,  0,   0, 16,  300,   80, 4000    },
X{ "green dragon",   9,   3, 8,  10, 0,   0, 15,  200,   70, 2500    },
X{ "purple worm",    9,  -1, 11, 0,  0,   0,  3,  100,   120,15000   },
X{ "xvart",          9,  -2, 12, 0,  0,   0, 13,  0,     90, 1000    },
X
X{ "spirit naga",    10, -20,12, 12, 0,   0, 23,  0,     95, 20000   },
X{ "silver dragon",  10, -1, 12, 3,  0,   0, 20,  700,   100,10000   },
X{ "platinum dragon",10, -5, 15, 13, 0,   0, 22,  1000,  130,24000   },
X{ "green urchin",   10, -3, 12, 0,  0,   0,  3,  0,     85, 5000    },
X{ "red dragon",     10, -2, 13, 3,  0,   0, 19,  800,   110,14000   },
X
X{ "type I demon lord",  12,-30, 18, 0,   0,  0, 20, 0,  140,50000   },
X{ "type II demon lord", 13,-30, 18, 0,   0,  0, 21, 0,  160,75000   },
X{ "type III demon lord",14,-30, 18, 0,   0,  0, 22, 0,  180,100000  },
X{ "type IV demon lord", 15,-35, 20, 0,   0,  0, 23, 0,  200,125000  },
X{ "type V demon lord",  16,-40, 22, 0,   0,  0, 24, 0,  220,150000  },
X{ "type VI demon lord", 17,-45, 24, 0,   0,  0, 25, 0,  240,175000  },
X{ "type VII demon lord",18,-70, 27, 6,   0,  0, 26, 0,  260,200000  },
X{ "demon prince",       25,-127,30, 6,   0,  0, 28, 0,  345,300000  }
X
X/*  NAME                LV  AC  DAM ATT DEF GEN INT GOLD    HP  EXP
X--------------------------------------------------------------------- */
X };
X
X/*  name array for scrolls      */
X
Xchar *scrollname[MAXSCROLL+1] = {
X"\0enchant armor",
X"\0enchant weapon",
X"\0enlightenment",
X"\0blank paper",
X"\0create monster",
X"\0create artifact",
X"\0aggravate monsters",
X"\0time warp",
X"\0teleportation",
X"\0expanded awareness",
X"\0haste monsters",
X"\0monster healing",
X"\0spirit protection",
X"\0undead protection",
X"\0stealth",
X"\0magic mapping",
X"\0hold monsters",
X"\0gem perfection",
X"\0spell extension",
X"\0identify",
X"\0remove curse",
X"\0annihilation",
X"\0pulverization",
X"\0life protection",
X"\0 ",
X"\0 ",
X"\0 ",
X"\0 ",
X"\0zzzzzzzzzzzzzz"    /* sentinel, for the sorted known objects inventory */
X };
X
X/*  name array for magic potions    */
Xchar *potionname[MAXPOTION+1] = {
X"\0sleep",
X"\0healing",
X"\0raise level",
X"\0increase ability",
X"\0wisdom",
X"\0strength",
X"\0raise charisma",
X"\0dizziness",
X"\0learning",
X"\0object detection",
X"\0monster detection",
X"\0forgetfulness",
X"\0water",
X"\0blindness",
X"\0confusion",
X"\0heroism",
X"\0sturdiness",
X"\0giant strength",
X"\0fire resistance",
X"\0treasure finding",
X"\0instant healing",
X" cure dianthroritis",
X"\0poison",
X"\0see invisible",
X"\0 ",
X"\0 ",
X"\0 ",
X"\0 ",
X"\0 ",
X"\0 ",
X"\0 ",
X"\0 ",
X"\0 ",
X"\0 ",
X"\0 ",
X"\0zzzzzzzzzzzzzz"    /* sentinel, for the sorted known objects inventory */
X };
X
X
X/*
X    spell data
X */
Xchar spelknow[SPNUM];
Xchar splev[] = { 1, 4, 9, 14, 18, 22, 26, 29, 32, 35, 37, 37, 37, 37, 37 };
X
Xchar *spelcode[SPNUM+1]={
X    "pro",  "mle",  "dex",  "sle",  "chm",  "ssp",
X    "web",  "str",  "enl",  "hel",  "cbl",  "cre",  "pha",  "inv",
X    "bal",  "cld",  "ply",  "can",  "has",  "ckl",  "vpr",
X    "dry",  "lit",  "drl",  "glo",  "flo",  "fgr",
X    "sca",  "hld",  "stp",  "tel",  "mfi", /* 31 */
X    "sph",  "gen",  "sum",  "wtw",  "alt",  "per", "zzz"
X };
X
Xchar *spelname[]={
X    "protection",               "magic missile",        "dexterity",
X    "sleep",                    "charm monster",        "sonic spear",
X
X    "web",                      "strength",             "enlightenment",
X    "healing",                  "cure blindness",       "create monster",
X    "phantasmal forces",        "invisibility",
X
X    "fireball",                 "cold",                 "polymorph",
X    "cancellation",             "haste self",           "cloud kill",
X    "vaporize rock",
X
X    "dehydration",              "lightning",            "drain life",
X    "invulnerability",          "flood",                "finger of death",
X
X    "scare monster",            "hold monster",         "time stop",
X    "teleport away",            "magic fire",
X
X    "sphere of annihilation",   "genocide",             "summon demon",
X    "walk through walls",       "alter reality",        "permanence",
X    ""
X };
X
Xchar *speldescript[]={
X/* 1 */
X    "generates a +2 protection field",
X    "creates and hurls a magic missile equivalent to a + 1 magic arrow",
X    "adds +2 to the casters dexterity",
X    "causes some monsters to go to sleep",
X    "some monsters may be awed at your magnificence",
X    "causes your hands to emit a screeching sound toward what they point",
X/* 7 */
X    "causes strands of sticky thread to entangle an enemy",
X    "adds +2 to the casters strength for a short term",
X    "the caster becomes aware of things around him",
X    "restores some hp to the caster",
X    "restores sight to one so unfortunate as to be blinded",
X    "creates a monster near the caster appropriate for the location",
X    "creates illusions, and if believed, monsters die",
X    "the caster becomes invisible",
X/* 15 */
X    "makes a ball of fire that burns on what it hits",
X    "sends forth a cone of cold which freezes what it touches",
X    "you can find out what this does for yourself",
X    "negates the ability of a monster to use his special abilities",
X    "speeds up the casters movements",
X    "creates a fog of poisonous gas which kills all that is within it",
X    "this changes rock to air",
X/* 22 */
X    "dries up water in the immediate vicinity",
X    "you finger will emit a lightning bolt when this spell is cast",
X    "subtracts hit points from both you and a monster",
X    "this globe helps to protect the player from physical attack",
X    "this creates an avalanche of H2O to flood the immediate chamber",
X    "this is a holy spell and calls upon your god to back you up",
X/* 28 */
X    "terrifies the monster so that hopefully he wont hit the magic user",
X    "the monster is frozen in his tracks if this is successful",
X    "all movement in the caverns ceases for a limited duration",
X    "moves a particular monster around in the dungeon (hopefully away from you)",
X    "this causes a curtain of fire to appear all around you",
X/* 33 */
X    "anything caught in this sphere is instantly killed.  Warning -- dangerous",
X    "eliminates a species of monster from the game -- use sparingly",
X    "summons a demon who hopefully helps you out",
X    "allows the player to walk through walls for a short period of time",
X    "god only knows what this will do",
X    "makes a character spell permanent, i. e. protection, strength, etc.",
X    ""
X };
X
Xchar spelweird[MAXMONST+8][SPNUM] = {
X/*                      p m d s c s    w s e h c c p i    b c p c h c v    d l d g f f    s h s t m    s g s w a p */
X/*                      r l e l h s    e t n e b r h n    a l l a a k p    r i r l l g    c l t e f    p e u t l e */
X/*                      o e x e m p    b r l l l e a v    l d y n s l r    y t l o o r    a d p l i    h n m w t r */
X    
X
X/*            bat */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*          gnome */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,5,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*      hobgoblin */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*         jackal */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*         kobold */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,5,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X
X/*            orc */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   4,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*          snake */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*giant centipede */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*         jaculi */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*     troglodyte */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X
X/*      giant ant */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*   floating eye */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*     leprechaun */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*          nymph */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*         quasit */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X
X/*   rust monster */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   4,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*         zombie */ {  0,0,0,8,0,4,   0,0,0,0,0,0,0,0,   0,0,0,0,0,4,0,   4,0,0,0,0,4,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*   assassin bug */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*        bugbear */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,5,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*     hell hound */ {  0,6,0,0,0,0,   12,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X
X/*     ice lizard */ {  0,0,0,0,0,0,   11,0,0,0,0,0,0,0,  0,15,0,0,0,0,0,  0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*        centaur */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*          troll */ {  0,7,0,0,0,0,   0,0,0,0,0,0,0,5,   0,0,0,0,0,0,0,   4,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*           yeti */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,15,0,0,0,0,0,  0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*   white dragon */ {  0,0,0,0,0,0,   0,0,0,0,0,0,14,0,  0,15,0,0,0,0,0,  4,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X
X/*            elf */ {  0,0,0,0,0,0,   0,0,0,0,0,0,14,5,  0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*gelatinous cube */ {  0,0,0,0,0,0,   2,0,0,0,0,0,0,0,   0,0,0,0,0,4,0,   0,0,0,0,0,4,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*      metamorph */ {  0,13,0,0,0,0,  2,0,0,0,0,0,0,0,   0,0,0,0,0,4,0,   4,0,0,0,0,4,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*         vortex */ {  0,13,0,0,0,10, 1,0,0,0,0,0,0,0,   0,0,0,0,0,4,0,   4,0,0,0,4,4,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*         ziller */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X
X/*   violet fungi */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*         wraith */ {  0,0,0,8,0,4,   0,0,0,0,0,0,0,0,   0,0,0,0,0,4,0,   4,0,0,0,0,4,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*      forvalaka */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,5,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*      lama nobe */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*        osequip */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X
X/*          rothe */ {  0,7,0,0,0,0,   0,0,0,0,0,0,0,5,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*           xorn */ {  0,7,0,0,0,0,   0,0,0,0,0,0,0,5,   0,0,0,0,0,0,0,   4,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*        vampire */ {  0,0,0,8,0,4,   0,0,0,0,0,0,0,0,   0,0,0,0,0,4,0,   0,0,0,0,0,4,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*invisible staker*/ {  0,0,0,0,0,0,   1,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*    poltergeist */ {  0,13,0,8,0,4,  1,0,0,0,0,0,0,0,   0,4,0,0,0,4,0,   4,0,0,0,4,4,   0,0,0,0,0,   0,0,0,0,0,0 },
X
X/* disenchantress */ {  0,0,0,8,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*shambling mound */ {  0,0,0,0,0,10,  0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*    yellow mold */ {  0,0,0,8,0,0,   1,0,0,0,0,0,4,0,   0,0,0,0,0,4,0,   0,0,0,0,0,4,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*     umber hulk */ {  0,7,0,0,0,0,   0,0,0,0,0,0,0,5,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*     gnome king */ {  0,7,0,0,3,0,   0,0,0,0,0,0,0,5,   0,0,9,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X
X/*          mimic */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*     water lord */ {  0,13,0,8,3,4,  1,0,0,0,0,0,0,0,   0,0,9,0,0,4,0,   0,0,0,0,16,4,  0,0,0,0,0,   0,0,0,0,0,0 },
X/*  bronze dragon */ {  0,7,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*   green dragon */ {  0,7,0,0,0,0,   11,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*    purple worm */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X
X/*          xvart */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*    spirit naga */ {  0,13,0,8,3,4,  1,0,0,0,0,0,0,5,   0,4,9,0,0,4,0,   4,0,0,0,4,4,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*  silver dragon */ {  0,6,0,9,0,0,   12,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*platinum dragon */ {  0,7,0,9,0,0,   11,0,0,0,0,0,14,0, 0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*   green urchin */ {  0,0,0,0,0,0,   0,0,0,0,0,0,0,0,   0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X/*     red dragon */ {  0,6,0,0,0,0,   12,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,   0,0,0,0,0,0,   0,0,0,0,0,   0,0,0,0,0,0 },
X
X/*                      p m d s c s    w s e h c c p i    b c p c h c v    d l d g f f    s h s t m    s g s w a p */
X/*                      r l e l h s    e t n e b r h n    a l l a a k p    r i r l l g    c l t e f    p e u t l e */
X/*                      o e x e m p    b r l l l e a v    l d y n s l r    y t l o o r    a d p l i    h n m w t r */
X
X/*     demon lord */ {  0,7,0,4,3,0,   1,0,0,0,0,0,14,5,  0,0,4,0,0,4,0,   4,0,0,0,4,4,   0,0,0,0,0,   9,0,0,0,0,0 },
X/*     demon lord */ {  0,7,0,4,3,0,   1,0,0,0,0,0,14,5,  0,0,4,0,0,4,0,   4,0,0,0,4,4,   0,0,0,0,0,   9,0,0,0,0,0 },
X/*     demon lord */ {  0,7,0,4,3,0,   1,0,0,0,0,0,14,5,  0,0,4,0,0,4,0,   4,0,0,0,4,4,   0,0,0,0,0,   9,0,0,0,0,0 },
X/*     demon lord */ {  0,7,0,4,3,0,   1,0,0,0,0,0,14,5,  0,0,4,0,0,4,0,   4,0,0,0,4,4,   0,0,0,0,0,   9,0,0,0,0,0 },
X/*     demon lord */ {  0,7,0,4,3,0,   1,0,0,0,0,0,14,5,  0,0,4,0,0,4,0,   4,0,0,0,4,4,   0,0,0,0,0,   9,0,0,0,0,0 },
X/*     demon lord */ {  0,7,0,4,3,0,   1,0,0,0,0,0,14,5,  0,0,4,0,0,4,0,   4,0,0,0,4,4,   0,0,0,0,0,   9,0,0,0,0,0 },
X/*     demon lord */ {  0,7,0,4,3,0,   1,0,0,0,0,0,14,5,  0,0,4,0,0,4,0,   4,0,0,0,4,4,   0,0,0,0,0,   9,0,0,0,0,0 },
X/*   demon prince */ {  0,7,0,4,3,9,   1,0,0,0,0,0,14,5,  0,0,4,0,0,4,0,   4,0,0,0,4,4,   4,0,0,0,4,   9,0,0,0,0,0 }
X
X };
X
Xchar *spelmes[] = { "",
X/*  1 */    "the web had no effect on the %s",
X/*  2 */    "the %s changed shape to avoid the web",
X/*  3 */    "the %s isn't afraid of you",
X/*  4 */    "the %s isn't affected",
X/*  5 */    "the %s can see you with his infravision",
X/*  6 */    "the %s vaporizes your missile",
X/*  7 */    "your missile bounces off the %s",
X/*  8 */    "the %s doesn't sleep",
X/*  9 */    "the %s resists",
X/* 10 */    "the %s can't hear the noise",
X/* 11 */    "the %s's tail cuts it free of the web",
X/* 12 */    "the %s burns through the web",
X/* 13 */    "your missiles pass right through the %s",
X/* 14 */    "the %s sees through your illusions",
X/* 15 */    "the %s loves the cold!",
X/* 16 */    "the %s loves the water!"
X };
X
X/*
X *  function to create scroll numbers with appropriate probability of 
X *  occurrence
X *
X *  0 - armor           1 - weapon      2 - enlightenment   3 - paper
X *  4 - create monster  5 - create item 6 - aggravate       7 - time warp
X *  8 - teleportation   9 - expanded awareness              10 - haste monst
X *  11 - heal monster   12 - spirit protection      13 - undead protection
X *  14 - stealth        15 - magic mapping          16 - hold monster
X *  17 - gem perfection 18 - spell extension        19 - identify
X *  20 - remove curse   21 - annihilation           22 - pulverization
X *  23 - life protection
X */
Xchar scprob[]= { 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3,
X    3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9,
X    9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14,
X    15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19, 19, 20, 20, 20, 20, 21, 22,
X    22, 22, 23 };
X
X/*
X *  function to return a potion number created with appropriate probability
X *  of occurrence
X *
X *  0 - sleep               1 - healing                 2 - raise level
X *  3 - increase ability    4 - gain wisdom             5 - gain strength
X *  6 - increase charisma   7 - dizziness               8 - learning
X *  9 - object detection    10 - monster detection      11 - forgetfulness
X *  12 - water              13 - blindness              14 - confusion
X *  15 - heroism            16 - sturdiness             17 - giant strength
X *  18 - fire resistance    19 - treasure finding       20 - instant healing
X *  21 - cure dianthroritis 22 - poison                 23 - see invisible
X */
Xchar potprob[] = { 0, 0, 1, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 9, 9,
X               10, 10, 10, 11, 11, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 19,
X               20, 20, 22, 22, 23, 23 };
X
Xchar nlpts[] = { 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7 };
Xchar nch[] = { 0, 0, 0, 1, 1, 1, 2, 2, 3, 4 };
Xchar nplt[] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 4 };
Xchar ndgg[] = { 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 5 };
Xchar nsw[] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 3 };
END_OF_FILE
if test 31296 -ne `wc -c <'data.c'`; then
    echo shar: \"'data.c'\" unpacked with wrong size!
fi
# end of 'data.c'
fi
if test -f 'movem.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'movem.c'\"
else
echo shar: Extracting \"'movem.c'\" \(18772 characters\)
sed "s/^X//" >'movem.c' <<'END_OF_FILE'
X/*
X *  movem.c (move monster)
X *
X *  movemonst()     Routine to move the monsters toward the player
X *  build_proximity_ripple()  Build proximity ripple for smart monster move
X *  move_scared()   Move scared monsters
X *  move_smart()    Move smart monsters
X *  move_dumb()     Move dumb monsters
X *  mmove(x,y,xd,yd)    Function to actually perform the monster movement
X */
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       void movemonst();
Xstatic void build_proximity_ripple();
Xstatic void move_scared();
Xstatic void move_smart();
Xstatic void move_dumb();
Xstatic void mmove();
X
X#if 0
X# define IDISTNORM   8  /* was 17 - dgk */
X# define IDISTAGGR  20  /* was 40 - dgk */
X#endif
X# define IDISTNORM  17  /* was 17 - dgk */
X# define IDISTAGGR  40  /* was 40 - dgk */
X
Xstatic short w1x[9],w1y[9];
Xstatic int tmp1,tmp2,tmp3,tmp4,distance;
X
X/* list of monsters to move */
Xstatic struct foo { char x ; char y; char smart; } movelist[250] ;
X
X/*
X *  movemonst()     Routine to move the monsters toward the player
X *
X *  This routine has the responsibility to determine which monsters are to
X *  move, and call movemt() to do the move.
X *  Returns no value.
X */
Xvoid movemonst()
X    {
X    register int i,j,movecnt=0, smart_count, min_int ;
X    if (c[HOLDMONST])  return;  /* no action if monsters are held */
X
X    if (c[AGGRAVATE])   /* determine window of monsters to move */
X      {
X      tmp1=playery-5; tmp2=playery+6; tmp3=playerx-10; tmp4=playerx+11;
X      distance=IDISTAGGR; /* depth of intelligent monster movement */
X      }
X    else
X      {
X      tmp1=playery-3; tmp2=playery+4; tmp3=playerx-5; tmp4=playerx+6;
X      distance=IDISTNORM; /* depth of intelligent monster movement */
X      }
X
X    if (level == 0) /* if on outside level monsters can move in perimeter */
X        {
X        if (tmp1 < 0) tmp1=0;        if (tmp2 > MAXY) tmp2=MAXY;
X        if (tmp3 < 0) tmp3=0;        if (tmp4 > MAXX) tmp4=MAXX;
X        }
X    else /* if in a dungeon monsters can't be on the perimeter (wall there) */
X        {
X        if (tmp1 < 1) tmp1=1;        if (tmp2 > MAXY-1) tmp2=MAXY-1;
X        if (tmp3 < 1) tmp3=1;        if (tmp4 > MAXX-1) tmp4=MAXX-1;
X        }
X
X    /* We now have a window in which to move monsters.  First find all
X       monsters in the window, then decide whether or not to move them.
X       Its faster that way since the size of the window is usually larger
X       than the # of monsters in that window.
X
X       Find all monsters in the window.  The only time a monster cannot
X       move is if: monsters are not aggrevated, AND player is stealthed,
X       AND the monster is asleep due to stealth.  Split into two
X       separate loops in order to simplify the if statement inside the
X       loop for the most common case.
X
X       Also count # of smart monsters.
X    */
X    smart_count = 0 ;
X    min_int = 10 - c[HARDGAME] ;    /* minimum monster intelligence to move smart */
X    if ( c[AGGRAVATE] || !c[STEALTH] )
X        {
X        for ( j = tmp1 ; j < tmp2 ; j++ )
X            for ( i = tmp3 ; i < tmp4 ; i++ )
X                if (mitem[i][j])
X                    {
X                    movelist[movecnt].x = i;
X                    movelist[movecnt].y = j ;
X                    if ( monster[mitem[i][j]].intelligence > min_int )
X                        {
X                        movelist[movecnt].smart = TRUE ;
X                        smart_count++;
X                        }
X                    else
X                        movelist[movecnt].smart = FALSE ;
X                    movecnt++;
X                    }
X        }
X    else
X        {
X        for ( j = tmp1; j < tmp2 ; j++ )
X            for ( i = tmp3 ; i < tmp4 ; i++ )
X                if ( mitem[i][j] && stealth[i][j] )   /* stealth[x][y] = 1 when AWAKE! */
X                    {
X                    movelist[movecnt].x = i;
X                    movelist[movecnt].y = j ;
X                    if ( monster[mitem[i][j]].intelligence > min_int )
X                        {
X                        movelist[movecnt].smart = TRUE ;
X                        smart_count++;
X                        }
X                    else
X                        movelist[movecnt].smart = FALSE ;
X                    movecnt++;
X                    }
X        }
X
X    /* now move the monsters in the movelist.  If we have at least one
X       smart monster, build a proximity ripple and use it for all smart
X       monster movement.
X    */
X    if (movecnt > 0 )
X        {
X        if ( c[SCAREMONST] )
X            for ( i = 0 ; i < movecnt ; i++ )
X                move_scared( movelist[i].x, movelist[i].y );
X        else
X            {
X            if ( smart_count > 0 )
X                {
X                /* I was going to put in code that prevented the rebuilding
X                   of the proximity ripple if the player had not moved since
X                   the last turn.  Unfortunately, this permits the player to
X                   blast down doors to treasure rooms and not have a single
X                   intelligent monster move.
X                */
X                build_proximity_ripple();
X                for ( i = 0 ; i < movecnt ; i++ )
X                    if ( movelist[i].smart )
X                        move_smart( movelist[i].x, movelist[i].y );
X                    else
X                        move_dumb( movelist[i].x, movelist[i].y );
X                }
X            else
X                for ( i = 0 ; i < movecnt ; i++ )
X                    move_dumb( movelist[i].x, movelist[i].y );
X            }
X        }
X
X    /* Also check for the last monster hit.  This is necessary to prevent
X       the player from getting free hits on a monster with long range
X       spells or when stealthed.
X    */
X    if ( c[AGGRAVATE] || !c[STEALTH] )
X        {
X        /* If the last monster hit is within the move window, its already
X           been moved.
X        */
X    if ( ( ( lasthx < tmp3 || lasthx >= tmp4 ) ||
X           ( lasthy < tmp1 || lasthy >= tmp2 ) ) &&
X           mitem[lasthx][lasthy] )
X            {
X        if ( c[SCAREMONST] )
X                move_scared( lasthx, lasthy );
X            else
X        if ( monster[mitem[lasthx][lasthy]].intelligence > min_int )
X                    {
X            if ( smart_count == 0 )
X                        build_proximity_ripple( );
X                    move_smart( lasthx, lasthy );
X                    }
X                else
X                    move_dumb( lasthx, lasthy );
X            lasthx = w1x[0];   /* make sure the monster gets moved again */
X            lasthy = w1y[0];
X            }
X        }
X    else
X        {
X        /* If the last monster hit is within the move window, and not
X           asleep due to stealth, then it has already been moved.
X       Otherwise (monster outside window, asleep due to stealth),
X       move the monster and update the lasthit x,y position.
X        */
X    if ( ( lasthx < tmp3 || lasthx >= tmp4 ) ||
X             ( lasthy < tmp1 || lasthy >= tmp2 ) &&
X       mitem[lasthx][lasthy] || !stealth[lasthx][lasthy] )
X            {
X        if ( c[SCAREMONST] )
X                move_scared( lasthx, lasthy );
X            else
X        if ( monster[mitem[lasthx][lasthy]].intelligence > min_int )
X                    {
X            if ( smart_count == 0 )
X                        build_proximity_ripple( );
X                    move_smart( lasthx, lasthy );
X                    }
X                else
X                    move_dumb( lasthx, lasthy );
X            lasthx = w1x[0];   /* make sure the monster gets moved again */
X            lasthy = w1y[0];
X            }
X        }
X    }
X
Xstatic char screen[MAXX][MAXY];    /* proximity ripple storage */
X
X/* queue for breadth-first 'search' build of proximity ripple.
X*/
X#define MAX_QUEUE 100
Xstatic struct queue_entry
X        {
X        char x ;
X        char y ;
X        char distance ;
X        } queue[MAX_QUEUE];
Xstatic int queue_head = 0 ;
Xstatic int queue_tail = 0 ;
X
X/* put a location on the proximity ripple queue
X*/
X#define PUTQUEUE( _x, _y, _d )          \
X    {                                   \
X    queue[queue_tail].x = (_x) ;        \
X    queue[queue_tail].y = (_y) ;        \
X    queue[queue_tail].distance = (_d);  \
X    queue_tail++;                       \
X    if (queue_tail == MAX_QUEUE)        \
X        queue_tail = 0 ;                \
X    }
X
X/* take a location from the proximity ripple queue
X*/
X#define GETQUEUE( _x, _y, _d )          \
X    {                                   \
X    (_x) = queue[queue_head].x ;        \
X    (_y) = queue[queue_head].y ;        \
X    (_d) = queue[queue_head].distance ; \
X    queue_head++;                       \
X    if (queue_head == MAX_QUEUE)        \
X        queue_head = 0 ;                \
X    }
X
X/* check for the proximity ripple queue being empty
X*/
X#define QUEUEEMPTY() (queue_head == queue_tail)
X
X/*
X    For smart monster movement, build a proximity ripple from the player's
X    position, out to a 'distance' of 20.  For example:
X
X    W 5 4 4 W W X    Player is at position marked 1
X    W 5 W 3 3 W W    W is a wall.  Monsters will attempt
X    W 6 W 2 W 4 W    to move to a location with a smaller
X    W 7 W 1 W 5 W    value than their current position.
X    W 8 W W W 6 W    Note that a monster at location X
X    W 9 9 8 7 7 7    will not move at all.
X    W W W 8 W W W
X*/
Xstatic void build_proximity_ripple()
X    {
X    int xl, yl, xh, yh ;
X    int k, m, z, tmpx, tmpy;
X    int curx, cury, curdist;
X
X    xl=tmp3-2; yl=tmp1-2; xh=tmp4+2;  yh=tmp2+2;
X    vxy(&xl,&yl);  vxy(&xh,&yh);
X    for (k=yl; k<=yh; k++)
X    for (m=xl; m<=xh; m++)
X        {
X        switch(item[m][k])
X        {
X        case OWALL:
X        case OPIT:
X        case OTRAPARROW:
X        case ODARTRAP:
X        case OCLOSEDDOOR:
X        case OTRAPDOOR:
X        case OTELEPORTER:
X            screen[m][k]=127;
X            break;
X        case OENTRANCE:
X            if (level==1)
X                screen[m][k] = 127;
X            else
X                screen[m][k] = 0;
X            break;
X        default:
X            screen[m][k] = 0;
X            break;
X        };
X          }
X      screen[playerx][playery]=1;
X
X/* now perform proximity ripple from playerx,playery to monster */
X      xl=tmp3-1; yl=tmp1-1; xh=tmp4+1;  yh=tmp2+1;
X      vxy(&xl,&yl);  vxy(&xh,&yh);
X
X      PUTQUEUE( playerx, playery, 1 );
X      do
X      {
X      GETQUEUE( curx, cury, curdist );
X
X      /* test all spots around the current one being looked at.
X      */
X      if ( ( curx >= xl && curx < xh ) &&
X           ( cury >= yl && cury < yh ) )
X          {
X          for (z=1; z<9; z++)
X          {
X          tmpx = curx + diroffx[z] ;
X          tmpy = cury + diroffy[z] ;
X          if (screen[tmpx][tmpy] == 0 )
X              {
X              screen[tmpx][tmpy] = curdist + 1;
X              PUTQUEUE( tmpx, tmpy, curdist + 1 );
X              }
X          }
X          }
X      }
X      while (!QUEUEEMPTY());
X
X    }
X
X/*
X    Move scared monsters randomly away from the player position.
X*/
Xstatic void move_scared( i, j )
Xint i, j ;
X    {
X    int xl, yl, tmp, tmpitem ;
X
X    /* check for a half-speed monster, and check if not to move.  Could be
X       done in the monster list build.
X    */
X    switch(mitem[i][j])
X        {
X        case TROGLODYTE:  case HOBGOBLIN:  case METAMORPH:  case XVART:
X        case INVISIBLESTALKER:  case ICELIZARD: if ((gtime & 1) == 1) return;
X        };
X
X    if ((xl = i+rnd(3)-2) < 0)
X    xl=0;
X    if (xl >= MAXX)
X    xl=MAXX-1;
X    if ((yl = j+rnd(3)-2) < 0)
X    yl=0;
X    if (yl >= MAXY)
X    yl=MAXY-1;
X
X    if ((tmp=item[xl][yl]) != OWALL)
X    if (mitem[xl][yl] == 0)
X        if ((mitem[i][j] != VAMPIRE) || (tmp != OMIRROR))
X        if (tmp != OCLOSEDDOOR)
X            mmove(i,j,xl,yl);
X    }
X
X/*
X    Move monsters that are moving intelligently, using the proximity
X    ripple.  Attempt to move to a position in the proximity ripple
X    that is closer to the player.
X
X    Parameters: the X,Y position of the monster to be moved.
X*/
Xstatic void move_smart( i, j )
Xint i,j ;
X    {
X    int x,y,z ;
X
X    /* check for a half-speed monster, and check if not to move.  Could be
X       done in the monster list build.
X    */
X    switch(mitem[i][j])
X        {
X        case TROGLODYTE:  case HOBGOBLIN:  case METAMORPH:  case XVART:
X        case INVISIBLESTALKER:  case ICELIZARD: if ((gtime & 1) == 1) return;
X        };
X
X    /* find an adjoining location in the proximity ripple that is
X       closer to the player (has a lower value) than the monster's
X       current position.
X    */
X    if (mitem[i][j] != VAMPIRE)
X    for (z=1; z<9; z++) /* go around in a circle */
X        {
X        x = i + diroffx[z] ;
X        y = j + diroffy[z] ;
X        if ( screen[x][y] < screen[i][j] )
X        if ( !mitem[x][y] )
X            {
X            mmove(i,j,w1x[0]=x,w1y[0]=y);
X            return;
X            }
X        }
X    else
X    /* prevent vampires from moving onto mirrors
X    */
X    for (z=1; z<9; z++) /* go around in a circle */
X        {
X        x = i + diroffx[z] ;
X        y = j + diroffy[z] ;
X        if (( screen[x][y] < screen[i][j] ) &&
X        ( item[x][y] != OMIRROR ))
X        if ( !mitem[x][y] )
X            {
X            mmove(i,j,w1x[0]=x,w1y[0]=y);
X            return;
X            }
X        }
X
X    }
X
X/*
X   For monsters that are not moving in an intelligent fashion.  Move
X   in a direct fashion toward the player's current position.
X
X   Parameters: the X,Y position of the monster to move.
X*/
Xstatic void move_dumb( i, j )
Xint i, j ;
X    {
X    int xl, yl, xh, yh ;
X    int k, m, tmp, tmpd, tmpx, tmpy ;
X
X    /* check for a half-speed monster, and check if not to move.  Could be
X       done in the monster list build.
X    */
X    switch(mitem[i][j])
X        {
X        case TROGLODYTE:  case HOBGOBLIN:  case METAMORPH:  case XVART:
X        case INVISIBLESTALKER:  case ICELIZARD: if ((gtime & 1) == 1) return;
X        };
X
X    /* dumb monsters move here */
X    /* set up range of spots to check.  instead of checking all points
X       around the monster, only check those closest to the player.  For
X       example, if the player is up and right of the monster, check only
X       the three spots up and right of the monster.
X    */
X    xl=i-1;  yl=j-1;  xh=i+2;  yh=j+2;
X    if (i<playerx) xl++; else if (i>playerx) --xh;
X    if (j<playery) yl++; else if (j>playery) --yh;
X
X    /* check all spots in the range.  find the one that is closest to
X       the player.  if the monster is already next to the player, exit
X       the check immediately.
X    */
X    tmpd = 10000 ;
X    tmpx = i ;  tmpy = j ;
X    for ( k = xl ; k < xh ; k++ )
X    for ( m = yl ; m < yh ; m++ )
X        if ( k == playerx && m == playery )
X        {
X        tmpd = 1 ;
X        tmpx = k ;
X        tmpy = m ;
X        break;       /* exitloop */
X        }
X        else if ((item[k][m] != OWALL) &&
X             (item[k][m] != OCLOSEDDOOR) &&
X             ((mitem[k][m] == 0 ) || (( k == i ) && ( m == j ))) &&
X             ((mitem[i][j] != VAMPIRE) || (item[k][m] != OMIRROR)))
X        {
X        tmp = (playerx-k)*(playerx-k)+(playery-m)*(playery-m);
X        if (tmp < tmpd)
X            {
X            tmpd = tmp;
X            tmpx = k;
X            tmpy = m;
X            }  /* end if */
X        }  /* end if */
X
X    /* we have finished checking the spaces around the monster.  if
X       any can be moved on and are closer to the player than the
X       current location, move the monster.
X    */
X    if ((tmpd < 10000) && ((tmpx != i) || (tmpy != j)))
X    {
X    mmove( i, j, tmpx, tmpy );
X    w1x[0] = tmpx ;              /* for last monster hit */
X    w1y[0] = tmpy ;
X    }
X    else
X    {
X    w1x[0] = i ;              /* for last monster hit */
X    w1y[0] = j ;
X    }
X    }  /* end move_dumb() */
X
X/*
X *  mmove(x,y,xd,yd)    Function to actually perform the monster movement
X *      int x,y,xd,yd;
X *
X *  Enter with the from coordinates in (x,y) and the destination coordinates
X *  in (xd,yd).
X */
Xstatic void mmove(aa,bb,cc,dd)
X    int aa,bb,cc,dd;
X    {
X    register int tmp,i,flag;
X    char *who,*p;
X    flag=0; /* set to 1 if monster hit by arrow trap */
X    if ((cc==playerx) && (dd==playery))
X        {
X        hitplayer(aa,bb);
X        return;
X        }
X    i=item[cc][dd];
X    if ((i==OPIT) || (i==OTRAPDOOR))
X      switch(mitem[aa][bb])
X        {
X    case BAT:           case EYE:
X    case SPIRITNAGA:    case PLATINUMDRAGON:    case WRAITH:
X        case VAMPIRE:       case SILVERDRAGON:      case POLTERGEIST:
X        case DEMONLORD:     case DEMONLORD+1:       case DEMONLORD+2:
X        case DEMONLORD+3:   case DEMONLORD+4:       case DEMONLORD+5:
X        case DEMONLORD+6:   case DEMONPRINCE:   break;
X
X        default:    mitem[aa][bb]=0; /* fell in a pit or trapdoor */
X        };
X    tmp = mitem[aa][bb];
X    mitem[cc][dd] = tmp;
X    if (i==OANNIHILATION)
X        {
X        if (tmp>=DEMONLORD+3) /* demons dispel spheres */
X            {
X            cursors();
X            lprintf("\nThe %s dispels the sphere!",monster[tmp].name);
X            rmsphere(cc,dd);    /* delete the sphere */
X            }
X        else mitem[cc][dd]=i=tmp=0;
X        }
X    stealth[cc][dd]=1;
X    if ((hitp[cc][dd] = hitp[aa][bb]) < 0) hitp[cc][dd]=1;
X    mitem[aa][bb] = 0;              
X    if (tmp == LEPRECHAUN)
X        switch(i)
X            {
X            case OGOLDPILE:  case OMAXGOLD:  case OKGOLD:  case ODGOLD:
X            case ODIAMOND:   case ORUBY:     case OEMERALD: case OSAPPHIRE:
X                    item[cc][dd] = 0; /* leprechaun takes gold */
X            };
X
X    if (tmp == TROLL)  /* if a troll regenerate him */
X        if ((gtime & 1) == 0)
X            if (monster[tmp].hitpoints > hitp[cc][dd])  hitp[cc][dd]++;
X
X    if (i==OTRAPARROW)  /* arrow hits monster */
X        { who = "An arrow";  if ((hitp[cc][dd] -= rnd(10)+level) <= 0)
X            { mitem[cc][dd]=0;  flag=2; } else flag=1; }
X    if (i==ODARTRAP)    /* dart hits monster */
X        { who = "A dart";  if ((hitp[cc][dd] -= rnd(6)) <= 0)
X            { mitem[cc][dd]=0;  flag=2; } else flag=1; }
X    if (i==OTELEPORTER) /* monster hits teleport trap */
X        { flag=3; fillmonst(mitem[cc][dd]);  mitem[cc][dd]=0; }
X    if (c[BLINDCOUNT]) return;  /* if blind don't show where monsters are   */
X    if (know[cc][dd] & HAVESEEN)
X        {
X        p=0;
X        if (flag) cursors();
X        switch(flag)
X          {
X          case 1: p="\n%s hits the %s";  break;
X          case 2: p="\n%s hits and kills the %s";  break;
X          case 3: p="\nThe %s%s gets teleported"; who="";  break;
X          };
X        if (p) { lprintf(p,who,monster[tmp].name); beep(); }
X        }
X/*  if (yrepcount>1) { know[aa][bb] &= 2;  know[cc][dd] &= 2; return; } */
X    if (know[aa][bb] & HAVESEEN)   show1cell(aa,bb);
X    if (know[cc][dd] & HAVESEEN)   show1cell(cc,dd);
X    }
END_OF_FILE
if test 18772 -ne `wc -c <'movem.c'`; then
    echo shar: \"'movem.c'\" unpacked with wrong size!
fi
# end of 'movem.c'
fi
if test -f 'os2larn.lnk' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'os2larn.lnk'\"
else
echo shar: Extracting \"'os2larn.lnk'\" \(567 characters\)
sed "s/^X//" >'os2larn.lnk' <<'END_OF_FILE'
Xobj\action.obj+
Xobj\bill.obj+
Xobj\config.obj+
Xobj\create.obj+
Xobj\data.obj+
Xobj\diag.obj+
Xobj\display.obj+
Xobj\fgetlr.obj+
Xobj\fortune.obj+
Xobj\global.obj+
Xobj\help.obj+
Xobj\io.obj+
Xobj\iventory.obj+
Xobj\main.obj+
Xobj\monster.obj+
Xobj\moreobj.obj+
Xobj\movem.obj+
Xobj\msdos.obj+
Xobj\nap.obj+
Xobj\object.obj+
Xobj\regen.obj+
Xobj\savelev.obj+
Xobj\scores.obj+
Xobj\signal.obj+
Xobj\spells.obj+
Xobj\spheres.obj+
Xobj\store.obj+
Xobj\tgetent.obj+
Xobj\tgetstr.obj+
Xobj\tgoto.obj+
Xobj\tputs.obj+
Xobj\tok.obj+
Xobj\vms.obj
Xlarn123.exe
Xlarn123.map/map /line
Xdoscalls.lib
Xos2larn.def
END_OF_FILE
if test 567 -ne `wc -c <'os2larn.lnk'`; then
    echo shar: \"'os2larn.lnk'\" unpacked with wrong size!
fi
# end of 'os2larn.lnk'
fi
if test -f 'tlink.rsp' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tlink.rsp'\"
else
echo shar: Extracting \"'tlink.rsp'\" \(373 characters\)
sed "s/^X//" >'tlink.rsp' <<'END_OF_FILE'
Xmain.obj object.obj create.obj tok.obj display.obj +
Xglobal.obj data.obj io.obj monster.obj action.obj  +
Xiventory.obj vms.obj store.obj diag.obj help.obj   +
Xconfig.obj nap.obj bill.obj scores.obj signal.obj  +
Xmoreobj.obj spheres.obj spells.obj movem.obj       +
Xregen.obj fortune.obj savelev.obj msdos.obj        +
Xfgetlr.obj tgoto.obj tgetent.obj tgetstr.obj tputs.obj
END_OF_FILE
if test 373 -ne `wc -c <'tlink.rsp'`; then
    echo shar: \"'tlink.rsp'\" unpacked with wrong size!
fi
# end of 'tlink.rsp'
fi
echo shar: End of archive 4 \(of 12\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 12 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