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

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

Submitted-by: "Laurence R. Brothers"   <brothers@paul.rutgers.edu>
Posting-number: Volume 7, Issue 36
Archive-name: omega3/Part17
Supersedes: omega2: Volume 5, Issue 12-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 17 (of 20)."
# Contents:  o.c ocountry.c oetc.c ogen2.c
# Wrapped by billr@saab on Thu Jun 29 08:14:13 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'o.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'o.c'\"
else
echo shar: Extracting \"'o.c'\" \(12602 characters\)
sed "s/^X//" >'o.c' <<'END_OF_FILE'
X/* omega copyright (c) 1987,1988,1989 by Laurence Raphael Brothers */
X
X/* this file includes main() and some top-level functions */
X/* o.c */
X
X#include <signal.h>
X#ifdef MSDOS
X#include <fcntl.h>
X/* Note: in order to avoid a memory bug I've been told about, I'm
X   explicitly initializing every global to something. */
X#endif
X
X#include "oglob.h"
X
X
X/* most globals originate in o.c */
X
X/* Objects and Monsters are allocated and initialized in oinit.c */
X
X/* one of each spell */
X#ifndef MSDOS
Xstruct spell Spells[NUMSPELLS+1];
X#else
Xstruct spell Spells[NUMSPELLS+1] = {0};
X#endif
X
X/* locations of city sites [0] - found, [1] - x, [2] - y */
X#ifndef MSDOS
Xint CitySiteList[NUMCITYSITES][3];
X#else
Xint CitySiteList[NUMCITYSITES][3] = {0};
X#endif
X
X/* Currently defined in caps since it is now a variable, was a constant */
Xint LENGTH=MAXLENGTH; 
Xint WIDTH=MAXWIDTH;
X
X#ifndef MSDOS
Xint GameStatus=0L;                    /* Game Status bit vector */
X#else
Xlong GameStatus=0L;                   /* Game Status bit vector */
X#endif
X#ifndef MSDOS
Xint ScreenLength;                     /* How large is level window */
X#else
Xint ScreenLength = 0;                 /* How large is level window */
X#endif
X#ifndef MSDOS
Xstruct player Player;                 /* the player */
X#else
Xstruct player Player = {0};           /* the player */
X#endif
X#ifndef MSDOS
Xstruct terrain Country[MAXWIDTH][MAXLENGTH];/* The countryside */
X#else
Xstruct terrain Country[MAXWIDTH][MAXLENGTH] = {0};/* The countryside */
X#endif
X#ifdef MSDOS
Xstruct level TheLevel;
X#endif
Xstruct level *City=NULL;              /* The city of Rampart */
Xstruct level *TempLevel=NULL;         /* Place holder */
Xstruct level *Level=NULL;             /* Pointer to current Level */
Xstruct level *Dungeon=NULL;           /* Pointer to current Dungeon */
X#ifndef MSDOS
Xint Villagenum;                       /* Current Village number */ 
X#else
Xint Villagenum = 0;                   /* Current Village number */ 
X#endif
X#ifndef MSDOS
Xint ScreenOffset;                     /* Offset of displayed screen to level */
X#else
Xint ScreenOffset = 0;                 /* Offset of displayed screen to level */
X#endif
X#ifndef MSDOS
Xint MaxDungeonLevels;                 /* Deepest level allowed in dungeon */
X#else
Xint MaxDungeonLevels = 0;             /* Deepest level allowed in dungeon */
X#endif
Xint Current_Dungeon= -1;              /* What is Dungeon now */
Xint Current_Environment= E_CITY;      /* Which environment are we in */
Xint Last_Environment= E_COUNTRYSIDE;  /* Which environment were we in */
X#ifndef MSDOS
Xint Dirs[2][9];                       /* 9 xy directions */
X#else
Xint Dirs[2][9]=                       /* 9 xy directions */
X  {1,1,-1,-1,1,-1,0,0,0,1,-1,1,-1,0,0,1,-1,0};
X#endif
Xchar Cmd='s';                         /* last player command */
Xint Command_Duration = 0;             /* how long does current command take */
Xstruct monster *Arena_Monster=NULL;   /* Opponent in arena */
Xint Arena_Opponent=0;                 /* case label of opponent in l_arena()*/
X#ifndef MSDOS
Xint Arena_Victory;                    /* did player win in arena? */
X#else
Xint Arena_Victory = 0;                /* did player win in arena? */
X#endif
Xint Imprisonment=0;                   /* amount of time spent in jail */
Xint Precipitation=0;                  /* Hours of rain, snow, etc */
Xint Lunarity=0;                       /* Effect of the moon on character */
X#ifndef MSDOS
Xint Phase;                            /* Phase of the moon */
Xint Date;                             /* Starting date */
Xint Pawndate;                         /* Pawn Shop item generation date */
X#else
Xint Phase = 0;                        /* Phase of the moon */
Xint Date = 0;                         /* Starting date */
Xint Pawndate = 0;                     /* Pawn Shop item generation date */
X#endif
Xpob Pawnitems[PAWNITEMS] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
X/* items in pawn shop */
Xint SymbolUseHour= -1;                /* holy symbol use marker */
Xint ViewHour= -1;                     /* crystal ball use marker */
Xint ZapHour= -1;                      /* staff of enchantment use marker */
Xint HelmHour= -1;                     /* helm of teleportation use marker*/
Xint Constriction=0;                   /* Dragonlord Attack State */
Xint Blessing=FALSE;                   /* Altar Blessing State */
Xint LastDay= -1;                      /* DPW date of dole */
Xint RitualHour= -1;                   /* last use of ritual magic */
Xint RitualRoom= -1;                   /* last room of ritual magic */
Xint Lawstone=0;                       /* magic stone counter */
Xint Chaostone=0;                      /* magic stone counter */
Xint Mindstone=0;                      /* magic stone counter */
Xint Searchnum = 1;                    /* number of times to search on 's' */
Xint Verbosity = VERBOSE;              /* verbosity level */
X#ifndef MSDOS
Xchar Seed;                            /* random seed */
X#else
Xchar Seed = 0;                            /* random seed */
X#endif
X#ifndef MSDOS
Xint Time = 0;                         /* turn number */
X#else
Xlong Time = 0;                        /* turn number */
X#endif
Xint Tick = 0;                         /* 10 a turn; action coordinator */
Xchar Stringbuffer[10][80] = {
X  "First String",  "First String",  "First String",  "First String",  
X  "First String",  "First String",  "First String",  "First String",
X  "First String",  "First String"}; /* last 10 strings */
X#ifndef MSDOS
Xint Gymcredit = 0;                    /* credit at rampart gym */
X#else
Xlong Gymcredit = 0;                   /* credit at rampart gym */
X#endif
Xint Spellsleft = 0;                   /* research allowance at college */
Xint StarGemUse = 0;                   /* last date of star gem use */
Xint HiMagicUse = 0;                   /* last date of high magic use */
Xint HiMagic = 0;                      /* current level for l_throne */ 
X#ifndef MSDOS
Xint Balance = 0;                      /* bank account */
X#else
Xlong Balance = 0;                     /* bank account */
X#endif
X#ifndef MSDOS
Xint FixedPoints = 0;                  /* points are frozen after adepthood*/
X#else
Xlong FixedPoints = 0;                 /* points are frozen after adepthood*/
X#endif
Xint LastTownLocX=0;            /* previous position in village or city */
Xint LastTownLocY=0;            /* previous position in village or city */
Xint LastCountryLocX=0;            /* previous position in countryside */
Xint LastCountryLocY=0;            /* previous position in countryside */
X#ifndef MSDOS
Xchar Password[64];                    /* autoteller password */
X#else
Xchar Password[64] = {0};              /* autoteller password */
X#endif
X#ifndef MSDOS
Xchar Str1[100],Str2[100],Str3[100],Str4[100];
X#else
Xchar Str1[100] = {0},Str2[100] = {0},Str3[100] = {0},Str4[100] = {0};
X#endif
X   /* Some string space, random uses */
X
Xpol Condoitems=NULL;                        /* Items in condo */
X
X/* high score names, levels, behavior */
X#ifndef MSDOS
Xint Shadowlordbehavior,Archmagebehavior,Primebehavior,Commandantbehavior;
Xint Championbehavior,Priestbehavior[7],Hibehavior,Dukebehavior;
Xint Chaoslordbehavior,Lawlordbehavior,Justiciarbehavior;
Xchar Shadowlord[80],Archmage[80],Prime[80],Commandant[80],Duke[80];
Xchar Champion[80],Priest[7][80],Hiscorer[80],Hidescrip[80];
Xchar Chaoslord[80],Lawlord[80],Justiciar[80];
Xint Shadowlordlevel,Archmagelevel,Primelevel,Commandantlevel,Dukelevel;
X#else
Xint Shadowlordbehavior = 0,Archmagebehavior = 0,Primebehavior = 0,Commandantbehavior = 0;
Xint Championbehavior = 0,Priestbehavior[7] = {0},Hibehavior = 0,Dukebehavior = 0;
Xint Chaoslordbehavior = 0,Lawlordbehavior = 0,Justiciarbehavior = 0;
Xchar Shadowlord[80] = {0},Archmage[80] = {0},Prime[80] = {0},Commandant[80] = {0},Duke[80] = {0};
Xchar Champion[80] = {0},Priest[7][80] = {0},Hiscorer[80] = {0},Hidescrip[80] = {0};
Xchar Chaoslord[80] = {0},Lawlord[80] = {0},Justiciar[80] = {0};
Xint Shadowlordlevel = 0,Archmagelevel = 0,Primelevel = 0,Commandantlevel = 0,Dukelevel = 0;
X#endif
X#ifndef MSDOS
Xint Championlevel,Priestlevel[7],Hiscore,Hilevel,Justiciarlevel;
X#else
Xint Championlevel = 0,Priestlevel[7] = {0},Hilevel = 0,Justiciarlevel = 0;
Xlong Hiscore = 0L;
X#endif
X#ifndef MSDOS
Xint Chaoslordlevel,Lawlordlevel,Chaos,Law;
X#else
Xint Chaoslordlevel = 0,Lawlordlevel = 0,Chaos = 0,Law = 0;
X#endif
X
X/* New globals which used to be statics */
Xint twiddle = FALSE;
Xint saved=FALSE;
Xint onewithchaos=FALSE;
Xint club_hinthour = 0;
Xint winnings = 0;
Xint tavern_hinthour;
Xint scroll_ids[30];
Xint potion_ids[30];
Xint stick_ids[30];
Xint ring_ids[30];
Xint cloak_ids[30];
Xint boot_ids[30];
X
Xint deepest[E_MAX + 1];
X
X
X/* This may be implementation dependent */
X/* SRANDFUNCTION is defined in odefs.h */
Xvoid initrand()
X{
X  SRANDFUNCTION;
X}
X
X
Xint game_restore(argc,argv)
Xint argc;
Xchar *argv[];
X{
X  char savestr[80];
X  int ok;
X  if (argc==2) {
X    strcpy(savestr,argv[1]);
X    ok = restore_game(savestr);
X    unlink(savestr);
X    if (! ok) {
X      endgraf();
X      printf("Try again with the right save file, luser!\n");
X      exit(0);
X    }
X    return(TRUE);
X  }
X  else return(FALSE);
X}
X
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X  int continuing;
X
X
X  /* always catch ^c and hang-up signals */
X
X  signal(SIGINT,quit);
X#ifndef MSDOS
X  signal(SIGHUP,signalsave);
X
X  if (CATCH_SIGNALS) {
X    signal(SIGQUIT,signalexit);
X    signal(SIGILL,signalexit);
X    signal(SIGTRAP,signalexit);
X    signal(SIGIOT,signalexit);
X    signal(SIGEMT,signalexit);
X    signal(SIGFPE,signalexit);
X    signal(SIGBUS,signalexit);
X    signal(SIGSEGV,signalexit);
X    signal(SIGSYS,signalexit);
X    }
X#endif
X
X
X
X  /* if filecheck is 0, some necessary data files are missing */
X  if (filecheck() == 0) exit(0);
X
X  /* all kinds of initialization */
X  initgraf();
X#ifndef MSDOS
X  initdirs();
X#endif
X  initrand();
X  initspells();
X
X#ifndef MSDOS
X  strcpy(Stringbuffer[0],"First String");
X  strcpy(Stringbuffer[1],"First String");
X  strcpy(Stringbuffer[2],"First String");
X  strcpy(Stringbuffer[3],"First String");
X  strcpy(Stringbuffer[4],"First String");
X  strcpy(Stringbuffer[5],"First String");
X  strcpy(Stringbuffer[6],"First String");
X  strcpy(Stringbuffer[7],"First String");
X  strcpy(Stringbuffer[8],"First String");
X  strcpy(Stringbuffer[9],"First String");
X#endif
X
X#ifdef MSDOS
X  msdos_init();
X#endif
X
X  /* game restore attempts to restore game if there is an argument */
X  continuing = game_restore(argc,argv);
X
X
X  /* monsters initialized in game_restore if game is being restored */  
X  /* items initialized in game_restore if game is being restored */
X  if (! continuing) {
X    inititem(1);
X    initplayer();
X    
X    Date = random_range(360);
X    Phase = random_range(24);
X    moon_check();
X    strcpy(Password,"");
X
X    init_world();
X    
X    mprint("'?' for help or commandlist, 'Q' to quit.");
X  }
X  else mprint("Your adventure continues....");
X
X  dataprint();
X  timeprint();
X  showflags();
X
X  screencheck(Player.y);
X
X /* game cycle */
X  time_clock(TRUE);
X  while (TRUE) {
X    if (Current_Environment == E_COUNTRYSIDE)
X      p_country_process();
X    else time_clock(FALSE);
X  }
X}
X
X#ifndef MSDOS
Xint signalexit()
X{
X  mprint("Yikes!");
X  morewait();
X  mprint("Sorry, caught a core-dump signal.");
X  mprint("Want to try and save the game?");
X  if (ynq()=='y')
X    save(FALSE); /* don't compress */
X  mprint("Bye!");
X  endgraf();
X  exit(0);
X}
X#endif
X
X
X
X
X/* Start up game with new dungeons; start with player in city */
Xvoid init_world()
X{
X  if (Level != NULL) free((char *) Level);
X  if (City != NULL) free((char *) City);
X  if (TempLevel != NULL) free((char *) TempLevel);
X  if (Dungeon != NULL) free_dungeon();
X  City = Level = TempLevel = Dungeon = NULL;
X  load_country();
X  load_city();
X  change_environment(E_CITY);
X  locprint("The City of Rampart.");
X}
X
X/* set variable item names */
Xvoid inititem(reset)
Xint reset;
X{
X  int i;
X  if (reset)
X    scrollname(TRUE,0);
X  for(i=0;i<NUMSCROLLS;i++) {
X    Objects[SCROLLID+i].objstr = salloc(scrollname(FALSE,i));
X  }
X  if (reset)
X    potionname(TRUE,0);
X  for(i=0;i<NUMPOTIONS;i++) {
X    Objects[POTIONID+i].objstr = salloc(potionname(FALSE,i));
X  }
X  if (reset)
X    stickname(TRUE,0);
X  for(i=0;i<NUMSTICKS;i++) {
X    Objects[STICKID+i].objstr = salloc(stickname(FALSE,i));
X  }
X  if (reset)
X    bootname(TRUE,0);
X  for(i=0;i<NUMBOOTS;i++) {
X    Objects[BOOTID+i].objstr = salloc(bootname(FALSE,i));
X  }
X  if (reset)
X    cloakname(TRUE,0);
X  for(i=0;i<NUMCLOAKS;i++) {
X    Objects[CLOAKID+i].objstr = salloc(cloakname(FALSE,i));
X  }
X  if (reset)
X    ringname(TRUE,0);
X  for(i=0;i<NUMRINGS;i++) {
X    Objects[RINGID+i].objstr = salloc(ringname(FALSE,i));
X  }
X}
END_OF_FILE
if test 12602 -ne `wc -c <'o.c'`; then
    echo shar: \"'o.c'\" unpacked with wrong size!
fi
# end of 'o.c'
fi
if test -f 'ocountry.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ocountry.c'\"
else
echo shar: Extracting \"'ocountry.c'\" \(12729 characters\)
sed "s/^X//" >'ocountry.c' <<'END_OF_FILE'
X/* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
X/* ocountry.c */
X/* load_country(), and all load_ functions for places which are
X/* accessible from the country and don't have their own files */
X
X#include "oglob.h"
X
X/* loads the countryside level from the data file */
Xvoid load_country()
X{
X  int i,j;
X  char site;
X  
X  FILE *fd;
X  
X  strcpy(Str3,OMEGALIB);
X  strcat(Str3,"ocountry.dat");
X  fd = fopen(Str3,"r");
X
X  for(j=0;j<LENGTH;j++) {
X    for(i=0;i<WIDTH;i++) {
X      site = getc(fd);
X      Country[i][j].base_terrain_type = site;
X      Country[i][j].aux = 0;
X      if ((site == PASS) ||
X	  (site == CASTLE) ||
X	  (site == STARPEAK) ||
X	  (site == CAVES) ||
X	  (site == VOLCANO)) Country[i][j].current_terrain_type = MOUNTAINS;
X      else if (site == DRAGONLAIR) Country[i][j].current_terrain_type = DESERT;
X      else if (site == MAGIC_ISLE) 
X	Country[i][j].current_terrain_type = CHAOS_SEA;
X      else if ((site >= 'a') && (site <= 'f')) {
X	Country[i][j].current_terrain_type =
X	  Country[i][j].base_terrain_type = 'o';
X	Country[i][j].aux = 1+site-'a';
X      }
X      else if ((site >= '1') && (site <= '6')) {
X	Country[i][j].current_terrain_type =
X	  Country[i][j].base_terrain_type = TEMPLE;
X	Country[i][j].aux = site-'0';
X      }
X      else Country[i][j].current_terrain_type = site;
X      Country[i][j].explored = FALSE;
X    }
X    fscanf(fd,"\n");
X  }
X  fclose(fd);
X}
X
X
X
X
X
X
X
X/* loads the dragon's lair into Level*/
Xvoid load_dlair(empty)
Xint empty;
X{
X  int i,j;
X  char site;
X  
X  FILE *fd;
X
X  if (empty) mprint("The Lair is now devoid of inhabitants and treasure.");
X
X  TempLevel = Level;
X  if (ok_to_free(TempLevel)) {
X#ifndef MSDOS
X    free((char *) TempLevel);
X#endif
X    TempLevel = NULL;
X  }
X#ifndef MSDOS
X  Level = ((plv) malloc(sizeof(levtype)));
X#else
X  msdos_changelevel(TempLevel,0,-1);
X  Level = &TheLevel;
X#endif
X  clear_level(Level);
X  Level->environment = E_DLAIR;
X  strcpy(Str3,OMEGALIB);
X  strcat(Str3,"odlair.dat");
X  fd = fopen(Str3,"r");
X  for(j=0;j<LENGTH;j++) {
X    for(i=0;i<WIDTH;i++) {
X      Level->site[i][j].lstatus = 0;
X      Level->site[i][j].roomnumber = RS_CAVERN;
X      Level->site[i][j].p_locf = L_NO_OP;
X      site = getc(fd);
X      switch(site) {
X      case 'D':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  make_site_monster(i,j,ML10+3); /* dlord */
X	Level->site[i][j].creature->specialf = M_SP_LAIR;
X	break;
X      case 'd':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  make_site_monster(i,j,ML8+3); /* elite dragons */
X	Level->site[i][j].creature->specialf = M_SP_LAIR;
X	Level->site[i][j].creature->hit *= 2;
X	Level->site[i][j].creature->dmg *= 2;
X	break;
X      case 'W':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  make_site_monster(i,j,ML9+2);
X	break;
X      case 'M':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  make_site_monster(i,j,-1);
X	break;
X      case 'S':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].showchar = WALL;
X	if (! empty)
X	  lset(i,j,SECRET);
X	Level->site[i][j].roomnumber = RS_SECRETPASSAGE;
X	break;
X      case '$':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].roomnumber = RS_DRAGONLORD;
X	if (! empty)
X	  make_site_treasure(i,j,10);
X	break;
X      case 's':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].p_locf = L_TRAP_SIREN;
X	break;
X      case '7':
X	if (! empty)
X	  Level->site[i][j].locchar = PORTCULLIS;
X	else Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].p_locf = L_PORTCULLIS;
X	break;
X      case 'R':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].p_locf = L_RAISE_PORTCULLIS;
X	break;
X      case 'p':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].p_locf = L_PORTCULLIS;
X	break;
X      case 'T':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  Level->site[i][j].p_locf = L_PORTCULLIS_TRAP;
X	break;
X      case 'X':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].p_locf = L_TACTICAL_EXIT;
X	break;
X      case '#':
X	Level->site[i][j].locchar = WALL;
X	Level->site[i][j].aux = 150; 
X	break;
X      case '.':
X	Level->site[i][j].locchar = FLOOR;
X	break;
X      }
X    }
X    fscanf(fd,"\n");
X  }
X  fclose(fd);
X}
X
X
X
X
X
X/* loads the star peak into Level*/
Xvoid load_speak(empty)
Xint empty;
X{
X  int i,j,safe = Player.alignment > 0;
X  char site;
X  
X  FILE *fd;
X
X  if (empty) mprint("The peak is now devoid of inhabitants and treasure.");
X
X  TempLevel = Level;
X  if (ok_to_free(TempLevel)) {
X#ifndef MSDOS
X    free((char *) TempLevel);
X#endif
X    TempLevel = NULL;
X  }
X#ifndef MSDOS
X  Level = ((plv) malloc(sizeof(levtype)));
X#else
X  msdos_changelevel(TempLevel,0,-1);
X  Level = &TheLevel;
X#endif
X  clear_level(Level);
X  Level->environment = E_STARPEAK;
X  strcpy(Str3,OMEGALIB);
X  strcat(Str3,"ospeak.dat");
X  fd = fopen(Str3,"r");
X  for(j=0;j<LENGTH;j++) {
X    for(i=0;i<WIDTH;i++) {
X      Level->site[i][j].lstatus = 0;
X      Level->site[i][j].roomnumber = RS_STARPEAK;
X      Level->site[i][j].p_locf = L_NO_OP;
X      site = getc(fd);
X      switch(site) {
X      case 'S':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].showchar = WALL;
X	lset(i,j,SECRET);
X	Level->site[i][j].roomnumber = RS_SECRETPASSAGE;
X	break;
X      case 'L':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  make_site_monster(i,j,ML10+2); /* lawbringer */
X	if (safe) m_status_reset(Level->site[i][j].creature,HOSTILE);
X	break;
X      case 's':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  make_site_monster(i,j,ML4+12); /* servant of law */
X	if (safe) m_status_reset(Level->site[i][j].creature,HOSTILE);
X	break;
X      case 'M':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  make_site_monster(i,j,-1);
X	if (safe) m_status_reset(Level->site[i][j].creature,HOSTILE);
X	break;
X      case '$':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  make_site_treasure(i,j,10);
X	break;
X      case '7':
X	if (! empty)
X	  Level->site[i][j].locchar = PORTCULLIS;
X	else Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].p_locf = L_PORTCULLIS;
X	break;
X      case 'R':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].p_locf = L_RAISE_PORTCULLIS;
X	break;
X      case '-':
X	Level->site[i][j].locchar = CLOSED_DOOR;
X	break;
X      case '|':
X	Level->site[i][j].locchar = OPEN_DOOR;
X	break;
X      case 'p':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].p_locf = L_PORTCULLIS;
X	break;
X      case 'T':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  Level->site[i][j].p_locf = L_PORTCULLIS_TRAP;
X	break;
X      case 'X':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].p_locf = L_TACTICAL_EXIT;
X	break;
X      case '#':
X	Level->site[i][j].locchar = WALL;
X	Level->site[i][j].aux = 150; 
X	break;
X      case '4':
X	Level->site[i][j].locchar = RUBBLE;
X	Level->site[i][j].p_locf = L_RUBBLE;
X	break;
X      case '.':
X	Level->site[i][j].locchar = FLOOR;
X	break;
X      }
X    }
X    fscanf(fd,"\n");
X  }
X  fclose(fd);
X}
X
X
X
X/* loads the magic isle into Level*/
Xvoid load_misle(empty)
Xint empty;
X{
X  int i,j;
X  char site;
X  
X  FILE *fd;
X
X  if (empty) mprint("The isle is now devoid of inhabitants and treasure.");
X
X  TempLevel = Level;
X  if (ok_to_free(TempLevel)) {
X#ifndef MSDOS
X    free((char *) TempLevel);
X#endif
X    TempLevel = NULL;
X  }
X#ifndef MSDOS
X  Level = ((plv) malloc(sizeof(levtype)));
X#else
X  msdos_changelevel(TempLevel,0,-1);
X  Level = &TheLevel;
X#endif
X  clear_level(Level);
X  Level->environment = E_MAGIC_ISLE;
X  strcpy(Str3,OMEGALIB);
X  strcat(Str3,"omisle.dat");
X  fd = fopen(Str3,"r");
X  for(j=0;j<LENGTH;j++) {
X    for(i=0;i<WIDTH;i++) {
X      Level->site[i][j].lstatus = 0;
X      Level->site[i][j].roomnumber = RS_MAGIC_ISLE;
X      Level->site[i][j].p_locf = L_NO_OP;
X      site = getc(fd);
X      switch(site) {
X      case 'E':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  make_site_monster(i,j,ML10+1); /* eater of magic */
X	break;
X      case 'm':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  make_site_monster(i,j,ML8+9); /* militant priest */
X	break;
X      case 'n':
X	Level->site[i][j].locchar = FLOOR;
X	if (! empty)
X	  make_site_monster(i,j,ML7+1); /* nazgul */
X	break;
X      case 'X':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].p_locf = L_TACTICAL_EXIT;
X	break;
X      case '#':
X	Level->site[i][j].locchar = WALL;
X	Level->site[i][j].aux = 150; 
X	break;
X      case '4':
X	Level->site[i][j].locchar = RUBBLE;
X	Level->site[i][j].p_locf = L_RUBBLE;
X	break;
X      case '~':
X	Level->site[i][j].locchar = WATER;
X	Level->site[i][j].p_locf = L_CHAOS;
X	break;
X      case '=':
X	Level->site[i][j].locchar = WATER;
X	Level->site[i][j].p_locf = L_MAGIC_POOL;
X	break;
X      case '-':
X	Level->site[i][j].locchar = CLOSED_DOOR;
X	break;
X      case '|':
X	Level->site[i][j].locchar = OPEN_DOOR;
X	break;
X      case '.':
X	Level->site[i][j].locchar = FLOOR;
X	break;
X      }
X    }
X    fscanf(fd,"\n");
X  }
X  fclose(fd);
X}
X
X
X/* loads a temple into Level*/
Xvoid load_temple(deity)
Xint deity;
X{
X  int i,j;
X  char site;
X  pml ml;
X  FILE *fd;
X
X  TempLevel = Level;
X  if (ok_to_free(TempLevel)) {
X#ifndef MSDOS
X    free((char *) TempLevel);
X#endif
X    TempLevel = NULL;
X  }
X#ifndef MSDOS
X  Level = ((plv) malloc(sizeof(levtype)));
X#else
X  msdos_changelevel(TempLevel,0,-1);
X  Level = &TheLevel;
X#endif
X  clear_level(Level);
X  Level->environment = E_TEMPLE;
X  strcpy(Str3,OMEGALIB);
X  strcat(Str3,"otemple.dat");
X  fd = fopen(Str3,"r");
X  for(j=0;j<LENGTH;j++) {
X    for(i=0;i<WIDTH;i++) {
X      switch(deity) {
X      case ODIN: Level->site[i][j].roomnumber = RS_ODIN; break;
X      case SET: Level->site[i][j].roomnumber = RS_SET; break;
X      case HECATE: Level->site[i][j].roomnumber = RS_HECATE; break;
X      case ATHENA: Level->site[i][j].roomnumber = RS_ATHENA; break;
X      case DRUID: Level->site[i][j].roomnumber = RS_DRUID; break;
X      case DESTINY: Level->site[i][j].roomnumber = RS_DESTINY; break;
X      }
X      site = getc(fd);
X      switch(site) {
X      case '8':
X	Level->site[i][j].locchar = ALTAR;
X	Level->site[i][j].p_locf = L_ALTAR;
X	Level->site[i][j].aux = deity;
X	break;
X      case 'H':
X	Level->site[i][j].locchar = FLOOR;
X	if (strcmp(Player.name,Priest[Player.patron]) != 0) 
X	  make_high_priest(i,j,deity);
X	break;
X      case 'S':
X	Level->site[i][j].locchar = FLOOR;
X	if (strcmp(Player.name,Priest[Player.patron]) != 0) 
X	  lset(i,j,SECRET);
X	break;
X      case 'W':
X	Level->site[i][j].locchar = FLOOR;
X	if ((deity != Player.patron) &&
X	    ((deity == ODIN) ||
X	     (deity == SET) ||
X	     (deity == HECATE) ||
X	     (deity == ATHENA) ||
X	     (deity == DESTINY)))
X	  Level->site[i][j].p_locf = L_TEMPLE_WARNING;
X	break;
X      case 'm':
X	Level->site[i][j].locchar = FLOOR;
X	make_site_monster(i,j,ML8+9); /* militant priest */
X	break;
X      case 'd':
X	Level->site[i][j].locchar = FLOOR;
X	make_site_monster(i,j,ML4+10); /* doberman death hound */
X	break;
X      case 'X':
X	Level->site[i][j].locchar = FLOOR;
X	Level->site[i][j].p_locf = L_TACTICAL_EXIT;
X	break;
X      case '#':
X	if (deity != DRUID) {
X	  Level->site[i][j].locchar = WALL;
X	  Level->site[i][j].aux = 150; 
X	}
X	else {
X	  Level->site[i][j].locchar = HEDGE;
X	  Level->site[i][j].p_locf = L_HEDGE; 
X	}
X	break;
X      case '.':
X	Level->site[i][j].locchar = FLOOR;
X	break;
X      case 'x':
X	Level->site[i][j].locchar = FLOOR;
X	random_temple_site(i,j,deity);
X	break;
X      case '?':
X	if (deity != DESTINY) 
X	  Level->site[i][j].locchar = FLOOR;
X	else {
X	  Level->site[i][j].locchar = ABYSS;
X	  Level->site[i][j].p_locf = L_ADEPT;
X	}
X	break;
X      case '-':
X	Level->site[i][j].locchar = CLOSED_DOOR;
X	break;
X      case '|':
X	Level->site[i][j].locchar = OPEN_DOOR;
X	break;
X      }
X    }
X    fscanf(fd,"\n");
X  }
X  /* Main Temple is peaceful for player of same sect,druids always peaceful. */
X  if ((Player.patron == deity) || (deity == DRUID))
X    for(ml=Level->mlist;ml!=NULL;ml=ml->next) 
X      m_status_reset(ml->m,HOSTILE);
X  fclose(fd);
X}
X
Xvoid random_temple_site(i,j,deity)
Xint i,j,deity;
X{
X  switch(random_range(12)) {
X  case 0:
X    make_site_monster(i,j,ML0+1); break; /* mendicant priest */
X  case 1:
X    Level->site[i][j].locchar = WATER;
X    Level->site[i][j].p_locf = L_MAGIC_POOL;
X  case 2: make_site_monster(i,j,ML7+14); break; /* inner circle demon */
X  case 3: 
X    make_site_monster(i,j,ML6+11);
X    Level->site[i][j].creature->aux1 = deity;
X    break; /* angel of apropriate sect */
X  case 4: 
X    make_site_monster(i,j,ML8+11);
X    Level->site[i][j].creature->aux1 = deity;
X    break; /* archangel of apropriate sect */
X  case 5: 
X    make_site_monster(i,j,ML9+6);
X    Level->site[i][j].creature->aux1 = deity;
X    break; /* archangel of apropriate sect */
X  }
X}
X
Xvoid make_high_priest(i,j,deity)
Xint i,j,deity;
X{
X  pml ml = ((pml) malloc(sizeof(mltype)));
X  pmt m = ((pmt) malloc(sizeof(montype)));
X  make_hiscore_npc(m,deity);
X  m->x = i;
X  m->y = j;
X  Level->site[i][j].creature = m;
X  ml->m = m;
X  ml->next = Level->mlist;
X  Level->mlist = ml;
X}
END_OF_FILE
if test 12729 -ne `wc -c <'ocountry.c'`; then
    echo shar: \"'ocountry.c'\" unpacked with wrong size!
fi
# end of 'ocountry.c'
fi
if test -f 'oetc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'oetc.c'\"
else
echo shar: Extracting \"'oetc.c'\" \(12952 characters\)
sed "s/^X//" >'oetc.c' <<'END_OF_FILE'
X/* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
X/* oetc.c */
X/* grab bag of random functions used in random places */
X
X#include "oglob.h"
X
X/* there are various ways for the player to receive one of these hints */
Xvoid hint()
X{
X  switch(random_range(95)) {
X  case 0:mprint("There is an entrance to the sewers in the Garden.");break;
X  case 1:mprint("Statues can be dangerous.");break;
X  case 2:mprint("Unidentified Artifacts can be dangerous.");break;
X  case 3:mprint("The higher form of mercury is desirable.");break;
X  case 4:mprint("A sense of unease is a good thing to have.");break;
X  case 5:mprint("If you dig too much, you might cause a cave in!.");break;
X  case 6:mprint("Be Lawful: Live and Let Live.");break;
X  case 7:mprint("Be Chaotic: Live and Let Die."); break;
X  case 8:mprint("The world doesn't slow down; you speed up.");break;
X  case 9:mprint("Security is a sense of dislocation.");break;
X  case 10:mprint("Tullimore Dew is a panacea.");break;
X  case 11:mprint("Thieves hide behind closed doors.");break;
X  case 12:mprint("`No jail is escapeproof' -- John Dillinger.");break;
X  case 13:mprint("Oh, to have an apartment of your own!");break;
X  case 14:mprint("Some homes have money and treasure.");break;
X  case 15:mprint("Some homes are defended.");break;
X  case 16:mprint("Sometimes you could just wish for Death."); break;
X  case 17:mprint("A cursed wish can be fatal.");break;
X  case 18:mprint("The way you play, you should wish for Skill."); break;
X  case 19:mprint("A druid might wish for Balance."); break;
X  case 20:mprint("Mages always wish for Knowledge.");break;
X  case 21:mprint("Some fairies are good.");break;
X  case 22:mprint("An affair with a demon can be heartbreaking."); break;
X  case 23:mprint("The Explorer's Club knows a useful spell."); break;
X  case 24:mprint("They say some famous people live in mansions."); break;
X  case 25:mprint("Magic pools are totally random."); break;
X  case 26:mprint("There are five elements, including Void."); break;
X  case 27:mprint("Humans can be good or evil, lawful or chaotic."); break;
X  case 28:mprint("There are many kinds of wishes. Case counts, you know.");
X    break;
X  case 29:mprint("There are caves due south of Rampart"); break;
X  case 30:mprint("Donaldson's Giants can withstand lava.");break;
X  case 31:mprint("Ritual magic can have many different effects.");break;
X  case 32:mprint("The Mercenaries are the best equipped fighters."); break;
X  case 33:mprint("The Gladiators are the most skilled fighters."); break;
X  case 34:mprint("Rent a flat and lose any bad stati you may have."); break;
X  case 35:mprint("Some junk may be worth a fortune if identified."); break;
X  case 36:mprint("Identify humans by talking to them."); break;
X  case 37:mprint("They say the Duke has a treasure trove."); break;
X  case 38:mprint("If you yield, your opponent will gain experience."); break;
X  case 39:mprint("The Dragon Lord lives in the Waste of Time."); break;
X  case 40:mprint("A full moon bodes well for the followers of Law."); break;
X  case 41:mprint("A new moon omens evil for the Law-abiding."); break;
X  case 42:mprint("Druids revere the half-moon."); break;
X  case 43:mprint("Most grot is useless."); break;
X  case 44:mprint("Cash can sometimes be found in the walls."); break;
X  case 45:mprint("Pointy weapons break often but dig better."); break;
X  case 46:mprint("The DREADED AQUAE MORTIS is invulnerable."); break;
X  case 47:mprint("There must be *some* reason to worship Destiny!"); break;
X  case 48:mprint("Kill a trifid? A puzzle! Try a saline solution!"); break;
X  case 49:mprint("Beware! The Eater of Souls inhabits the abyss!"); break;
X  case 50:mprint("They say there's a red-light district in town."); break;
X  case 51:mprint("The House of the Eclipse is behind a closed door."); break;
X  case 52:mprint("The Orbs may be encountered on the Astral Plane."); break;
X  case 53:mprint("The Champion should never refuse a challenge."); break;
X  case 54:mprint("They say that the autoteller program is buggy."); break;
X  case 55:mprint("It's better not to sleep on the ground."); break;
X  case 56:mprint("Try ritual magic in different kinds of rooms."); break;
X  case 57:mprint("Breaking down a wall by bashing it is a bad idea!"); break;
X  case 58:mprint("Follow the Oracle's advice; she is all-wise."); break;
X  case 59:mprint("The ArchDruid lives in the northern forest.");break;
X  case 60:mprint("A search of the mountains may reveal a secret pass.");break;
X  case 61:mprint("Star Peak is to the far North-East."); break;
X  case 62:mprint("The Archmage lives in the far North-West beyond a pass.");
X    break;
X  case 63:mprint("There is a volcano in the southern marshes."); break;
X  case 64:mprint("The Demon Emperor resides in the Volcano."); break;
X  case 65:mprint("The Lawgiver can be found at Star Peak."); break;
X  case 66:mprint("The Temple of Athena is to the North-East."); break;
X  case 67:mprint("The Temple of Set can be found in a desert.");break;
X  case 68:mprint("The Temple of Hecate is in the swamp."); break;
X  case 69:mprint("The Temple of Odin is to the South in some mountains.");
X    break;
X  case 70:mprint("There is a curious island off a promontory of the swamp.");
X    break;
X  case 71:mprint("The Eater of Magic can be found on an island.");break;
X  case 72:mprint("The Temple of Destiny is practically inaccessible.");break;
X  case 73:mprint("Each sect has its own main temple outside the city.");break;
X  case 74:mprint("The aligned temples are dangerous to unbelievers.");break;
X  case 75:mprint("If you are poor, maybe you should wish for Wealth.");break;
X  case 76:mprint("Need mana? Wish for Power.");break;
X  case 77:mprint("Wishing for Law, Balance, or Chaos alters alignment.");break;
X  case 78:mprint("Feeling out of sorts? Wish for Health.");break;
X  case 79:mprint("Challenge the abyss at the Temple of Destiny.");break;
X  case 80:mprint("The Circle of Sorcerors has an Astral HQ");break;
X  case 81:mprint("The Star Gem is the only way back from the Astral Plane.");
X    break;
X  case 82:mprint("The Star Gem is guarded by the Circle of Sorcerors.");break;
X  case 83:mprint("The Star Gem is rightfully the property of the LawBringer.");
X    break;
X  case 84:mprint("They say the Demon Emperor owns the Amulet of the Planes.");
X    break;
X  case 85:mprint("An Amulet might get you to the Temple of Destiny.");break;
X  case 86:mprint("A wish for Location might help you become Adept.");break;
X  case 87:mprint("Some Artifacts may be used only once per day.");break;
X  case 88:mprint("Overusing Artifacts can be a bad move."); break;
X  case 89:mprint("You might starve in the Swamp or the Mountains!");break;
X  case 90:mprint("You would have to be very chaotic to attack a guard!");break;
X  case 91:mprint("You would have to be very foolhardy to attack a guard!");
X    break;
X  case 92:mprint("Only a master of chaos would kill all the city guards!");
X    break;
X  case 93:mprint("The Order depends on the force of the LawGiver");break;
X  case 94:mprint("City Guards are employees of the Order");break;
X  }
X}
X
X/* for when a deity teaches spells to a devotee */
Xvoid learnclericalspells(deity,level)
Xint deity,level;
X{
X  mprint("With your new clerical rank comes knowledge of magic...");
X  Player.pow+=level;
X  Player.maxpow+=level;
X  switch(level) {
X    case LAY: 
X      if (deity==ODIN) 
X	Spells[S_MISSILE].known = TRUE;
X      else if (deity==SET)
X	Spells[S_INVISIBLE].known = TRUE;
X      else if (deity==ATHENA)
X	Spells[S_IDENTIFY].known = TRUE;
X      else if (deity==HECATE)
X	Spells[S_DRAIN].known = TRUE;
X      else if (deity==DRUID) {
X	Spells[S_KNOWLEDGE].known = TRUE;
X	Spells[S_MON_DET].known = TRUE;
X      }
X      break;
X    case ACOLYTE: 
X      if (deity==ODIN) {
X	Spells[S_LBALL].known = TRUE;
X	Spells[S_TRUESIGHT].known = TRUE;
X      }
X      else if (deity==SET) {
X	Spells[S_SUMMON].known = TRUE;
X	Spells[S_FIREBOLT].known = TRUE;
X      }
X      else if (deity==ATHENA) {
X	Spells[S_HEAL].known = TRUE;
X	Spells[S_SANCTUARY].known = TRUE;
X      }
X      else if (deity==HECATE) {
X	Spells[S_SLEEP].known = TRUE;
X	Spells[S_DISPEL].known = TRUE;
X      }
X      else if (deity==DRUID) {
X	Spells[S_HEAL].known = TRUE;
X	Spells[S_CURE].known = TRUE;
X      }
X      else if (deity==DESTINY)
X	mprint("An acolyte of the Lords of Destiny. Gee whiz.");
X      break;
X    case PRIEST: 
X      Spells[S_SANCTIFY].known = TRUE;
X      if (deity==ODIN) {
X	Spells[S_HERO].known = TRUE;
X	Spells[S_HEAL].known = TRUE;
X      }
X      else if (deity==SET) {
X	Spells[S_INVISIBLE].known = TRUE;
X	Spells[S_DISPEL].known = TRUE;
X      }
X      else if (deity==ATHENA) {
X	Spells[S_REGENERATE].known = TRUE;
X	Spells[S_ACCURACY].known = TRUE;
X      }
X      else if (deity==HECATE) {
X	Spells[S_SHADOWFORM].known = TRUE;
X	Spells[S_CURE].known = TRUE;
X      }
X      else if (deity==DRUID) {
X	Spells[S_DISRUPT].known = TRUE;
X	Spells[S_ALERT].known = TRUE;
X	Spells[S_CLAIRVOYANCE].known = TRUE;
X      }
X      else if (deity==DESTINY)
X	mprint("How useless, a new priest of the Lords of Destiny.");
X      break;
X    case SPRIEST:
X      Spells[S_BLESS].known = TRUE;
X      if (deity == ODIN) 
X	Spells[S_ACCURACY].known = TRUE;
X      else if (deity == SET)
X	Spells[S_SHADOWFORM].known = TRUE;
X      else if (deity == ATHENA)
X	Spells[S_HERO].known = TRUE;
X      else if (deity == HECATE)
X	Spells[S_POLYMORPH].known = TRUE;
X      else if (deity == DRUID) {
X	Spells[S_POLYMORPH].known = TRUE;	
X	Spells[S_LEVITATE].known = TRUE;
X      }
X      else if (deity == DESTINY)
X	mprint("Wow, a new senior priest of the Lords of Destiny.");
X      break;
X    case HIGHPRIEST:
X      if (deity == ODIN)
X	Spells[S_RESTORE].known = TRUE;
X      else if (deity == SET)
X	Spells[S_HELLFIRE].known = TRUE;
X      else if (deity == ATHENA)
X	Spells[S_HELLFIRE].known = TRUE;
X      else if (deity == HECATE)
X	Spells[S_DESECRATE].known = TRUE;
X      else if (deity == DRUID) {
X	Spells[S_DISINTEGRATE].known = TRUE;
X	Spells[S_HERO].known = TRUE;
X      }
X      else if (deity == DESTINY) {
X	mprint("So you're now the high priest of the Lords of Destiny.");
X	mprint("You didn't think you were going to get anything, did you?");
X      }
X    }
X}
X
X/* for the use of the casino slot machine */
Xchar *slotstr(num)
Xint num;
X{
X  switch(num) {
X  case 0:
X    return("<Slime Mold>");
X    break;
X  case 1:
X    return("<Lemon>");
X    break;
X  case 2:
X    return("<Copper>");
X    break;
X  case 3:
X    return("<Nymph>");
X    break;
X  case 4:
X    return("<Sword>");
X    break;
X  case 5:
X    return("<Shield>");
X    break;
X  case 6:
X    return("<Chest>");
X    break;
X  case 7:
X    return("<Bar>");
X    break;
X  case 8:
X    return("<Orb>");
X    break;
X  case 9:
X    return("<Mithril Nugget>");
X    break;
X  }
X}
X
X/* random names for various uses */
Xchar *nameprint()
X{
X  switch(random_range(40)) {
X  case 0:strcpy(Str3,"Orion Splash");break;
X  case 1:strcpy(Str3,"Gorgar");break;
X  case 2:strcpy(Str3,"Hieronymous");break;
X  case 3:strcpy(Str3,"Quantifor Quotron");break;
X  case 4:strcpy(Str3,"Leon");break;
X  case 5:strcpy(Str3,"Joyce");break;
X  case 6:strcpy(Str3,"Leticia Smiley");break;
X  case 7:strcpy(Str3,"Ogilvy the Grim");break;
X  case 8:strcpy(Str3,"Salara Storn");break;
X  case 9:strcpy(Str3,"Murgo");break;
X  case 10:strcpy(Str3,"Jonathan Atwilder");break;
X  case 11:strcpy(Str3,"Xylos the Tan");break;
X  case 12:strcpy(Str3,"Terence");break;
X  case 13:strcpy(Str3,"Toronado");break;
X  case 14:strcpy(Str3,"Kelly");break;
X  case 15:strcpy(Str3,"Cantinflas");break;
X  case 16:strcpy(Str3,"Ixel");break;
X  case 17:strcpy(Str3,"Toto");break;
X  case 18:strcpy(Str3,"Frost");break;
X  case 19:strcpy(Str3,"Aliera Erinyes");break;
X  case 20:strcpy(Str3,"Godel");break;
X  case 21:strcpy(Str3,"Kerst Blackblade");break;
X  case 22:strcpy(Str3,"Ebenezer");break;
X  case 23:strcpy(Str3,"Jeremiah");break;
X  case 24:strcpy(Str3,"Triskelion Shadow");break;
X  case 25:strcpy(Str3,"Eleskir Eremar");break;
X  case 26:strcpy(Str3,"Tyron");break;
X  case 27:strcpy(Str3,"Morgon");break;
X  case 28:strcpy(Str3,"Achmed");break;
X  case 29:strcpy(Str3,"Chin");break;
X  case 30:strcpy(Str3,"Fujimoto");break;
X  case 31:strcpy(Str3,"Dos Santos");break;
X  case 32:strcpy(Str3,"Federico");break;
X  case 33:strcpy(Str3,"Jaime");break;
X  case 34:strcpy(Str3,"Siobhan");break;
X  case 35:strcpy(Str3,"Hans");break;
X  case 36:strcpy(Str3,"Gurkov");break;
X  case 37:strcpy(Str3,"Krilos the Slayer");break;
X  case 38:strcpy(Str3,"Oxxblud");break;
X  case 39:strcpy(Str3,"Dorian");break;
X  }
X  return(Str3);
X}
X
X
X/* returns english string equivalent of number */
Xchar *wordnum(num)
X{
X  switch(num) {
X  case 0: return("zero "); break;
X  case 1: return("one "); break;
X  case 2: return("two "); break;
X  case 3: return("three "); break;
X  case 4: return("four "); break;
X  case 5: return("five "); break;
X  case 6: return("six "); break;
X  case 7: return("seven "); break;
X  case 8: return("eight "); break;
X  case 9: return("nine "); break;
X  case 10: return("ten "); break;
X  default: return(""); break;
X  }
X}
END_OF_FILE
if test 12952 -ne `wc -c <'oetc.c'`; then
    echo shar: \"'oetc.c'\" unpacked with wrong size!
fi
# end of 'oetc.c'
fi
if test -f 'ogen2.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ogen2.c'\"
else
echo shar: Extracting \"'ogen2.c'\" \(12449 characters\)
sed "s/^X//" >'ogen2.c' <<'END_OF_FILE'
X/* omega copyright (c) 1987,1988,1989 by Laurence Raphael Brothers */
X/* ogen2.c */
X/* level generator functions */
X
X#include "oglob.h"
X
X
X
X/* For each level, there should be one stairway going up and one down. 
Xfromlevel determines whether the player is placed on the up or the down
Xstaircase. The aux value is currently unused elsewhere, but is set 
Xto the destination level. */
X
Xvoid make_stairs(fromlevel)
Xint fromlevel;
X{
X  int i,j;
X  /* no stairway out of astral */
X  if (Current_Environment != E_ASTRAL) {
X    findspace(&i,&j,-1);
X    Level->site[i][j].locchar = UP;
X    Level->site[i][j].aux = Level->depth-1;
X    lset(i,j,STOPS);
X    if (fromlevel < Level->depth) { 
X      Player.x = i;
X      Player.y = j;
X    }
X  }
X  if (Level->depth < MaxDungeonLevels) {
X    findspace(&i,&j,-1);
X    Level->site[i][j].locchar = DOWN;
X    Level->site[i][j].aux = Level->depth+1;
X    lset(i,j,STOPS);
X    if (fromlevel > Level->depth) { 
X      Player.x = i;
X      Player.y = j;
X    }
X  }
X}
X
X
X
X
X
X/* tactical map generating functions */
X
X
Xvoid make_country_screen(terrain)
Xchar terrain;
X{
X  int i,j;
X  TempLevel = Level;
X  if (ok_to_free(TempLevel)) {
X#ifndef MSDOS
X    free((char *) TempLevel);
X#endif
X    TempLevel = NULL;
X  }
X#ifndef MSDOS
X  Level = ((plv) malloc(sizeof(levtype)));
X#else
X  msdos_changelevel(TempLevel,0,-1);
X  Level = &TheLevel;
X#endif
X  clear_level(Level);
X  Level->environment = E_TACTICAL_MAP;
X  Level->generated = TRUE;
X  switch(terrain) {
X  case FOREST: make_forest(); break;
X  case JUNGLE: make_jungle(); break;
X  case SWAMP: make_swamp(); break;
X  case RIVER: make_river(); break;
X  case MOUNTAINS: case PASS: make_mountains(); break;
X  case ROAD: make_road(); break;
X  default: make_plains(); break;
X  }
X  if (nighttime()) {
X    print3("Night's gloom shrouds your sight.");    
X    for(i=0;i<WIDTH;i++)
X      for(j=0;j<LENGTH;j++) {
X	Level->site[i][j].showchar = ' ';    
X	Level->site[i][j].lstatus = 0;
X      }
X  }
X}
X
Xvoid make_plains()
X{
X  int i,j;
X
X  for(i=0;i<WIDTH;i++)
X    for(j=0;j<LENGTH;j++) {
X      Level->site[i][j].locchar = FLOOR;
X      Level->site[i][j].roomnumber = RS_COUNTRYSIDE;
X      Level->site[i][j].showchar = FLOOR;
X      Level->site[i][j].lstatus = SEEN+LIT;
X      if ((i == 0) || (j == 0) || (i == WIDTH-1) || (j == LENGTH-1))
X	Level->site[i][j].p_locf = L_TACTICAL_EXIT;
X      else Level->site[i][j].p_locf = L_NO_OP;
X    }
X}
X
Xvoid make_road()
X{
X  int i,x,y;
X  make_plains();
X  for(i=0;i<191;i++) {
X    do {
X      x = random_range(WIDTH);
X    } while ((x < WIDTH/2+3) && (x > WIDTH/2-3));
X    y = random_range(LENGTH);
X    Level->site[x][y].locchar = HEDGE;
X    Level->site[x][y].showchar = HEDGE;
X    Level->site[x][y].p_locf = L_HEDGE;
X  }    
X  for(i=0;i<31;i++) {
X    do {
X      x = random_range(WIDTH);
X    } while ((x < WIDTH/2+3) && (x > WIDTH/2-3));
X    y = random_range(LENGTH);
X    Level->site[x][y].locchar = WATER;
X    Level->site[x][y].showchar = WATER;
X    Level->site[x][y].p_locf = L_WATER;
X  }    
X  for(i=0;i<127;i++) {
X    do {
X      x = random_range(WIDTH);
X    } while ((x < WIDTH/2+3) && (x > WIDTH/2-3));
X    y = random_range(LENGTH);
X    Level->site[x][y].locchar = RUBBLE;
X    Level->site[x][y].showchar = RUBBLE;
X    Level->site[x][y].p_locf = L_RUBBLE;
X  }    
X}
X
X
X
Xvoid make_forest()
X{
X  int i,x,y,x1,y1;
X  make_plains();
X  for(i=0;i<255;i++){
X    x = random_range(WIDTH);
X    y = random_range(LENGTH);
X    Level->site[x][y].locchar = HEDGE;
X    Level->site[x][y].showchar = HEDGE;
X    Level->site[x][y].p_locf = L_HEDGE;
X  }
X  x = 0; 
X  x1 = WIDTH;
X  y = random_range(LENGTH);
X  y1 = random_range(LENGTH);
X  straggle_corridor(x,y,x1,y1,WATER,RS_COUNTRYSIDE);
X}
X
X
Xvoid make_jungle()
X{
X  int i,x,y;
X  make_plains();
X  for(i=0;i<511;i++){
X    x = random_range(WIDTH);
X    y = random_range(LENGTH);
X    Level->site[x][y].locchar = HEDGE;
X    Level->site[x][y].showchar = HEDGE;
X    Level->site[x][y].p_locf = L_HEDGE;
X  }
X}
X
X
Xvoid make_river()
X{
X  int i,x,y,x1,y1;
X  make_plains();
X  for(i=0;i<127;i++){
X    x = random_range(WIDTH);
X    y = random_range(LENGTH);
X    Level->site[x][y].locchar = HEDGE;
X    Level->site[x][y].showchar = HEDGE;
X    Level->site[x][y].p_locf = L_HEDGE;
X  }
X  x = 0; 
X  x1 = WIDTH;
X  y = random_range(LENGTH);
X  y1 = random_range(LENGTH);
X  straggle_corridor(x,y,x1,y1,WATER,RS_COUNTRYSIDE);
X  for(i=0;i<7;i++) {
X    if (y > LENGTH/2) y--;
X    else y++;
X    if (y1 > LENGTH/2) y1--;
X    else y1++;
X    straggle_corridor(x,y,x1,y1,WATER,RS_COUNTRYSIDE);
X  }
X}
X
X
Xvoid make_mountains()
X{
X  int i,x,y,x1,y1;
X  make_plains();
X  for(i=0;i<256;i++){
X    x = random_range(WIDTH);
X    y = random_range(LENGTH);
X    Level->site[x][y].locchar = RUBBLE;
X    Level->site[x][y].showchar = RUBBLE;
X    Level->site[x][y].p_locf = L_RUBBLE;
X  }
X  x = 0; 
X  x1 = WIDTH;
X  y = random_range(LENGTH);
X  y1 = random_range(LENGTH);
X  straggle_corridor(x,y,x1,y1,WATER,RS_COUNTRYSIDE);
X  for(i=0;i<7;i++) {
X    x = random_range(WIDTH); 
X    x1 = random_range(WIDTH);
X    y = 0;
X    y1 = LENGTH;
X    straggle_corridor(x,y,x1,y1,WATER,RS_COUNTRYSIDE);
X  }
X}
X
X
X
Xvoid make_swamp()
X{
X  int i,x,y;
X  make_plains();
X  for(i=0;i<511;i++){
X    x = random_range(WIDTH);
X    y = random_range(LENGTH);
X    Level->site[x][y].locchar = WATER;
X    Level->site[x][y].showchar = WATER;
X    Level->site[x][y].p_locf = L_WATER;
X  }
X
X  for(i=0;i<255;i++){
X    x = random_range(WIDTH);
X    y = random_range(LENGTH);
X    Level->site[x][y].locchar = HEDGE;
X    Level->site[x][y].showchar = HEDGE;
X    Level->site[x][y].p_locf = L_HEDGE;
X  }
X}
X
X
X
X
X
X
X/* builds a room. Then, for each successive room, sends off at least one
Xcorridor which is guaranteed to connect up to another room, thus guaranteeing
Xfully connected level. */
X
Xvoid room_level()
X{
X  int i,fx,fy,tx,ty,t,l,e;
X  char rsi;
X
X  Level->numrooms = random_range(8)+9;
X
X  do {
X    t = random_range(LENGTH-10)+1;
X    l = random_range(WIDTH-10)+1;
X    e = 4+random_range(5);
X  } while ((Level->site[l][t].roomnumber != RS_WALLSPACE) ||
X	   (Level->site[l+e][t].roomnumber != RS_WALLSPACE) ||
X	   (Level->site[l][t+e].roomnumber != RS_WALLSPACE) ||
X	   (Level->site[l+e][t+e].roomnumber != RS_WALLSPACE));
X  if (Current_Dungeon == E_SEWERS) {
X    if (random_range(2)) rsi = ROOMBASE+25;
X    else rsi = ROOMBASE+random_range(NUMROOMNAMES);
X  }
X  else rsi = ROOMBASE+random_range(NUMROOMNAMES);
X  build_room(l,t,e,rsi,1);
X
X
X  for (i=2;i<=Level->numrooms;i++) {
X    do {
X      t = random_range(LENGTH-10)+1;
X      l = random_range(WIDTH-10)+1;
X      e = 4+random_range(5);
X    } while ((Level->site[l][t].roomnumber != RS_WALLSPACE) ||
X	     (Level->site[l+e][t].roomnumber != RS_WALLSPACE) ||
X	     (Level->site[l][t+e].roomnumber != RS_WALLSPACE) ||
X	     (Level->site[l+e][t+e].roomnumber != RS_WALLSPACE));
X    if (Current_Dungeon == E_SEWERS) {
X      if (random_range(2)) rsi = ROOMBASE+25;
X      else rsi = ROOMBASE+random_range(NUMROOMNAMES);
X    }
X    else rsi = ROOMBASE+random_range(NUMROOMNAMES);
X    build_room(l,t,e,rsi,i);
X    
X
X    /* corridor which is guaranteed to connect */
X    findspace(&tx,&ty,i);
X
X    /* figure out where to start corridor from */
X    if ((ty <= t) && (tx <= l+e)) {
X      fx = l+1+random_range(e-1);
X      fy = t;
X    }
X    else if ((tx >= l+e) && (ty <= t+e)) {
X      fx = l+e;
X      fy = t+1+random_range(e-1);
X    }
X    else if ((ty >= t+e) && (tx >= l)) {
X      fx = l+1+random_range(e-1);
X      fy = t+e;
X    }
X    else {
X      fx = l;
X      fy = t+1+random_range(e-1);
X    }
X
X    room_corridor(fx,fy,tx,ty,i);
X
X
X    /* corridor which may not go anywhere */
X    if (random_range(2)) {
X      findspace(&tx,&ty,i);
X      if ((ty <= t) && (tx <= l+e)) {
X	fx = l+1+random_range(e-1);
X	fy = t;
X      }
X      else if ((tx >= l+e) && (ty <= t+e)) {
X	fx = l+e;
X	fy = t+1+random_range(e-1);
X      }
X      else if ((ty >= t+e) && (tx >= l)) {
X	fx = l+1+random_range(e-1);
X	fy = t+e;
X      }
X      else {
X	fx = l;
X	fy = t+1+random_range(e-1);
X      }
X      room_corridor(fx,fy,tx,ty,i);
X    }
X  }
X
X  if (Current_Dungeon == E_SEWERS) {
X    if (Level->depth == SEWERLEVELS) {
X      findspace(&tx,&ty,-1);
X      Level->mlist = ((pml) malloc(sizeof(mltype)));
X      Level->mlist->next = NULL;
X      Level->mlist->m = 
X	Level->site[tx][ty].creature = 
X	  ((pmt) make_creature(ML7+5)); /* The Great Wyrm */
X      Level->mlist->m->x = tx;
X      Level->mlist->m->y = ty;
X    }
X  }
X  else if (Current_Environment == E_CASTLE) {
X    if (Level->depth == CASTLELEVELS) {
X      findspace(&tx,&ty,-1);
X      Level->site[tx][ty].locchar = DOWN;
X      Level->site[tx][ty].p_locf = L_ENTER_COURT;
X    }
X  }
X  else if (Current_Environment == E_VOLCANO) {
X    if (Level->depth == VOLCANOLEVELS) {
X      findspace(&tx,&ty,-1);
X      Level->mlist = ((pml) malloc(sizeof(mltype)));
X      Level->mlist->next = NULL;
X      Level->mlist->m = 
X	Level->site[tx][ty].creature = 
X	  ((pmt) make_creature(ML10+4)); /* The dark emp */
X      Level->mlist->m->x = tx;
X      Level->mlist->m->y = ty;
X    }
X  }
X  populate_level(Current_Environment);
X  stock_level();
X}
X
X
X
X/* goes from f to t unless it hits a site which is not a wall and doesn't
X   have buildaux field == baux */
Xvoid room_corridor(fx,fy,tx,ty,baux)
Xint fx,fy,tx,ty,baux;
X{
X  int dx,dy,continuing = TRUE;
X
X  dx = sign(tx-fx);
X  dy = sign(ty-fy);
X
X  makedoor(fx,fy);
X
X  fx+=dx;
X  fy+=dy;
X
X  while(continuing) {
X    Level->site[fx][fy].locchar = FLOOR;
X    Level->site[fx][fy].roomnumber = RS_CORRIDOR;
X    Level->site[fx][fy].buildaux = baux;
X    dx = sign(tx-fx);
X    dy = sign(ty-fy);
X    if ((dx != 0) && (dy != 0)) {
X      if (random_range(2)) dx = 0;
X      else if (random_range(2)) dy = 0;
X    }
X    fx+=dx;
X    fy+=dy;
X    continuing = (((fx != tx) || (fy != ty)) &&
X		  ((Level->site[fx][fy].buildaux == 0) ||
X		   (Level->site[fx][fy].buildaux == baux)));
X  }
X  makedoor(fx,fy);
X}
X
X
X
X
X
Xvoid maze_level()
X{
X  int i,j,tx,ty,mid;
X  char rsi;
X  if (Current_Environment == E_ASTRAL)
X    switch(Level->depth){
X    case 1: rsi = RS_EARTHPLANE; break;
X    case 2: rsi = RS_AIRPLANE; break;
X    case 3: rsi = RS_WATERPLANE; break;
X    case 4: rsi = RS_FIREPLANE; break;
X    case 5: rsi = RS_HIGHASTRAL; break;
X    }
X  else rsi = RS_VOLCANO;
X  maze_corridor(random_range(WIDTH-1)+1,
X		random_range(LENGTH-1)+1,
X		random_range(WIDTH-1)+1,
X		random_range(LENGTH-1)+1,
X		rsi,0);
X  if (Current_Dungeon == E_ASTRAL) {
X    for(i=0;i<WIDTH;i++) 
X      for(j=0;j<LENGTH;j++) 
X	if (Level->site[i][j].locchar == WALL)
X	  switch(Level->depth){
X	  case 1: Level->site[i][j].aux = 500; break;
X	  case 2: 
X	    Level->site[i][j].locchar = WHIRLWIND;
X	    Level->site[i][j].p_locf = L_WHIRLWIND;
X	    break;
X	  case 3: 
X	    Level->site[i][j].locchar = WATER;
X	    Level->site[i][j].p_locf = L_WATER;
X	    break;
X	  case 4:
X	    Level->site[i][j].locchar = FIRE;
X	    Level->site[i][j].p_locf = L_FIRE;
X	    break;
X	  case 5: 
X	    Level->site[i][j].locchar = ABYSS;
X	    Level->site[i][j].p_locf = L_ABYSS;
X	    break;
X	  }
X    switch(Level->depth) {
X    case 1: mid = ML10+5; break; /* Elemental Lord of Earth */
X    case 2: mid = ML10+6; break; /* Elemental Lord of Air */
X    case 3: mid = ML10+7; break; /* Elemental Lord of Water */
X    case 4: mid = ML10+8; break; /* Elemental Lord of Fire */
X    case 5: mid = ML10+9; break; /* Elemental Master */
X    }
X    if (Level->depth == 5) {
X      findspace(&tx,&ty,-1);
X      Level->site[tx][ty].p_locf = L_ENTER_CIRCLE;
X      Level->site[tx][ty].locchar = DOWN;
X    }
X    if (! gamestatusp(COMPLETED_ASTRAL)) {
X      findspace(&tx,&ty,-1);
X      Level->mlist = ((pml) malloc(sizeof(mltype)));
X      Level->mlist->next = NULL;
X      Level->mlist->m = 
X	Level->site[tx][ty].creature = 
X	  ((pmt) make_creature(mid)); 
X      Level->mlist->m->x = tx;
X      Level->mlist->m->y = ty;
X    }
X  }
X  else if (Current_Environment == E_VOLCANO) {
X    if (Level->depth == VOLCANOLEVELS) {
X      findspace(&tx,&ty,-1);
X      Level->mlist = ((pml) malloc(sizeof(mltype)));
X      Level->mlist->next = NULL;
X      Level->mlist->m = 
X	Level->site[tx][ty].creature = 
X	  ((pmt) make_creature(ML10+4)); /* The dark emp */
X      Level->mlist->m->x = tx;
X      Level->mlist->m->y = ty;
X    }
X  }
X  populate_level(Current_Environment);
X  stock_level();
X}
X
X
X/* keep drawing corridors recursively for 2^5 endpoints */
Xvoid maze_corridor(fx,fy,tx,ty,rsi,num)
Xint fx,fy,tx,ty;
Xchar rsi,num;
X{
X  if (num < 6) {
X    straggle_corridor(fx,fy,tx,ty,FLOOR,rsi);
X    maze_corridor(tx,ty,
X		  random_range(WIDTH-1)+1,
X		  random_range(LENGTH-1)+1,
X		  rsi,num+1);
X    
X  }
X}
X
X
X
X
X
END_OF_FILE
if test 12449 -ne `wc -c <'ogen2.c'`; then
    echo shar: \"'ogen2.c'\" unpacked with wrong size!
fi
# end of 'ogen2.c'
fi
echo shar: End of archive 17 \(of 20\).
cp /dev/null ark17isdone
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