[comp.sources.games] v03i051: omega - rogue like dungeon exploration, Part04/15

games-request@tekred.TEK.COM (01/20/88)

Submitted by: "Laurence R. Brothers" <brothers@paul.rutgers.edu>
Comp.sources.games: Volume 3, Issue 51
Archive-name: omega/Part04

#! /bin/sh

# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 4 (of 15)."
# Contents:  oguild.c omega.programming.notes outil.c
# Wrapped by billr@tekred on Mon Jan 18 10:20:16 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f oguild.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"oguild.c\"
else
echo shar: Extracting \"oguild.c\" \(40166 characters\)
sed "s/^X//" >oguild.c <<'END_OF_oguild.c'
X/* omega copyright (C) by Laurence Raphael Brothers, 1987 */
X/* oguild.c */
X/* L_ functions  */ 
X/* These functions implement the guilds, priesthoods, etc. */
X/* They are all l_ functions since they are basically activated*/
X/* at some site or other. */
X
X#include <strings.h>
X#include "oglob.h"
X
X/* from ospell */
Xextern char *spellid();
X
X
X/* from oinv */
Xextern char *itemid();
Xextern int inpack();
X
X/* from oetc */
Xextern void hint(),learnclericalspells(),nameprint();
Xextern char *slotstr();
X
X/* from omon */
Xextern void m_status_set();
X
X/* from osite */
Xextern void l_jail();
X
X/* from oaux */
Xextern void conform_lost_object(),conform_unused_object(),p_death();
Xextern void p_damage(),p_poison(),calc_melee(),gain_experience(),tacmode();
Xextern void add_item_to_pack(),p_drown(),p_teleport(),p_win(),foodcheck();
Xextern int item_value(),true_item_value();
X
X/* from oeffect (1 or 2)*/
Xextern void disintegrate(),identify(),level_drain(),augment(),cleanse();
Xextern void heal(),acquire(),enchant(),bless(),learnspell();
X
X/* from outil */
Xextern int random_range(),hour();
X
X/* from oscr */
Xextern void mprint(),menuclear(),menuprint(),xredraw(),printm();
Xextern void menu_item_print(),mnumprint(),dataprint();
Xextern char ynq(),mgetc(),*msgscanstring();
X
X/* from oitem */
Xextern pob create_object();
X
X/* from olev */
Xpmt m_create();
X
X/* site movef functions */
X
Xvoid l_druid(),l_thieves_guild(),l_college(),l_merc_guild(),l_sorcerors();
Xvoid l_altar(),l_arena();
X
X/* auxillary functions for above */
Xvoid make_hp(),hp_req_test(),hp_req_print();
X
Xvoid l_thieves_guild()
X{
X  int fee,i,done=FALSE,dues=1000;
X  char action;
X  pob lockpick;
X  mprint("You have penetrated to the Lair of the Thieves' Guild.");
X  if (! nighttime()) 
X    mprint("There aren't any thieves around in the daytime.");
X  else {
X    while (! done) {
X      menuclear();
X      menuprint("a: Join the Thieves' Guild.\n");
X      menuprint("b: Raise your Guild rank.\n");
X      menuprint("c: Get an item identified.\n");
X      menuprint("d: Fence an item.\n");
X      menuprint("ESCAPE: Leave this Den of Iniquity.");
X      action = mgetc();
X      if (action == ESCAPE) done = TRUE;
X      else if (action == 'a') {
X	done = TRUE;
X	if (Player.rank[THIEVES]> 0)
X	  mprint("You are already a member!");
X	else if (Player.alignment > 10) 
X	  mprint("You are too lawful to be a thief!");
X	else {
X	  dues = (int) (dues * (1+(12-Player.dex)/9.0));
X	  dues += Player.alignment*5;
X	  dues = max(100,dues);
X	  mprint("Dues are ");
X	  mnumprint(dues);
X	  mprint("Au");
X	  mprint("Pay it? [yn]");
X	  if (ynq() =='y') {
X	    if (Player.cash < dues) {
X	      mprint("You can't cheat the Thieves' Guild!");
X	      mprint("... but the Thieves' Guild can cheat you....");
X	      Player.cash = 0;
X	    }
X	    else {
X	      printm("\nShadowlord");
X	      mprint(Shadowlord);
X	      mprint("enters your name into the roll of the Thieves' Guild."); 
X	      mprint("As a special bonus, you get a free lockpick.");
X	      mprint("You are taught the spell of Object Detection.");
X	      Spells[S_OBJ_DET].known = TRUE; 
X	      Thieflevel = Player.level;
X	      lockpick = ((pob) calloc(1,sizeof(objtype)));
X	      *lockpick = Objects[THINGID+2]; /* lock pick */
X	      add_item_to_pack(lockpick);
X	      Player.cash -= dues;
X	      dataprint();
X	      Player.rank[THIEVES]=TMEMBER;
X	      Player.maxdex++;Player.dex++;Player.agi++;Player.maxagi++;
X	    }
X	  }
X	}
X      }
X      else if (action == 'b') {
X	if (Player.rank[THIEVES]==0)
X	  mprint("You are not even a member!");
X	else if (Player.rank[THIEVES]==SHADOWLORD) 
X	  mprint("You can't get any higher than this!");
X	else if (Player.rank[THIEVES]==TMASTER) {
X	  if (Player.level-Thieflevel <= Shadowlordlevel)
X	    mprint("You are not experienced enough to advance.");
X	  if (! (i=inpack(THINGID+16,-1))+1)
X	    mprint("You must bring back Morgon's Badge!");
X	  else  {
X	    mprint("The Badge is put in a place of honor in the Guild Hall.");
X	    conform_lost_object(Player.possessions[i]);
X	    mprint("You are now the Shadowlord of the Thieves' Guild!");
X	    strcpy(Shadowlord,Player.name);
X	    Shadowlordlevel = Player.level;
X	    mprint("You now know the Spell of Shadowform.");
X	    Spells[S_SHADOWFORM].known = TRUE;
X	    Player.rank[THIEVES]=SHADOWLORD;
X	    Player.maxagi += 2;
X	    Player.maxdex += 2;
X	    Player.agi += 2;
X	    Player.dex += 2;
X	  }
X	}
X	else if (Player.rank[THIEVES]==THIEF) {
X	  if (Player.level-Thieflevel < 13)
X	    mprint("You are not experienced enough to advance.");
X	  else  {
X	    mprint("You are now a Master Thief of the Guild!");
X	    mprint("You now know the Spell of Apportation.");
X	    mprint("To advance to the next level you must return with");
X	    mprint("the badge of Morgon, the Justiciar (cursed be his name).");
X	    mprint("If you don't meet him on a higher level, Morgon may");
X	    mprint("be found as one of the Guardians on level 39.");
X	    Spells[S_APPORT].known = TRUE;
X	    Player.rank[THIEVES]=TMASTER;
X	    Player.maxagi++;
X	    Player.maxdex++;
X	    Player.agi++;
X	    Player.dex++;
X	  }
X	}
X	else if (Player.rank[THIEVES]==ATHIEF) {	
X	  if (Player.level-Thieflevel < 7)
X	    mprint("You are not experienced enough to advance.");
X	  else  {
X	    mprint("You are now a ranking Thief of the Guild!");
X	    mprint("You now know the Spell of Invisibility.");
X	    Spells[S_INVISIBLE].known = TRUE;
X	    Player.rank[THIEVES]=THIEF;
X	    Player.agi++;
X	    Player.maxagi++;
X	  }
X	}
X	else if (Player.rank[THIEVES]==TMEMBER) {
X	  if (Player.level-Thieflevel < 3)
X	    mprint("You are not experienced enough to advance.");
X	  else  {
X	    mprint("You are now an Apprentice Thief!");
X	    mprint("You now know the Spell of Levitation.");
X	    Spells[S_LEVITATE].known = TRUE;
X	    Player.rank[THIEVES]=ATHIEF;
X	    Player.dex++;
X	    Player.maxdex++;
X	  }
X	}
X      }
X      else if (action == 'c') {
X	if (Player.rank[THIEVES]==0) {
X	  printm("\nRTG, Inc, Appraisers. Identification Fee: 50Au.");
X	  fee = 50;
X	}
X	else {
X	  fee = 5;
X	  printm("\nIt'll cost you 5Au, mac!");
X	}
X	mprint("Pay it? [yn]");
X	if (ynq()=='y') {
X	  if (Player.cash < fee)
X	    mprint("Try again when you have the cash.");
X	  else {
X	    Player.cash -= fee;
X	    dataprint();
X	    identify(0);
X	  }
X	}
X      }
X      else if (action == 'd') {
X	if (Player.rank[THIEVES]==0)
X	  mprint("Fence? Who said anything about a fence?");
X	else {
X	  printm("\nFence which item?");
X	  i = getitem(NULL);
X	  if ((i==ABORT) || (Player.possessions[i-'a'] == NULL))
X	    mprint("Huh, Is this some kind of set-up?");
X	  else if (Player.possessions[i-'a']->known == 0)
X	    mprint("You got to have it appraised, first!");
X	  else {
X	    mprint("I'll give you ");
X	    mnumprint((int) (item_value(Player.possessions[i-'a'])/2));
X	    mprint("Au for it. OK? [yn]");
X	    if (ynq() == 'y') {
X	      Player.cash += ((int) (item_value(Player.possessions[i-'a'])/2));
X	      dataprint();
X	      conform_lost_objects(1,Player.possessions[i-'a']);
X	    }
X	    else mprint("Hey, gimme a break, it was a fair price!");
X	  }
X	}
X      }
X    }
X  }
X  xredraw();
X}
X
Xvoid l_college()
X{
X  char action;
X  int i,j,done=FALSE,enrolled = FALSE;
X  mprint("The Collegium Magii. Founded 16937, AOF.");
X  if (nighttime())
X    mprint("The Registration desk is closed at night....");
X  else {
X    while (! done) {
X      menuclear();
X      menuprint("a: Enroll in the College.\n");
X      menuprint("b: Raise your College rank.\n");
X      menuprint("c: Do spell research.\n");
X      menuprint("ESCAPE: Leave these hallowed halls.\n");
X      action = mgetc();
X      if (action == ESCAPE) done = TRUE;
X      else if (action == 'a') {
X	if (Player.rank[COLLEGE] > 0)
X	  mprint("You are already enrolled!");
X	else if (Player.iq < 13) 
X	  mprint("Your low IQ renders you incapable of being educated.");
X	else {
X	  if (Player.iq > 17) {
X	    mprint("You are given a scholarship!");
X	    enrolled=TRUE;
X	  }
X	  else {
X	    mprint("Tuition is 1000Au");
X	    mprint("Pay it? [yn]");
X	    if (ynq() =='y') {
X	      if (Player.cash < 1000)
X		mprint("You don't have the funds!");
X	      else {
X		Player.cash -= 1000;
X		enrolled = TRUE;
X		dataprint();
X	      }		
X	    }
X	  }
X	  if (enrolled) {
X	    mprint("Archmage");
X	    mprint(Archmage);
X	    mprint("greets you and congratulates you on your acceptance.");
X	    mprint("You are now enrolled in the Collegium Magii!");
X	    mprint("You are now a Novice.");
X	    Collegelevel = Player.level;
X	    Player.rank[COLLEGE] = INITIATE;
X	    Player.maxiq += 1;
X	    Player.iq += 1;
X	    Player.maxpow += 1;
X	    Player.pow += 1;
X	  }
X	}
X      }
X      else if (action == 'b') {
X	if (Player.rank[COLLEGE] == 0)
X	  mprint("You have not even been initiated, yet!");
X	else if (Player.rank[COLLEGE]==ARCHMAGE) 
X	  mprint("You are at the pinnacle of mastery in the Collegium.");
X	else if (Player.rank[COLLEGE]==MAGE) {
X	  if (Player.level-Collegelevel <= Archmagelevel)
X	    mprint("You are not experienced enough to advance.");
X	  else if (! (i=(inpack(CORPSEID,ML10+1)+1)))
X	    mprint("You must return with the heart of the Eater of Magic!");
X	  else  {
X	    mprint("The Heart is sent to the labs for analysis.");
X	    conform_lost_object(Player.possessions[i]);
X	    mprint("You are now Archmage of the Collegium Magii!");
X	    strcpy(Archmage,Player.name);
X	    Archmagelevel = Player.level-Collegelevel;
X	    Player.rank[COLLEGE] = ARCHMAGE;
X	    Player.maxiq += 5;
X	    Player.iq += 5;
X	    Player.maxpow += 5;
X	    Player.pow += 5;
X	  }
X	}
X	else if (Player.rank[COLLEGE]==PRECEPTOR) {
X	  if (Player.level-Collegelevel < 13)
X	    mprint("You are not experienced enough to advance.");
X	  else  {
X	    mprint("You are now a Mage of the Collegium Magii!");
X	    mprint("To become Archmage, you must return with the");
X	    mprint("heart of the Eater of Magic");
X	    mprint("If you don't meet it on a higher level, the Eater may");
X	    mprint("be found as one of the Guardians on level 39.");
X	    Player.rank[COLLEGE] = MAGE;
X	    Player.maxiq += 2;
X	    Player.iq += 2;
X	    Player.maxpow += 2;
X	    Player.pow += 2;
X	  }
X	}
X	else if (Player.rank[COLLEGE]==STUDENT) {
X	  if (Player.level-Collegelevel < 7)
X	    mprint("You are not experienced enough to advance.");
X	  else  {
X	    mprint("You are now a Preceptor of the Collegium Magii!");
X	    mprint("You are taught the basics of ritual magic.");
X	    Spells[S_RITUAL].known = TRUE;
X	    Player.rank[COLLEGE] = PRECEPTOR;
X	  }
X	  Player.maxiq += 1;
X	  Player.iq += 1;
X	  Player.maxpow += 1;
X	  Player.pow += 1;
X	}
X	else if (Player.rank[COLLEGE]==NOVICE) {
X	  if (Player.level-Collegelevel < 3)
X	    mprint("You are not experienced enough to advance.");
X	  else  {
X	    mprint("You are now a Student at the Collegium Magii!");
X	    mprint("You are taught the spell of identification.");
X	    Spells[S_IDENTIFY].known = TRUE;
X	    Player.rank[COLLEGE] = STUDENT;
X	    Player.maxiq += 1;
X	    Player.iq += 1;
X	    Player.maxpow += 1;
X	    Player.pow += 1;
X	  }
X	}
X      }
X      else if (action == 'c') {
X	if (Player.rank[COLLEGE]==0) 
X	  mprint("Only Students and Faculty may do spell research here.");
X	else {
X	  printm("\nLab fee: 2000 Au.");
X	  mprint("Pay it? [yn]");
X	  if (ynq()=='y') {
X	    if (Player.cash < 2000)
X	      mprint("Try again when you have the cash.");
X	    else {
X	      Player.cash -= 2000;
X	      dataprint();
X	      learnspell(0);
X	    }
X	  }
X	}
X      }
X    }
X  }
X  xredraw();
X}
X
X
X
Xvoid l_sorcerors()
X{
X  char action;
X  int i,j,done=FALSE,fee=3000,total;
X  mprint("The Circle of Sorcerors. May we help you?");
X  while (! done) {
X    menuclear();
X    menuprint("a: Become an Initiate of the Circle.\n");
X    menuprint("b: Raise your rank in the Circle.\n");
X    menuprint("c: Restore mana points\n");
X    menuprint("ESCAPE: Leave these Chambers of Power.\n");
X    action = mgetc();
X    if (action == ESCAPE) done = TRUE;
X    else if (action == 'a') {
X      if (Player.rank[CIRCLE] > 0)
X	  mprint("You are already an initiate!");
X      else if (Player.alignment > 0)
X	mprint("You may not join -- you reek of Law!");
X      else {
X	fee += Player.alignment*100;
X	fee = (int) (fee * (1+(12-Player.pow)/9.0));
X	fee = max(100,fee);
X	mprint("For you, there is an initiation fee of ");
X	mnumprint(fee);
X	mprint("Au");
X	mprint("Pay it? [yn]");
X	if (ynq() =='y') {
X	  if (Player.cash < fee) 
X	    mprint("Try again when you have the cash!");
X	  else {
X	    printm("\nPrime Sorceror");
X	    mprint(Prime);
X	    mprint("conducts your initiation into the circle of novices.");
X	    mprint("You learn the Spell of Magic Missiles.");
X	    Spells[S_MISSILE].known = TRUE;
X	    Sorcerorlevel = Player.level;
X	    Player.cash -= fee;
X	    dataprint();
X	    Player.rank[CIRCLE] = INITIATE;
X	    Player.maxpow++;
X	    Player.pow++;
X	  }
X	}
X      }
X    }
X    else if (action == 'b') {
X      if (Player.rank[CIRCLE] == 0)
X	mprint("You have not even been initiated, yet!");
X      else if (Player.alignment > -1) {
X	mprint("Ahh! You have grown too lawful!!!");
X	mprint("You are hereby blackballed from the Circle!");
X	Player.rank[CIRCLE]=0;
X	mprint("A pox upon thee!");
X	if (! Player.immunity[INFECTION])
X	  Player.status[DISEASED]+=100;
X	mprint("And a curse on your possessions!");
X	acquire(-1);
X	enchant(-1);
X	bless(-1);
X	mprint("Die, false sorceror!");
X	p_damage(25,UNSTOPPABLE,"a sorceror's curse");
X      }
X      else if (Player.rank[CIRCLE]==PRIME) 
X	mprint("You are at the pinnacle of mastery in the Circle.");
X      else if (Player.rank[CIRCLE]==HIGHSORCEROR) {
X	if (Player.level-Sorcerorlevel <= Primelevel)
X	  mprint("You are not experienced enough to advance.");
X	else if (! (i=(inpack(CORPSEID,ML10+2)+1)))
X	  mprint("You must return with the Crown of the LawBringer!");
X	else  {
X	  mprint("The Crown is ritually sacrificed to the Lords of Chaos.");
X	  conform_lost_object(Player.possessions[i]);
X	  mprint("You are now the Prime Sorceror of the Inner Circle!");
X	  strcpy(Prime,Player.name);
X	  Primelevel = Player.level-Sorcerorlevel;
X	  mprint("You learn the Spell of Disintegration!");
X	  Spells[S_DISINTEGRATE].known = TRUE;
X	  Player.rank[CIRCLE] = PRIME;
X	  Player.maxpow += 10;
X	  Player.pow += 10;
X	}
X      }
X      else if (Player.rank[CIRCLE]==SORCEROR) {
X	if (Player.level-Sorcerorlevel < 13)
X	  mprint("You are not experienced enough to advance.");
X	else  {
X	  mprint("You are now a High Sorceror of the Inner Circle!");
X	  mprint("You learn the Spell of Disruption!");
X	  mprint("To advance you must return with the LawBringer's Crown!");
X	  mprint("If you don't meet him on a higher level, he may");
X	  mprint("be found as one of the Guardians on level 39.");
X	  Spells[S_DISRUPT].known = TRUE;
X	  Player.rank[CIRCLE] = HIGHSORCEROR;
X	  Player.maxpow += 5;
X	  Player.pow += 5;
X	}
X      }
X      else if (Player.rank[CIRCLE]==ENCHANTER) {
X	if (Player.level-Sorcerorlevel < 7)
X	  mprint("You are not experienced enough to advance.");
X	else  {
X	  mprint("You are now a member of the Circle of Sorcerors!");
X	  mprint("You learn the Spell of Ball Lightning!");
X	  Spells[S_LBALL].known = TRUE;
X	  Player.rank[CIRCLE] = SORCEROR;
X	  Player.maxpow += 2; 
X	  Player.pow+=2;
X	}
X      }
X      else if (Player.rank[CIRCLE]==INITIATE) {
X	if (Player.level-Sorcerorlevel < 3)
X	  mprint("You are not experienced enough to advance.");
X	else  {
X	  mprint("You are now a member of the Circle of Enchanters!");
X	  mprint("You learn the Spell of Firebolts.");
X	  Spells[S_FIREBOLT].known = TRUE;
X	  Player.rank[CIRCLE] = ENCHANTER;
X	  Player.maxpow++;
X	  Player.pow++;
X	}
X      }
X    }
X    else if (action == 'c') {
X      done = TRUE;
X      fee = Player.level*100;
X      if (Player.rank[CIRCLE]) fee = fee / 2;
X      mprint("That will be:");
X      mnumprint(fee);
X      mprint("Au.");
X      mprint("Pay it [yn]?");
X      if (ynq()=='y') {
X	if (Player.cash < fee) 
X	  mprint("Begone, deadbeat, or face the wrath of the Circle!");
X	else {
X	  Player.cash -= fee;
X	  total = calcmana();
X	  while (Player.mana < total) {
X	    Player.mana++;
X	    dataprint();
X	  }
X	  mprint("Have a sorcerous day, now!");
X	}
X      }
X      else mprint("Be seeing you!");
X    }
X  }
X  xredraw();
X}
X
X
X
Xvoid l_merc_guild()
X{
X  char action;
X  int i,j,done=FALSE;
X  pob newitem;
X
X  mprint("Legion of Destiny, Mercenary Guild, Inc.");
X  if (nighttime())
X    mprint("The barracks are under curfew right now."); 
X  else {
X    while (! done) {
X      menuclear();
X      menuprint("a: Enlist in the Guild.\n");
X      menuprint("b: Apply for a promotion.\n");
X      menuprint("ESCAPE: Go on leave.\n");
X      action = mgetc();
X      if (action == ESCAPE) done = TRUE;
X      else if (action == 'a') {
X	done = TRUE;
X	if (Player.rank[LEGION]>0)
X	  mprint("You are already a recruit!");
X	else if (Player.rank[ARENA]>0)
X	  mprint("The legion don't need any Arena Jocks. Git!");
X	else if (Player.con < 13) {
X	  mprint("You are too fragile to join the legion.");
X	}
X	else if (Player.str < 13) {
X	  mprint("Your strength is too low to pass the physical!");
X	}
X	else {
X	  printm("\nCommandant");
X	  mprint(Commandant);
X	  mprint("shakes your hand.");
X	  mprint("The Legion pays you a 100Au induction fee.");
X	  mprint("You are also issued a shortsword and leather.");
X	  mprint("You are now a Legionaire.");
X	  newitem = ((pob) calloc(1,sizeof(objtype)));
X	  *newitem = Objects[WEAPONID+1]; /* shortsword */
X	  add_item_to_pack(newitem);
X	  newitem = ((pob) calloc(1,sizeof(objtype)));
X	  *newitem = Objects[ARMORID+1]; /* leather */
X	  add_item_to_pack(newitem);
X	  Player.cash += 100;
X	  Player.rank[LEGION] = LEGIONAIRE;
X	  Merclevel = Player.level;
X	  Player.str++; Player.con++;
X	  Player.maxstr++; Player.maxcon++;
X	}
X      }
X      else if (action == 'b') {
X	done = TRUE;
X	if (Player.rank[LEGION]==0)
X	  mprint("You have not even enlisted, yet!");
X	else if (Player.rank[LEGION]==COMMANDANT)
X	  mprint("You can't be promoted any further!");
X	else if (Player.rank[LEGION]==COLONEL) {
X	  if (Player.level-Merclevel <= Commandantlevel)
X	    mprint("Your record does not yet permit promotion.");
X	  else if (! (i=inpack(WEAPONID+37,-1)+1))
X	    mprint("You must return with the Sword of the Dark Emperor!");
X	  else  {
X	    mprint("The Sword of Empire is melted down....");
X	    conform_lost_object(Player.possessions[i]);
X	    mprint("You have been promoted to Commandant of the Legion!");
X	    strcpy(Commandant,Player.name);
X	    Commandantlevel = Player.level-Merclevel;
X	    mprint("You now know the Spell of Regeneration.");
X	    Spells[S_REGENERATE].known = TRUE;
X	    Player.rank[LEGION]=COMMANDANT;
X	    Player.maxstr += 2;
X	    Player.str += 2;
X	    Player.maxcon += 2;
X	    Player.con += 2;
X	    mprint("You are awarded a vorpal sword, and mithril plate.");
X	    newitem = ((pob) calloc(1,sizeof(objtype)));
X	    *newitem = Objects[WEAPONID+31]; /* vorpal sword */
X	    newitem->known = 2;
X	    add_item_to_pack(newitem);
X	    newitem = ((pob) calloc(1,sizeof(objtype)));
X	    *newitem = Objects[ARMORID+11]; /* mithril plate */
X	    newitem->known = 2;
X	    mprint("You also receive a salary upgrade.");
X	    add_item_to_pack(newitem);
X	    Player.cash += 1000;
X	  }
X	}
X	else if (Player.rank[LEGION]==FORCE_LEADER) {
X	  if (Player.level-Merclevel < 13)
X	    mprint("Your request is denied.");
X	  else  {
X	    mprint("You have been promoted to Legion Colonel!");
X	    mprint("You now know the spell of Heroism.");
X	    mprint("Your next promotion is contingent on the return of");
X	    mprint("the Sword of the Dark Emperor.");
X	    mprint("If you don't meet him on a higher level, he may");
X	    mprint("be found as one of the Guardians on level 39.");
X	    Spells[S_HERO].known = TRUE;
X	    Player.rank[LEGION]=COLONEL;
X	    Player.maxstr++;
X	    Player.str++;
X	    Player.maxcon++;
X	    Player.con++;
X	    mprint("You are awarded a magic greatsword, and plate armor.");
X	    newitem = ((pob) calloc(1,sizeof(objtype)));
X	    *newitem = Objects[WEAPONID+5]; /* greatsword */
X	    newitem->plus = 5;
X	    newitem->known = 2;
X	    add_item_to_pack(newitem);
X	    newitem = ((pob) calloc(1,sizeof(objtype)));
X	    *newitem = Objects[ARMORID+8]; /* plate */
X	    newitem->known = 2;
X	    add_item_to_pack(newitem);
X	    mprint("You also receive a salary upgrade.");
X	    Player.cash += 500;
X	  }
X	}
X	else if (Player.rank[LEGION] == CENTURION) {
X	  if (Player.level-Merclevel < 7)
X	    mprint("You are not admitted to OCS.");
X	  else  {
X	    mprint("You are now a Legion Force-Leader!");
X	    mprint("You now know the Spell of Invulnerability.");
X	    Spells[S_INVULNERABLE].known = TRUE;
X	    Player.rank[LEGION]=FORCE_LEADER;
X	    Player.maxstr++;
X	    Player.str++;
X	    mprint("You are awarded a bastard sword, and plate mail.");
X	    newitem = ((pob) calloc(1,sizeof(objtype)));
X	    *newitem = Objects[WEAPONID+3]; /* bastard sword */
X	    newitem->known = 2;
X	    add_item_to_pack(newitem);
X	    newitem = ((pob) calloc(1,sizeof(objtype)));
X	    *newitem = Objects[ARMORID+7]; /* plate mail*/
X	    newitem->known = 2;
X	    add_item_to_pack(newitem);
X	    mprint("You also receive a salary upgrade.");
X	    Player.cash += 250;
X	  }
X	}
X	else if (Player.rank[LEGION]==LEGIONAIRE) {
X	  if (Player.level-Merclevel < 3)
X	    mprint("You do not get the promotion!");
X	  else  {
X	    mprint("You are now a Legion Centurion!");
X	    mprint("You now know the spell of Monster Detection.");
X	    Spells[S_MON_DET].known = TRUE;
X	    Player.rank[LEGION] = CENTURION;
X	    Player.maxcon++;
X	    Player.con++;
X	    mprint("You are awarded a broad sword, and chain mail.");
X	    newitem = ((pob) calloc(1,sizeof(objtype)));
X	    *newitem = Objects[WEAPONID+2]; /* broad sword */
X	    newitem->known = 2;
X	    add_item_to_pack(newitem);
X	    newitem = ((pob) calloc(1,sizeof(objtype)));
X	    *newitem = Objects[ARMORID+4]; /* plate mail*/
X	    newitem->known = 2;
X	    add_item_to_pack(newitem);
X	    mprint("You also receive a salary upgrade.");
X	    Player.cash += 100;
X	  }
X	}
X      }
X    }
X  }
X  xredraw();
X}
X
Xvoid l_castle()
X{
X  int i,done=FALSE;
X  char action;
X  if (Player.level < 3) {
X    mprint("You can't possibly enter the castle, you nobody!");
X    mprint("Come back when you are famous.");
X  }
X  else {
X    while (! done) {
X      menuclear();
X      menuprint("a: Ask for an audience with the Duke.\n");
X      menuprint("ESCAPE: Leave this seat of nobility.\n");
X      action = mgetc();
X      if (action == ESCAPE) done = TRUE;
X      else if (action == 'a') {
X	if (Player.rank[NOBILITY]<DUKE) {
X	  printm("\nHis Grace,");
X	  mprint(Duke);
X	  mprint("-- Duke of Rampart! <fanfare>");
X	}
X	if (Player.rank[NOBILITY]==0) {
X	  mprint("Well, sirrah, wouldst embark on a quest? [yn]");
X	  if (ynq() == 'y') {
X	    mprint("Splendid. Bring me the head of the Goblin King.");
X	    Player.rank[NOBILITY]=COMMONER;
X	  }
X	  else {
X	    mprint("You scoundrel! Guards! Take this blackguard away!");
X	    p_damage(25,UNSTOPPABLE,"castle guards for lese majeste");
X	    l_jail();
X	    done = TRUE;
X	  }
X	}
X	else if (Player.rank[NOBILITY]==COMMONER) {
X	  if ((i=inpack(CORPSEID,ML3+5))+1) {
X	    mprint("Good job, sirrah! I promote you to the rank of esquire.");
X	    conform_lost_object(Player.possessions[i]);
X	    Player.rank[NOBILITY]=ESQUIRE;
X	    gain_experience(100);
X	    mprint("Now that you have proved yourself true, another quest!");
X	    mprint("Bring me a suit of dragonscale armor.");
X	  }
X	  else mprint("Do not return until you achieve the quest, caitiff!");
X	}
X	else if (Player.rank[NOBILITY]==ESQUIRE) {
X	  if ((i=inpack(ARMORID+12,-1))+1) { 
X	    mprint("My thanks, squire. In return, I dub thee knight!");
X	    conform_lost_object(Player.possessions[i]);
X	    Player.rank[NOBILITY]=KNIGHT;
X	    gain_experience(1000);
X	    mprint("If thou wouldst please me further...");
X	    mprint("Bring to me the sword: Defender!");
X	    mprint("It is said to be in the possession of the Great Wyrm");
X	  }
X	  else mprint("Your quest is not yet complete, squire.");
X	}
X	else if (Player.rank[NOBILITY]==KNIGHT) {
X	  if ((i=inpack(WEAPONID+34,-1))+1) {
X	    mprint("Thanks, good sir knight.");
X	    mprint("Here are letters patent to a peerage!");
X	    conform_lost_object(Player.possessions[i]);
X	    Player.rank[NOBILITY]=LORD;
X	    gain_experience(10000);
X	    mprint("If you would do me a final service...");
X	    mprint("I require the Orb of Mastery. If you would be so kind...");
X	    mprint("By the way, you might find the Orb in the possession");
X	    mprint("Of the Elemental Master on Level 39");
X	  }
X	  else mprint("Greetings, sir. My sword? What, you don't have it?");
X	}
X	else if (Player.rank[NOBILITY]==LORD) {
X	  if ((i=inpack(ARTIFACTID+0,-1))+1) {
X	    mprint("My sincerest thanks, my lord.");
X	    mprint("You have proved yourself a true paragon of chivalry");
X	    mprint("I abdicate the Duchy in your favor....");
X	    mprint("Oh, you can keep the Orb, by the way....");
X	    Player.rank[NOBILITY]=DUKE;
X	    gain_experience(10000);
X	    strcpy(Duke,Player.name);
X	  }
X	  else mprint("I didn't really think you were up to the task....");
X	}
X	else if (Player.rank[NOBILITY]==DUKE)
X	  mprint("Hey, you ARE the Duke of Rampart.");
X      }
X    }
X  }
X  xredraw();
X}
X
Xvoid l_arena()
X{
X  char response;
X  pob newitem;
X  struct monster m;
X  int prize,value;
X  static int kills=0;
X
X  if (Player.rank[ARENA] == -1)
X    mprint("A gang of gladiators hurls you out by the scruff of your neck.");
X  else {
X    mprint("Rampart Coliseum");
X    menuclear();
X    menuprint("\na: Become a registered Gladiator");
X    menuprint("\nb: Enter the Games");
X    menuprint("\nESCAPE: leave this bloodstained pit");
X    response = mgetc();
X    if (response == 'a') {
X      if (Player.rank[ARENA]>0)
X	mprint("No more training until you kill something.");
X      else if (Player.rank[LEGION]>0)
X	mprint("We don't train no stinkin' mercs!");
X      else if (Player.str < 16)
X	mprint("Yer too weak to train!");
X      else {
X	mprint("Ok, yer now an Arena Trainee.");
X	mprint("Here's a wooden sword, and a shield");
X	newitem = ((pob) calloc(1,sizeof(objtype)));
X	*newitem = Objects[WEAPONID+17]; /* club */
X	add_item_to_pack(newitem);
X	newitem = ((pob) calloc(1,sizeof(objtype)));
X	*newitem = Objects[SHIELDID+2]; /* shield */
X	add_item_to_pack(newitem);
X	Player.rank[ARENA] = TRAINEE;
X	mprint("You've got 5000Au credit at the Gym.");
X	Gymcredit+=5000;
X      }
X    }
X    else if (response == 'b') {
X      printm("\nOK, we're arranging a match....");
X      switch(Player.rank[ARENA]*2+random_range(2)) {
X      case 0: 
X	nameprint(); mprint("the pencil-necked geek");
X	m = Monsters[ML1+9];
X	value = 0;
X	break;
X      case 1:
X	nameprint(); mprint("the hornet");
X	m = Monsters[ML0+0];
X	value = 0;
X	break;
X      case 2:
X	nameprint(); mprint("the goblin");
X	value = 2;
X	m = Monsters[ML1+6];
X	break;
X      case 3:
X	value = 1;
X	nameprint(); mprint("the grunt");
X	m = Monsters[ML1+0];
X	break;
X      case 4:
X	value = 2;
X	nameprint(); mprint("the ninja");
X	m = Monsters[ML2+0];
X	break;
X      case 5:
X	value = 1;
X	nameprint(); mprint("the salamander");
X	m = Monsters[ML3+0];
X	break;
X      case 6:
X	value = 2;
X	nameprint(); mprint("the lich");
X	m = Monsters[ML6+5];
X	break;
X      case 7:
X	value = 2;
X	nameprint(); mprint("the behemoth");
X	m = Monsters[ML7+0];
X	break;
X      case 8:
X      case 9:
X	value = 3;
X	mprint(Champion); ("the arena champion");
X	strcpy(m.monstring,Champion);
X	m = Monsters[ML7+3];
X	m.level = 20;
X	m.hp = Championlevel*20;
X	m.hit = Championlevel*2;
X	m.ac = Championlevel*2;
X	m.dmg = Championlevel;
X	m.xpv = Championlevel*Championlevel;
X	m.actions = min(10,Championlevel/3);
X	m.tactics = MM_GOOD;
X	break;
X      default:
X	mprint("You have a challenger:");
X	do 
X	  m = Monsters[random_range(ML9-ML0)+ML0];
X	while ((m.uniqueness != COMMON) || (m.dmg == 0));
X	morewait();
X	nameprint();
X	strcpy(Str1,"the ");
X	strcat(Str1,m.monstring);
X	mprint(Str1);
X	break;
X      }
X      m.attacked = TRUE;
X      mprint("You sure you want to fight? [yn]");
X      if (ynq()=='y') {
X	mprint("Then let the battle begin....");
X	m.x = Player.x; m.y = Player.y;
X	Arena = TRUE;
X	tacmode(&m);
X	Arena = FALSE;
X	if (m.hp>0) {
X	  mprint("You wimp! How could you disappoint our fans!");
X	  kills = 0;
X	  if (Player.rank[ARENA] < 5) {
X	    mprint("For your cowardice you are penalized 2500Au Gym credit!");
X	    Gymcredit-=2500;
X	  }
X	  else {
X	    mprint("A disappointed crowd thrashes you within inches...");
X	    mprint("You are kicked out of the gladiators' guild!");
X	    Player.rank[ARENA] = -1;
X	    Player.hp = -1;
X	  }
X	}
X	else {
X	  if (Player.rank[ARENA]==0)
X	    mprint("So big deal, you won. Do you expect a prize?");
X	  else {
X	    if (m.level == 20) {
X	      mprint("The crowd roars its approval!");
X	      mprint("You are the new Arena Champion!");
X	      Championlevel = Player.level;
X	      strcpy(Champion,Player.name);
X	    }
X	    kills+=value;
X	    mprint("Good fight!");
X	    mprint("Your prize is:");
X	    prize = m.level * m.level * m.level * 20;
X	    mnumprint(prize);
X	    mprint("Au");
X	    Player.cash+=prize;
X	    if ((kills > 3) && (Player.rank[ARENA] < 5)){
X	      kills = 0;
X	      mprint("You've been promoted to a stronger class!");
X	      Player.rank[ARENA]++;
X	      mprint("You are also entitled to additional training.");
X	      Gymcredit+=value*2500;
X	    }
X	  }
X	}
X      }
X      else {
X	mprint("What kind of gladiator are you, anyhow? A gladiolus?");
X	mprint("Oh, ha ha ha, that was a funny one. Oh, ha ha.");
X      }
X    }
X    xredraw();
X  }
X}
Xvoid l_altar()
X{
X  int i,j,done=FALSE,deity = Dungeon[Dlevel][Player.x][Player.y].aux;
X  char response;
X
X  switch(deity) {
X    default:
X      mprint("This rude altar has no markings.");
X      break;
X    case ODIN:
X      mprint("This granite altar is graven with a gallows.");
X      break;
X    case SET:
X      mprint("This sandstone altar has a black hand drawn on it.");
X      break;
X    case HECATE:
X      mprint("This silver altar is inlaid with a black crescent moon.");
X      break;
X    case ATHENA:
X      mprint("This golden altar is inscribed with an owl");
X      break;
X    case DESTINY:
X      mprint("This crystal altar is in the form of an omega.");
X      break;
X    case DRUID:
X      mprint("This oaken altar is ornately engraved with leaves.");
X      break;
X  }
X  menuclear();
X  menuprint("a: Pray to the deity of the altar.\n");
X  menuprint("ESCAPE: Leave this sacred ground.\n");
X  while(! done) {
X    response = mgetc();
X    if (response == 'a') {
X      done = TRUE;
X      if (Player.patron != deity) {
X	if (Player.patron) {
X	  Player.pow--;
X	  Player.maxpow--;
X	  switch(Player.patron) {
X	  case ODIN:
X	    mprint("Odin notices your lack of faith!");
X	    mprint("You are struck by a thunderbolt!");
X	    p_damage(Player.level*5,UNSTOPPABLE,"Odin's wrath");
X	    if (Player.hp > 0) {
X	      mprint("The bolt warps your feeble frame....");
X	      Player.maxcon = ((int)(Player.maxcon/2));
X	      Player.con = min(Player.con,Player.maxcon);
X	      Player.maxstr = ((int)(Player.maxstr/2));
X	      Player.con = min(Player.str,Player.maxstr);
X	      if (Player.primary != NULL) {
X		mprint("Your weapon disintegrates....");
X		conform_lost_object(Player.primary);
X	      }
X	      if (Player.armor != NULL) {
X		mprint("Your armor disintegrates....");
X		conform_lost_object(Player.armor);
X	      }
X	      if (Player.secondary != NULL) {
X		mprint("Your shield disintegrates....");
X		conform_lost_object(Player.secondary);
X	      }
X	      Player.patron = 0;
X	    }
X	    break;
X  	  case SET:
X	    mprint("Set notices your lack of faith!");
X	    mprint("You are blasted by a shaft of black fire!");
X	    p_damage(Player.level*5,UNSTOPPABLE,"Set's anger");
X	    if (Player.hp > 0) {
X	      mprint("You are wreathed in clouds of smoke.");
X	      for(i=0;i<MAXITEMS;i++) 
X		if ((Player.possessions[i] != NULL) &&
X		    (Player.possessions[i]->blessing > -1))
X		  conform_lost_object(Player.possessions[i]);
X	      Player.patron = 0;
X	      mprint("You feel Set's Black Hand on your heart....");
X	      Player.con = Player.maxcon = ((int) (Player.maxcon / 4));
X	    }
X	    break;
X	  case HECATE:
X	    mprint("Hecate notices your lack of faith!");
X	    mprint("You are zapped by dark moonbeams!");
X	    p_damage(Player.level*5,UNSTOPPABLE,"Hecate's malice");
X	    if (Player.hp > 0) {
X	      mprint("The beams leach you of magical power!");
X	      Player.maxpow = ((int) (Player.maxpow/5));
X	      Player.pow = min(Player.pow,Player.maxpow);
X	      for(i=0;i<NUMSPELLS;i++) 
X		Spells[i].known = FALSE;
X	      Player.patron = 0;
X	    }
X	    break;
X  	  case ATHENA:
X	    mprint("Athena notices your lack of faith!");
X	    mprint("You are zorched by godsfire!");
X	    if (Player.hp > 0) {
X	      mprint("The fire burns away your worldly experience!");
X	      Player.level = 0;
X	      Player.xp = 0;
X	      Player.maxhp = Player.hp = Player.con;
X	      Player.patron = 0;
X	      mprint("Your power is reduced by the blast!!!");
X	      Player.pow = Player.maxpow = ((int)Player.maxpow/3);
X	      Player.mana = min(Player.mana,calcmana());
X	    }
X	    break;
X	  case DESTINY:
X	    mprint("The Lords of Destiny ignore your lack of faith.");
X	    break;
X	  case DRUID:
X	    mprint("Your treachery to the ArchDruid has been noted.");
X	    if (random_range(2) == 1)
X	      Player.alignment += 20;
X	    else Player.alignment -= 20;
X	    break;
X	  }
X	}
X	else switch(deity) {
X	default:
X	  mprint("Some nameless god blesses you....");
X	  Player.hp = Player.maxhp;
X	  mprint("The altar crumbles to dust and blows away");
X	  Dungeon[Dlevel][Player.x][Player.y].locchar = FLOOR;
X	  Dungeon[Dlevel][Player.x][Player.y].p_locf = L_NO_OP;
X	  break;
X	case ODIN:
X	  if (Player.alignment > 0) {
X	    mprint("Odin hears your prayer!");
X	    mprint(Priest[ODIN]);
X	    mprint("personally blesses you.");
X	    mprint("You are now a lay devotee of Odin.");
X	    Clericlevel = Player.level;
X	    Player.patron = ODIN;
X	    Player.rank[PRIESTHOOD] = LAY;
X	    learnclericalspells(ODIN,LAY);
X	  }
X	  else mprint("Odin ignores you.");
X	    break;
X	case SET:
X	  if (Player.alignment < 0) {
X	    mprint("Set hears your prayer!");
X	    mprint(Priest[SET]);
X	    mprint("personally blesses you.");
X	    mprint("You are now a lay devotee of Set.");
X	    Clericlevel = Player.level;
X	    Player.patron = SET;
X	    Player.rank[PRIESTHOOD] = LAY;
X	    learnclericalspells(SET,LAY);
X	  }
X	  else mprint("Set ignores you.");
X	  break;
X	case ATHENA:
X	  if (Player.alignment > 0) {
X	    mprint("Athena hears your prayer!");
X	    mprint(Priest[ATHENA]);
X	    mprint("personally blesses you.");
X	    mprint("You are now a lay devotee of Athena.");
X	    Clericlevel = Player.level;
X	    Player.patron = ATHENA;
X	    Player.rank[PRIESTHOOD] = LAY;
X	    learnclericalspells(ATHENA,LAY);
X	  }
X	  else mprint("Athena ignores you.");
X	  break;
X	case HECATE:
X	  if (Player.alignment < 0) {
X	    mprint("Hecate hears your prayer!");
X	    mprint(Priest[HECATE]);
X	    mprint("personally blesses you.");
X	    mprint("You are now a lay devotee of Hecate.");
X	    Clericlevel = Player.level;
X	    Player.patron = HECATE;
X	    Player.rank[PRIESTHOOD] = LAY;
X	    learnclericalspells(HECATE,LAY);
X	  }
X	  else mprint("Hecate ignores you.");
X	  break;
X	case DRUID:
X	  if (abs(Player.alignment) < 10) {
X	    mprint(Priest[DRUID]);
X	    mprint("personally blesses you.");
X	    mprint("You are now a lay devotee of the Druids.");
X	    Clericlevel = Player.level;
X	    Player.patron = DRUID;
X	    Player.rank[PRIESTHOOD] = LAY;
X	    learnclericalspells(DRUID,LAY);
X	  }
X	  else {
X	    mprint("You hear a voice....");
X	    mprint("Only those who embody the Balance may become Druids.");
X	  }
X	  break;
X	case DESTINY:
X	  mprint("The Lords of Destiny could hardly care less.");
X	  mprint("But you can consider yourself now to be a lay devotee.");
X	  Clericlevel = Player.level;
X	  Player.patron = DESTINY;
X	  Player.rank[PRIESTHOOD] = LAY;
X	  break;
X	}
X      }
X      else {
X	if ((((deity == ODIN) || (deity == ATHENA)) && 
X	     (Player.alignment < 1)) ||
X	    (((deity == SET) || (deity == HECATE)) && 
X	     (Player.alignment > 1)) ||
X	    ((deity == DRUID) && (abs(Player.alignment) > 10))) {
X	  mprint("You have swerved from the One True Path!");
X	  mprint("Your deity is greatly displeased...");
X	  Player.xp -= Player.level*Player.level;
X	  Player.xp = max(0,Player.xp);
X	}
X	else if (Player.rank[PRIESTHOOD]==HIGHPRIEST)
X	  mprint("Your prayer gladdens your deity, but has no other effect.");
X	else if (Player.rank[PRIESTHOOD]== SPRIEST) {
X	  if (Player.level-Clericlevel <= Priestlevel[deity])
X	    mprint("Your prayers yield no results.");
X	  else hp_req_test(Clericlevel);
X	}
X	else if (Player.rank[PRIESTHOOD]==PRIEST) {
X	  if (Player.level-Clericlevel < 13)
X	    mprint("Your prayers yield no results.");
X	  else  {
X	    mprint("Your deity raises you to the post of Senior Priest");
X	    hp_req_print();
X	    Player.rank[PRIESTHOOD] = SPRIEST;
X	  }
X	}
X	else if (Player.rank[PRIESTHOOD]==ACOLYTE) {
X	  if (Player.level-Clericlevel < 7)
X	    mprint("Your prayers yield no results.");
X	  else  {
X	    mprint("Your deity raises you to the post of Priest");
X	    Player.rank[PRIESTHOOD] = PRIEST;
X	    learnclericalspells(deity,PRIEST);
X	  }
X	}
X	else if (Player.rank[PRIESTHOOD]==LAY) {
X	  if (Player.level-Clericlevel < 3)
X	    mprint("Your prayers yield no results.");
X	  else  {
X	    mprint("Your deity raises you to the post of Acolyte");
X	    Player.rank[PRIESTHOOD] = ACOLYTE;
X	    learnclericalspells(deity,ACOLYTE);
X	  }
X	}
X      }
X    }
X    else if (response == ESCAPE) done = TRUE;
X  }
X  xredraw();
X}
X
X
Xvoid hp_req_test(entrylevel)
Xint entrylevel;
X{
X  int i,j,k,l,ok=FALSE;
X  switch  (Player.patron) {
X  case ODIN:
X    if ((i=inpack(ARTIFACTID+17,-1))+1)
X      make_hp(i,entrylevel);
X    else hp_req_print();
X    break;
X  case SET:
X    if ((i=inpack(ARTIFACTID+14,-1))+1)
X      make_hp(i,entrylevel);
X    else hp_req_print();
X    break;
X  case ATHENA:
X    if ((i=inpack(ARTIFACTID+15,-1))+1)
X      make_hp(i,entrylevel);
X    else hp_req_print();
X    break;
X  case HECATE:
X    if ((i=inpack(ARTIFACTID+16,-1))+1)
X      make_hp(i,entrylevel);
X    else hp_req_print();
X    break;
X  case DRUID:
X    if ((i=inpack(ARTIFACTID+14,-1))+1)
X      make_hp(i,entrylevel);
X    else if ((i=inpack(ARTIFACTID+15,-1))+1)
X      make_hp(i,entrylevel);
X    else if ((i=inpack(ARTIFACTID+16,-1))+1)
X      make_hp(i,entrylevel);
X    else if ((i=inpack(ARTIFACTID+17,-1))+1)
X      make_hp(i,entrylevel);
X    else hp_req_print();
X    break;
X  case DESTINY:
X    if ((i=inpack(ARTIFACTID+19,-1))+1)
X      make_hp(i,entrylevel);
X    else hp_req_print();
X    break;
X  }
X}
X
X
Xvoid hp_req_print()
X{
X  mprint("To advance further, you must obtain the Holy Symbol of");
X  switch(Player.patron) {
X  case ODIN:
X    mprint(Priest[SET]);
X    mprint("whose Temple of the Black Hand is somewhere on levels 34 to 38");
X    break;
X  case SET:
X    mprint(Priest[ODIN]);
X    mprint("whose Shrine of the Noose is somewhere on levels 34 to 38");
X    break;
X  case ATHENA:
X    mprint(Priest[HECATE]);
X    mprint("whose Church of the Far Side is somewhere on levels 34 to 38");
X    break;
X  case HECATE:
X    mprint(Priest[ATHENA]);
X    mprint("whose Parthenon is somewhere on levels 34 to 38");
X    break;
X  case DRUID:
X    mprint("any of the aligned priests");
X    mprint("whose temples are somewhere on levels 34 to 38");
X    break;
X  case DESTINY:
X    mprint(Priest[DESTINY]);
X    mprint("whose Hall of Fate is somewhere on levels 34 to 38");
X    break;
X  }
X}
X
Xvoid make_hp(i,entrylevel)
Xint i,entrylevel;
X{
X  mprint("You notice a change in the symbol you carry....");
X  switch(Player.patron) {
X  case ODIN:
X    *(Player.possessions[i]) = Objects[ARTIFACTID+14];
X    break;
X  case SET:
X    *(Player.possessions[i]) = Objects[ARTIFACTID+15];
X    break;
X  case ATHENA:
X    *(Player.possessions[i]) = Objects[ARTIFACTID+16];
X    break;
X  case HECATE:
X    *(Player.possessions[i]) = Objects[ARTIFACTID+17];
X    break;
X  case DRUID:
X    *(Player.possessions[i]) = Objects[ARTIFACTID+18];
X    break;
X  case DESTINY:
X    *(Player.possessions[i]) = Objects[ARTIFACTID+19];
X    break;
X  }
X  Player.possessions[i]->known = 2;
X  Player.possessions[i]->charge = 17;
X  mprint("Your deity raises you to the post of High Priest!");
X  strcpy(Priest[Player.patron],Player.name);
X  Priestlevel[Player.patron] = Player.level - entrylevel;
X  Player.rank[PRIESTHOOD] = HIGHPRIEST;
X  learnclericalspells(Player.patron,HIGHPRIEST);
X}
END_OF_oguild.c
if test 40166 -ne `wc -c <oguild.c`; then
    echo shar: \"oguild.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f omega.programming.notes -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"omega.programming.notes\"
else
echo shar: Extracting \"omega.programming.notes\" \(3415 characters\)
sed "s/^X//" >omega.programming.notes <<'END_OF_omega.programming.notes'
XPRERELEASE VERSION: 0.xx (alpha).
X
XThese versions should basically be considered a "sampler". While it is
Xcertainly playable, and more or less bug-free (ha!), the final version
Xwill be much better, as well as probably being about 3/2 the size,
Xeven considering the savings when my space-consuming ugly code is
Xcleaned up. In general, the final version will have more
X"intelligence" than this version, as well as having features such as
Xmultiple dungeons, more player interaction, smarter monsters, etc.
X
XDespite my best intentions, I have to admit that this program is a
Xhack.  Hopefully future releases will have cleaner code, but 'til then
Xyou will see a melange of poor programming practices, misfeatures, and
Xdownright bugs. In particular, the code is rather comment-free....
X
X
XNotes on the Code:
X
XAs far as I can tell, all this should work on any Unix* system, but
XI've never tried it on anything but a Sun-3, not having enough disk
Xspace to my name anywhere else to try.... It uses curses for I/O, and
Xtries to use as few OS-dependent functions as it can elsewhere. It
Xshould be pretty easy to port to any Unix* variant that has curses.
X
XCONSTANTS are all #defined in odefs.h
XGlobals are all defined in o.c and externally declared in oglob.h
Xother identifiers look out for themselves
X
XI have attempted to keep extremely system-dependent stuff segregated
Xfrom the rest of the code.
X
XFor example, all screen manipulation functions are in oscr.c, for
Xthose of you who want to port omega to something that doesn't have
Xcurses. (Well, there's a little in ofile.c)
X
XAlmost all file manipulation is done in ofile.c, and I have attempted
Xto keep this simple and consistent.
X
XUnfortunately, commenting is pretty minimal, mostly stupid things like:
X
X  /* this routine shows a monster */
X  void showmonster(m)
X
X...and abstruse reminders to myself. As I clean the code up for the
Xfinal release version, this will improve. I usually try to avoid
Xcleverness in my c code, preferring two assignments and an if
Xstatement to a single complex line with three nested conditional
Xexpressions. Still, there are some places where the code is pretty
Xopaque... sorry about that. 
X
XEach module has a short description of its contents at the top, and
Xmostly functions tend to stay where it is reasonable to find them.
XThere are a few grab-bag modules, though, such as oaux1 and oaux2
X(utility functions for ocom and other modules), oetc (total grab-bag),
Xand outil (mostly more general utility functions used by everything).
X
XAll functions are seperately defined, declared, and extern defined in
Xeach module that it is appropriate to do so, that's something. At
Xleast lint will not complain about my code.... not much, anyhow.
X
XThose of you wishing to port omega to machines without virtual memory
Xwill probably want to keep only one dungeon level in memory at a time
X(the whole 40x64x64 dungeon is in memory right now); you ought to be
Xable to use the save_level and restore_level routines in olev.c to get
Xthat working.
X
XI can always answer any questions you have, of course....
X
X-Laurence,
X
X			 Laurence R. Brothers
X		      brothers@paul.rutgers.edu
X            {anywhere}!rutgers!paul.rutgers.edu!brothers
X		       "One life -- one arrow."
X
X
X* Ha, I bet you were expecting some different message. Well, this is not
Xa commercial document or a public net announcement, so I don't see
Xwhy I have to credit Bell Labs or UCB. So there.
END_OF_omega.programming.notes
if test 3415 -ne `wc -c <omega.programming.notes`; then
    echo shar: \"omega.programming.notes\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f outil.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"outil.c\"
else
echo shar: Extracting \"outil.c\" \(10756 characters\)
sed "s/^X//" >outil.c <<'END_OF_outil.c'
X/* copyright (c) 1987 by Laurence Raphael Brothers */
X/* outils.c */
X
X#include <stdio.h>
X#include "oglob.h"
X
X
X/* from oscr */
Xextern void plotchar(),levelrefresh(),plotspot();
Xextern char ynq();
X
Xint inbounds(),random_range(),hitp(),sign(),max(),min(),distance();
Xint unblocked(),los_p(),screenmod(),offscreen(),pow2(),calc_points();
Xint bitp(),nighttime(),hour(),showhour(),day();
Xint view_unblocked(),m_unblocked();
Xint view_los_p(),confirmation();
Xchar inversedir(),*getarticle(),*ordinal(),*month();
Xvoid initdirs(),do_los(),do_object_los(),bitset(),bitreset();
Xvoid findspace(); 
X
X/* from oaux */
Xextern int item_value();
X
X/* x and y on level? */
Xint inbounds(x,y)
Xint x,y;
X{
X  if ((x<0)||(y<0)||(x>WIDTH-1)||(y>LENGTH-1)) return(FALSE);
X  else return(TRUE);
X}
X
Xint random_range(k)
Xint k;
X{
Xreturn( k==0 ? 0 : ((int) random()) % k ) ;
X}
X
X
X/* modify y coord relative to which part of level we are on */
Xint screenmod(y)
Xint y;
X{
X  switch(WhichScreen) {
X  case 0:return(y+2);break;
X  case 1:return(y+2-EDGE1);break;
X  case 2:return(y+2-EDGE2);break;
X  case 3:return(y+2-EDGE3);break;
X  }
X}
X
X
Xint offscreen(y)
Xint y;
X{
X  switch(WhichScreen) {
X  case 0: return((y<0)||(y>EDGE1+1));
X  case 1: return((y<EDGE1-1)||(y>EDGE2+1));
X  case 2: return((y<EDGE2-1)||(y>EDGE3+1));
X  case 3: return((y<EDGE3-1)||(y>BOTTOMEDGE));
X  }
X}
X
Xint hitp(hit,ac)
Xint hit,ac;
X{
X  int roll = random_range(20);
X  if (roll == 0) return(TRUE);
X  else if (roll == 19) return(FALSE);
Xelse return((roll < (hit - ac)) ? TRUE : FALSE );
X}
X
X
X
X/* this function doesnt seem to exist by itself... */
Xint sign(n)
Xint n;
X{
X  if (n == 0) return(0);
X  else return((n < 0) ? -1 : 1);
X}
X
X
X/* why load the math library.... */
Xint max(a,b)
Xint a,b;
X{
X  return((a>b) ? a : b);
X}
X
X/* why load the math library.... */
Xint min(a,b)
Xint a,b;
X{
X  return((a<b) ? a : b);
X}
X
X
X/* number of moves from x1,y1 to x2,y2 */
Xint distance(x1,y1,x2,y2)
Xint x1,y1,x2,y2;
X{
X  return(max(abs(x2-x1),abs(y2-y1)));
X}
X
X
X/* can you shoot, or move monsters through a spot? */
Xint unblocked(x,y)
Xint x,y;
X{
X  if ((! inbounds(x,y)) ||
X      (Dungeon[Dlevel][x][y].creature != NULL) ||
X      (Dungeon[Dlevel][x][y].locchar == WALL) ||
X      (Dungeon[Dlevel][x][y].locchar == STATUE) ||
X      (Dungeon[Dlevel][x][y].locchar == HEDGE) ||
X      (Dungeon[Dlevel][x][y].locchar == WHIRLWIND) ||
X      (Dungeon[Dlevel][x][y].locchar == CLOSED_DOOR) ||
X      (Dungeon[Dlevel][x][y].secret) ||
X      ((x==Player.x) && (y==Player.y)))
X    return(FALSE);
X  else 
X    return(TRUE);
X}
X
X
X/* do monsters want to move through a spot */
Xint m_unblocked(m,x,y)
Xstruct monster *m;
Xint x,y;
X{
X  if ((! inbounds(x,y)) ||
X      (Dungeon[Dlevel][x][y].creature != NULL) ||
X      (Dungeon[Dlevel][x][y].locchar == WALL) ||
X      (Dungeon[Dlevel][x][y].locchar == STATUE) ||
X      (Dungeon[Dlevel][x][y].locchar == WHIRLWIND) ||
X      (Dungeon[Dlevel][x][y].secret) ||
X      ((x==Player.x) && (y==Player.y)))
X    return(FALSE);
X  else if (m_statusp(m,SWIMMING) &&
X	   (Dungeon[Dlevel][m->x][m->y].locchar==WATER) &&
X	   (Dungeon[Dlevel][x][y].locchar==WATER))
X    return(FALSE);
X  else if (Dungeon[Dlevel][x][y].locchar == CLOSED_DOOR) {
X    if ((m->movef==M_MOVE_SPIRIT) || (m->movef==M_MOVE_SMART))
X      return(TRUE);
X    else return(FALSE);
X  }
X  else if (m_statusp(m,FLYING)) return(TRUE);
X  else if (Dungeon[Dlevel][x][y].locchar == LAVA)
X    return(m_immunityp(m,FLAME) && m_statusp(m,SWIMMING));
X  else if (Dungeon[Dlevel][x][y].locchar == WATER)
X    return(m_statusp(m,SWIMMING));
X  else if (Dungeon[Dlevel][x][y].locchar == FIRE)
X    return(m_immunityp(m,FLAME));
X  else if ((Dungeon[Dlevel][x][y].locchar == TRAP) ||
X	   (Dungeon[Dlevel][x][y].locchar == HEDGE) ||
X	   (Dungeon[Dlevel][x][y].locchar == ABYSS))
X    return(FALSE);
X  else return(TRUE);
X}
X
X
X
X/* can you see through a spot? */
Xint view_unblocked(x,y)
Xint x,y;
X{
X  if (! inbounds(x,y)) return(FALSE);
X  else if ((Dungeon[Dlevel][x][y].locchar == WALL) ||
X	   (Dungeon[Dlevel][x][y].locchar == STATUE) ||
X	   (Dungeon[Dlevel][x][y].locchar == HEDGE) ||
X	   (Dungeon[Dlevel][x][y].locchar == FIRE) ||
X	   (Dungeon[Dlevel][x][y].locchar == WHIRLWIND) ||
X	   (Dungeon[Dlevel][x][y].locchar == CLOSED_DOOR) ||
X	   (Dungeon[Dlevel][x][y].secret))
X    return(FALSE);
X  else 
X    return(TRUE);
X}
X
X
X/* 8 moves in Dirs */
Xvoid initdirs()
X{
X  Dirs[0][0] = 1;
X  Dirs[0][1] = 1;
X  Dirs[0][2] = -1;
X  Dirs[0][3] = -1;
X  Dirs[0][4] = 1;
X  Dirs[0][5] = -1;
X  Dirs[0][6] = 0;
X  Dirs[0][7] = 0;
X  Dirs[0][8] = 0;
X  Dirs[1][0] = 1;
X  Dirs[1][1] = -1;
X  Dirs[1][2] = 1;
X  Dirs[1][3] = -1;
X  Dirs[1][4] = 0;
X  Dirs[1][5] = 0;
X  Dirs[1][6] = 1;
X  Dirs[1][7] = -1;
X  Dirs[1][8] = 0;
X}
X
X
X
X
X
X/* do_los moves pyx along a lineofsight from x1 to x2 */
X/* x1 and x2 are pointers because as a side effect they are changed */
X/* to the final location of the pyx */
Xvoid do_los(pyx,x1,y1,x2,y2)
Xchar pyx;
Xint *x1,*y1,x2,y2;
X{
X  int ox,oy,sx,sy,v;
X
X  do {
X    ox = *x1;
X    oy = *y1;
X    sx=sign(x2-*x1);
X    sy=sign(y2-*y1);
X    if (abs(x2-*x1) > abs(y2-*y1))
X      *x1 += sx;
X    else if (abs(x2-*x1) < abs(y2-*y1))
X      *y1 += sy;
X    else {
X      *x1 += sx;
X      *y1 += sy;
X    }
X    Dungeon[Dlevel][*x1][*y1].showchar = pyx;
X    /* delay enough to make pyx visible */
X    for(v=1;v<10;v++) plotchar(pyx,*x1,*y1);
X    plotspot(ox,oy,TRUE);
X  } while(unblocked(*x1,*y1) && ((*x1 != x2) || (*y1 != y2)));
X  
X  plotspot(*x1,*y1,TRUE);
X  levelrefresh();
X}
X
X
X/* This is the same as do_los, except we stop before hitting nonliving
Xobstructions */
Xvoid do_object_los(pyx,x1,y1,x2,y2)
Xchar pyx;
Xint *x1,*y1,x2,y2;
X{
X  int ox,oy,sx,sy,v;
X
X  do {
X    ox = *x1;
X    oy = *y1;
X    sx=sign(x2-*x1);
X    sy=sign(y2-*y1);
X    if (abs(x2-*x1) > abs(y2-*y1))
X      *x1 += sx;
X    else if (abs(x2-*x1) < abs(y2-*y1))
X      *y1 += sy;
X    else {
X      *x1 += sx;
X      *y1 += sy;
X    }
X    if (unblocked(*x1,*y1)) {
X      for(v=1;v<10;v++) plotchar(pyx,*x1,*y1);
X      Dungeon[Dlevel][*x1][*y1].showchar = pyx;
X    }
X    plotspot(ox,oy,TRUE);
X  } while(unblocked(*x1,*y1) && ((*x1 != x2) || (*y1 != y2)));
X  
X  if ((! unblocked(*x1,*y1)) && (Dungeon[Dlevel][*x1][*y1].creature == NULL)) {
X    *x1 = ox;
X    *y1 = oy;
X  }
X  plotspot(*x1,*y1,TRUE);
X  levelrefresh();
X}
X      
X    
X
X
X/* los_p checks to see whether there is an unblocked los from x1,y1 to x2,y2 */
Xint los_p(x1,y1,x2,y2)
Xint x1,y1,x2,y2;
X{
X  int sx,sy;
X  do {
X    sx=sign(x2-x1);
X    sy=sign(y2-y1);
X    if (abs(x2-x1) > abs(y2-y1))
X      x1 += sx;
X    else if (abs(x2-x1) < abs(y2-y1))
X      y1 += sy;
X    else {
X      x1 += sx;
X      y1 += sy;
X    }
X  } while (unblocked(x1,y1) && ((x1 != x2) || (y1 != y2)));
X  return((x1==x2) && (y1==y2));
X}
X
X
X/* view_los_p sees through monsters */
Xint view_los_p(x1,y1,x2,y2)
Xint x1,y1,x2,y2;
X{
X  int sx,sy;
X  do {
X    sx=sign(x2-x1);
X    sy=sign(y2-y1);
X    if (abs(x2-x1) > abs(y2-y1))
X      x1 += sx;
X    else if (abs(x2-x1) < abs(y2-y1))
X      y1 += sy;
X    else {
X      x1 += sx;
X      y1 += sy;
X    }
X  } while (view_unblocked(x1,y1) && ((x1 != x2) || (y1 != y2)));
X  return((x1==x2) && (y1==y2));
X}
X
X
X
X
X/* why load the math library.... */
Xint pow2(n)
Xint n;
X{
X  switch(n) {
X    case 0: return(1);break;
X    case 1: return(2);break;
X    case 2: return(4);break;
X    case 3: return(8);break;
X    case 4: return(16);break;
X    case 5: return(32);break;
X    case 6: return(64);break;
X    case 7: return(128);break;
X    case 8: return(256);break;
X    case 9: return(512);break;
X    case 10: return(1024);break;
X    case 11: return(2048);break;
X    case 12: return(4096);break;
X    case 13: return(8192);break;
X    case 14: return(16384);break;
X    case 15: return(32768);break;
X    default: return(-1);break;
X  }
X}
X
X
Xint bitp(bv,flag)
Xint bv,flag;
X{
X  return(bv & flag);
X}
X
Xvoid bitset(pbv,flag)
Xint *pbv,flag;
X{
X  *pbv |= flag;
X}
X
Xvoid bitreset(pbv,flag)
Xint *pbv,flag;
X{
X  *pbv -= ( bitp(*pbv,flag) ? flag : 0);
X}
X
X
X
X
X/* returns the command direction from the index into Dirs */
Xchar inversedir(dirindex)
Xint dirindex;	  
X{
X  switch (dirindex) {
X    case 0:return('n');break;
X    case 1:return('u');break;
X    case 2:return('b');break;
X    case 3:return('y');break;
X    case 4:return('l');break;
X    case 5:return('h');break;
X    case 6:return('j');break;
X    case 7:return('k');break;
X  }
X}
X
X
Xint calc_points()
X{
X  int i,points=0;
X  
X  for(i=0;i<MAXITEMS;i++)
X    if (Player.possessions[i] != NULL)
X      points += Player.possessions[i]->level;
X  points += Deepest*5;
X  points += 10*Player.level;
X  for (i=0;i<NUMRANKS;i++)
X    points += 10*Player.rank[i];
X  if (Player.hp < 0)
X    points = (points / 2);
X  else if (Player.rank[ADEPT])
X    points *= 10;
X  return(points);
X}
X
Xint hour()
X{
X  return(((int) ((Time+1200) / 100)) % 24);
X}
X
Xint showhour()
X{
X  int showtime;
X  if ((hour() == 0) || (hour() == 12)) showtime = 12;
X  else showtime = (hour() % 12);
X  return(showtime);
X}
X
Xint nighttime()
X{
X  return((hour() > 20) || (hour() < 7));
X}
X
Xchar *getarticle(str)
Xchar *str;
X{
X  if ((str[0]=='a') ||
X      (str[0]=='e') ||
X      (str[0]=='i') ||
X      (str[0]=='o') ||
X      (str[0]=='u') ||
X      (str[0]=='h'))
X    return("an ");
X  else return("a ");
X}
X
Xint day()
X{
X  return ((Date % 30) + 1);
X}
X
Xchar *ordinal(number)
Xint number;
X{
X  if ((number == 11) || (number == 12) || (number == 13)) return("th");
X  else  switch(number % 10) {
X    case 1:return("st");break;
X    case 2:return("nd");break;
X    case 3:return("rd");break;
X    default: return("th");break;
X  }
X}
X	   
Xchar *month()
X{
X  switch((Date % 360) / 30) {
X    case 0: return("Freeze"); break;
X    case 1: return("Ice"); break;
X    case 2: return("Mud"); break;
X    case 3: return("Storm"); break;
X    case 4: return("Breeze"); break;
X    case 5: return("Light"); break;
X    case 6: return("Flame"); break;
X    case 7: return("Broil"); break;
X    case 8: return("Cool"); break;
X    case 9: return("Haunt"); break;
X    case 10: return("Chill"); break;
X    case 11: return("Dark"); break;
X    case 12: return("Twixt"); break;
X  }
X}
X
X
X/* finds an empty space, sets x,y */
Xvoid findspace(x,y)
Xint *x,*y;
X{
X  do {
X    *x = random_range(WIDTH);
X    *y = random_range(LENGTH);
X  } while ((Dungeon[Dlevel][*x][*y].locchar != FLOOR) ||
X	   (Dungeon[Dlevel][*x][*y].creature != NULL));
X}
X
X/* is prefix a prefix of s? */
Xint strprefix(prefix,s)
Xchar *prefix,*s;
X{
X  int i=0,matched=TRUE;
X  if (strlen(prefix) > strlen(s)) return(FALSE);
X  else {
X    while (matched && (i<strlen(prefix))) {
X      matched = (prefix[i] == s[i]);
X      i++;
X    }
X    return(matched);
X  }
X}
X
Xint confirmation()
X{
X  switch(random_range(4)) {
X  case 0:  mprint("Are you sure? [yn]"); break;
X  case 1:  mprint("Certain about that? [yn]"); break;
X  case 2:  mprint("Do you really mean it? [yn]"); break;
X  case 3:  mprint("Confirm that, would you? [yn]"); break;
X  }
X  return(ynq()=='y');
X}
END_OF_outil.c
if test 10756 -ne `wc -c <outil.c`; then
    echo shar: \"outil.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 4 \(of 15\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 15 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