[comp.sources.games] v07i029: omega3 - rogue like dungeon exploration

billr@saab.CNA.TEK.COM (Bill Randle) (07/13/89)

Submitted-by: "Laurence R. Brothers"   <brothers@paul.rutgers.edu>
Posting-number: Volume 7, Issue 29
Archive-name: omega3/Part10
Supersedes: omega2: Volume 5, Issue 11-29,38-40



#! /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 10 (of 20)."
# Contents:  ocom3.c ofile.c ohelp8.txt
# Wrapped by billr@saab on Thu Jun 29 08:14:05 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'ocom3.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ocom3.c'\"
else
echo shar: Extracting \"'ocom3.c'\" \(27478 characters\)
sed "s/^X//" >'ocom3.c' <<'END_OF_FILE'
X/* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
X/* ocom3.c */
X
X/* This file contains some more top level command functions
X   called from ocom1.c */
X
X#include "oglob.h"
X#include "odate.h"
X
X/* look at some spot */
Xvoid examine()
X{
X  pol ol;
X  int x=Player.x,y=Player.y,drewmenu=FALSE;
X
X  clearmsg();
X
X  setgamestatus(SKIP_MONSTERS);
X  mprint("Examine --");
X  setspot(&x,&y);
X  if (inbounds(x,y)) {
X    clearmsg();
X    if (Current_Environment == E_COUNTRYSIDE) {
X      if (! Country[x][y].explored) 
X	print3("How should I know what that is?");
X      else {
X	mprint("That terrain is:");
X	mprint(countryid(Country[x][y].current_terrain_type));
X      }
X    } 
X    else if (! los_p(Player.x,Player.y,x,y))
X      print3("I refuse to examine something I can't see.");
X    else {
X      clearmsg();
X      if (Level->site[x][y].creature != NULL) 
X	mprint(mstatus_string(Level->site[x][y].creature));
X      else if ((Player.x == x) && (Player.y ==y)) 
X	describe_player();
X      if (loc_statusp(x,y,SECRET))
X	print2("An age-worn stone wall.");
X      else
X	switch (Level->site[x][y].locchar) {
X	case SPACE: print2("An infinite void."); break;
X	case PORTCULLIS: print2("A heavy steel portcullis"); break;
X	case ABYSS: print2("An entrance to the infinite abyss"); break;
X	case FLOOR:
X	  if (Current_Dungeon == Current_Environment)
X	    print2("A dirty stone floor.");
X	  else print2("The ground.");
X	  break;
X	case WALL:
X	  if (Level->site[x][y].aux == 0)
X	    print2("A totally impervious wall.");
X	  else if (Level->site[x][y].aux < 10)
X	    print2("A pitted concrete wall.");
X	  else if (Level->site[x][y].aux < 30)
X	    print2("An age-worn sandstone wall.");
X	  else if (Level->site[x][y].aux < 50)
X	    print2("A smooth basalt wall.");
X	  else if (Level->site[x][y].aux < 70)
X	    print2("A solid granite wall.");
X	  else if (Level->site[x][y].aux < 90)
X	    print2("A wall of steel.");
X	  else if (Level->site[x][y].aux < 210) {
X	    if (Current_Environment == E_CITY)
X	      print2("A thick wall of Rampart bluestone");
X	    else print2("A magically reinforced wall.");
X	  }
X	  else print2("An almost totally impervious wall.");
X	  break;
X	case RUBBLE:print2("A dangerous-looking pile of rubble."); break;
X	case SAFE:print2("A steel safe inset into the floor."); break;
X	case CLOSED_DOOR:print2("A solid oaken door, now closed."); break;
X	case OPEN_DOOR:print2("A solid oaken door, now open."); break;
X	case STATUE:print2("A strange-looking statue."); break;
X	case UP:print2("A stairway leading up."); break;
X	case DOWN:print2("A stairway leading down...."); break;
X	case TRAP:print2(trapid(Level->site[x][y].p_locf)); break;
X	case HEDGE:
X	  if (Level->site[x][y].p_locf == L_EARTH_STATION)
X	    print2("A weird fibrillation of oozing tendrils.");
X	  else print2("A brambly, thorny hedge."); 
X	  break;
X	case LAVA:print2("A bubbling pool of lava."); break;
X	case LIFT:print2("A strange glowing disk."); break;
X	case ALTAR:print2("An (un?)holy altar."); break;
X	case CHAIR:print2("A chair."); break;
X	case WHIRLWIND:print2("A strange cyclonic electrical storm."); break;
X	case WATER: 
X	  if (Level->site[x][y].p_locf == L_WATER)
X	    print2("A deep pool of water.");
X	  else if (Level->site[x][y].p_locf == L_CHAOS)
X	    print2("A pool of primal chaos.");
X	  else if (Level->site[x][y].p_locf == L_WATER_STATION)
X	    print2("A bubbling pool of acid.");
X	  else print2("An eerie pool of water.");
X	  break;
X	case FIRE:print2("A curtain of fire."); break;
X	default:print2("Wow, I haven't the faintest idea!"); break;
X	}
X      if ((ol = Level->site[x][y].things) != NULL) {
X	if (ol->next == NULL)
X	  print3(itemid(ol->thing));
X	else {
X	  drewmenu = TRUE;
X	  menuclear();
X	  menuprint("Things on floor:\n");
X	  while (ol != NULL) {
X	    menuprint("\n");
X	    menuprint(itemid(ol->thing));
X	    ol = ol->next;
X	  }
X	}
X      }
X      morewait();
X      sign_print(x,y,TRUE);
X    }
X  }
X  if (drewmenu) xredraw();
X}
X
Xvoid help()
X{
X  char c;
X  char filestr[80];
X  int n,filenum;
X  clearmsg();
X  print1("Please enter the letter indicating what topic you want help on.");
X  menuclear();
X  menuprint("a: Overview\n");
X  menuprint("b: Characters\n");
X  menuprint("c: Inventories\n");
X  menuprint("d: Movement\n");
X  menuprint("e: Combat\n");
X  menuprint("f: Bugs\n");
X  menuprint("g: Magic\n");
X  menuprint("h: The Countryside\n");
X  menuprint("i: The Screen Display\n");
X  menuprint("j: Saving and Restoring\n");
X  menuprint("k: Options Settings\n");
X  menuprint("l: Dungeon/City/Other Command List\n");
X  menuprint("m: Countryside Command List\n");
X  menuprint("n: Everything\n");
X  menuprint("ESCAPE: Forget the whole thing.");
X  do 
X    c = mcigetc();
X  while ((c < 'a') && (c > 'n') && (c != ESCAPE));
X  if (c == 'n') {
X    print1("Trying to copy all help files to ./omega.doc ");
X    nprint1("Confirm [yn]");
X    if (ynq1()=='y') {
X      print2("Copying");
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp1.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp2.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp3.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp4.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp5.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp6.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp7.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp8.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp9.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp10.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp11.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp12.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(".");
X      strcpy(Str1,"cat ");
X      strcat(Str1,OMEGALIB);
X      strcat(Str1,"ohelp13.txt");
X      strcat(Str1," >> omega.doc");
X      system(Str1);
X      nprint2(" Done.");
X    }
X  }
X  else if (c != ESCAPE) {
X    strcpy(filestr,OMEGALIB);
X    strcat(filestr,"ohelp");
X    filenum = c+1-'a';
X    n = strlen(filestr);
X    if (filenum<10) {
X      filestr[n] = filenum+'0';
X      filestr[n+1] = 0;
X    }
X    else {
X      filestr[n] = '1';
X      filenum = c - 'j';
X      filestr[n+1] = filenum+'0';
X      filestr[n+2] = 0;
X    }
X    strcat(filestr,".txt");
X    print1("Display help file, or Copy help file to file in wd. [dc] ");
X    do 
X      c = mcigetc();
X    while ((c != 'd') && (c != 'c')&& (c!=ESCAPE));
X    if (c == 'd')
X      displayfile(filestr);
X    else if (c == 'c') copyfile(filestr);
X  }
X  xredraw();
X}
X
Xvoid version()
X{
X  setgamestatus(SKIP_MONSTERS);
X  print3(VERSIONSTRING);
X  nprint3(":");
X  nprint3(" Last Edited: ");
X  nprint3(LAST_OMEGA_EDIT_DATE);
X}
X
Xvoid fire()
X{
X  int index,x1,y1,x2,y2;
X  pob obj;
X  struct monster *m;
X
X  clearmsg();
X
X  print1("Fire/Throw --");
X  index = getitem(NULL);
X  if (index == ABORT)
X    setgamestatus(SKIP_MONSTERS);
X  else if (index == CASHVALUE) print3("Can't fire money at something!");
X  else if (cursed(Player.possessions[index]) && 
X	   Player.possessions[index]->used)
X    print3("You can't seem to get rid of it!");
X  /* load a crossbow */
X  else if ((Player.possessions[O_WEAPON_HAND] != NULL) &&  
X	   (Player.possessions[O_WEAPON_HAND]->id == WEAPONID+27) && 
X	   (Player.possessions[O_WEAPON_HAND]->aux != LOADED) &&
X	   (Player.possessions[index]->id == WEAPONID+29)) {
X	     mprint("You crank back the crossbow and load a bolt.");
X	     Player.possessions[O_WEAPON_HAND]->aux = LOADED;
X	   }
X  else {
X    if (Player.possessions[index]->used) {
X      Player.possessions[index]->used = FALSE;
X      item_use(Player.possessions[index]);
X    }
X    obj = Player.possessions[index];
X    x1 = x2 = Player.x;
X    y1 = y2 = Player.y;
X    setspot(&x2,&y2);
X    if ((x2 == Player.x) && (y2 == Player.y)) 
X      mprint("You practice juggling for a moment or two.");
X    else {
X      do_object_los(obj->objchar,&x1,&y1,x2,y2);
X      if ((m=Level->site[x1][y1].creature) != NULL) {
X	if (obj->dmg == 0) {
X	  if (m->treasure > 0) { /* the monster can have treasure/objects */
X	    mprint("Your gift is caught!");
X	    givemonster(m,obj);
X	    conform_lost_objects(1,obj);
X	  }
X	  else {
X	    mprint("Your thrown offering is ignored.");
X	    p_drop_at(x1,y1,1,obj);
X	    conform_lost_objects(1,obj);
X	  }
X	}
X	else if (hitp(Player.hit,m->ac)) {/* ok already, hit the damn thing */
X	  weapon_use(2*statmod(Player.str),obj,m);
X	  dispose_lost_objects(1,obj);
X	}
X	else {
X	  mprint("You miss it.");
X	  p_drop_at(x1,y1,1,obj);
X	  conform_lost_objects(1,obj);
X	}
X      }
X      else {
X	p_drop_at(x1,y1,1,obj);
X	conform_lost_objects(1,obj);
X      }
X    }
X  }
X}
X
X
X
Xint quit()
X{
X  clearmsg();
X  mprint("Quit: Are you sure? [yn] ");
X  if (ynq()=='y') {
X    if (Player.rank[ADEPT] == 0) display_quit();
X    else display_bigwin();
X#ifdef MSDOS
X    kill_all_levels();
X#endif
X    endgraf();
X    exit(0);
X  }
X  else resetgamestatus(SKIP_MONSTERS);
X}
X
X
X
X/* rest in 10 second segments so if woken up by monster won't
Xdie automatically.... */
Xvoid nap()
X{
X  static int naptime;
X  if (gamestatusp(FAST_MOVE)) {
X    if (naptime-- < 1) {
X      clearmsg();
X      mprint("Yawn. You wake up.");
X      resetgamestatus(FAST_MOVE);
X      drawvision(Player.x,Player.y);
X    }
X  }
X  else {
X    clearmsg();
X    mprint("Rest for how long? (in minutes) ");
X    naptime = parsenum();
X    if (naptime > 600) {
X      print3("You can only sleep up to 10 hours (600 minutes)");
X      naptime = 3600;
X    }
X    else naptime *= 6;
X    if (naptime > 1) {
X      clearmsg();
X      setgamestatus(FAST_MOVE);
X      mprint("Resting.... ");
X    }
X  }
X}
X
X
Xvoid charid()
X{
X  char id;
X  int countryside=FALSE;
X  char cstr[80];
X
X  clearmsg();
X  mprint("Character to identify: ");
X  id = mgetc();
X  if (Current_Environment == E_COUNTRYSIDE) {
X    countryside = TRUE;
X    strcpy(cstr,countryid(id));
X    if (strcmp(cstr,"I have no idea.")==0)
X      countryside = FALSE;
X    else mprint(cstr);
X  }
X  if (! countryside) {
X    if (((id >= 'a') && (id <= 'z')) || ((id >= 'A') && (id <= 'Z'))) 
X      mprint("A monster or NPC -- examine (x) to find out exactly.");
X    else switch(id) {
X    case SPACE:
X      mprint(" : An airless void (if seen) or unknown region (if unseen)");
X      break;
X    case WALL:
X      mprint(" : An (impenetrable?) wall");
X      break;
X    case OPEN_DOOR:
X      mprint(" : An open door");
X      break;
X    case CLOSED_DOOR:
X      mprint(" : A closed (possibly locked) door");
X      break;
X    case LAVA:
X      mprint(" : A pool of lava");
X      break;
X    case HEDGE:
X      mprint(" : A dense hedge");
X      break;
X    case WATER:
X      mprint(" : A deep body of water");
X      break;
X    case FIRE:
X      mprint(" : A curtain of fire");
X      break;
X    case TRAP:
X      mprint(" : An uncovered trap");
X      break;
X    case UP:
X      mprint(" : A stairway leading up");
X      break;
X    case DOWN:
X      mprint(" : A stairway leading down");
X      break;
X    case FLOOR:
X      mprint(" : The dungeon floor");
X      break;
X    case PORTCULLIS:
X      mprint(" : A heavy steel portcullis");
X      break;
X    case ABYSS:
X      mprint(" : An entrance to the infinite abyss");
X      break;
X    case PLAYER:
X      mprint(" : You, the player");
X      break;
X    case CORPSE:
X      mprint(" : The remains of some creature");
X      break;
X    case THING:
X      mprint(" : Some random miscellaneous object");
X      break;
X    case SAFE:
X      mprint(" : A steel safe inset into the floor"); 
X      break;
X    case RUBBLE:
X      mprint(" : A dangerous-looking pile of rubble");
X      break;
X    case STATUE:
X      mprint(" : A statue");
X      break;
X    case ALTAR:
X      mprint(" : A (un?)holy altar");
X      break;
X    case CASH:
X      mprint(" : Bills, specie, gems: cash");
X      break;
X    case PILE:
X      mprint(" : A pile of objects");
X      break;
X    case FOOD:
X      mprint(" : Something edible");
X      break;
X    case WEAPON:
X      mprint(" : Some kind of weapon");
X      break;
X    case MISSILEWEAPON:
X      mprint(" : Some kind of missile weapon");
X      break;
X    case SCROLL:
X      mprint(" : Something readable");
X      break;
X    case POTION:
X      mprint(" : Something drinkable");
X      break;
X    case ARMOR:
X      mprint(" : A suit of armor");
X      break;
X    case SHIELD:
X      mprint(" : A shield");
X      break;
X    case CLOAK:
X      mprint(" : A cloak");
X      break;
X    case BOOTS:
X      mprint(" : A pair of boots");
X      break;
X    case STICK:
X      mprint(" : A stick");
X      break;
X    case RING:
X      mprint(" : A ring");
X      break;
X    case ARTIFACT:
X      mprint(" : An artifact");
X      break;
X    case CHAIR:
X      mprint(" : A chair");
X      break;
X    case WHIRLWIND:
X      mprint(" : A whirlwind");
X      break;
X    default:
X      mprint("That character is unused.");
X      break;
X    }
X  }
X}
X
X
Xvoid wizard()
X{
X  setgamestatus(SKIP_MONSTERS);
X  if (gamestatusp(CHEATED)) mprint("You're already in wizard mode!");
X  else {
X    clearmsg();
X    mprint("Really try to enter wizard mode? [yn] ");
X    if (ynq()=='y') {
X      if (strcmp(getlogin(),WIZARD)==0) {
X	setgamestatus(CHEATED);
X	mprint("Wizard mode set.");
X      }
X      else {
X	mprint("There is a shrieking sound, as of reality being distorted.");
X	strcpy(Str1,WIZARD);
X	strcat(Str1,", the Wizard of omega appears before you....");
X	mprint(Str1);
X	mprint("'Do not meddle in the affairs of Wizards --");
X	if (random_range(2)) mprint("it makes them soggy and hard to light.'");
X	else mprint("for they are subtle, and swift to anger!'");
X      }
X    }
X  }
X}
X
X/* Jump, that is */
Xvoid vault()
X{
X  int x=Player.x,y=Player.y,jumper=0;
X  
X  clearmsg();
X
X  if (Player.possessions[O_BOOTS] != NULL)
X    if (Player.possessions[O_BOOTS]->usef == I_BOOTS_JUMPING)
X      jumper = 2;
X  if (Player.status[IMMOBILE] > 0) {
X    resetgamestatus(FAST_MOVE);
X    print3("You are unable to move");
X  }
X  else {
X    setgamestatus(SKIP_MONSTERS);
X    mprint("Jump where?");
X    setspot(&x,&y);
X    if (! los_p(x,y,Player.x,Player.y))
X      print3("The way is obstructed.");
X    else if (Player.itemweight > Player.maxweight) 
X      print3("You are too burdened to jump anywhere.");
X    else if (distance(x,y,Player.x,Player.y) > 
X	     max(2,statmod(Player.agi)+2)+jumper)
X      print3("The jump is too far for you.");
X    else if (Level->site[x][y].creature != NULL)
X      print3("You can't jump on another creature.");
X    else if (! p_moveable(x,y))
X      print3("You can't jump there.");
X    else {
X      resetgamestatus(SKIP_MONSTERS);
X      Player.x = x;
X      Player.y = y;
X      if ((! jumper) && (random_range(30) > Player.agi)) {
X	mprint("Oops -- took a tumble.");
X	setgamestatus(SKIP_PLAYER);
X	p_damage((Player.itemweight/250),UNSTOPPABLE,"clumsiness");
X      }
X      p_movefunction(Level->site[Player.x][Player.y].p_locf);
X      if (Current_Environment != E_COUNTRYSIDE) 
X	if ((Level->site[Player.x][Player.y].things != NULL) &&
X	    (optionp(PICKUP)))
X	  pickup();
X    }
X  }
X}
X
X
X/* Sets sequence of combat maneuvers. */
Xvoid tacoptions()
X{
X  int actionsleft,done,place;
X  float times;
X
X  setgamestatus(SKIP_MONSTERS);
X
X  done = FALSE;
X  actionsleft = maneuvers();
X  menuclear();
X  place = 0;
X  menuprint("Enter a combat maneuvers sequence.\n");
X  menuprint("? for help, ! for default, RETURN to save sequence\n");
X  do {
X    clearmsg1();
X    mprint("Maneuvers Left:");
X    mnumprint(actionsleft);
X    switch(mgetc()) {
X    case '?':
X      combat_help();
X      break;
X    case 'a': case 'A':
X      if (actionsleft < 1) print3("No more maneuvers!");
X      else {
X	if (Player.possessions[O_WEAPON_HAND] == NULL) {
X	  Player.meleestr[place] = 'C';
X	  menuprint("\nPunch:");
X	}
X	else if (Player.possessions[O_WEAPON_HAND]->type == THRUSTING) {
X	  Player.meleestr[place] = 'T';
X	  menuprint("\nThrust:");
X	}
X	else if (Player.possessions[O_WEAPON_HAND]->type == STRIKING) {
X	  Player.meleestr[place] = 'C';
X	  menuprint("\nStrike:");
X	}
X	else {
X	  menuprint("\nCut:");
X	  Player.meleestr[place] = 'C';
X	}
X	place++;
X	Player.meleestr[place]=getlocation();
X	place++;
X	actionsleft--;
X      }
X      break;
X    case 'b': case 'B':
X      if (actionsleft<1) print3("No more maneuvers!");
X      else {
X	Player.meleestr[place] = 'B';
X	if (Player.possessions[O_WEAPON_HAND] == NULL)
X	  menuprint("\nDodge (from):");
X	else if (Player.possessions[O_WEAPON_HAND]->type == THRUSTING) 
X	  menuprint("\nParry:");
X	else menuprint("\nBlock:");
X	place++;
X	Player.meleestr[place]= getlocation();
X	place++;
X	actionsleft--;
X      }
X      break;
X    case 'l': case 'L':
X      if (actionsleft<2) print3("Not enough maneuvers to lunge!");
X      else {
X	if (Player.possessions[O_WEAPON_HAND] != NULL) {
X	  if (Player.possessions[O_WEAPON_HAND]->type != MISSILE) {
X	    Player.meleestr[place] = 'L';
X	    place++;
X	    Player.meleestr[place]=getlocation();
X	    place++;
X	    actionsleft -= 2;
X	    menuprint("\nLunge:");
X	  }
X	  else {
X	    print3("Can't lunge with a missile weapon!");
X	    morewait();
X	  }
X	}
X	else {
X	  print3("Can't lunge without a weapon!");
X	  morewait();
X	}
X      }
X      break;
X    case 'r': case 'R':
X      if (actionsleft<2) print3("Not enough maneuvers to riposte!");
X      else {
X	if (Player.possessions[O_WEAPON_HAND] != NULL) {
X	  if (Player.possessions[O_WEAPON_HAND]->type == THRUSTING) {
X	    Player.meleestr[place] = 'R';
X	    menuprint("\nRiposte ");
X	    Player.meleestr[place]=getlocation();
X	    actionsleft -= 2;
X	  }
X	  else {
X	    print3("Can't riposte without a thrusting weapon!");
X	    morewait();
X	  }
X	}
X	else {
X	  print3("Can't riposte without a thrusting weapon!");
X	  morewait();
X	}
X      }
X      break;
X    case BACKSPACE:
X    case DELETE:
X      place = 0;
X      actionsleft=maneuvers();
X      break;
X    case RETURN:
X    case LINEFEED:
X    case ESCAPE:
X      done = TRUE;
X      break;
X    }
X  } while (! done);
X  xredraw();
X  Player.meleestr[place] = 0;
X}
X
X
X
X
X/* Do the Artful Dodger trick */
Xvoid pickpocket()
X{
X  int dx,dy,index=0;
X  struct monster *m;
X
X  clearmsg();
X
X  mprint("Pickpocketing --");
X
X  index = getdir();
X
X  if (index == ABORT)
X    setgamestatus(SKIP_MONSTERS);
X  else {
X    dx = Dirs[0][index];
X    dy = Dirs[1][index];
X    
X    if ((! inbounds(Player.x+dx, Player.y+dy)) ||
X	(Level->site[Player.x+dx][Player.y+dy].creature == NULL)) {
X      print3("There's nothing there to steal from!!!");
X      setgamestatus(SKIP_MONSTERS);
X    }
X    else {
X      m = Level->site[Player.x+dx][Player.y+dy].creature;
X      if (m->id == ML0+3) {
X	mprint("Trying to steal from a guardsman, eh?");
X	mprint("Not a clever idea.");
X	if (Player.cash > 0) {
X	  mprint("As a punitive fine, the guard takes all your money.");
X	  Player.cash = 0;
X	  dataprint();
X	}
X	else {
X	  mprint("The guardsman places you under arrest.");
X	  morewait();
X	  send_to_jail();
X	}
X      }
X      else if (m->possessions == NULL) {
X	mprint("You couldn't find anything worth taking!");
X	mprint("But you managed to annoy it...");
X	m_status_set(m,HOSTILE);
X      }
X      else if (Player.dex*5+Player.rank[THIEVES]*20+random_range(100) >
X	       random_range(100)+m->level*20) {
X	mprint("You successfully complete your crime!");
X	mprint("You stole:");
X	mprint(itemid(m->possessions->thing));
X	Player.alignment--;
X	gain_experience(m->level*m->level);
X	gain_item(m->possessions->thing);
X	m->possessions = m->possessions->next;
X      }
X    }
X  }
X}
X
X
X
Xvoid rename_player()
X{
X  setgamestatus(SKIP_MONSTERS);
X  clearmsg();
X  mprint("Rename Character:");
X  strcpy(Player.name,msgscanstring());
X}
X
X
Xvoid abortshadowform()
X{
X  setgamestatus(SKIP_MONSTERS);
X  if (Player.status[SHADOWFORM] && (Player.status[SHADOWFORM]<1000)) {
X    mprint("You abort your spell of Shadow Form.");
X    Player.immunity[NORMAL_DAMAGE]--;
X    Player.immunity[ACID]--;
X    Player.immunity[THEFT]--;
X    Player.immunity[INFECTION]--;
X    mprint("You feel less shadowy now.");
X    Player.status[SHADOWFORM] = 0;
X  }
X}
X
Xvoid tunnel()
X{
X  int dir,ox,oy,aux;
X
X  clearmsg();
X  mprint("Tunnel -- ");
X  dir = getdir();
X  if (dir == ABORT)
X    setgamestatus(SKIP_MONSTERS);
X  else {
X    ox = Player.x + Dirs[0][dir];
X    oy = Player.y + Dirs[1][dir];
X    if (loc_statusp(ox,oy,SECRET))
X      mprint("You have no success as yet.");
X    else if (Level->site[ox][oy].locchar != WALL) {
X      print3("You can't tunnel through that!");
X      setgamestatus(SKIP_MONSTERS);
X    }
X    else {
X      aux = Level->site[ox][oy].aux;
X      if (random_range(20)==1){
X	if (Player.possessions[O_WEAPON_HAND] == NULL) {
X	  mprint("Ouch! broke a fingernail...");
X	  p_damage(Player.str / 6,UNSTOPPABLE,"A broken fingernail");
X	}
X	else if ((Player.possessions[O_WEAPON_HAND]->type == THRUSTING) ||
X		 ((Player.possessions[O_WEAPON_HAND]->type != STRIKING) &&
X		  (Player.possessions[O_WEAPON_HAND]->fragility < 
X		   random_range(20)))) {
X	  mprint("Clang! Uh oh...");
X	  damage_item(Player.possessions[O_WEAPON_HAND]);
X	}
X	else mprint("Your digging implement shows no sign of breaking.");
X      }
X      if (Player.possessions[O_WEAPON_HAND] == NULL) {
X	if ((aux > 0) && ((Player.str/3)+random_range(100) > aux)) {
X	  mprint("You carve a tunnel through the stone!");
X	  tunnelcheck();
X	  Level->site[ox][oy].locchar = RUBBLE;
X	  Level->site[ox][oy].p_locf = L_RUBBLE;
X	}
X	else mprint("No joy.");
X      }
X      else if (Player.possessions[O_WEAPON_HAND]->type == THRUSTING) {
X	if ((aux > 0) && 
X	    (Player.possessions[O_WEAPON_HAND]->dmg*2+random_range(100) > 
X	     aux)) {
X	  mprint("You carve a tunnel through the stone!");
X	  tunnelcheck();
X	  Level->site[ox][oy].locchar = RUBBLE;
X	  Level->site[ox][oy].p_locf = L_RUBBLE;
X	}
X	else mprint("No luck.");
X      }
X      else if ((aux > 0) && 
X	       (Player.possessions[O_WEAPON_HAND]->dmg+random_range(100) 
X		> aux)) {
X	mprint("You carve a tunnel through the stone!");
X	tunnelcheck();
X	Level->site[ox][oy].locchar = RUBBLE;
X	Level->site[ox][oy].p_locf = L_RUBBLE;
X      }
X      else mprint("You have no success as yet.");
X    }
X  }
X}
X
X
X
X
Xvoid hunt(terrain)
Xchar terrain;     
X{
X  int fertility=0;
X  switch(terrain) {
X  case SWAMP: 
X    mprint("You hesitate to hunt for food in the marshy wasteland.");
X    break;
X  case VOLCANO:
X  case CASTLE:
X  case TEMPLE:
X  case CAVES:
X  case STARPEAK:
X  case MAGIC_ISLE:
X  case DRAGONLAIR:
X    mprint("There is nothing alive here (or so it seems)");
X    break;
X  case VILLAGE:
X  case CITY:
X    mprint("You can find no food here; perhaps if you went inside....");
X    break;
X  case ROAD:
X    mprint("You feel it would be a better idea to hunt off the road.");
X    break;
X  case CHAOS_SEA:
X    mprint("Food in the Sea of Chaos? Go on!");
X    break;
X  case DESERT:
X    mprint("You wander off into the trackless desert in search of food...");
X    Time += 100;
X    hourly_check();  
X    fertility = 10;
X    break;
X  case JUNGLE:
X    mprint("You search the lush and verdant jungle for game....");
X    Time += 100;
X    hourly_check();
X    fertility = 80;
X    break;
X  case PLAINS:
X    mprint("You set off through the tall grass; the game is afoot.");
X    Time += 100;
X    hourly_check();
X    fertility = 50;
X    break;
X  case TUNDRA:
X    mprint("You blaze a trail through the frozen wasteland....");
X    Time += 100;
X    hourly_check();
X    fertility = 30;
X    break;
X  case FOREST:
X    mprint("You try to follow the many tracks through the forest loam....");
X    Time += 100;
X    hourly_check();
X    fertility = 70;
X    break;
X  case MOUNTAINS: case PASS:
X    mprint("You search the cliff walls looking for something to eat....");
X    Time += 100;
X    hourly_check();  
X    fertility = 30;
X    break;
X  case RIVER:
X    mprint("The halcyon river is your hopeful food source...");
X    Time += 100;
X    hourly_check();  
X    fertility = 80;
X    break;
X  }
X  if (((Date % 360 < 60) || (Date % 360 > 300)) && 
X      (terrain != DESERT) &&
X      (terrain != JUNGLE)) {
X    mprint("The cold weather impedes your hunt....");
X    fertility = fertility / 2;
X  }
X  if (fertility > random_range(100)) {
X    mprint("You have an encounter...");
X    change_environment(E_TACTICAL_MAP);
X  }
X  else mprint("Your hunt is fruitless.");
X}
X
Xvoid dismount_steed()
X{
X  pml ml;
X  if (! gamestatusp(MOUNTED))
X    print3("You're on foot already!");
X  else if (Current_Environment == E_COUNTRYSIDE) {
X    mprint("If you leave your steed here he will wander away!");
X    mprint("Do it anyway? [yn] ");
X    if (ynq()=='y') resetgamestatus(MOUNTED);
X  }
X  else {
X    resetgamestatus(MOUNTED);;
X    ml = ((pml) malloc(sizeof(mltype)));
X    ml->m = ((pmt) malloc(sizeof(montype)));
X    *(ml->m) = Monsters[HORSE];
X    ml->m->x = Player.x;
X    ml->m->y = Player.y;
X    ml->m->status = MOBILE+SWIMMING;
X    ml->next = Level->mlist;
X    Level->site[Player.x][Player.y].creature = ml->m;
X    Level->mlist = ml;
X  }
X  calc_melee();
X}
X
X
Xvoid city_move()
X{
X  int site,x=Player.x,y=Player.y,toggle=FALSE;
X  clearmsg();
X  if (Current_Environment != E_CITY) {
X    print3("This command only works in the city!");
X    setgamestatus(SKIP_MONSTERS);
X  }
X  else if (Player.status[IMMOBILE] > 0) 
X    print3("You can't even move!");
X  else if (hostilemonstersnear()) {
X    setgamestatus(SKIP_MONSTERS);
X    print3("You can't move this way with hostile monsters around!");
X  }
X  else if (Level->site[Player.x][Player.y].aux == NOCITYMOVE)
X    print3("You can't use the 'M' command from this location.");
X  else {
X    mprint("Move to which establishment [? for help, ESCAPE to quit] ");
X    site = parsecitysite();
X    if (site != ABORT) {
X      mprint("You're on your way...");
X      morewait();
X      while ((x != CitySiteList[site][1]) || (y != CitySiteList[site][2])) {
X	toggle = ! toggle;
X	if (toggle) {
X	  Time++;
X	  if (Time % 10 == 0) tenminute_check();
X	  else minute_status_check();
X	}
X	x += sign(CitySiteList[site][1] - x);
X	y += sign(CitySiteList[site][2] - y);
X	screencheck(y);
X	showcursor(x,y);
X      }
X      Player.x = x;
X      Player.y = y;
X      screencheck(Player.y);
X      mprint("Made it!");
X      morewait();
X      p_movefunction(Level->site[x][y].p_locf);
X    }
X  }
X}
X
X
X
Xvoid frobgamestatus()
X{
X  char response;
X  long num;
X  mprint("Set or Reset or Forget it [s,r,ESCAPE]:");
X  do response = mcigetc();
X  while ((response != 'r') && (response != 's') && (response != ESCAPE));
X  if (response != ESCAPE) {
X    mprint("Enter log2 of flag:");
X    num = parsenum();
X    if (num > -1) {
X      num = pow2(num);
X      if (response == 's') setgamestatus(num);
X      else resetgamestatus(num);
X      mprint("Done....");
X    }
X  }
X}
X      
END_OF_FILE
if test 27478 -ne `wc -c <'ocom3.c'`; then
    echo shar: \"'ocom3.c'\" unpacked with wrong size!
fi
# end of 'ocom3.c'
fi
if test -f 'ofile.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ofile.c'\"
else
echo shar: Extracting \"'ofile.c'\" \(21773 characters\)
sed "s/^X//" >'ofile.c' <<'END_OF_FILE'
X/* omega (c) 1987,1988,1989 by Laurence Raphael Brothers */
X/* ofile.c */
X/* functions with file access in them. Also some direct calls to
X   curses functions */
X
X#include <curses.h>
X#ifndef MSDOS
X#include <sys/file.h>
X#endif
X#include "oglob.h"
X
X#ifndef F_OK
X#define F_OK 00 
X#define R_OK 04
X#define W_OK 02
X#endif
X
XFILE *checkfopen(filestring,optionstring)
Xchar *filestring,*optionstring;
X{
X  FILE *fd;
X  char response;
X  fd = fopen(filestring,optionstring);
X  clearmsg();
X  while (fd == NULL) {
X    print3("Warning! Error opening file:");
X    nprint3(filestring);
X    print1(" Abort or Retry? [ar] ");
X    do response = mcigetc(); while ((response != 'a') && (response != 'r'));
X    if (response == 'r') fd = fopen(filestring,optionstring);
X    else {
X      print2("Sorry 'bout that.... Bye!");
X      morewait();
X      endgraf();
X      exit(0);
X    }
X  }
X  return(fd);
X}
X
Xvoid commandlist()
X{
X  FILE *fd; 
X  strcpy(Str1,OMEGALIB);
X  if (Current_Environment == E_COUNTRYSIDE)
X    strcat(Str1,"ohelp13.txt");
X  else strcat(Str1,"ohelp12.txt");
X  fd = checkfopen(Str1,"r");
X  showfile(fd);
X  fclose(fd);
X  clear();
X  refresh();
X  xredraw();
X}
X
X
Xvoid user_intro()
X{
X  FILE *fd; 
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ointro.txt");
X  fd = checkfopen(Str1,"r");
X  showfile(fd);
X  fclose(fd);
X  clear();
X  refresh();
X  xredraw();
X}
X
Xvoid show_license()
X{
X  FILE *fd; 
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"olicense.txt");
X  fd = checkfopen(Str1,"r");
X  showfile(fd);
X  fclose(fd);
X  clear();
X  refresh();
X  xredraw();
X}
X
X
X
Xvoid abyss_file()
X{
X  FILE *fd; 
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oabyss.txt");
X  fd = checkfopen(Str1,"r");
X  showfile(fd);
X  fclose(fd);
X  clear();
X  refresh();
X}
X
X
X
X
Xvoid inv_help()
X{
X  FILE *fd; 
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp3.txt");
X  fd = checkfopen(Str1,"r");
X  showfile(fd);
X  fclose(fd);
X  clear();
X  refresh();
X  xredraw();
X}
X
X
X
Xvoid combat_help()
X{
X  FILE *fd; 
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp5.txt");
X  fd = checkfopen(Str1,"r");
X  showfile(fd);
X  fclose(fd);
X  clear();
X  refresh();
X  xredraw();
X}
X
X
X
X
Xvoid cityguidefile()
X{
X  FILE *fd;
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oscroll2.txt");
X  fd = checkfopen(Str1,"r");
X  showfile(fd);
X  fclose(fd);
X  clear();
X  refresh();
X  xredraw();
X}
X
X
Xvoid wishfile()
X{
X  FILE *fd;
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oscroll3.txt");
X  fd = checkfopen(Str1,"r");
X  showfile(fd);
X  fclose(fd);
X  clear();
X  refresh();
X  xredraw();
X}
X
Xvoid adeptfile()
X{
X  FILE *fd;
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oscroll4.txt");
X  fd = checkfopen(Str1,"r");
X  showfile(fd);
X  fclose(fd);
X  clear();
X  refresh();
X  xredraw();
X}
X
Xvoid theologyfile()
X{
X  FILE *fd;
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oscroll1.txt");
X  fd = checkfopen(Str1,"r");
X  showfile(fd);
X  fclose(fd);
X  clear();
X  refresh();
X  xredraw();
X}
X
X
Xvoid showmotd()
X{
X  FILE *fd;
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"omotd.txt");
X  fd = checkfopen(Str1,"r");
X  showfile(fd);
X  fclose(fd);
X  clear();
X  refresh();
X}
X
X
X
X
X/* display a file page at a time */
Xvoid showfile(fd)
XFILE *fd;
X{
X  int c,d=' ';
X  int x,y;
X  clear();
X  refresh();
X  c = fgetc(fd);
X  while ((c != EOF)&&((char) d != 'q')&&((char) d!=ESCAPE)) {
X    getyx(stdscr,y,x);
X    if (y > ScreenLength) {
X      printw("\n-More-");
X      refresh();
X      d = wgetch(stdscr);
X      clear();
X    }
X    printw("%c",(char) c);
X    c = fgetc(fd);
X  }
X  if (((char) d != 'q')&&((char) d!=ESCAPE)) {
X    printw("\n-Done-");
X    refresh();
X    getch();
X  }
X}    
X
X
X
Xvoid showscores()
X{
X  FILE *fd;
X  int i;
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"omega.hi");
X  fd = checkfopen(Str1,"r");
X  filescanstring(fd,Hiscorer);
X  filescanstring(fd,Hidescrip);
X#ifndef MSDOS
X  fscanf(fd,"%d\n%d\n%d\n",&Hiscore,&Hilevel,&Hibehavior);
X#else
X  fscanf(fd,"%ld\n%d\n%d\n",&Hiscore,&Hilevel,&Hibehavior);
X#endif
X  filescanstring(fd,Chaoslord);
X  fscanf(fd,"%d\n%d\n%d\n",&Chaoslordlevel,&Chaos,&Chaoslordbehavior);
X  filescanstring(fd,Lawlord);
X  fscanf(fd,"%d\n%d\n%d\n",&Lawlordlevel,&Law,&Lawlordbehavior);
X  filescanstring(fd,Duke);
X  fscanf(fd,"%d\n%d\n",&Dukelevel,&Dukebehavior);
X  filescanstring(fd,Justiciar);
X  fscanf(fd,"%d\n%d\n",&Justiciarlevel,&Justiciarbehavior);
X  filescanstring(fd,Commandant);
X  fscanf(fd,"%d\n%d\n",&Commandantlevel,&Commandantbehavior);
X  filescanstring(fd,Champion);
X  fscanf(fd,"%d\n%d\n",&Championlevel,&Championbehavior);
X  filescanstring(fd,Archmage);
X  fscanf(fd,"%d\n%d\n",&Archmagelevel,&Archmagebehavior);
X  filescanstring(fd,Prime);
X  fscanf(fd,"%d\n%d\n",&Primelevel,&Primebehavior);
X  filescanstring(fd,Shadowlord);
X  fscanf(fd,"%d\n%d\n",&Shadowlordlevel,&Shadowlordbehavior);
X  for(i=1;i<7;i++) {
X    filescanstring(fd,Priest[i]);
X    fscanf(fd,"%d\n%d\n",&(Priestlevel[i]),&(Priestbehavior[i]));
X  }
X  fclose(fd);
X  clear();
X#ifndef MSDOS
X  printw("High Score: %d",Hiscore);
X#else
X  printw("High Score: %ld",Hiscore);
X#endif
X  printw(", by %s (%s)",Hiscorer,levelname(Hilevel));
X  printw("\n%s\n",Hidescrip);
X  printw("\nLord of Chaos: %s (%s)",Chaoslord,levelname(Chaoslordlevel));
X  printw("\nLord of Law: %s (%s)",Lawlord,levelname(Lawlordlevel));
X  printw("\n\nDuke of Rampart:              ");
X  printw("%s (%s)",Duke,levelname(Dukelevel));
X  printw("\nJusticiar:                    ");
X  printw("%s (%s)",Justiciar,levelname(Justiciarlevel));
X  printw("\nCommandant:                   ");
X  printw("%s (%s)",Commandant,levelname(Commandantlevel));
X  printw("\nChampion:                     ");
X  printw("%s (%s)",Champion,levelname(Championlevel));
X  printw("\nArchmage:                     ");
X  printw("%s (%s)",Archmage,levelname(Archmagelevel));
X  printw("\nPrime Sorceror:               ");
X  printw("%s (%s)",Prime,levelname(Primelevel));
X  printw("\nShadowlord:                   ");
X  printw("%s (%s)",Shadowlord,levelname(Shadowlordlevel));
X  printw("\n\nHigh Priests:");
X  printw("\n of Odin:                     ");
X  printw("%s (%s)",Priest[ODIN],levelname(Priestlevel[ODIN]));
X  printw("\n of Set:                      ");
X  printw("%s (%s)",Priest[SET],levelname(Priestlevel[SET]));
X  printw("\n of Athena:                   ");
X  printw("%s (%s)",Priest[ATHENA],levelname(Priestlevel[ATHENA]));
X  printw("\n of Hecate:                   ");
X  printw("%s (%s)",Priest[HECATE],levelname(Priestlevel[HECATE]));
X  printw("\n of the Lords of Destiny:     ");
X  printw("%s (%s)",Priest[DESTINY],levelname(Priestlevel[DESTINY]));
X  printw("\nThe ArchDruid:                ");
X  printw("%s (%s)",Priest[DRUID],levelname(Priestlevel[DRUID]));
X  printw("\n\nHit any key to continue.");
X  refresh();
X  wgetch(stdscr);
X}
X
X
X/* writes a new high score file */
Xvoid checkhigh(descrip,behavior)
Xchar *descrip;
Xint behavior;
X{
X#ifndef MSDOS
X  int i,points;
X#else
X  int i;
X  long points;
X#endif
X  FILE *fd;
X
X  if (FixedPoints > 0) points = FixedPoints;
X  else points = calc_points();
X
X  if (! gamestatusp(CHEATED)) {
X    strcpy(Str1,OMEGALIB);
X    strcat(Str1,"omega.hi");
X    fd = checkfopen(Str1,"w");
X    
X    if (Hiscore < points) {
X      morewait();
X      mprint("Yow! A new high score!");
X      morewait();
X      fprintf(fd,"%s\n",Player.name);
X      fprintf(fd,"%s\n",descrip);
X#ifndef MSDOS
X      fprintf(fd,"%d\n",points);
X#else
X      fprintf(fd,"%ld\n",points);
X#endif
X      fprintf(fd,"%d\n",Player.level);
X      fprintf(fd,"%d\n",behavior);
X    }
X    else {
X      fprintf(fd,"%s\n",Hiscorer);
X      fprintf(fd,"%s\n",Hidescrip);
X#ifndef MSDOS
X      fprintf(fd,"%d\n",Hiscore);
X#else
X      fprintf(fd,"%ld\n",Hiscore);
X#endif
X      fprintf(fd,"%d\n",Hilevel);
X      fprintf(fd,"%d\n",Hibehavior);
X    }
X
X
X
X    if (Player.alignment < Chaos) {
X      morewait();
X      mprint("Criminy! A new Lord of Chaos!");
X      morewait();
X      fprintf(fd,"%s\n",Player.name);
X      fprintf(fd,"%d\n",Player.level);
X      fprintf(fd,"%d\n",Player.alignment);
X      fprintf(fd,"%d\n",behavior);
X    }
X    else {
X      fprintf(fd,"%s\n",Chaoslord);
X      fprintf(fd,"%d\n",Chaoslordlevel);
X      fprintf(fd,"%d\n",Chaos);
X      fprintf(fd,"%d\n",Chaoslordbehavior);
X    }
X
X
X
X
X
X
X    if (Player.alignment > Law) {
X      morewait();
X      mprint("Gosh! A new Lord of Law!");
X      morewait();
X      fprintf(fd,"%s\n",Player.name);
X      fprintf(fd,"%d\n",Player.level);
X      fprintf(fd,"%d\n",Player.alignment);
X      fprintf(fd,"%d\n",behavior);
X    }
X    else {
X      fprintf(fd,"%s\n",Lawlord);
X      fprintf(fd,"%d\n",Lawlordlevel);
X      fprintf(fd,"%d\n",Law);
X      fprintf(fd,"%d\n",Lawlordbehavior);
X    }
X
X
X
X
X    fprintf(fd,"%s",Duke);
X    fprintf(fd,"\n%d",Dukelevel);
X    if (Player.rank[NOBILITY] == DUKE)
X      fprintf(fd,"\n%d",behavior);
X    else fprintf(fd,"\n%d",Dukebehavior);
X    fprintf(fd,"\n%s",Justiciar);
X    fprintf(fd,"\n%d",Justiciarlevel);
X    if (Player.rank[ORDER] == JUSTICIAR)
X      fprintf(fd,"\n%d",behavior);
X    else fprintf(fd,"\n%d",Justiciarbehavior);
X    fprintf(fd,"\n%s",Commandant);
X    fprintf(fd,"\n%d",Commandantlevel);
X    if (Player.rank[LEGION] == COMMANDANT)
X      fprintf(fd,"\n%d",behavior);
X    else fprintf(fd,"\n%d",Commandantbehavior);
X    fprintf(fd,"\n%s",Champion);
X    fprintf(fd,"\n%d",Championlevel);
X    if (Player.rank[ARENA] == CHAMPION)
X      fprintf(fd,"\n%d",behavior);
X    else fprintf(fd,"\n%d",Championbehavior);
X    fprintf(fd,"\n%s",Archmage);
X    fprintf(fd,"\n%d",Archmagelevel);
X    if (Player.rank[COLLEGE] == ARCHMAGE)
X      fprintf(fd,"\n%d",behavior);
X    else fprintf(fd,"\n%d",Archmagebehavior);
X    fprintf(fd,"\n%s",Prime);
X    fprintf(fd,"\n%d",Primelevel);
X    if (Player.rank[CIRCLE] == PRIME)
X      fprintf(fd,"\n%d",behavior);
X    else fprintf(fd,"\n%d",Primebehavior);
X    fprintf(fd,"\n%s",Shadowlord);
X    fprintf(fd,"\n%d",Shadowlordlevel);
X    if (Player.rank[THIEVES] == SHADOWLORD)
X      fprintf(fd,"\n%d",behavior);
X    else fprintf(fd,"\n%d",Shadowlordbehavior);
X    for(i=1;i<7;i++) {
X      fprintf(fd,"\n%s",Priest[i]);
X      fprintf(fd,"\n%d",Priestlevel[i]);
X      if ((Player.rank[PRIESTHOOD] == HIGHPRIEST) && (Player.patron == i))
X	fprintf(fd,"\n%d",behavior);
X      else fprintf(fd,"\n%d",Priestbehavior[i]);
X    }
X    fprintf(fd,"\n");
X    fclose(fd);
X  }
X}
X
Xvoid extendlog(descrip,lifestatus)
Xchar *descrip;
Xint lifestatus;
X{
X  FILE *fd;
X  char username[60];
X  int npcbehavior;
X  strcpy(username,getlogin());
X  if ((Player.level > 0) && (! gamestatusp(CHEATED))) {
X    npcbehavior=fixnpc(lifestatus);
X    checkhigh(descrip,npcbehavior);
X    strcpy(Str1,OMEGALIB);
X    strcat(Str1,"omega.log");
X    fd = checkfopen(Str1,"a");
X    fprintf(fd,
X	    " %d %d %d %s\n",
X	    lifestatus,
X	    Player.level,
X	    npcbehavior,
X	    Player.name);
X    fclose(fd);
X  }
X}
X
X
X
X
X
X#ifndef MSDOS
X/* reads a string from a file. If it is a line with more than 80 char's,
X   then remainder of line to \n is consumed */
Xvoid filescanstring(fd,fstr)
XFILE *fd;
Xchar *fstr;
X{
X  int i= -1;
X  int byte='x';
X  while ((i<80) && (byte != '\n') && (byte != EOF)) {
X    i++;
X    byte=fgetc(fd);
X    fstr[i] = byte;
X  } 
X  if (byte != '\n')
X    while((byte!='\n') && (byte != EOF))
X      byte=fgetc(fd);
X  fstr[i]=0;
X}
X#endif
X
X
X/* Checks existence of omega data files */
X/* Returns 1 if OK, 0 if impossible to run, -1 if possible but not OK */
Xint filecheck()
X{
X  int impossible=FALSE,badbutpossible=FALSE;
X  int result;
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ocity.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ocountry.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"odlair.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"omisle.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ocourt.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ospeak.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"otemple.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oabyss.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X#ifndef MSDOS
X  strcat(Str1,"ovillage1.dat");
X#else
X  strcat(Str1,"ovillag1.dat");
X#endif
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X#ifndef MSDOS
X  strcat(Str1,"ovillage2.dat");
X#else
X  strcat(Str1,"ovillag2.dat");
X#endif
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X#ifndef MSDOS
X  strcat(Str1,"ovillage3.dat");
X#else
X  strcat(Str1,"ovillag3.dat");
X#endif
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X#ifndef MSDOS
X  strcat(Str1,"ovillage4.dat");
X#else
X  strcat(Str1,"ovillag4.dat");
X#endif
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohome1.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohome2.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohome3.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oarena.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  
X  
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"omaze1.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not appendable or accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"omaze2.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not appendable or accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"omaze3.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not appendable or accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"omaze4.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not appendable or accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"omega.hi");
X  result = access(Str1,F_OK|R_OK|W_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not appendable or accessible:");
X    printf(Str1);
X  }
X  
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"omega.log");
X  result = access(Str1,F_OK|R_OK|W_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not appendable or accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"omotd.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"olicense.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ocircle.dat");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    impossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp1.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp2.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp3.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp4.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp5.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp6.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp7.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp8.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp9.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp10.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp11.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp12.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"ohelp13.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  
X  
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oabyss.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oscroll1.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oscroll2.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oscroll3.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X
X  strcpy(Str1,OMEGALIB);
X  strcat(Str1,"oscroll4.txt");
X  result = access(Str1,F_OK|R_OK);
X  if (result == -1) {
X    badbutpossible = TRUE;
X    printf("\nWarning! File not accessible:");
X    printf(Str1);
X  }
X  
X  if (impossible) {
X    printf("\nFurther execution is impossible. Sorry.");
X    printf("\nOMEGALIB may be badly #defined in odefs.h\n");
X    return(0);
X  }
X  else if (badbutpossible) {
X    printf("\nFurther execution may cause anomalous behavior.");
X    printf("\nContinue anyhow? [yn] ");
X    if (getchar()=='y') return(-1);
X    else return(0);
X  }
X  else return(1);
X}
X
X
X/* display a file given a string name of file */
Xvoid displayfile(filestr)
Xchar *filestr;
X{
X  FILE *fd = checkfopen(filestr,"r");
X  int c,d=' ';
X  int x,y;
X  clear();
X  refresh();
X  c = fgetc(fd);
X  while ((c != EOF)&&((char) d != 'q')&&((char) d!=ESCAPE)) {
X    getyx(stdscr,y,x);
X    if (y > ScreenLength) { 
X      printw("\n-More-");
X      refresh();
X      d = wgetch(stdscr);
X      clear();
X    }
X    printw("%c",(char) c);
X    c = fgetc(fd);
X  }
X  if (((char) d != 'q')&&((char) d!=ESCAPE)) {
X    printw("\n-Done-");
X    refresh();
X    getch();
X  }
X  clear();
X  refresh();
X}    
X
X
X/* display a file given a string name of file */
Xvoid copyfile(srcstr)
Xchar *srcstr;
X{
X  char deststr[80];
X  char cmd[200];
X  print1("Enter name of file to create: ");
X  strcpy(deststr,msgscanstring());
X  strcpy(cmd,"cp ");
X  strcat(cmd,srcstr);
X  strcat(cmd," ");
X  strcat(cmd,deststr);
X  print2("Copying file....");
X  system(cmd);
X  print3("Done.");
X}    
X
END_OF_FILE
if test 21773 -ne `wc -c <'ofile.c'`; then
    echo shar: \"'ofile.c'\" unpacked with wrong size!
fi
# end of 'ofile.c'
fi
if test -f 'ohelp8.txt' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ohelp8.txt'\"
else
echo shar: Extracting \"'ohelp8.txt'\" \(2033 characters\)
sed "s/^X//" >'ohelp8.txt' <<'END_OF_FILE'
X
XTHE COUNTRYSIDE
X===============
XRampart is set in a strange landscape of different terrain types. The
Xland is surrounded in part by a mystic sea of chaos which it is
Xprobably a good idea to avoid. Screen characters have a different
Xmeaning in the countryside than they do elsewhere, by the way, and
Xthere is a different command set (accessible by '?' when out of the
Xcity). Time passes much more quickly in countryside movement; you will
Xhave to bring a lot of food with you, though you may wish to
Xhunt ('H' command) to supplement your food reserves; many of the
Xanimals that you may encounter, for example, are edible.
X
XSince each countryside site is quite a large area, you may have
Xto search ('s' command) to learn of interesting sites nearby.
X
XCountryside Map Example:
X
X++----.--- The @ as usual is the player; the +'s are an arm of the Sea of
X+++++O--^^ Chaos; the O is the city of Rampart; the ^'s are mountains;
X----@----^ the .'s are a road; the -'s are plains and meadows;
X---.-^^^^^ and the * is a dungeon entrance.
X...-^*^^^^
X
XThe countryside can be rather dangerous for low level characters to
Xexplore at random. However, maps of the surrounding areas can be
Xpurchased at the villages which can be found mostly at the ends
Xof the roads. Each village has a "special" magical site somewhere
Xinside its borders. These sites may be beneficial or harmful
Xdepending how they are approached and the circumstances of their
Xactivation.
X
XThere are a number of "special" locations in the countryside; these
Xare basically one-level screens of various sorts, or they may be
Xmulti-level dungeons. If you follow the advice of the oracle
Xwho may be found somewhere in Rampart, you will wind up visiting most
Xof these sites.
X
XA special site or dungeon may be entered from the Countryside
Xenvironment by means of the '>' command. Depending whether or not it
Xis a multilevel or single level site, it may be exited simply by
Xmoving off the edge of the screen, or by ascending or descending a
Xstairway from the first level of the dungeon.
X
END_OF_FILE
if test 2033 -ne `wc -c <'ohelp8.txt'`; then
    echo shar: \"'ohelp8.txt'\" unpacked with wrong size!
fi
# end of 'ohelp8.txt'
fi
echo shar: End of archive 10 \(of 20\).
cp /dev/null ark10isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 20 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