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

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

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

#! /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 13 (of 15)."
# Contents:  oeffect1.c oitem.c omega.intro
# Wrapped by billr@tekred on Mon Jan 18 10:20:46 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f oeffect1.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"oeffect1.c\"
else
echo shar: Extracting \"oeffect1.c\" \(29791 characters\)
sed "s/^X//" >oeffect1.c <<'END_OF_oeffect1.c'
X/* omega copyright (C) by Laurence Raphael Brothers, 1987 */
X/* oeffect1.c */
X
X#include <strings.h>
X#include "oglob.h"
X
X/* from omove.c */
Xextern void l_trap_disintegrate();
X
X/* from oaux */
Xextern void setspot(),roomcheck(),tunnelcheck();
Xextern void calc_melee(),p_death();
Xextern void p_damage(),damage_item();
Xextern int p_immune();
Xextern char *spellid();
X
X/* from oinv */
Xextern void drop_at(),pickup_at(),add_item_to_pack(),conform_lost_objects();
Xextern void conform_unused_object();
Xextern int getitem();
X
X
X/* from oitem */
Xextern int i_nothing();
Xextern void make_potion(), make_scroll(), make_ring(), make_stick();
Xextern void make_armor(), make_shield(), make_weapon(), make_boots();
Xextern void make_cloak(),make_food(),make_artifact(),make_thing();
Xextern void item_use();
X
X
X/* from omon */
Xextern void m_damage(),m_status_set(),m_status_reset(),m_death();
Xextern struct monster *make_creature(),*m_create();
Xextern int m_immunityp();
X
X/* from outil */
Xextern int random_range(),inbounds(),hitp(),cursed();
Xextern void do_los(),findspace();
X
X
X/* from oscr */
Xextern void mprint(),printm(),morewait(),drawvision();
Xextern void draw_explosion(),erase_level(),plotmon(),menuprintitem();
Xextern void levelrefresh(),menuclear(),screencheck();
Xextern void show_screen(),putspot(),menuprint(),plotspot();
Xextern void clearmsg(),xredraw(),drawspot(),showflags();
Xextern char mgetc(),*msgscanstring();
X
X
X
X/* oeffect functions */
Xvoid bless(),identify(),bolt(),ball(),megawish(),amnesia();
Xvoid heal(),mondet(),objdet(),enchant(),wish(),manastorm();
Xvoid acquire(),cleanse(),annihilate(),sleep_monster(),apport();
Xvoid sleep_player(),summon(),hide(),clairvoyance(),aggravate(),p_poison();
Xvoid fbolt(),lbolt(),lball(),fball(),nbolt(),learnspell(),level_drain();
Xvoid disintegrate(),disrupt(),snowball(),p_teleport();
X
Xint random_item(),itemlist(),monsterlist();
X
X/* enchant */
Xvoid enchant(delta)
Xint delta;
X{
X  int i,used = FALSE;
X  float mult;
X
X  if (delta < 0) {
X    i = random_item();
X    if (i == ABORT) mprint("You feel fortunate.");
X    else {
X      if (Player.possessions[i]->blessing < 0)
X	mprint("The item glows, but the glow flickers out...");
X      else {
X	used = (Player.possessions[i]->used);
X	if (used) {
X	  Player.possessions[i]->used = FALSE;
X	  item_use(Player.possessions[i]);
X	} 
X	mprint("An aura of mundanity surrounds you!");
X	Player.possessions[i]->plus = 0;
X	Player.possessions[i]->charge = -1;
X	Player.possessions[i]->usef = I_NOTHING;
X	if (used) {
X	  Player.possessions[i]->used = TRUE;
X	  item_use(Player.possessions[i]);      
X	}
X      }
X    }
X  }
X  else {
X    i = getitem(NULL);
X    if (i == ABORT) mprint("You feel unlucky.");
X    else if (i == CASHVALUE) {
X      mprint("You enchant your money.... What a concept!");
X      mult = 1 + (random_range(7)-3)/6.0;
X      if (mult > 1.0) mprint("Seems to have been a good idea!");
X      else mprint("Maybe it wasn't such a good idea....");
X      Player.cash = ((int) (mult*Player.cash));
X    }
X    else {
X      i -= 'a';
X      if (Player.possessions[i]->plus > random_range(20)+1) {
X	mprint("Uh-oh, the force of the enchantment was too much!");
X	mprint("There is a loud explosion!");
X	manastorm(Player.x,Player.y,Player.possessions[i]->plus*5);
X	conform_lost_objects(1,Player.possessions[i]);
X      }
X      else {
X	used = (Player.possessions[i]->used);
X	if (used) {
X	  SuppressPrinting = TRUE;
X	  Player.possessions[i]->used = FALSE;
X	  item_use(Player.possessions[i]);
X	  SuppressPrinting = FALSE;
X	}
X	mprint("The item shines!");
X	Player.possessions[i]->plus += delta+1;
X	if (Player.possessions[i]->charge > -1)
X	  Player.possessions[i]->charge += 
X	    ((delta+1) * (random_range(10) + 1));
X	if (used) {
X	  SuppressPrinting = TRUE;
X	  Player.possessions[i]->used = TRUE;
X	  item_use(Player.possessions[i]);      
X	  SuppressPrinting = FALSE;
X	}
X      }
X    }
X    calc_melee();
X  }
X}
X
X/* bless */
Xvoid bless(blessing)
Xint blessing;
X{
X  int index,used;
X
X  if (blessing < 0) {
X    index = random_item();
X    if (index == ABORT) mprint("You feel fortunate.");
X    else {
X      mprint("A foul odor arises from your pack... ");
X      used = (Player.possessions[index]->used);
X      if (used) {
X	SuppressPrinting = TRUE;
X	Player.possessions[index]->used = FALSE;
X	item_use(Player.possessions[index]);
X	SuppressPrinting = FALSE;
X      }
X      Player.possessions[index]->blessing -= 2;
X      if (Player.possessions[index]->blessing < 0) 
X	Player.possessions[index]->plus =
X	  abs(Player.possessions[index]->plus) - 1;
X      if (used) {
X	SuppressPrinting = TRUE;
X	Player.possessions[index]->used = TRUE;
X	item_use(Player.possessions[index]);      
X	SuppressPrinting = FALSE;
X      }
X    }
X  }
X  else {
X    index = getitem(NULL);
X    if (index == CASHVALUE) mprint("Blessing your money has no effect.");
X    else if (index != ABORT) {
X      index -= 'a';
X      used = (Player.possessions[index]->used == TRUE);
X      if (used) {
X	SuppressPrinting = TRUE;
X	Player.possessions[index]->used = TRUE;
X	item_use(Player.possessions[index]);      
X	SuppressPrinting = FALSE;
X      }
X      mprint("A pure white light surrounds the item... ");
X      if (Player.possessions[index]->blessing < 0-blessing)
X	mprint("which is evil enough to resist the effect of the blessing!");
X      else if (Player.possessions[index]->blessing < -1) {
X	mprint("which disintegrates under the influence of the holy aura!");
X	Player.itemweight -=  Player.possessions[index]->weight;
X	conform_lost_object(Player.possessions[index]);
X      }
X      else {
X	mprint("which now seems affected by afflatus!");
X	Player.possessions[index]->blessing++;
X	Player.possessions[index]->plus =
X	  abs(Player.possessions[index]->plus)+1;
X      }
X      if (used && (Player.possessions[index] != NULL)) {
X	SuppressPrinting = TRUE;
X	Player.possessions[index]->used = TRUE;
X	item_use(Player.possessions[index]);     
X	SuppressPrinting = FALSE;
X      } 
X    }
X  }
X  calc_melee();
X}
X
X
X
Xvoid heal(amount)
Xint amount;
X{
X  if (amount > -1) {
X    mprint("You feel better.");
X    Player.hp += random_range(10*amount)+1;
X    Player.status[BLINDED] = 0;
X    if (Player.hp > Player.maxhp)
X      Player.hp = Player.maxhp + amount;
X  }
X  else {
X    mprint("You feel unwell.");
X    Player.hp -= random_range(10*abs(amount)+1);
X    if (Player.hp < 0)
X      p_death("magical disruption");
X  }
X}
X
X
Xvoid fbolt(fx,fy,tx,ty,hit,dmg)
Xint fx,fy,tx,ty,hit,dmg;
X{
X  bolt(fx,fy,tx,ty,hit,dmg,FLAME);
X}
X
Xvoid lbolt(fx,fy,tx,ty,hit,dmg)
Xint fx,fy,tx,ty,hit,dmg;
X{
X  bolt(fx,fy,tx,ty,hit,dmg,ELECTRICITY);
X}
X
Xvoid nbolt(fx,fy,tx,ty,hit,dmg)
Xint fx,fy,tx,ty,hit,dmg;
X{
X  bolt(fx,fy,tx,ty,hit,dmg,NORMAL_DAMAGE);
X}
X
X
X/* from f to t */
Xvoid bolt(fx,fy,tx,ty,hit,dmg,dtype)
Xint fx,fy,tx,ty,hit,dmg,dtype;
X{
X  int xx,yy;
X  struct monster *target;
X  char boltchar;
X  xx = fx; yy = fy;
X  
X  switch(dtype) {
X    case FLAME:boltchar='*';break;
X    case ELECTRICITY:boltchar = '^';break;
X    case NORMAL_DAMAGE:boltchar = '!';break;
X  }
X
X  do_los(boltchar,&xx,&yy,tx,ty);
X
X  if ((xx == Player.x) && (yy == Player.y)) {
X    switch (dtype) {
X      case FLAME:mprint("You were blasted by a firebolt!");break;
X      case ELECTRICITY:mprint("You were zapped by lightning!");break;
X      case NORMAL_DAMAGE:mprint("You were hit by a missile!"); break;
X    }
X    p_damage(random_range(dmg),dtype,"magic");
X  }
X  else if (NULL != (target = Dungeon[Dlevel][xx][yy].creature)) {
X    if (hitp(hit,target->ac)) {
X      if (target->uniqueness == COMMON) {
X	strcpy(Str1,"The ");
X	strcat(Str1,target->monstring);
X      }
X      else strcpy(Str1,target->monstring);
X      switch (dtype) {
X      case FLAME:strcat(Str1," was blasted by a firebolt!");break;
X      case ELECTRICITY:strcat(Str1," was zapped by lightning!");break;
X      case NORMAL_DAMAGE:strcat(Str1," was hit by a missile!"); break;
X      }
X      mprint(Str1);
X      m_status_set(target,HOSTILE);
X      m_damage(target,random_range(dmg),dtype);
X    }
X    else {
X      if (target->uniqueness == COMMON) {
X	strcpy(Str1,"The ");
X	strcat(Str1,target->monstring);
X      }
X      else strcpy(Str1,target->monstring);
X      switch (dtype) {
X      case FLAME:strcat(Str1," was missed by a firebolt!");break;
X      case ELECTRICITY:strcat(Str1," was missed by lightning!");break;
X      case NORMAL_DAMAGE:strcat(Str1," was missed by a missile!"); break;
X      }
X      mprint(Str1);
X    }
X  }
X  else if (Dungeon[Dlevel][xx][yy].locchar == HEDGE)
X    if (Dungeon[Dlevel][xx][yy].p_locf == L_HEDGE) {
X      if ((dtype == FLAME)||(dtype == ELECTRICITY)) {
X	mprint("The hedge is blasted away!");
X	Dungeon[Dlevel][xx][yy].p_locf = L_NO_OP;
X	Dungeon[Dlevel][xx][yy].locchar = FLOOR;
X      }
X      else mprint("The hedge is unaffected.");
X    }
X    else mprint("The trifid absorbs the energy and laughs!");
X  else if (Dungeon[Dlevel][xx][yy].locchar == WATER)
X    if (dtype == FLAME) {
X      mprint("The water is vaporised!");
X      Dungeon[Dlevel][xx][yy].p_locf = L_NO_OP;
X      Dungeon[Dlevel][xx][yy].locchar = FLOOR;
X    }
X}
X
X
Xvoid lball(fx,fy,tx,ty,dmg)
Xint fx,fy,tx,ty,dmg;
X{
X  ball(fx,fy,tx,ty,dmg,ELECTRICITY);
X}
X
Xvoid manastorm(x,y,dmg)
Xint x,y,dmg;
X{
X  ball(x,y,x,y,dmg,UNSTOPPABLE);
X}
X
Xvoid snowball(fx,fy,tx,ty,dmg)
Xint fx,fy,tx,ty,dmg;
X{
X  ball(fx,fy,tx,ty,dmg,COLD);
X}
X
Xvoid fball(fx,fy,tx,ty,dmg)
Xint fx,fy,tx,ty,dmg;
X{
X  ball(fx,fy,tx,ty,dmg,FLAME);
X}
X
X
X/* from f to t */
Xvoid ball(fx,fy,tx,ty,dmg,dtype)
Xint fx,fy,tx,ty,dmg,dtype;
X{
X  int xx,yy,ex,ey,i;
X  struct monster *target;
X  char expchar='@';
X
X  xx = fx; yy = fy;
X
X  switch(dtype){
X    case FLAME:expchar='*';break;
X    case COLD:expchar='o';break;
X    case ELECTRICITY:expchar='^';break;
X  }
X
X  do_los(expchar,&xx,&yy,tx,ty);
X  draw_explosion(expchar,xx,yy);
X  for(i=0;i<9;i++) {
X    ex = xx + Dirs[0][i];
X    ey = yy + Dirs[1][i];
X    
X    if ((ex == Player.x) && (ey == Player.y)) {
X      switch(dtype) {
X	case FLAME:mprint("You were blasted by a fireball!");
X	  p_damage(random_range(dmg),FLAME,"a fireball");
X	  break;
X	case COLD:mprint("You were blasted by a snowball!");
X	  p_damage(random_range(dmg),COLD,"a snowball");
X	  break;
X	case ELECTRICITY:mprint("You were blasted by ball lightning!");
X	  p_damage(random_range(dmg),ELECTRICITY,"ball lightning");
X	  break;
X	case UNSTOPPABLE:mprint("Oh No! Manastorm!");
X	  p_damage(random_range(dmg),UNSTOPPABLE,"a manastorm!");
X	  break;
X      }
X    }
X    else if (NULL != (target = Dungeon[Dlevel][ex][ey].creature)) {
X      if (los_p(Player.x,Player.y,target->x,target->y)) {
X      if (target->uniqueness == COMMON) {
X	strcpy(Str1,"The ");
X	strcat(Str1,target->monstring);
X      }
X      else strcpy(Str1,target->monstring);
X	switch(dtype) {
X	  case FLAME:strcat(Str1," was zorched by a fireball!"); break;
X	  case COLD:strcat(Str1," was blasted by a snowball!"); break;
X	  case ELECTRICITY:strcat(Str1," was zapped by ball lightning!");break;
X	  case UNSTOPPABLE:strcat(Str1," was nuked by a manastorm!");break;
X	}
X	mprint(Str1);
X      }
X      m_status_set(target,HOSTILE);
X      m_damage(target,random_range(dmg),dtype);
X    }
X    else if (Dungeon[Dlevel][ex][ey].locchar == HEDGE)
X      if (Dungeon[Dlevel][ex][ey].p_locf == L_HEDGE) {
X	if ((dtype == FLAME)||(dtype == ELECTRICITY)) {
X	  mprint("The hedge is blasted away!");
X	  Dungeon[Dlevel][ex][ey].p_locf = L_NO_OP;
X	  Dungeon[Dlevel][ex][ey].locchar = FLOOR;
X	}
X	else mprint("The hedge is unaffected.");
X      }
X      else mprint("The trifid absorbs the energy and laughs!");
X    else if (Dungeon[Dlevel][xx][yy].locchar == WATER)
X      if (dtype == FLAME) {
X	mprint("The water is vaporised!");
X	Dungeon[Dlevel][xx][yy].p_locf = L_NO_OP;
X	Dungeon[Dlevel][xx][yy].locchar = FLOOR;
X      }
X  }
X}
X
X
X
X
Xvoid mondet(blessing)
Xint blessing;    
X{
X  pml ml;
X  if (Dlevel == NUMLEVELS-1)
X    mprint("That's funny, no effect!");
X  else {
X    for (ml=Mlist[Dlevel];ml!=NULL;ml=ml->next) 
X      plotmon(blessing > -1 ? ml->m : &(Monsters[random_range(NUMMONSTERS)]));
X    levelrefresh();
X    if (blessing < 1) {
X      morewait();
X      erase_level();
X      show_screen(WhichScreen);
X    }
X  }
X} 
X
Xvoid objdet(blessing)
Xint blessing;     
X{
X  int i,j;
X if (Dlevel == NUMLEVELS-1)
X    mprint("That's funny, no effect!");
X  else {
X    for (i=0;i<WIDTH;i++)
X      for (j=0;j<LENGTH;j++) 
X	if (Dungeon[Dlevel][i][j].things != NULL) {
X	  if (blessing < 0)
X	    putspot(random_range(WIDTH),
X		    random_range(LENGTH),
X		    Dungeon[Dlevel][i][j].things->thing->objchar);
X	  else putspot(i,j,Dungeon[Dlevel][i][j].things->thing->objchar);
X	}
X    levelrefresh();
X    if (blessing < 1) {
X      morewait();
X      erase_level();
X      show_screen(WhichScreen);
X    }
X  } 
X}
X
Xvoid identify(blessing)
X{
X  int index;
X  int ok = FALSE;;
X
X  if (blessing == 0) {
X    printm("\nIdentify:");
X    index = getitem(NULL);
X    if (index == CASHVALUE) mprint("Your money is really money.");
X    if (index == ABORT)
X      Skipmonsters = TRUE;
X    else {
X      index -= 'a';
X      if (Player.possessions[index]->objchar == FOOD)
X	Player.possessions[index]->known = 1;
X      else {
X	Player.possessions[index]->known = 2;
X	Objects[Player.possessions[index]->id].known = 1;
X      }
X      printm("\nIdentified: ");
X      mprint(itemid(Player.possessions[index]));
X    }
X  }
X  else if (blessing < 0) {
X    mprint("You feel forgetful.");
X    for (index=0;index<MAXITEMS;index++) 
X      if (Player.possessions[index] != NULL) {
X	Player.possessions[index]->known = 0;
X	Objects[Player.possessions[index]->id].known = 0;
X      }
X  }
X  else {
X    mprint("You feel encyclopaedic.");
X    for (index=0;index<MAXITEMS;index++)
X      if (Player.possessions[index] != NULL) {
X	if (Player.possessions[index]->objchar == FOOD)
X	  Player.possessions[index]->known = 1;
X	else {
X	  Player.possessions[index]->known = 2;
X	  Objects[Player.possessions[index]->id].known = 1;
X	}
X      }
X  }
X  calc_melee();
X}
X
X
X
X
X/* returns index of random item, ABORT if player carrying none */
Xint random_item()
X{
X  int item,tries=0;
X  int done = FALSE;
X
X  while (! done) {
X    item = random_range(MAXITEMS);
X    done = ((tries == MAXITEMS) || (Player.possessions[item] != NULL));
X  }
X  return(done ? item : ABORT);
X}
X
X
X/* various kinds of wishes */
Xvoid wish(blessing)
Xint blessing;
X{
X  char wishtype;
X  
X  if (blessing == 0) {
X    wishtype = 'a'+random_range(5);
X    switch(wishtype) {
X      case 'a': mprint("A wish for acquiring."); break;
X      case 'b': mprint("A wish for cleansing."); break;
X      case 'c': mprint("A wish for healing."); break;
X      case 'd': mprint("A wish for annihilation."); break;
X      case 'e': mprint("A wish for summoning."); break;
X    }
X  }
X  else {
X    mprint("Wish for: ");
X    menuclear();
X    menuprint("a: acquiring\n");
X    menuprint("b: cleansing\n");
X    menuprint("c: healing\n");
X    menuprint("d: annihilation\n");
X    menuprint("e: summoning\n");
X    wishtype = mgetc();
X    clearmsg();
X  }
X  
X  if (blessing == 0) blessing = 1;
X  switch(wishtype) {
X    case 'a': acquire(blessing); break;
X    case 'b': cleanse(blessing); break;
X    case 'c': heal(10*blessing); break;
X    case 'd': annihilate(blessing); break;
X    case 'e': summon(blessing,-1); break;
X    case 'f': megawish(); break;
X    default:mprint("You feel stupid."); break;
X  }
X  xredraw();
X}
X
X/* gain for an item */
Xvoid acquire(blessing)
Xint blessing;
X{
X  char otype;
X  int index,id = ABORT;
X  pob newthing;
X
X  if (blessing < 0) {
X    index = random_item();
X    if (index == ABORT)
X      mprint("You feel fortunate.");
X    else {
X      mprint("Smoke drifts out of your pack.... ");
X      mprint("Destroyed... ");
X      mprint(itemid(Player.possessions[index]));
X      conform_lost_object(Player.possessions[index]);
X    }
X  }
X  else if (blessing == 0) {
X    newthing = ((pob) calloc(1,sizeof(objtype)));
X    *newthing = Objects[random_range(TOTALITEMS)];
X    newthing->used = FALSE;
X    mprint("An item appears in your pack.");
X    add_item_to_pack(newthing);
X  }
X  else {
X    newthing = ((pob) calloc(1,sizeof(objtype)));
X    newthing->id = -1;
X    
X    mprint("Acquire which kind of item: !?][}{)/=\%%\\");
X    otype = mgetc();
X    mprint("Item ID?");
X    switch (otype) {
X    case POTION: 
X      id = itemlist(POTIONID,NUMPOTIONS);
X      if (id < 0) mprint("You feel stupid."); 
X      else make_potion(newthing,id); 
X      break;
X    case SCROLL:
X      id = itemlist(SCROLLID,NUMSCROLLS);
X      if (id < 0) mprint("You feel stupid."); 
X      else make_scroll(newthing,id); 
X      break;
X    case RING: 
X      id = itemlist(RINGID,NUMRINGS);
X      if (id < 0) mprint("You feel stupid."); 
X      else make_ring(newthing,id); 
X      break;
X    case STICK:
X      id = itemlist(STICKID,NUMSTICKS);
X      if (id < 0) mprint("You feel stupid."); 
X      else make_stick(newthing,id); 
X      break;
X    case ARMOR: 
X      id = itemlist(ARMORID,NUMARMOR);
X      if (id < 0) mprint("You feel stupid."); 
X      else make_armor(newthing,id); 
X      break;
X    case SHIELD:
X      id = itemlist(SHIELDID,NUMSHIELDS);
X      if (id < 0) mprint("You feel stupid."); 
X      else make_shield(newthing,id); 
X      break;
X    case WEAPON:
X      id = itemlist(WEAPONID,NUMWEAPONS);
X      if (id < 0) mprint("You feel stupid."); 
X      else make_weapon(newthing,id); 
X      break;
X    case BOOTS:
X      id = itemlist(BOOTID,NUMBOOTS);
X      if (id < 0) mprint("You feel stupid."); 
X      else make_boots(newthing,id); 
X      break;
X    case CLOAK: 
X      id = itemlist(CLOAKID,NUMCLOAKS);
X      if (id < 0) mprint("You feel stupid."); 
X      else make_cloak(newthing,id); 
X      break;
X    case FOOD: 
X      id = itemlist(FOODID,NUMFOODS);
X      if (id < 0) mprint("You feel stupid."); 
X      else make_food(newthing,id); 
X      break;
X    case THING:
X      id = itemlist(THINGID,10); /* crock to avoid grot*/
X      if (id < 0) mprint("You feel stupid."); 
X      else make_thing(newthing,id); 
X      break;
X    }
X    if (id != ABORT) {
X      mprint("An item appears in your pack.");
X      newthing->known = 2;
X      Objects[id].known = 1;
X      add_item_to_pack(newthing);
X    }
X  }
X}
X
X/* if know id, then summon that monster; else (if < 0) get one. */
Xvoid summon(blessing,id)
Xint blessing,id;
X{
X  int i,looking=TRUE,x,y;
X  pml tml;
X
X  if (id < 0) {
X    if (blessing > 0) {
X      id = monsterlist();
X      xredraw();
X    }
X    /* for (id ==0) case, see below -- get a "fair" monster */
X    else if (blessing < 0) id = random_range(NUMMONSTERS);
X  }
X  for(i=0;((i<8) && looking);i++) {
X    x = Player.x+Dirs[0][i];
X    y = Player.y+Dirs[1][i];
X    looking = ((! inbounds(x,y)) ||
X	       (Dungeon[Dlevel][x][y].locchar != FLOOR) ||
X	       (Dungeon[Dlevel][x][y].creature != NULL));
X  }
X
X  if (! looking) {
X    if ((blessing == 0) && (id < 0))
X      Dungeon[Dlevel][x][y].creature = m_create(x,y,WANDERING,Dlevel);
X    else Dungeon[Dlevel][x][y].creature = make_creature(id);
X    Dungeon[Dlevel][x][y].creature->x = x;
X    Dungeon[Dlevel][x][y].creature->y = y;
X    tml = ((pml) (calloc(1,sizeof(mltype))));
X    tml->m = Dungeon[Dlevel][x][y].creature;
X    if (blessing > 0)
X      m_status_reset(tml->m,HOSTILE);
X    else if (blessing < 0)
X      m_status_set(tml->m,HOSTILE);
X    tml->next = Mlist[Dlevel];
X    Mlist[Dlevel] = tml;
X  }
X}
X
X
X
Xint itemlist(itemindex,num)
Xint itemindex,num;
X{
X  int i,itemno;
X
X  menuclear();
X  for(i=0;i<num;i++)
X    menuprintitem(i+1,Objects[i+itemindex].truename);
X  itemno = parsenum()-1;
X  if ((itemno > num)||(itemno<0)) itemno = ABORT;
X  return(itemno);
X}
X
Xint monsterlist()
X{
X  int i,itemno;
X  do {
X    printm("\nSummon monster: ");
X    menuclear();
X    for(i=0;i<NUMMONSTERS;i++)
X      menuprintitem(i+1,Monsters[i].monstring);
X    itemno = parsenum()-1;
X    if ((itemno < 0) || (itemno > NUMMONSTERS-1)) {
X      printm("\nHow about trying a real monster?");
X      morewait();
X    }
X  } while ((itemno < 0) || (itemno > NUMMONSTERS-1));
X  return(itemno);
X}
X      
X
X
X/* uncurse all items, cure diseases, and neutralize poison */
Xvoid cleanse(blessing)
X{
X  int i;
X
X  if (blessing > -1) {
X    for(i=0;i<MAXITEMS;i++) 
X      if (Player.possessions[i] != NULL) {
X	if ((Player.possessions[i]->used) &&
X	    (Player.possessions[i]->blessing < 0)) {
X	  Player.possessions[i]->used = FALSE;
X	  item_use(Player.possessions[i]);
X	  Player.possessions[i]->blessing = 0;
X	  Player.possessions[i]->used = TRUE;
X	  item_use(Player.possessions[i]);
X	}
X      }
X    
X    if (Player.status[POISONED] > 0) {
X      Player.status[POISONED] = 0;
X    }
X    if (Player.status[DISEASED] > 0) {
X      Player.status[DISEASED] = 0;
X    }
X    showflags();
X    mprint("You feel radiant!");
X  }
X  else {
X    Player.status[POISONED] += 10;
X    Player.status[DISEASED] += 10;
X    mprint("You feel besmirched!");
X    showflags();
X  }
X}
X
Xvoid annihilate(blessing)
Xint blessing;
X{
X  pml ml;
X  mprint("Lightning strikes flash all around you!!!");
X  if (blessing > -1) {
X    for(ml=Mlist[Dlevel];ml!=NULL;ml=ml->next)
X      if (ml->m != NULL)
X      m_death(ml->m);
X    Mlist[Dlevel] = NULL;
X  }
X  else {
X    mprint("You are hit by a bolt of mystic lightning!");
X    p_death("self-annihilation");
X  }
X}
X
X  
Xvoid megawish()
X{
X  char wishstr[256];
X  mprint("What do you wish for? ");
X  strcpy(wishstr,msgscanstring());
X  if (strcmp(wishstr,"Power")==0) {
X    mprint("You feel a sudden surge of energy");
X    Player.mana+=1000;
X  }
X  else if (strcmp(wishstr,"Wealth")==0) {
X    mprint("You are submerged in shower of gold pieces!");
X    Player.cash += 10000;
X  }
X  else if (strcmp(wishstr,"Skill")==0) {
X    mprint("You feel enlightened!");
X    gain_experience(10000);
X  }
X  else if (strcmp(wishstr,"Balance")==0) {
X    mprint("You feel neutral.");
X    Player.alignment = 0;
X  }
X  else mprint("You feel stupid.");
X}
X
X
X
X
X
Xvoid sleep_monster(blessing)
Xint blessing;
X{
X  pml ml;
X  int x=Player.x,y=Player.y;
X  struct monster *target;
X
X  if (blessing == 0) setspot(&x,&y);
X
X  if (blessing < 0)
X    sleep_player(abs(blessing)+2);
X  else if (blessing > 0) {
X    mprint("A silence pervades the area.");
X    for (ml=Mlist[Dlevel];ml!=NULL;ml=ml->next) {
X      m_status_reset(ml->m,AWAKE);
X      ml->m->wakeup = 0;
X    }
X  }
X  else {
X    target = Dungeon[Dlevel][x][y].creature;
X    if (target != NULL) {
X      if (target->uniqueness == COMMON) {
X	strcpy(Str1,"The ");
X	strcat(Str1,target->monstring);
X      }
X      else strcpy(Str1,target->monstring);
X      if (! m_immunityp(target,SLEEP)) {
X	strcat(Str1," seems to have fallen asleep.");
X	m_status_reset(target,AWAKE);
X	target->wakeup = 0;
X      }
X      else strcat(Str1," is bright eyed, and bushy tailed!");
X      mprint(Str1);
X    }
X    else mprint("Nothing to sleep there!");
X  }
X}
X  
Xvoid sleep_player(amount)
Xint amount;
X{
X  if (Player.status[SLEPT] == 0) {
X    mprint("You feel sleepy...");
X    if (! p_immune(SLEEP)) {
X      Player.status[SLEPT] += amount*(random_range(10)+3);
X    }
X    else mprint("but you shrug off the momentary lassitude.");
X  }
X}
X
X
Xvoid hide(x,y)
Xint x,y;
X{
X  if (inbounds(x,y)) {
X    Dungeon[Dlevel][x][y].secret = TRUE;
X    mprint("You feel knowledgeable.");
X  }
X}
X
Xvoid clairvoyance(vision)
Xint vision;
X{
X  int i,j;
X  int x = Player.x, y = Player.y;
X  if (Dlevel == NUMLEVELS-1)
X    mprint("That's funny, no effect!");
X  else {
X    mprint("Clairvoyance... ");
X    setspot(&x,&y);
X    for(i=x-vision;i<x+vision+1;i++)
X      for(j=y-vision;j<y+vision+1;j++) {
X	if (inbounds(i,j)) {
X	  Dungeon[Dlevel][i][j].secret = FALSE;
X	  Dungeon[Dlevel][i][j].seen = TRUE;
X	  plotspot(i,j,FALSE);
X	}
X      }
X    levelrefresh();
X  }
X}
X
Xvoid aggravate()
X{
X  pml tm;
X
X  for (tm=Mlist[Dlevel];tm!=NULL;tm=tm->next){
X    m_status_set(tm->m,AWAKE);
X    m_status_set(tm->m,HOSTILE);
X  }
X}
X
X
X
X
Xvoid learnspell(blessing)
Xint blessing;
X{
X  int i,spell,done=FALSE;
X  char c;
X  if (blessing < 0) {
X    for(i=NUMSPELLS;((i>-1) && (! done));i--)
X      if (Spells[i].known) {
X	done = TRUE;
X	Objects[SCROLLID+1].known = TRUE;
X	mprint("You feel forgetful.");
X	Spells[i].known = FALSE;
X      }
X    if (i == ABORT)
X      mprint("You feel fortunate.");
X  }
X  else {
X    Objects[SCROLLID+1].known = TRUE;
X    spell = random_range(NUMSPELLS);
X    printm("\nSpell Research");
X    if ((random_range(50)+Spells[spell].powerdrain) <
X	(4*(Player.iq+Player.level))) {
X      mprint(" -- Research successful!");
X      mprint(spellid(spell));
X      if (Spells[spell].known) {
X	mprint("is now easier to cast.");
X	Spells[spell].powerdrain = ((int) ((Spells[spell].powerdrain+1)/2));
X      }
X      else {
X	mprint("You discovered the spell:");
X	mprint(spellid(spell));
X	Spells[spell].known = TRUE;
X	gain_experience(Spells[spell].powerdrain*Spells[spell].powerdrain);
X      }
X    }
X    else mprint(" -- Research unsuccessful.");
X  }
X}
X
X
Xvoid amnesia()
X{
X  int i,j;
X  for (j=0;j<LENGTH;j++)
X    for (i=0;i<WIDTH;i++)
X      Dungeon[Dlevel][i][j].seen=FALSE;
X
X  erase_level();
X  drawvision(Player.x,Player.y,Player.vision);
X}
X
X
Xvoid level_drain(levels,source)
Xint levels;
Xchar *source;
X{
X  int decrement = ((int) (Player.maxhp / (Player.level+1)));
X
X  Player.level -= levels;
X
X  Player.maxhp -= (levels * decrement);
X  Player.hp -= (levels * decrement);
X
X  if ((Player.hp < 1) || (Player.level < 0))
X    p_death(source);
X}
X
X
X
X
Xvoid disrupt(x,y,amount)
Xint x,y,amount;
X{
X  pml ml;
X  struct monster *target;
X
X  if ((x ==Player.x) && (y==Player.y)) {
X    mprint("You feel disrupted!");
X    p_damage(amount,NORMAL_DAMAGE,"magical disruption");
X  }
X  else {
X    target = Dungeon[Dlevel][x][y].creature;
X    if (target != NULL) {
X      if (target->uniqueness == COMMON) {
X	strcpy(Str1,"The ");
X	strcat(Str1,target->monstring);
X      }
X      else strcpy(Str1,target->monstring);
X      if (! m_immunityp(target,NORMAL_DAMAGE)) {
X	strcat(Str1," was blasted!");
X	mprint(Str1);
X	m_damage(target,amount,NORMAL_DAMAGE);
X	target->wakeup = 0;
X      }
X      else {
X	strcat(Str1," does not seem affected.");
X	mprint(Str1);
X      }
X    }
X  }
X}
X
X
X
X
Xvoid disintegrate(x,y)
Xint x,y;
X{
X  struct monster *target;
X  if (! inbounds(x,y)) mprint("You feel a sense of wastage.");
X  else if ((x==Player.x)&&(y==Player.y)) {
X    if (Player.cloak != NULL) {
X      mprint("Your cloak disintegrates!");
X      conform_lost_objects(1,Player.cloak);
X    }
X    else if (Player.armor != NULL) {
X      mprint("Your armor disintegrates!");
X      conform_lost_objects(1,Player.armor);
X    }
X    else {
X      mprint("Uh, oh....");
X      mprint("Zzzap! You've been disintegrated!");
X      p_damage(250,UNSTOPPABLE,"disintegration");
X    }
X  }
X  else if ((target = Dungeon[Dlevel][x][y].creature) != NULL) {
X    if (target->uniqueness == COMMON) {
X      strcpy(Str1,"The ");
X      strcat(Str1,target->monstring);
X    }
X    else strcpy(Str1,target->monstring);
X    strcat(Str1," disintegrates!");
X    mprint(Str1);
X    m_damage(target,100,UNSTOPPABLE);
X    if (target->hp > 0) mprint("It was partially protected by its armor.");
X  }
X  else if (Dlevel == NUMLEVELS-1)
X    mprint("Your blast seems to vanish just before it strikes!");
X  else if (Dungeon[Dlevel][x][y].locchar == ALTAR) {
X    mprint("Zzzzap! the altar seems unaffected...");
X    mprint("But an angry deity retaliates....");
X    disintegrate(Player.x,Player.y);
X  }
X  else if (Dungeon[Dlevel][x][y].p_locf == L_TRAP_PIT) {
X    mprint("A hole is blasted in the base of the pit!");
X    Dungeon[Dlevel][x][y].locchar = '>';
X    Dungeon[Dlevel][x][y].aux = Dlevel+1;
X    Dungeon[Dlevel][x][y].stopsrun = TRUE;
X    Dungeon[Dlevel][x][y].p_locf = L_NO_OP;
X  }
X  else if (Dungeon[Dlevel][x][y].locchar == FLOOR) {
X    mprint("You zap a hole in the floor!");
X    Dungeon[Dlevel][x][y].locchar = '^';
X    Dungeon[Dlevel][x][y].p_locf = L_TRAP_PIT;
X  }
X  else {
X    mprint("A new floorspace is blasted!");
X    if (Dungeon[Dlevel][x][y].locchar == WALL)
X      tunnelcheck();
X    Dungeon[Dlevel][x][y].p_locf = L_NO_OP;
X    Dungeon[Dlevel][x][y].locchar = FLOOR;
X  }
X  if (Dungeon[Dlevel][x][y].things != NULL) 
X    Dungeon[Dlevel][x][y].things = NULL;
X  /* blow up all the items there too */
X}
X
X
Xvoid acid_cloud()
X{
X  mprint("You are caught in an acid cloud!");
X  if (Player.cloak != NULL) {
X    damage_item(Player.cloak);
X    mprint("You are burned by acid.");
X    p_damage(3,ACID,"an acid cloud");
X  }
X  else if (Player.armor != NULL) {
X    mprint("You are burned by acid.");
X    p_damage(3,ACID,"an acid cloud");
X    damage_item(Player.armor);
X  }
X  else {
X    mprint("The acid eats away at your bare skin!");
X    p_damage(25,ACID,"an acid cloud");
X  }
X}
X
X
X
X/* teleport player */
Xvoid p_teleport(type)
Xint type;
X{
X  int x=Player.x,y=Player.y;
X  drawspot(x,y);
X  if (Dlevel == NUMLEVELS-1) 
X    mprint("Some force seems to block the operation of the effect!");
X  else if (type < 0) {
X    x = random_range(WIDTH);
X    y = random_range(LENGTH);
X    if (Dungeon[Dlevel][x][y].locchar != FLOOR) {
X      mprint("You teleported into a stone wall.");
X      mprint("You are dead!");
X      p_death("teleportation into a solid object");
X    }
X    else {
X      Player.x = x;
X      Player.y = y;
X    }
X  }
X  else if (type == 0)
X    findspace(&(Player.x),&(Player.y));
X  else {
X    setspot(&Player.x,&Player.y);
X    if ((Dungeon[Dlevel][Player.x][Player.y].locchar != FLOOR) ||
X	(Dungeon[Dlevel][Player.x][Player.y].creature != NULL)) {
X      mprint("You feel deflected.");
X      p_teleport(0);
X    }
X  }
X  screencheck(Player.y);
X  roomcheck();
X}
X
X
Xvoid p_poison(toxicity)
Xint toxicity;
X{
X  mprint("You feel sick.");
X  if (! p_immune(POISON))
X    Player.status[POISONED]+=toxicity;
X  else mprint("The sickness fades!");
X  showflags();
X}
X
Xvoid apport(blessing)
Xint blessing;
X{
X  int i,index,x=Player.x,y=Player.y;
X  if (blessing > -1) {
X    mprint("Apport from:");
X    setspot(&x,&y);
X    if (Dungeon[Dlevel][x][y].things != NULL)
X      pickup_at(x,y);
X    else mprint("There's nothing there to apport!");
X  }
X  else {
X    mprint("You have a sense of loss.");
X    for(i=0;i<abs(blessing);i++) {
X      index = random_item();
X      if (index != ABORT) {
X	conform_unused_object(Player.possessions[index]);
X	drop_at(x,y,Player.possessions[index]);
X      }
X    }
X  }
X}
END_OF_oeffect1.c
if test 29791 -ne `wc -c <oeffect1.c`; then
    echo shar: \"oeffect1.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f oitem.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"oitem.c\"
else
echo shar: Extracting \"oitem.c\" \(22699 characters\)
sed "s/^X//" >oitem.c <<'END_OF_oitem.c'
X/* omega copyright (C) 1987 by Laurence Raphael Brothers */
X/* oitem.c */
X
X#include <strings.h>
X#include "oglob.h"
X
X
X/* from oetc */
Xextern void hint();
X
X/* from outil */
Xextern int random_range(),pow2();
X
X/* from oitemf */
Xextern void i_no_op(),i_nothing(),i_heal(),i_victrix(),i_desecrate();
Xextern void i_spells(),i_bless(),i_enchant(),i_acquire(),i_jane_t();
Xextern void i_flux(),i_breathing(),i_invisible(),i_perm_invisible();
Xextern void i_teleport(),i_wish(),i_clairvoyance(),i_displace(),i_id();
Xextern void i_objdet(),i_mondet(),i_sleep_self(),i_neutralize_poison();
Xextern void i_speed(),i_restore(),i_azoth(),i_regenerate(),i_demonblade();
Xextern void i_firebolt(),i_lbolt(),i_missile(),i_fireball(),i_lball();
Xextern void i_sleep_other(),i_summon(),i_hide(),i_disrupt(),i_disintegrate();
Xextern void i_perm_vision(),i_perm_burden(),i_perm_fire_resist(),i_charge();
Xextern void i_perm_poison_resist(),i_perm_strength(),i_perm_gaze_immune();
Xextern void i_perm_energy_resist();void i_perm_speed(),i_perm_breathing();
Xextern void i_perm_displace(),i_perm_negimmune(),i_mace_disrupt(),i_warp();
Xextern void i_food(),i_poison_food(),i_stim(),i_immune(),i_lembas();
Xextern void i_orbfire(),i_orbwater(),i_orbair(),i_orbearth(),i_orbdead();
Xextern void i_orbmastery(),i_lightsabre(),i_alert(),i_snowball(),i_pow();
Xextern void i_knowledge(),i_perm_knowledge(),i_fear_resist(),i_corpse();
Xextern void i_perm_fear_resist(),i_pick(),i_key(),i_defend(),i_apport();
Xextern void i_chaos(),i_law(),i_augment(),i_perm_regenerate(),i_symbol();
Xextern void i_accuracy(),i_perm_accuracy(),i_hero(),i_perm_hero();
Xextern void i_levitate(),i_perm_levitate(),i_perm_protection();
Xextern void i_perm_agility(),i_cure(),i_dispel(),i_pepper_food();
Xextern void i_enchantment(),i_polymorph(),i_illuminate(),i_perm_illuminate();
Xextern void i_crystal(),i_kolwynia(),i_death(),i_life(),i_helm(),i_antioch();
Xextern void i_juggernaut(),i_trap(),i_truesight(),i_perm_truesight();
X
X/* oitem functions */
Xvoid item_use();
Xpob create_object();
Xvoid make_shield(),make_armor(),make_weapon();
Xvoid make_scroll(),make_potion(),make_food();
Xvoid make_thing(),make_ring(),make_artifact();
Xvoid make_boots(),make_cloak(),make_stick(),make_cash();
X
Xint itemplus(),itemcharge(),itemblessing(),twohanded_p();
X
X
Xvoid scrollname(),potionname(),stickname(),ringname(),cloakname(),grotname();
Xvoid bootname();
X
X/* make a random new object, returning pointer */
Xpob create_object()
X{
X  pob new;
X  int  r; 
X  int ok = FALSE;
X
X  while (! ok) {
X    new = ((pob) malloc(sizeof(objtype)));
X    r= random_range(135);
X    if (r < 20) make_thing(new,-1);
X    else if (r < 40) make_food(new,-1);
X    else if (r < 50) make_scroll(new,-1);
X    else if (r < 60) make_potion(new,-1);
X    else if (r < 70) make_weapon(new,-1);
X    else if (r < 80) make_armor(new,-1);
X    else if (r < 90) make_shield(new,-1);
X    else if (r < 100) make_stick(new,-1);
X    else if (r < 110) make_boots(new,-1);
X    else if (r < 120) make_cloak(new,-1);
X    else if (r < 130) make_ring(new,-1);
X    else make_artifact(new,-1);
X    /* not ok if object is too good for level, or if unique and already made */
X    /* 1/100 chance of finding object if too good for level */
X    ok = ((new->uniqueness != UNIQUE_MADE) &&
X	  ((new->level*3 < Dlevel+random_range(3)) 
X	   || ((Dlevel == 0) && (new->level < 5)) /* better stuff in city */
X	   || (random_range(100)==23)));
X    if (! ok)    free((char *) new);
X  }
X  if (new->uniqueness == UNIQUE_UNMADE) 
X    Objects[new->id].uniqueness=UNIQUE_MADE;
X  return(new);
X}
X
Xvoid make_cash(new,level)
Xpob new;
Xint level;
X{
X  *new = Objects[CASHID];
X  new->basevalue = random_range(level*level+10)+1; /* aux is AU value */
X  strcpy(new->objstr,cashstr());
X  strcpy(new->truename,cashstr());
X  strcpy(new->cursestr,cashstr());
X}
X
Xvoid make_food(new,id)
Xpob new;
Xint id;
X{
X  if (id == -1) id = random_range(NUMFOODS);
X  *new = Objects[FOODID+id];
X}
X
Xvoid make_ring(new,id)
Xpob new;
Xint id;
X{
X  if (id == -1) id = random_range(NUMRINGS);
X  *new = Objects[RINGID+id];
X  if (new->blessing == 0) new->blessing = itemblessing();
X  if (new->plus == 0) new->plus = itemplus()+1;
X  if (new->blessing < 0) new->plus = -1 - abs(new->plus);
X}
X
Xvoid make_thing(new,id)
Xpob new;
Xint id;
X{
X  if (id == -1) id = random_range(NUMTHINGS);
X  *new = Objects[THINGID+id];
X  if (strcmp(new->objstr,"grot") == 0) {
X    grotname(new->objstr);
X    strcpy(new->truename,new->objstr);
X    strcpy(new->cursestr,new->objstr);
X  }
X}
X
X
Xvoid make_scroll(new,id)
Xpob new;
Xint id;
X{
X  if (id == -1) id = random_range(NUMSCROLLS);
X  *new = Objects[SCROLLID+id];
X  /* if a scroll of spells, aux is the spell id in Spells */
X  if (new->id == SCROLLID+1) {
X    new->aux = random_range(NUMSPELLS);
X  }
X}
X
Xvoid make_potion(new,id)
Xpob new;
Xint id;
X{
X  if (id == -1) id = random_range(NUMPOTIONS);
X  *new = Objects[POTIONID+id];
X  if (new->plus == 0) new->plus = itemplus();
X}
X
Xvoid make_weapon(new,id)
Xpob new;
Xint id;
X{
X  if (id == -1) id = random_range(NUMWEAPONS);
X  *new = Objects[WEAPONID+id];
X  if ((id == 28) || (id == 29)) /* bolt or arrow */
X    new->number = random_range(20)+1;
X  if (new->blessing == 0) new->blessing = itemblessing();
X  if (new->plus == 0) {
X    new->plus = itemplus();
X    if (new->blessing < 0)
X      new->plus = -1 - abs(new->plus);
X    else if (new->blessing > 0)
X      new->plus = 1 + abs(new->plus);
X  }
X}
X
Xvoid make_shield(new,id)
Xpob new;
Xint id;
X{
X  if (id == -1) id = random_range(NUMSHIELDS);
X  *new = Objects[SHIELDID+id];
X  if (new->plus == 0)
X    new->plus = itemplus();
X  if (new->blessing == 0) new->blessing = itemblessing();
X  if (new->blessing < 0)
X    new->plus = -1 - abs(new->plus);
X  else if (new->blessing > 0)
X    new->plus = 1 + abs(new->plus);
X}
X
Xvoid make_armor(new,id)
Xpob new;
Xint id;
X{
X  if (id == -1) id = random_range(NUMARMOR);
X  *new = Objects[ARMORID+id];
X  if (new->plus == 0) new->plus = itemplus();
X  if (new->blessing == 0) new->blessing = itemblessing();
X  if (new->blessing < 0)
X    new->plus = -1 - abs(new->plus);
X  else if (new->blessing > 0)
X    new->plus = 1 + abs(new->plus);  
X}
X
Xvoid make_cloak(new,id)
Xpob new;
Xint id;
X{
X  if (id == -1) id = random_range(NUMCLOAKS);
X  Objects[CLOAKID+4].plus = 2;
X  *new = Objects[CLOAKID+id];
X  if (new->blessing == 0) new->blessing = itemblessing();
X}
X
Xvoid make_boots(new,id)
Xpob new;
Xint id;
X{
X  if (id == -1) id = random_range(NUMBOOTS);
X  *new = Objects[BOOTID+id];
X  if (new->blessing == 0) new->blessing = itemblessing();
X}
X
Xvoid make_stick(new,id)
Xpob new;
Xint id;
X{
X  if (id == -1) id = random_range(NUMSTICKS);
X  *new = Objects[STICKID+id];
X  new->charge = itemcharge();
X  if (new->blessing == 0) new->blessing = itemblessing();
X}
X
Xvoid make_artifact(new,id)
Xpob new;
X{
X  if (id == -1) id = random_range(NUMARTIFACTS);
X  *new = Objects[ARTIFACTID+id];
X}
X
X
X
X
X/* item name functions */
X
Xvoid scrollname(reset,sstr)
Xint reset;
Xchar sstr[64];
X{
X  static int used[30];
X  int i;
X
X  if (reset)
X    for(i=0;i<30;i++)
X      used[i]=FALSE;
X  else {
X    do 
X      i = random_range(30);
X    while(used[i]);
X    
X    used[i] = TRUE;
X    
X    switch(i) {
X      case 0: strcpy(sstr,"scroll-GRISTOGRUE"); break;
X      case 1: strcpy(sstr,"scroll-Kho Reck Tighp"); break;
X      case 2: strcpy(sstr,"scroll-E Z"); break;
X      case 3: strcpy(sstr,"scroll-Kevitz"); break;
X      case 4: strcpy(sstr,"scroll-Arcanum Prime"); break;
X      case 5: strcpy(sstr,"scroll-NYARLATHOTEP"); break;
X      case 6: strcpy(sstr,"scroll-Gilthoniel"); break;
X      case 7: strcpy(sstr,"scroll-Zarathustra"); break;
X      case 8: strcpy(sstr,"scroll-Ancient Lore"); break;
X      case 9: strcpy(sstr,"scroll-Eyes Only"); break;
X      case 10: strcpy(sstr,"scroll-Ambogar Empheltz"); break;
X      case 11: strcpy(sstr,"scroll-Isengard"); break;
X      case 12: strcpy(sstr,"scroll-Deosil Widdershins"); break;
X      case 13: strcpy(sstr,"scroll-Magister Paracelsus"); break;
X      case 14: strcpy(sstr,"scroll-Qlipphotic Summons"); break;
X      case 15: strcpy(sstr,"scroll-Aratron Samael"); break;
X      case 16: strcpy(sstr,"scroll-De Wormiis Mysterius"); break;
X      case 17: strcpy(sstr,"scroll-Necronomicon"); break;
X      case 18: strcpy(sstr,"scroll-Pnakotic Manuscript"); break;
X      case 19: strcpy(sstr,"scroll-Codex of Xalimar"); break;
X      case 20: strcpy(sstr,"scroll-The Mabinogion"); break;
X      case 21: strcpy(sstr,"scroll-Ginseng Shiatsu"); break;
X      case 22: strcpy(sstr,"scroll-Tome of Tromax"); break;
X      case 23: strcpy(sstr,"scroll-Book of the Dead "); break;
X      case 24: strcpy(sstr,"scroll-The Flame Tongue"); break;
X      case 25: strcpy(sstr,"scroll-Karst Khogar"); break;
X      case 26: strcpy(sstr,"scroll-The Yellow Sign"); break;
X      case 27: strcpy(sstr,"scroll-The Kevillist Manifesto"); break;
X      case 28: strcpy(sstr,"scroll-Goshtar Script"); break;
X      case 29: strcpy(sstr,"scroll-Pendragon Encryption"); break;
X    }
X  }
X}
X
X/* actually copies into gstr for some reason */
Xvoid grotname(gstr)
Xchar gstr[64];
X{
X  switch(random_range(20)) {
X    case 0: strcpy(gstr,"pot lid"); break;
X    case 1: strcpy(gstr,"mound of offal"); break;
X    case 2: strcpy(gstr,"sword that was broken"); break;
X    case 3: strcpy(gstr,"salted snail"); break;
X    case 4: strcpy(gstr,"key"); break;
X    case 5: strcpy(gstr,"toadstool"); break;
X    case 6: strcpy(gstr,"greenish spindle"); break;
X    case 7: strcpy(gstr,"tin soldier"); break;
X    case 8: strcpy(gstr,"broken yo-yo"); break;
X    case 9: strcpy(gstr,"NYC subway map"); break;
X    case 10: strcpy(gstr,"Nixon's the One! button"); break;
X    case 11: strcpy(gstr,"beer can (empty)"); break;
X    case 12: strcpy(gstr,"golden bejewelled falcon"); break;
X    case 13: strcpy(gstr,"hamster cage"); break;
X    case 14: strcpy(gstr,"wooden nickel"); break;
X    case 15: strcpy(gstr,"three-dollar bill"); break;
X    case 16: strcpy(gstr,"rosebud"); break;
X    case 17: strcpy(gstr,"water pistol"); break;
X    case 18: strcpy(gstr,"shattered skull"); break;
X    case 19: strcpy(gstr,"jawbone of an ass"); break;
X  }
X}
X
X
X
X
Xvoid potionname(reset,pstr)
Xint reset;
Xchar pstr[64];
X{
X  static int used[20];
X  int i;
X  if (reset)
X    for(i=0;i<20;i++)
X      used[i]=FALSE;
X  else {
X    do 
X      i = random_range(20);
X    while(used[i]);
X    
X    used[i] = TRUE;
X
X    switch (i) {
X      case 0: strcpy(pstr,"vial of dewy liquid"); break;
X      case 1: strcpy(pstr,"jug of tarry black substance"); break;
X      case 2: strcpy(pstr,"flask of cold smoking froth"); break;
X      case 3: strcpy(pstr,"phial of glowing fluid"); break;
X      case 4: strcpy(pstr,"bottle of sickening slime"); break;
X      case 5: strcpy(pstr,"sac of greenish gel"); break;
X      case 6: strcpy(pstr,"wineskin of odorous goo"); break;
X      case 7: strcpy(pstr,"canteen of sweet sap"); break;
X      case 8: strcpy(pstr,"urn of clear fluid"); break;
X      case 9: strcpy(pstr,"clotted grey ooze"); break;
X      case 10: strcpy(pstr,"keg of bubbly golden fluid"); break;
X      case 11: strcpy(pstr,"tube of minty paste"); break;
X      case 12: strcpy(pstr,"pitcher of aromatic liquid"); break;
X      case 13: strcpy(pstr,"pot of rancid grease"); break;
X      case 14: strcpy(pstr,"thermos of hot black liquid"); break;
X      case 15: strcpy(pstr,"magnum of deep red liquid"); break;
X      case 16: strcpy(pstr,"vase full of ichor"); break;
X      case 17: strcpy(pstr,"container of white cream"); break;
X      case 18: strcpy(pstr,"syringe of clear fluid"); break;
X      case 19: strcpy(pstr,"can of volatile essence"); break;
X    }      
X  }
X}
X
X
Xvoid stickname(reset,sstr)
Xint reset;
Xchar sstr[64];
X{
X  static int used[20];
X  int i;
X  if (reset)
X    for(i=0;i<20;i++)
X      used[i]=FALSE;
X  else {
X    do 
X      i = random_range(20);
X    while(used[i]);
X    
X    used[i] = TRUE;
X
X    switch (i) {
X      case 0: strcpy(sstr,"oaken staff"); break;
X      case 1: strcpy(sstr,"heavy metal rod"); break;
X      case 2: strcpy(sstr,"shaft of congealed light"); break;
X      case 3: strcpy(sstr,"slender ceramic wand"); break;
X      case 4: strcpy(sstr,"rune-inscribed bone wand"); break;
X      case 5: strcpy(sstr,"knurly staff"); break;
X      case 6: strcpy(sstr,"steel knobbed rod");  break;
X      case 7: strcpy(sstr,"lucite wand"); break;
X      case 8: strcpy(sstr,"sturdy alpenstock"); break;
X      case 9: strcpy(sstr,"gem-studded ebony staff"); break;
X      case 10: strcpy(sstr,"chromed sequinned staff"); break;
X      case 11: strcpy(sstr,"old peeling stick"); break;
X      case 12: strcpy(sstr,"jointed metal rod"); break;
X      case 13: strcpy(sstr,"wand with lead ferrules"); break;
X      case 14: strcpy(sstr,"forked wooden stick"); break;
X      case 15: strcpy(sstr,"cane with gold eagle handle"); break;
X      case 16: strcpy(sstr,"crystalline wand");  break;
X      case 17: strcpy(sstr,"metal stick with trigger"); break;
X      case 18: strcpy(sstr,"leather-handled stone rod"); break;
X      case 19: strcpy(sstr,"tiny mithril wand"); break;
X    }      
X  }
X}
X
Xvoid ringname(reset,rstr)
Xint reset;
Xchar rstr[64];
X{
X  static int used[20];
X  int i;
X  if (reset)
X    for(i=0;i<20;i++)
X      used[i]=FALSE;
X  else {
X    do 
X      i = random_range(20);
X    while(used[i]);
X    
X    used[i] = TRUE;
X
X    switch (i) {
X      case 0: strcpy(rstr,"gold ring with a blue gem"); break;
X      case 1: strcpy(rstr,"brass ring"); break;
X      case 2: strcpy(rstr,"mithril ring with a red gem"); break;
X      case 3: strcpy(rstr,"platinum ring");  break;
X      case 4: strcpy(rstr,"gold dragon's head ring"); break;
X      case 5: strcpy(rstr,"bronze ring"); break;
X      case 6: strcpy(rstr,"aardvark seal ring"); break;
X      case 7: strcpy(rstr,"grey metal ring"); break;
X      case 8: strcpy(rstr,"silver skull ring"); break;
X      case 9: strcpy(rstr,"onyx ring"); break;
X      case 10: strcpy(rstr,"Collegium Magii class ring"); break;
X      case 11: strcpy(rstr,"worn stone ring"); break;
X      case 12: strcpy(rstr,"diorite ring"); break;
X      case 13: strcpy(rstr,"ancient scarab ring");  break;
X      case 14: strcpy(rstr,"plastic charm ring"); break;
X      case 15: strcpy(rstr,"soapy gypsum ring"); break;
X      case 16: strcpy(rstr,"glass ring"); break;
X      case 17: strcpy(rstr,"glowing bluestone ring"); break;
X      case 18: strcpy(rstr,"ring with eye sigil"); break;
X      case 19: strcpy(rstr,"zirconium ring"); break;
X    }      
X  }
X}
X
X
Xvoid cloakname(reset,cstr)
Xint reset;
Xchar cstr[64];
X{
X  static int used[20];
X  int i;
X  if (reset)
X    for(i=0;i<20;i++)
X      used[i]=FALSE;
X  else {
X    do 
X      i = random_range(20);
X    while(used[i]);
X    
X    used[i] = TRUE;
X
X    switch (i) {
X      case 0: strcpy(cstr,"tattered piece of cloth"); break;
X      case 1: strcpy(cstr,"fuligin cloak"); break;
X      case 2: strcpy(cstr,"chintz cloak"); break;
X      case 3: strcpy(cstr,"diaphanous cape");  break;
X      case 4: strcpy(cstr,"red half-cloak"); break;
X      case 5: strcpy(cstr,"mouse-hide cloak"); break;
X      case 6: strcpy(cstr,"kelly green cloak"); break;
X      case 7: strcpy(cstr,"cloth-of-gold cloak"); break;
X      case 8: strcpy(cstr,"dirty old cloak"); break;
X      case 9: strcpy(cstr,"weightless cloak"); break;
X      case 10: strcpy(cstr,"boat cloak"); break;
X      case 11: strcpy(cstr,"greasy tarpaulin"); break;
X      case 12: strcpy(cstr,"sable cloak"); break;
X      case 13: strcpy(cstr,"soft velvet cloak");  break;
X      case 14: strcpy(cstr,"opera cape"); break;
X      case 15: strcpy(cstr,"elegant brocade cloak"); break;
X      case 16: strcpy(cstr,"cloak of many colors"); break;
X      case 17: strcpy(cstr,"grey-green rag"); break;
X      case 18: strcpy(cstr,"puce and chartreuse cloak"); break;
X      case 19: strcpy(cstr,"smoky cloak"); break;
X    }      
X  }
X}
X
Xvoid bootname(reset,cstr)
Xint reset;
Xchar cstr[64];
X{
X  static int used[20];
X  int i;
X  if (reset)
X    for(i=0;i<20;i++)
X      used[i]=FALSE;
X  else {
X    do 
X      i = random_range(20);
X    while(used[i]);
X    
X    used[i] = TRUE;
X
X    switch (i) {
X      case 0: strcpy(cstr,"sturdy leather boots"); break;
X      case 1: strcpy(cstr,"dayglo spandex socks"); break;
X      case 2: strcpy(cstr,"dark-colored tabi"); break;
X      case 3: strcpy(cstr,"patent-leather shoes");  break;
X      case 4: strcpy(cstr,"beaten-up gumshoes"); break;
X      case 5: strcpy(cstr,"alligator-hide boots"); break;
X      case 6: strcpy(cstr,"comfortable sandals"); break;
X      case 7: strcpy(cstr,"roller skates"); break;
X      case 8: strcpy(cstr,"purple suede gaiters"); break;
X      case 9: strcpy(cstr,"mirror-plated wingtips"); break;
X      case 10: strcpy(cstr,"heavy workboots"); break;
X      case 11: strcpy(cstr,"polyurethane-soled sneakers"); break;
X      case 12: strcpy(cstr,"clodhoppers"); break;
X      case 13: strcpy(cstr,"wooden shoes");  break;
X      case 14: strcpy(cstr,"ski boots"); break;
X      case 15: strcpy(cstr,"hob-nailed boots"); break;
X      case 16: strcpy(cstr,"elven boots"); break;
X      case 17: strcpy(cstr,"cowboy boots"); break;
X      case 18: strcpy(cstr,"flipflop slippers"); break;
X      case 19: strcpy(cstr,"riding boots"); break;
X    }      
X  }
X}
X
X
X
Xint itemplus()
X{
X  int p = 0;
X
X  while (random_range(2) == 0)
X    p++;
X  return(p);
X}
X
X
X
Xint itemcharge()
X{
X  return(random_range(20)+1);
X}
X
X
X
Xint itemblessing()
X{
X  switch(random_range(10)) {
X    case 0:
X    case 1:return(-1-random_range(10)); break;
X    case 8:
X    case 9:return(1+random_range(10)); break;
X    default: return(0);	   
X  }
X}
X
X    
Xint twohanded_p(id)
Xint id;
X{
X  switch(id) {
X  case WEAPONID+5:
X  case WEAPONID+12:
X  case WEAPONID+18:
X  case WEAPONID+20:
X  case WEAPONID+24:
X  case WEAPONID+26:
X  case WEAPONID+27:
X  case WEAPONID+32:
X  case WEAPONID+36:
X    return(TRUE); break;
X  default: return(FALSE); break;
X  }
X}
X
X
Xvoid item_use(o)
Xstruct object *o;
X{
X  switch(o->usef) {
X    case -1:i_no_op(o); break;
X    case 0:i_nothing(o); break;
X
X    /* scrolls */	    
X    case I_SPELLS: i_spells(o); break;
X    case I_BLESS: i_bless(o); break;
X    case I_ACQUIRE: i_acquire(o); break;
X    case I_ENCHANT: i_enchant(o); break;
X    case I_TELEPORT: i_teleport(o); break;
X    case I_WISH: i_wish(o); break;
X    case I_CLAIRVOYANCE: i_clairvoyance(o); break;
X    case I_DISPLACE: i_displace(o); break;
X    case I_ID: i_id(o); break;
X    case I_JANE_T: i_jane_t(o); break;
X    case I_FLUX: i_flux(o); break;
X    case I_WARP: i_warp(o); break;
X    case I_ALERT: i_alert(o); break;
X    case I_CHARGE: i_charge(o); break;
X    case I_KNOWLEDGE: i_knowledge(o); break;
X    case I_LAW: i_law(o); break;
X    case I_HINT: hint(); break;
X    case I_HERO: i_hero(o); break;
X    case I_TRUESIGHT: i_truesight(o); break;
X    case I_ILLUMINATE: i_illuminate(o); break;
X
X    /* potion functions */
X    case I_HEAL: i_heal(o); break;
X    case I_OBJDET: i_objdet(o); break;
X    case I_MONDET: i_mondet(o); break;
X    case I_SLEEP_SELF: i_sleep_self(o); break;
X    case I_NEUTRALIZE_POISON: i_neutralize_poison(o); break;
X    case I_RESTORE: i_restore(o); break;
X    case I_AZOTH: i_azoth(o); break;
X    case I_AUGMENT: i_augment(o); break;
X    case I_REGENERATE: i_regenerate(o); break;
X    case I_INVISIBLE: i_invisible(o); break;
X    case I_BREATHING: i_breathing(o); break;
X    case I_FEAR_RESIST: i_fear_resist(o); break;
X    case I_CHAOS: i_chaos(o); break;
X    case I_ACCURACY: i_accuracy(o); break;
X    case I_LEVITATION: i_levitate(o); break;
X    case I_CURE: i_cure(o); break;
X	    
X    /* stick functions */
X    case I_FIREBOLT: i_firebolt(o); break;
X    case I_LBOLT: i_lbolt(o); break;
X    case I_MISSILE: i_missile(o); break;
X    case I_SLEEP_OTHER: i_sleep_other(o); break;
X    case I_FIREBALL: i_fireball(o); break;
X    case I_LBALL: i_lball(o); break;    
X    case I_SNOWBALL: i_snowball(o); break;
X    case I_SUMMON: i_summon(o); break;
X    case I_HIDE: i_hide(o); break;
X    case I_DISRUPT: i_disrupt(o); break;
X    case I_DISINTEGRATE: i_disintegrate(o); break;
X    case I_APPORT: i_apport(o); break;
X    case I_DISPEL: i_dispel(o); break;
X    case I_POLYMORPH: i_polymorph(o); break;
X
X    /* food functions */
X    case I_FOOD: i_food(o); break;
X    case I_LEMBAS: i_lembas(o); break;
X    case I_STIM: i_stim(o); break;
X    case I_POW: i_pow(o); break;
X    case I_IMMUNE: i_immune(o); break;
X    case I_POISON_FOOD: i_poison_food(o); break;
X    case I_PEPPER_FOOD: i_pepper_food(o); break;
X    case I_CORPSE: i_corpse(o); break;
X
X    /* boots functions */
X    case I_PERM_SPEED: i_perm_speed(o); break;
X    case I_PERM_HERO: i_perm_hero(o); break;
X    case I_PERM_LEVITATE: i_perm_levitate(o); break;
X    case I_PERM_AGILITY: i_perm_agility(o); break;
X      
X    /* artifact functions */
X    case I_SYMBOL:i_symbol(o); break;
X    case I_ORBMASTERY: i_orbmastery(o); break;
X    case I_ORBFIRE: i_orbfire(o); break;
X    case I_ORBWATER: i_orbwater(o); break;
X    case I_ORBEARTH: i_orbearth(o); break;
X    case I_ORBAIR: i_orbair(o); break;
X    case I_ORBDEAD: i_orbdead(o); break;
X    case I_CRYSTAL: i_crystal(o); break;
X    case I_LIFE: i_life(o); break;
X    case I_DEATH: i_death(o); break;
X    case I_ANTIOCH: i_antioch(o); break;
X    case I_HELM: i_helm(o); break;
X    case I_KOLWYNIA: i_kolwynia(o); break;
X    case I_ENCHANTMENT: i_enchantment(o); break;
X    case I_JUGGERNAUT: i_juggernaut(o); break;
X
X    /* cloak functions */
X    case I_PERM_DISPLACE: i_perm_displace(o); break;
X    case I_PERM_NEGIMMUNE: i_perm_negimmune(o); break;
X    case I_PERM_INVISIBLE: i_perm_invisible(o); break;
X    case I_PERM_PROTECTION: i_perm_protection(o);break;
X    case I_PERM_ACCURACY: i_perm_accuracy(o);break;
X    case I_PERM_TRUESIGHT: i_perm_truesight(o); break;
X
X    /* ring functions */
X    case I_PERM_VISION: i_perm_vision(o); break;
X    case I_PERM_BURDEN: i_perm_burden(o); break;
X    case I_PERM_STRENGTH: i_perm_strength(o); break;
X    case I_PERM_GAZE_IMMUNE: i_perm_gaze_immune(o); break;
X    case I_PERM_FIRE_RESIST: i_perm_fire_resist(o); break;
X    case I_PERM_POISON_RESIST: i_perm_poison_resist(o); break;
X    case I_PERM_REGENERATE: i_perm_regenerate(o); break;
X    case I_PERM_KNOWLEDGE: i_perm_knowledge(o); break;
X
X    /* armor functions */
X    case I_PERM_FEAR_RESIST: i_perm_fear_resist(o); break;
X    case I_PERM_ENERGY_RESIST: i_perm_energy_resist(o); break;
X    case I_PERM_BREATHING: i_perm_breathing(o); break;
X
X    /* weapons functions */
X    case I_LIGHTSABRE: i_lightsabre(o); break;
X    case I_DEMONBLADE: i_demonblade(o); break;
X    case I_DESECRATE: i_desecrate(o); break;
X    case I_MACE_DISRUPT: i_mace_disrupt(o); break;
X    case I_DEFEND: i_defend(o); break;
X    case I_VICTRIX: i_victrix(o); break;
X
X    /* thing functions */	    
X    case I_PICK: i_pick(o); break;
X    case I_KEY: i_key(o); break;
X    case I_PERM_ILLUMINATE: i_perm_illuminate(o); break;
X    case I_TRAP: i_trap(o); break;
X  }
X}
X
END_OF_oitem.c
if test 22699 -ne `wc -c <oitem.c`; then
    echo shar: \"oitem.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f omega.intro -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"omega.intro\"
else
echo shar: Extracting \"omega.intro\" \(1868 characters\)
sed "s/^X//" >omega.intro <<'END_OF_omega.intro'
X	(ESTABLISHING SHOT) A weary ADVENTURER, wearing battered armor
Xand 10 glowing rings, clutching a potion bottle, and laden with all
Xmanner of weapons, magical devices, and sacks of gold, lies panting on
Xthe ground outside of the seedy-looking entrance to a grimy Dungeon.
XThe nearby scenery is uniformly grey and uninteresting.
X
XBluff Male Voice: Retrieved the Amulet of Yendor too many times to
Xcount?
X
XSultry Female Voice: Can't see anything in the Eye of Larn?
X
XBMV: Eaten one too many Zombie corpses?
X
XSFV: Run out of Greater Gods to kill?
X
X	CLOSE-UP: The ADVENTURER's sweat-streaked face, which is
Xnicked and bruised. He has a black eye.
X
X	The ADVENTURER nods wearily, and, it seems, with some boredom.
X
XMBV+SFV: Then take the ultimate challenge ... The final quest ... OMEGA!
X
X	(PAN VERTICALLY TOWARD SKY)
X
XThe Mormon Tabernacle Choir: Ooooooo -- mega!
X
X	A shaft of brilliant sunlight pierces the overcast sky,
Xrevealing a Mystic Portal in the sky. A rainbow bridge lances from
Xthe portal toward the ADVENTURER. As the ADVENTURER hesitantly sets
Xfoot on the bridge, he (with the viewer) is swept through the M.P.
Xin a masterpiece of computer animation. There is a flash of light,
Xand a TRANSFORMED ADVENTURER, in newly polished and chromed armor,
Xwielding a flaming sword, strides confidently toward an edifice that
Xmakes the Castle of Ultimate Darkness look like a sandcastle. The
Xlandscape is vibrantly colored, and we feel that there are new
Xchallenges awaiting just over the horizon.
X
XTMTC: Magnificat! Magnificat! Magnificat!
X
XBMV: Coming Soon to a site near you!
X
XSFV: Challenge Omega -- The Final Quest!
X
X	As the ADVENTURER passes through the entrance to the AWESOME
XCASTLE, a giant portcullis slams shut behind him with the force of
Xa Death Star bulkhead, and we hear a muffled scream, soon cut off.
X
XSatanic Male Voice: If you dare! <laughs insanely>
X
X
END_OF_omega.intro
if test 1868 -ne `wc -c <omega.intro`; then
    echo shar: \"omega.intro\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 13 \(of 15\).
cp /dev/null ark13isdone
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