예제 #1
0
int TattooMap::show() {
	Debugger &debugger = *_vm->_debugger;
	Events &events = *_vm->_events;
	Music &music = *_vm->_music;
	Resources &res = *_vm->_res;
	TattooScene &scene = *(TattooScene *)_vm->_scene;
	Screen &screen = *_vm->_screen;
	int result = 0;

	// Check if we need to keep track of how many times player has been to the map
	for (uint idx = 0; idx < scene._sceneTripCounters.size(); ++idx) {
		SceneTripEntry &entry = scene._sceneTripCounters[idx];

		if (entry._sceneNumber == OVERHEAD_MAP || entry._sceneNumber == OVERHEAD_MAP2) {
			if (--entry._numTimes == 0) {
				_vm->setFlagsDirect(entry._flag);
				scene._sceneTripCounters.remove_at(idx);
			}
		}
	}

	if (music._musicOn) {
		// See if Holmes or Watson is the active character	
		Common::String song;
		if (_vm->readFlags(FLAG_PLAYER_IS_HOLMES))
			// Player is Holmes
			song = "Cue9";
		else if (_vm->readFlags(FLAG_ALT_MAP_MUSIC))
			song = "Cue8";
		else
			song = "Cue7";

		if (music.loadSong(song)) {
			music.startSong();
		}
	}

	screen.initPaletteFade(1364485);
	
	// Load the custom mouse cursors for the map
	ImageFile cursors("omouse.vgs");
	events.setCursor(cursors[0]._frame);
	events.warpMouse();

	// Load the data for the map
	_iconImages = new ImageFile("mapicons.vgs");
	loadData();

	// Load the palette
	Common::SeekableReadStream *stream = res.load("map.pal");
	stream->read(screen._cMap, PALETTE_SIZE);
	screen.translatePalette(screen._cMap);
	delete stream;

	// Load the map image and draw it to the back buffer
	ImageFile *map = new ImageFile("map.vgs");
	screen._backBuffer1.create(SHERLOCK_SCREEN_WIDTH * 2, SHERLOCK_SCREEN_HEIGHT * 2);
	screen._backBuffer1.SHblitFrom((*map)[0], Common::Point(0, 0));
	screen.activateBackBuffer1();
	delete map;

	screen.clear();
	screen.setPalette(screen._cMap);
	drawMapIcons();

	// Copy the map drawn in the back buffer to the secondary back buffer
	screen._backBuffer2.create(SHERLOCK_SCREEN_WIDTH * 2, SHERLOCK_SCREEN_HEIGHT * 2);
	screen._backBuffer2.SHblitFrom(screen._backBuffer1);

	// Display the built map to the screen
	screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);

	// Set initial scroll position
	_targetScroll = _bigPos;
	screen._currentScroll = Common::Point(-1, -1);

	do {
		// Allow for event processing and get the current mouse position
		events.pollEventsAndWait();
		events.setButtonState();
		Common::Point mousePos = events.screenMousePos();

		if (debugger._showAllLocations == LOC_REFRESH) {
			drawMapIcons();
			screen.slamArea(screen._currentScroll.x, screen._currentScroll.y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_WIDTH);
		}

		music.checkSongProgress();
		checkMapNames(true);

		if (mousePos.x < (SHERLOCK_SCREEN_WIDTH / 6))
			_targetScroll.x -= 2 * SCROLL_SPEED * (SHERLOCK_SCREEN_WIDTH / 6 - mousePos.x) / (SHERLOCK_SCREEN_WIDTH / 6);
		if (mousePos.x > (SHERLOCK_SCREEN_WIDTH * 5 / 6))
			_targetScroll.x += 2 * SCROLL_SPEED * (mousePos.x - (SHERLOCK_SCREEN_WIDTH * 5 / 6)) / (SHERLOCK_SCREEN_WIDTH / 6);
		if (mousePos.y < (SHERLOCK_SCREEN_HEIGHT / 6))
			_targetScroll.y -= 2 * SCROLL_SPEED * (SHERLOCK_SCREEN_HEIGHT / 6 - mousePos.y) / (SHERLOCK_SCREEN_HEIGHT / 6);
		if (mousePos.y > (SHERLOCK_SCREEN_HEIGHT * 5 / 6))
			_targetScroll.y += 2 * SCROLL_SPEED * (mousePos.y - SHERLOCK_SCREEN_HEIGHT * 5 / 6) / (SHERLOCK_SCREEN_HEIGHT / 6);

		if (_targetScroll.x < 0)
			_targetScroll.x = 0;
		if ((_targetScroll.x + SHERLOCK_SCREEN_WIDTH) > screen._backBuffer1.width())
			_targetScroll.x = screen._backBuffer1.width() - SHERLOCK_SCREEN_WIDTH;
		if (_targetScroll.y < 0)
			_targetScroll.y = 0;
		if ((_targetScroll.y + SHERLOCK_SCREEN_HEIGHT) > screen._backBuffer1.height())
			_targetScroll.y = screen._backBuffer1.height() - SHERLOCK_SCREEN_HEIGHT;

		// Check the keyboard
		if (events.kbHit()) {
			Common::KeyState keyState = events.getKey();

			switch (keyState.keycode) {
			case Common::KEYCODE_HOME:
				_targetScroll.x = 0;
				_targetScroll.y = 0;
				break;

			case Common::KEYCODE_END:
				_targetScroll.x = screen._backBuffer1.width() - SHERLOCK_SCREEN_WIDTH;
				_targetScroll.y = screen._backBuffer1.height() - SHERLOCK_SCREEN_HEIGHT;
				break;

			case Common::KEYCODE_PAGEUP:
				_targetScroll.y -= SHERLOCK_SCREEN_HEIGHT;
				if (_targetScroll.y < 0)
					_targetScroll.y = 0;
				break;

			case Common::KEYCODE_PAGEDOWN:
				_targetScroll.y += SHERLOCK_SCREEN_HEIGHT;
				if (_targetScroll.y > (screen._backBuffer1.height() - SHERLOCK_SCREEN_HEIGHT))
					_targetScroll.y = screen._backBuffer1.height() - SHERLOCK_SCREEN_HEIGHT;
				break;

			case Common::KEYCODE_SPACE:
				events._pressed = false;
				events._oldButtons = 0;
				events._released = true;
				break;

			default:
				break;
			}
		}

		// Handle any scrolling of the map
		if (screen._currentScroll != _targetScroll) {
			// If there is a Text description being displayed, restore the area under it
			_mapTooltip.erase();

			screen._currentScroll = _targetScroll;

			checkMapNames(false);
			screen.slamArea(_targetScroll.x, _targetScroll.y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
		}

		// Handling if a location has been clicked on
		if (events._released && _bgFound != -1) {
			// If there is a Text description being displayed, restore the area under it
			_mapTooltip.erase();

			// Save the current scroll position on the map
			_bigPos = screen._currentScroll;

			showCloseUp(_bgFound);
			result = _bgFound + 1;
		}
	} while (!result && !_vm->shouldQuit());

	music.stopMusic();
	events.clearEvents();
	_mapTooltip.banishWindow();

	// Reset the back buffers back to standard size
	screen._backBuffer1.create(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
	screen._backBuffer2.create(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
	screen.activateBackBuffer1();

	return result;
}
예제 #2
0
파일: scores.c 프로젝트: JamesWR/Larn
void
died (int x)
{
  int f, win;
  /*char ch, *mod;
     time_t zzz; */

  if (cdesc[LIFEPROT] > 0)	/* if life protection */
    {
      switch ((x > 0) ? x : -x)
	{
	case 256:
	case 257:
	case 262:
	case 263:
	case 265:
	case 266:
	case 267:
	case 268:
	case 269:
	case 271:
	case 282:
	case 284:
	case 285:
	case 300:
	  goto invalid;		/* can't be saved */
	};
      --cdesc[LIFEPROT];
      cdesc[HP] = 1;
      --cdesc[CONSTITUTION];
      cursors ();
      lprcat ("\nYou feel wiiieeeeerrrrrd all over! ");
      lflush ();
      nap (NAPTIME);
      return;			/* only case where died() returns */
    }

  cursors ();
  lprcat ("\nPress any key to continue. ");
  ttgetch ();

invalid:
  /*clearvt100(); */
  lflush ();
  f = 0;

  /* if we are not to display the scores */
  if (x < 0)
    {
      f++;
      x = -x;
    }

  /* for quick exit or saved game */
  if ((x == 300) || (x == 257))
    {
      clearvt100 ();
      exit (EXIT_SUCCESS);
    }

  if (x == 263)
    win = 1;
  else
    win = 0;

  cdesc[GOLD] += cdesc[BANKACCOUNT];
  cdesc[BANKACCOUNT] = 0;

  /*  now enter the player at the end of the scoreboard */
  newscore (cdesc[GOLD], logname, x, win);
  diedsub (x);			/* print out the score line */
  lflush ();

  set_score_output ();
  if ((wizard == 0) && (cdesc[GOLD] > 0))	/*  wizards can't score     */
    {
      /*if (lappend(logfile)<0)
         {
         if (lcreat(logfile)<0) {
         lcreat((char*)0);
         lprcat("\nCan't open record file:  I can't post your score.\n");
         sncbr();
         resetscroll();
         lflush();
         clearvt100();
         exit(EXIT_SUCCESS);
         }
         _chmod(logfile,0666);
         }
         strcpy(logg.who,logname);
         logg.score = cdesc[GOLD];  
         logg.diff = cdesc[HARDGAME];
         if (x < 256) {
         ch = *monster[x].name;
         if (ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
         mod="an";
         else
         mod="a";
         sprintf(logg.what,"killed by %s %s",mod,monster[x].name);
         }
         else sprintf(logg.what,"%s",whydead[x - 256]);
         logg.cavelev=level;
         time(&zzz);
         logg.diedtime=zzz;
         #ifdef EXTRA
         logg.lev=cdesc[LEVEL];          logg.ac=cdesc[AC];
         logg.hpmax=cdesc[HPMAX];        logg.hp=cdesc[HP];
         logg.elapsedtime=(zzz-initialtime+59)/60;
         logg.usage=(10000*i)/(zzz-initialtime);
         logg.bytin=cdesc[BYTESIN];      logg.bytout=cdesc[BYTESOUT];
         logg.moves=cdesc[MOVESMADE];    logg.spused=cdesc[SPELLSCAST];
         logg.killed=cdesc[MONSTKILLED];
         #endif
         lwrite((char*)&logg,sizeof(struct log_fmt));
         lwclose(); */

      /*  now for the scoreboard maintenance -- not for a suspended game  */
      if (x != 257)
	{
	  if (sortboard ())
	    scorerror = writeboard ();
	}
    }
  if ((x == 256) || (x == 257) || (f != 0))
    {
      clearvt100 ();
      exit (EXIT_SUCCESS);
    }
  if (scorerror == 0)
    {
      lflush ();
      clear ();
      resetscroll ();
      showscores ();		/* if we updated the scoreboard */
      cursors ();
      lprcat ("\nPress any key to exit. ");
      scbr ();
      ttgetch ();
    }
  clearvt100 ();
  exit (EXIT_SUCCESS);
}
예제 #3
0
/*
	a subroutine to raise or lower character levels
	if x > 0 they are raised   if x < 0 they are lowered
 */
void
fntchange(int how)
{
	long   j;
	lprc('\n');
	switch (rnd(9)) {
	case 1:
		lprcat("Your strength");
		fch(how, &c[0]);
		break;
	case 2:
		lprcat("Your intelligence");
		fch(how, &c[1]);
		break;
	case 3:
		lprcat("Your wisdom");
		fch(how, &c[2]);
		break;
	case 4:
		lprcat("Your constitution");
		fch(how, &c[3]);
		break;
	case 5:
		lprcat("Your dexterity");
		fch(how, &c[4]);
		break;
	case 6:
		lprcat("Your charm");
		fch(how, &c[5]);
		break;
	case 7:
		j = rnd(level + 1);
		if (how < 0) {
			lprintf("You lose %ld hit point", (long) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
			losemhp((int) j);
		} else {
			lprintf("You gain %ld hit point", (long) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
			raisemhp((int) j);
		}
		bottomline();
		break;

	case 8:
		j = rnd(level + 1);
		if (how > 0) {
			lprintf("You just gained %ld spell", (long) j);
			raisemspells((int) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
		} else {
			lprintf("You just lost %ld spell", (long) j);
			losemspells((int) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
		}
		bottomline();
		break;

	case 9:
		j = 5 * rnd((level + 1) * (level + 1));
		if (how < 0) {
			lprintf("You just lost %ld experience point", (long) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
			loseexperience((long) j);
		} else {
			lprintf("You just gained %ld experience point", (long) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
			raiseexperience((long) j);
		}
		break;
	}
	cursors();
}
예제 #4
0
/*
	*******
	REGEN()
	*******
	regen()

	subroutine to regenerate player hp and spells
 */
void
regen(void)
{
	int i, flag;
	long *d;
	d = c;
#ifdef EXTRA
	d[MOVESMADE]++;
#endif
	if (d[TIMESTOP]) {
		if (--d[TIMESTOP] <= 0)
			bottomline();
		return;
	}			/* for stop time spell */
	flag = 0;

	if (d[STRENGTH] < 3) {
		d[STRENGTH] = 3;
		flag = 1;
	}
	if ((d[HASTESELF] == 0) || ((d[HASTESELF] & 1) == 0))
		gtime++;

	if (d[HP] != d[HPMAX])
		if (d[REGENCOUNTER]-- <= 0) {	/* regenerate hit points */
			d[REGENCOUNTER] = 22 + (d[HARDGAME] << 1) - d[LEVEL];
			if ((d[HP] += d[REGEN]) > d[HPMAX])
				d[HP] = d[HPMAX];
			bottomhp();
		}

	if (d[SPELLS] < d[SPELLMAX])	/* regenerate spells */
		if (d[ECOUNTER]-- <= 0) {
			d[ECOUNTER] = 100 + 4 * (d[HARDGAME] - d[LEVEL] - d[ENERGY]);
			d[SPELLS]++;
			bottomspell();
		}

	if (d[HERO])
		if (--d[HERO] <= 0) {
			for (i = 0; i < 6; i++)
				d[i] -= 10;
			flag = 1;
		}
	if (d[ALTPRO])
		if (--d[ALTPRO] <= 0) {
			d[MOREDEFENSES] -= 3;
			flag = 1;
		}
	if (d[PROTECTIONTIME])
		if (--d[PROTECTIONTIME] <= 0) {
			d[MOREDEFENSES] -= 2;
			flag = 1;
		}
	if (d[DEXCOUNT])
		if (--d[DEXCOUNT] <= 0) {
			d[DEXTERITY] -= 3;
			flag = 1;
		}
	if (d[STRCOUNT])
		if (--d[STRCOUNT] <= 0) {
			d[STREXTRA] -= 3;
			flag = 1;
		}
	if (d[BLINDCOUNT])
		if (--d[BLINDCOUNT] <= 0) {
			cursors();
			lprcat("\nThe blindness lifts  ");
			beep();
		}
	if (d[CONFUSE])
		if (--d[CONFUSE] <= 0) {
			cursors();
			lprcat("\nYou regain your senses");
			beep();
		}
	if (d[GIANTSTR])
		if (--d[GIANTSTR] <= 0) {
			d[STREXTRA] -= 20;
			flag = 1;
		}
	if (d[CHARMCOUNT])
		if ((--d[CHARMCOUNT]) <= 0)
			flag = 1;
	if (d[INVISIBILITY])
		if ((--d[INVISIBILITY]) <= 0)
			flag = 1;
	if (d[CANCELLATION])
		if ((--d[CANCELLATION]) <= 0)
			flag = 1;
	if (d[WTW])
		if ((--d[WTW]) <= 0)
			flag = 1;
	if (d[HASTESELF])
		if ((--d[HASTESELF]) <= 0)
			flag = 1;
	if (d[AGGRAVATE])
		--d[AGGRAVATE];
	if (d[SCAREMONST])
		if ((--d[SCAREMONST]) <= 0)
			flag = 1;
	if (d[STEALTH])
		if ((--d[STEALTH]) <= 0)
			flag = 1;
	if (d[AWARENESS])
		--d[AWARENESS];
	if (d[HOLDMONST])
		if ((--d[HOLDMONST]) <= 0)
			flag = 1;
	if (d[HASTEMONST])
		--d[HASTEMONST];
	if (d[FIRERESISTANCE])
		if ((--d[FIRERESISTANCE]) <= 0)
			flag = 1;
	if (d[GLOBE])
		if (--d[GLOBE] <= 0) {
			d[MOREDEFENSES] -= 10;
			flag = 1;
		}
	if (d[SPIRITPRO])
		if (--d[SPIRITPRO] <= 0)
			flag = 1;
	if (d[UNDEADPRO])
		if (--d[UNDEADPRO] <= 0)
			flag = 1;
	if (d[HALFDAM])
		if (--d[HALFDAM] <= 0) {
			cursors();
			lprcat("\nYou now feel better ");
			beep();
		}
	if (d[SEEINVISIBLE])
		if (--d[SEEINVISIBLE] <= 0) {
			monstnamelist[INVISIBLESTALKER] = ' ';
			cursors();
			lprcat("\nYou feel your vision return to normal");
			beep();
		}
	if (d[ITCHING]) {
		if (d[ITCHING] > 1)
			if ((d[WEAR] != -1) || (d[SHIELD] != -1))
				if (rnd(100) < 50) {
					d[WEAR] = d[SHIELD] = -1;
					cursors();
					lprcat("\nThe hysteria of itching forces you to remove your armor!");
					beep();
					recalc();
					bottomline();
				}
		if (--d[ITCHING] <= 0) {
			cursors();
			lprcat("\nYou now feel the irritation subside!");
			beep();
		}
	}
	if (d[CLUMSINESS]) {
		if (d[WIELD] != -1)
			if (d[CLUMSINESS] > 1)
				if (item[playerx][playery] == 0)	/* only if nothing there */
					if (rnd(100) < 33)	/* drop your weapon due to clumsiness */
						drop_object((int)d[WIELD]);
		if (--d[CLUMSINESS] <= 0) {
			cursors();
			lprcat("\nYou now feel less awkward!");
			beep();
		}
	}
	if (flag)
		bottomline();
}
예제 #5
0
파일: main.c 프로젝트: HunterZ/larn
/*
 * common routine to say you can't wield an item
 */   
static void ycwi(int x)
{
	cursors();
	
	lprintf("\nYou can't wield item %c!",x);
}
예제 #6
0
파일: main.c 프로젝트: HunterZ/larn
static void consume(int search_item, char *prompt, int (*showfunc)())
{
	int i;

    while (1)
        {
        if ((i = whatitem( prompt )) == '\33')
            return;
        if (i != '.' && i != '-')
            {
            if (i == '*')
                {
                i = showfunc();
                cursors();
                }
            if (i && i != '.')
                {
                switch (iven[i-'a'])
                    {
                    case OSCROLL:
                        if ( search_item != OSCROLL )
                            {
                            lprintf("\nYou can't %s that.", prompt );
                            return;
                            }
                        read_scroll( ivenarg[i-'a'] );
                        break;
                    case OBOOK:
                        if ( search_item != OSCROLL )
                            {
                            lprintf("\nYou can't %s that.", prompt );
                            return;
                            }
                        readbook( ivenarg[i-'a'] );
                        break;
                    case OCOOKIE:
                        if ( search_item != OCOOKIE )
                            {
                            lprintf("\nYou can't %s that.", prompt );
                            return;
                            }
                        outfortune();
                        break;
                    case OPOTION:
                        if ( search_item != OPOTION )
                            {
                            lprintf("\nYou can't %s that.", prompt );
                            return;
                            }
                        quaffpotion( ivenarg[i-'a'], TRUE );
                        break;
                    case 0:
                        ydhi(i);
                        return;
                    default:
                        lprintf("\nYou can't %s that.", prompt );
                        return;
                    }
                iven[i-'a'] = 0;
                return;
                }
            }
        }
}
예제 #7
0
파일: main.c 프로젝트: HunterZ/larn
/*
 * parse()
 *
 * get and execute a command
 */
static void parse(void)
{
	int i, j, k, flag;

    while   (1)
        {
        k = yylex();
        switch(k)   /*  get the token from the input and switch on it   */
            {
            case 'h':   moveplayer(4);  return;     /*  west        */
            case 'H':   run(4);         return;     /*  west        */
            case 'l':   moveplayer(2);  return;     /*  east        */
            case 'L':   run(2);         return;     /*  east        */
            case 'j':   moveplayer(1);  return;     /*  south       */
            case 'J':   run(1);         return;     /*  south       */
            case 'k':   moveplayer(3);  return;     /*  north       */
            case 'K':   run(3);         return;     /*  north       */
            case 'u':   moveplayer(5);  return;     /*  northeast   */
            case 'U':   run(5);         return;     /*  northeast   */
            case 'y':   moveplayer(6);  return;     /*  northwest   */
            case 'Y':   run(6);         return;     /*  northwest   */
            case 'n':   moveplayer(7);  return;     /*  southeast   */
            case 'N':   run(7);         return;     /*  southeast   */
            case 'b':   moveplayer(8);  return;     /*  southwest   */
            case 'B':   run(8);         return;     /*  southwest   */

            case '.':                               /*  stay here       */
                if (yrepcount) 
                    viewflag=1;
                return;

            case 'c':
                yrepcount=0;
                cast();
                return;     /*  cast a spell    */

            case 'd':
                yrepcount=0;
                if (c[TIMESTOP]==0)
                    dropobj();
                return; /*  to drop an object   */

            case 'e':
                yrepcount=0;
                if (c[TIMESTOP]==0)
                    if (!floor_consume( OCOOKIE, "eat" ))
                        consume( OCOOKIE, "eat", showeat );
                return; /*  to eat a fortune cookie */

            case 'g':   
                yrepcount = 0 ;
                cursors();
                lprintf("\nThe stuff you are carrying presently weighs %d pounds",(long)packweight());
                break ;

            case 'i':       /* inventory */
                yrepcount=0;
                nomove=1;
                showstr(FALSE);
                return;

            case 'p':           /* pray at an altar */
                yrepcount = 0;
                    pray_at_altar();
                return;

            case 'q':           /* quaff a potion */
                yrepcount=0;
                if (c[TIMESTOP]==0)
                    if (!floor_consume( OPOTION, "quaff"))
                        consume( OPOTION, "quaff", showquaff );
                return;

            case 'r':
                yrepcount=0;
                if (c[BLINDCOUNT])
                    {
                    cursors();
                    lprcat("\nYou can't read anything when you're blind!");
                    }
                else if (c[TIMESTOP]==0)
                    if (!floor_consume( OSCROLL, "read" ))
                        if (!floor_consume( OBOOK, "read" ))
                            consume( OSCROLL, "read", showread );
                return;     /*  to read a scroll    */

            case 's':
                yrepcount = 0 ;
                    sit_on_throne();
                return ;

            case 't':                       /* Tidy up at fountain */
                yrepcount = 0 ;
                    wash_fountain() ;
                return ;

            case 'v':
                yrepcount=0;
                nomove = 1;
                cursors();
                lprintf("\nLarn, Version %d.%d.%d, Diff=%d",(long)VERSION,(long)SUBVERSION,(long)PATCHLEVEL,(long)c[HARDGAME]);
                if (wizard)
                    lprcat(" Wizard");
                if (cheat) 
                    lprcat(" Cheater");
                return;

            case 'w':                       /*  wield a weapon */
                yrepcount=0;
                wield();
                return;

            case 'A':
                yrepcount = 0;
                    desecrate_altar();
                return;

            case 'C':                       /* Close something */
                yrepcount = 0 ;
                    close_something();
                return;

            case 'D':                       /* Drink at fountain */
                yrepcount = 0 ;
                    drink_fountain() ;
                return ;

            case 'E':               /* Enter a building */
                yrepcount = 0 ;
                    enter() ;
                break ;

            case 'I':              /*  list spells and scrolls */
                yrepcount=0;
                seemagic(0);
                nomove=1;
                return;

            case 'O':               /* Open something */
                yrepcount = 0 ;
                    open_something();
                return;

            case 'P':
                cursors();
                yrepcount = 0;
                nomove = 1;
                if (outstanding_taxes>0)
                    lprintf("\nYou presently owe %d gp in taxes.",(long)outstanding_taxes);
                else
                    lprcat("\nYou do not owe any taxes.");
                return;

            case 'Q':    /*  quit        */
                yrepcount=0;
                quit();
                nomove=1;
                return;

            case 'R' :          /* remove gems from a throne */
                yrepcount = 0 ;
                    remove_gems( );
                return ;

            case 'S':
                /* And do the save.
                 */
                cursors();
                lprintf("\nSaving to `%s' . . . ", savefilename);
                lflush();
                save_mode = 1;
                savegame(savefilename);
                clear();
                lflush();
                wizard=1;
                died(-257); /* doesn't return */
                break;


            case 'T':   yrepcount=0;    cursors();  if (c[SHIELD] != -1) { c[SHIELD] = -1; lprcat("\nYour shield is off"); bottomline(); } else
                                        if (c[WEAR] != -1) { c[WEAR] = -1; lprcat("\nYour armor is off"); bottomline(); }
                        else lprcat("\nYou aren't wearing anything");
                        return;

            case 'W':
                yrepcount=0;
                wear();
                return; /*  wear armor  */

            case 'Z':
                yrepcount=0;
                if (c[LEVEL]>9) 
                    { 
                    oteleport(1);
                    return; 
                    }
                cursors(); 
                lprcat("\nAs yet, you don't have enough experience to use teleportation");
                return; /*  teleport yourself   */

            case ' ':   yrepcount=0;    nomove=1;  return;

            case 'L'-64:  yrepcount=0;  drawscreen();  nomove=1; return;    /*  look        */

#if WIZID
#ifdef EXTRA
            case 'A'-64:    yrepcount=0;    nomove=1; if (wizard) { diag(); return; }  /*   create diagnostic file */
                        return;
#endif
#endif
	    
	    case '<':                       /* Go up stairs or vol shaft */
                yrepcount = 0;
                    up_stairs();
                return ;

            case '>':                       /* Go down stairs or vol shaft*/
                yrepcount = 0 ;
                    down_stairs();
                return ;

            case '?':                       /* give the help screen */
                yrepcount=0;
                help();
                nomove=1;
                return; 

        case ',':                       /* pick up an item */
            yrepcount = 0 ;
            /* pickup, don't identify or prompt for action */
            lookforobject( FALSE, TRUE, FALSE );
        return;

            case ':':                       /* look at object */
                yrepcount = 0 ;
            /* identify, don't pick up or prompt for action */
                    lookforobject( TRUE, FALSE, FALSE );
                nomove = 1;  /* assumes look takes no time */
                return;

        case '/':        /* identify object/monster */
            specify_object();
            nomove = 1 ;
            yrepcount = 0 ;
            return;

        case '^':                       /* identify traps */
                flag = yrepcount = 0;
                cursors();
                lprc('\n');
                for (j=playery-1; j<playery+2; j++)
                    {
                    if (j < 0)
                        j=0;
                    if (j >= MAXY)
                        break;
                    for (i=playerx-1; i<playerx+2; i++)
                        {
                        if (i < 0) 
                            i=0;
                        if (i >= MAXX) 
                            break;
                        switch(item[i][j])
                            {
                            case OTRAPDOOR:     case ODARTRAP:
                            case OTRAPARROW:    case OTELEPORTER:
                            case OPIT:
                                lprcat("\nIts ");
                                lprcat(objectname[item[i][j]]);
                                flag++;
                            };
                        }
                    }
                if (flag==0) 
                    lprcat("\nNo traps are visible");
                return;

#if WIZID
            case '_':   /*  this is the fudge player password for wizard mode*/
                        yrepcount=0;    cursors(); nomove=1;

                        if (getpassword()==0)
                            {
                            scbr(); /* system("stty -echo cbreak"); */ return;
                            }
                        wizard=1;  scbr(); /* system("stty -echo cbreak"); */
                        for (i=0; i<6; i++)  c[i]=70;  iven[0]=iven[1]=0;
                        take(OPROTRING,50);   take(OLANCE,25);  c[WIELD]=1;
                        c[LANCEDEATH]=1;   c[WEAR] = c[SHIELD] = -1;
                        raiseexperience(6000000L);  c[AWARENESS] += 25000;
                        {
                        int i,j;
                        for (i=0; i<MAXY; i++)
                            for (j=0; j<MAXX; j++)  know[j][i]=KNOWALL;
                        for (i=0; i<SPNUM; i++) spelknow[i]=1;
                        for (i=0; i<MAXSCROLL; i++)  scrollname[i][0]=' ';
                        for (i=0; i<MAXPOTION; i++)  potionname[i][0]=' ';
                        }
                        for (i=0; i<MAXSCROLL; i++)
                          if (strlen(scrollname[i])>2) /* no null items */
                            { item[i][0]=OSCROLL; iarg[i][0]=i; }
                        for (i=MAXX-1; i>MAXX-1-MAXPOTION; i--)
                          if (strlen(potionname[i-MAXX+MAXPOTION])>2) /* no null items */
                            { item[i][0]=OPOTION; iarg[i][0]=i-MAXX+MAXPOTION; }
                        for (i=1; i<MAXY; i++)
                            { item[0][i]=i; iarg[0][i]=0; }
                        for (i=MAXY; i<MAXY+MAXX; i++)
                            { item[i-MAXY][MAXY-1]=i; iarg[i-MAXY][MAXY-1]=0; }
            for (i=MAXX+MAXY; i<MAXOBJECT; i++)
                {
                item[MAXX-1][i-MAXX-MAXY]=i;
                iarg[MAXX-1][i-MAXX-MAXY]=0;
                }
                        c[GOLD]+=250000;    drawscreen();   return;
#endif

            };
        }
}
예제 #8
0
파일: main.c 프로젝트: HunterZ/larn
/*
 * function to wield a weapon
 */
static void wield(void)
{
	int i;

	while (TRUE) {
		
		i = whatitem("wield (- for nothing)");
		if (i == '\33') return;
		
		
		if (i != '.') {
            
			if (i == '*') {
				
				i = showwield();
				cursors();
			}
		
			if ( i == '-' ) {
				
				c[WIELD] = -1 ;
				bottomline();
				
				return;
			}
			
			if (!i || i == '.') {
		
				continue;
			}

			if (iven[i-'a']==0) { 
					
				ydhi(i);
				return;
					
			} else if (iven[i - 'a'] == OPOTION) { 
					
				ycwi(i); 
				return;
					
			} else if (iven[i-'a'] == OSCROLL) {
					
				ycwi(i);
				return;
					
			} else if (c[SHIELD] != -1 &&
				iven[i-'a'] == O2SWORD) {
						
				lprcat("\nBut one arm is busy with your shield!");
				return;
						
			} else {
			
				c[WIELD]= i - 'a';
					
				if (iven[i - 'a'] == OLANCE) {
						
					c[LANCEDEATH]=1;
						
				} else {
						
					c[LANCEDEATH]=0;
				}
					
				bottomline();
				return;
			}
		}
	}
}
예제 #9
0
파일: main.c 프로젝트: ajinkya93/netbsd-src
/*
	parse()

	get and execute a command
 */
static void
parse(void)
{
	int    i, j, k, flag;
	while (1) {
		k = yylex();
		switch (k) {	/* get the token from the input and switch on
				 * it	 */
		case 'h':
			moveplayer(4);
			return;	/* west		 */
		case 'H':
			run(4);
			return;	/* west		 */
		case 'l':
			moveplayer(2);
			return;	/* east		 */
		case 'L':
			run(2);
			return;	/* east		 */
		case 'j':
			moveplayer(1);
			return;	/* south		 */
		case 'J':
			run(1);
			return;	/* south		 */
		case 'k':
			moveplayer(3);
			return;	/* north		 */
		case 'K':
			run(3);
			return;	/* north		 */
		case 'u':
			moveplayer(5);
			return;	/* northeast	 */
		case 'U':
			run(5);
			return;	/* northeast	 */
		case 'y':
			moveplayer(6);
			return;	/* northwest	 */
		case 'Y':
			run(6);
			return;	/* northwest	 */
		case 'n':
			moveplayer(7);
			return;	/* southeast	 */
		case 'N':
			run(7);
			return;	/* southeast	 */
		case 'b':
			moveplayer(8);
			return;	/* southwest	 */
		case 'B':
			run(8);
			return;	/* southwest	 */

		case '.':
			if (yrepcount)
				viewflag = 1;
			return;	/* stay here		 */

		case 'w':
			yrepcount = 0;
			wield();
			return;	/* wield a weapon */

		case 'W':
			yrepcount = 0;
			wear();
			return;	/* wear armor	 */

		case 'r':
			yrepcount = 0;
			if (c[BLINDCOUNT]) {
				cursors();
				lprcat("\nYou can't read anything when you're blind!");
			} else if (c[TIMESTOP] == 0)
				readscr();
			return;	/* to read a scroll	 */

		case 'q':
			yrepcount = 0;
			if (c[TIMESTOP] == 0)
				quaff();
			return;	/* quaff a potion		 */

		case 'd':
			yrepcount = 0;
			if (c[TIMESTOP] == 0)
				dropobj();
			return;	/* to drop an object	 */

		case 'c':
			yrepcount = 0;
			cast();
			return;	/* cast a spell	 */

		case 'i':
			yrepcount = 0;
			nomove = 1;
			showstr();
			return;	/* status		 */

		case 'e':
			yrepcount = 0;
			if (c[TIMESTOP] == 0)
				eatcookie();
			return;	/* to eat a fortune cookie */

		case 'D':
			yrepcount = 0;
			seemagic(0);
			nomove = 1;
			return;	/* list spells and scrolls */

		case '?':
			yrepcount = 0;
			help();
			nomove = 1;
			return;	/* give the help screen */

		case 'S':
			clear();
			lprcat("Saving . . .");
			lflush();
			savegame(savefilename);
			wizard = 1;
			died(-257);	/* save the game - doesn't return	 */

		case 'Z':
			yrepcount = 0;
			if (c[LEVEL] > 9) {
				oteleport(1);
				return;
			}
			cursors();
			lprcat("\nAs yet, you don't have enough experience to use teleportation");
			return;	/* teleport yourself	 */

		case '^':	/* identify traps */
			flag = yrepcount = 0;
			cursors();
			lprc('\n');
			for (j = playery - 1; j < playery + 2; j++) {
				if (j < 0)
					j = 0;
				if (j >= MAXY)
					break;
				for (i = playerx - 1; i < playerx + 2; i++) {
					if (i < 0)
						i = 0;
					if (i >= MAXX)
						break;
					switch (item[i][j]) {
					case OTRAPDOOR:
					case ODARTRAP:
					case OTRAPARROW:
					case OTELEPORTER:
						lprcat("\nIt's ");
						lprcat(objectname[item[i][j]]);
						flag++;
					};
				}
			}
			if (flag == 0)
				lprcat("\nNo traps are visible");
			return;

#if WIZID
		case '_':	/* this is the fudge player password for
				 * wizard mode */
			yrepcount = 0;
			cursors();
			nomove = 1;
			if (userid != wisid) {
				lprcat("Sorry, you are not empowered to be a wizard.\n");
				scbr();	/* system("stty -echo cbreak"); */
				lflush();
				return;
			}
			if (getpassword() == 0) {
				scbr();	/* system("stty -echo cbreak"); */
				return;
			}
			wizard = 1;
			scbr();	/* system("stty -echo cbreak"); */
			for (i = 0; i < 6; i++)
				c[i] = 70;
			iven[0] = iven[1] = 0;
			take(OPROTRING, 50);
			take(OLANCE, 25);
			c[WIELD] = 1;
			c[LANCEDEATH] = 1;
			c[WEAR] = c[SHIELD] = -1;
			raiseexperience(6000000L);
			c[AWARENESS] += 25000;
			{
				int    i, j;
				for (i = 0; i < MAXY; i++)
					for (j = 0; j < MAXX; j++)
						know[j][i] = 1;
				for (i = 0; i < SPNUM; i++)
					spelknow[i] = 1;
				for (i = 0; i < MAXSCROLL; i++)
					scrollname[i] = scrollhide[i];
				for (i = 0; i < MAXPOTION; i++)
					potionname[i] = potionhide[i];
			}
			for (i = 0; i < MAXSCROLL; i++)
				if (strlen(scrollname[i]) > 2) {	/* no null items */
					item[i][0] = OSCROLL;
					iarg[i][0] = i;
				}
			for (i = MAXX - 1; i > MAXX - 1 - MAXPOTION; i--)
				if (strlen(potionname[i - MAXX + MAXPOTION]) > 2) {	/* no null items */
					item[i][0] = OPOTION;
					iarg[i][0] = i - MAXX + MAXPOTION;
				}
			for (i = 1; i < MAXY; i++) {
				item[0][i] = i;
				iarg[0][i] = 0;
			}
			for (i = MAXY; i < MAXY + MAXX; i++) {
				item[i - MAXY][MAXY - 1] = i;
				iarg[i - MAXY][MAXY - 1] = 0;
			}
			for (i = MAXX + MAXY; i < MAXX + MAXY + MAXY; i++) {
				item[MAXX - 1][i - MAXX - MAXY] = i;
				iarg[MAXX - 1][i - MAXX - MAXY] = 0;
			}
			c[GOLD] += 25000;
			drawscreen();
			return;
#endif

		case 'T':
			yrepcount = 0;
			cursors();
			if (c[SHIELD] != -1) {
				c[SHIELD] = -1;
				lprcat("\nYour shield is off");
				bottomline();
			} else if (c[WEAR] != -1) {
				c[WEAR] = -1;
				lprcat("\nYour armor is off");
				bottomline();
			} else
				lprcat("\nYou aren't wearing anything");
			return;

		case 'g':
			cursors();
			lprintf("\nThe stuff you are carrying presently weighs %ld pounds", (long) packweight());
		case ' ':
			yrepcount = 0;
			nomove = 1;
			return;

		case 'v':
			yrepcount = 0;
			cursors();
			lprintf("\nCaverns of Larn, Version %ld.%ld, Diff=%ld",
				(long) VERSION, (long) SUBVERSION,
				(long) c[HARDGAME]);
			if (wizard)
				lprcat(" Wizard");
			nomove = 1;
			if (cheat)
				lprcat(" Cheater");
			lprcat(copyright);
			return;

		case 'Q':
			yrepcount = 0;
			quit();
			nomove = 1;
			return;	/* quit		 */

		case 'L' - 64:
			yrepcount = 0;
			drawscreen();
			nomove = 1;
			return;	/* look		 */

#if WIZID
#ifdef EXTRA
		case 'A':
			yrepcount = 0;
			nomove = 1;
			if (wizard) {
				diag();
				return;
			}	/* create diagnostic file */
			return;
#endif
#endif
		case 'P':
			cursors();
			if (outstanding_taxes > 0)
				lprintf("\nYou presently owe %ld gp in taxes.",
					(long) outstanding_taxes);
			else
				lprcat("\nYou do not owe any taxes.");
			return;
		};
	}
}
예제 #10
0
파일: main.c 프로젝트: ajinkya93/netbsd-src
/*
	common routine to say you don't have an item
 */
static void
ydhi(int x)
{
	cursors();
	lprintf("\nYou don't have item %c!", x);
}
예제 #11
0
/*
*  mmove(x,y,xd,yd)    Function to actually perform the monster movement
*      int x,y,xd,yd;
*
*  Enter with the from coordinates in (x,y) and the destination coordinates
*  in (xd,yd).
*/
static void mmove(int aa, int bb, int cc, int dd)
{
	int tmp,i,flag;
	char *who = "";
	char *p = "";

	flag=0; /* set to 1 if monster hit by arrow trap */
	if ((cc==playerx) && (dd==playery))
	{
		hitplayer(aa,bb);
		return;
	}
	i=item[cc][dd];
	if ((i==OPIT) || (i==OTRAPDOOR))
		switch(mitem[aa][bb])
	{
		case BAT:           case EYE:
		case SPIRITNAGA:    case PLATINUMDRAGON:    case WRAITH:
		case VAMPIRE:       case SILVERDRAGON:      case POLTERGEIST:
		case DEMONLORD:     case DEMONLORD+1:       case DEMONLORD+2:
		case DEMONLORD+3:   case DEMONLORD+4:       case DEMONLORD+5:
		case DEMONLORD+6:   case DEMONPRINCE:   break;

		default:    mitem[aa][bb]=0; /* fell in a pit or trapdoor */
	};
	tmp = mitem[aa][bb];
	mitem[cc][dd] = tmp;
	if (i==OANNIHILATION)
	{
		if (tmp>=DEMONLORD+3) /* demons dispel spheres */
		{
			cursors();
			lprintf("\nThe %s dispels the sphere!",monster[tmp].name);
			rmsphere(cc,dd);    /* delete the sphere */
		}
		else mitem[cc][dd]=i=tmp=0;
	}
	stealth[cc][dd]=1;
	if ((hitp[cc][dd] = hitp[aa][bb]) < 0) hitp[cc][dd]=1;
	mitem[aa][bb] = 0;              
	if (tmp == LEPRECHAUN)
		switch(i)
	{
		case OGOLDPILE:  case OMAXGOLD:  case OKGOLD:  case ODGOLD:
		case ODIAMOND:   case ORUBY:     case OEMERALD: case OSAPPHIRE:
			item[cc][dd] = 0; /* leprechaun takes gold */
	};

	if (tmp == TROLL)  /* if a troll regenerate him */
		if ((gtime & 1) == 0)
			if (monster[tmp].hitpoints > hitp[cc][dd])  hitp[cc][dd]++;

	if (i==OTRAPARROW)  /* arrow hits monster */
	{ who = "An arrow";  if ((hitp[cc][dd] -= rnd(10)+level) <= 0)
	{ mitem[cc][dd]=0;  flag=2; } else flag=1; }
	if (i==ODARTRAP)    /* dart hits monster */
	{ who = "A dart";  if ((hitp[cc][dd] -= rnd(6)) <= 0)
	{ mitem[cc][dd]=0;  flag=2; } else flag=1; }
	if (i==OTELEPORTER) /* monster hits teleport trap */
	{ flag=3; fillmonst(mitem[cc][dd]);  mitem[cc][dd]=0; }
	if (cdesc[BLINDCOUNT]) return;  /* if blind don't show where monsters are   */
	if (know[cc][dd] & HAVESEEN)
	{
		p=0;
		if (flag) cursors();
		switch(flag)
		{
		case 1: p="\n%s hits the %s";  break;
		case 2: p="\n%s hits and kills the %s";  break;
		case 3: p="\nThe %s%s gets teleported"; who="";  break;
		};
		if (p) { lprintf(p,who,monster[tmp].name); }
	}
	/*  if (yrepcount>1) { know[aa][bb] &= 2;  know[cc][dd] &= 2; return; } */
	if (know[aa][bb] & HAVESEEN)   show1cell(aa,bb);
	if (know[cc][dd] & HAVESEEN)   show1cell(cc,dd);
}
예제 #12
0
파일: object.c 프로젝트: joshbressers/ularn
/*
	function to drink a potion
 */
void quaffpotion(int pot)
{
	int i,j;
	int k;

	if (pot<0 || pot>=MAXPOTION) 
		return; /* check for within bounds */

/* first character of potion name starts off as \0. */
/* drinking a certain type of potion changes that to a space */
/* ...and from then on it is printable.  */
/*	if (potionname[pot][0] == '\0')   */
/*		potionname[pot][0] = ' '; */
	if (potionknown[pot] == 0) 
	  potionknown[pot] = 1;
	lprintf("\nYou drink a potion of %s.", &potionname[pot][1]);

	switch(pot) {
	case PSLEEP:
		lprcat("  You fall asleep...");
		lflush();
		i=rnd(11)-(c[CONSTITUTION]>>2)+2;
		while(--i>0) {
			parse2();
			nap(1000);
		}
		cursors();
		lprcat("\n.. you wake up.");
		return;

	case PHEALING:
		lprcat("  You feel better.");
		if (c[HP] == c[HPMAX])
			raisemhp(1);
		else if ((c[HP] += rnd(20)+20+c[LEVEL]) > c[HPMAX])
			c[HP]=c[HPMAX];
		break;

	case PRAISELEVEL:
		lprcat("  You feel much more skillful!");
		raiselevel();
		raisemhp(1);
		return;

	case PINCABILITY:
		lprcat("  You feel strange for a moment.");
		c[rund(6)]++;
		break;

	case PWISDOM:
		lprcat("  You feel more self-confident!");
		c[WISDOM] += rnd(2);
		break;

	case PSTRENGTH:
		lprcat("  Wow!  You feel great!");
		if (c[STRENGTH]<12) c[STRENGTH]=12;
		else c[STRENGTH]++;
		break;

	case PCHARISMA:
		lprcat("  You feel charismatic!");
		c[CHARISMA]++;
		break;

	case PDIZZINESS:
		lprcat("  You become dizzy!");
		if (--c[STRENGTH] < 3) c[STRENGTH]=3;
		break;

	case PLEARNING:
		lprcat("  You feel clever!");
		c[INTELLIGENCE]++;
		break;

	case PGOLDDET:
		lprcat("  You feel greedy...");
		lflush();
		nap(2000);
		for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
			if ((item[j][i]==OGOLDPILE) || (item[j][i]==OMAXGOLD)) {
				know[j][i]=1; 
				show1cell(j,i);
			}
		showplayer();
		return;

	case PMONSTDET:
		for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
			if (mitem[j][i].mon) {
				know[j][i]=1; 
				show1cell(j,i);
			}
		return;

	case PFORGETFUL:
		lprcat("  You stagger for a moment...");
		lflush();
		for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
			know[j][i]=0;
		nap(2000);	
		draws(0,MAXX,0,MAXY);
		return;

	case PWATER:
		return;

	case PBLINDNESS:
		lprcat("  You can't see anything!"); 
		c[BLINDCOUNT]+=500;  /* dang, that's a long time. */
		/* erase the character, too! */
		cursor(playerx+1,playery+1);
		lprc(' ');
		cursor(playerx+1,playery+1);
		return;

	case PCONFUSION:
		lprcat("  You feel confused.");
		c[CONFUSE]+= 20+rnd(9); 
		return;

	case PHEROISM:
		lprcat("  WOW!  You feel fantastic!");
		if (c[HERO]==0) for (i=0; i<6; i++) c[i] += 11;
		c[HERO] += 250;  
		break;

	case PSTURDINESS:
		lprcat("  You feel healthier!");
		c[CONSTITUTION]++;  
		break;

	case PGIANTSTR:
		lprcat("  You now have incredible bulging muscles!");
		if (c[GIANTSTR]==0) c[STREXTRA] += 21;
		c[GIANTSTR] += 700;  
		break;

	case PFIRERESIST:
		lprcat("  You feel a chill run up your spine!");
		c[FIRERESISTANCE] += 1000;  
		break;

	case PTREASURE:
		lprcat("  You feel greedy...");
		lflush();
		nap(2000);
		for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++) {
			k=item[j][i];
			if ((k==ODIAMOND) || (k==ORUBY) || (k==OEMERALD) 
		 	    || (k==OMAXGOLD) || (k==OSAPPHIRE) 
			    || (k==OLARNEYE) || (k==OGOLDPILE)) {
				know[j][i]=1; 
				show1cell(j,i);
			}
		}
		showplayer();  
		return;

	case PINSTHEAL:
		c[HP] = c[HPMAX]; 
		removecurse();
		break;

	case PCUREDIANTH:
		lprcat("  You don't seem to be affected.");
		return;

	case PPOISON:
		lprcat("  You feel a sickness engulf you!");
		c[HALFDAM] += 200 + rnd(200);  
		return;

	case PSEEINVIS:
		lprcat("  You feel your vision sharpen.");
		c[SEEINVISIBLE] += rnd(1000)+400;
		monstnamelist[INVISIBLESTALKER] = 'I';  
		return;
	};
	/*	show new stats		*/
	bottomline();		
	return;
}
예제 #13
0
파일: object.c 프로젝트: joshbressers/ularn
/*
	***************
	LOOK_FOR_OBJECT
	***************

	subroutine to look for an object and give the player his options
	if an object was found.
 */
void lookforobject()
{
	int i,j;

	/* can't find objects is time is stopped*/
	if (c[TIMESTOP])  return;	

	i=item[playerx][playery];	
	if (i==0) return;

	showcell(playerx,playery);  
	cursors();  
	yrepcount=0;

	switch(i) {
	case OGOLDPILE:	
	case OMAXGOLD:
	case OKGOLD:	
	case ODGOLD:	
		ogold(i);	
		break;

	case OPOTION:	
		lprcat("\n\nYou find a magic potion");
		i = iarg[playerx][playery];
		if (potionknown[i]) lprintf(" of %s",&potionname[i][1]);
		lprcat(".");
		opotion(i);  
		break;

	case OSCROLL:	
		lprcat("\n\nYou find a magic scroll");
		i = iarg[playerx][playery];
		if (scrollknown[i]) lprintf(" of %s",&scrollname[i][1]);
		lprcat(".");
		oscroll(i);  
		break;

	case OALTAR:	
		if (nearbymonst()) return;
		lprcat("\n\nThere is a holy altar here.");
		oaltar(); 
		break;

	case OBOOK:	
		lprcat("\n\nYou find a book.");
		obook(); 
		break;

	case OCOOKIE:	
		lprcat("\n\nYou find a fortune cookie.");
		ocookie(); 
		break;

	case OTHRONE:	
		if (nearbymonst()) return;
		lprintf("\n\nThere is %s here.",objectname[i]);
		othrone(0); 
		break;

	case OTHRONE2:	
		if (nearbymonst()) return;
		lprintf("\n\nThere is %s here.",objectname[i]);
		othrone(1); 
		break;

	case ODEADTHRONE: 
		lprintf("\n\nThere is %s here.",objectname[i]);
		odeadthrone(); 
		break;

	case OORB:	
		if (nearbymonst()) return;
		finditem(i);
		break;

	case OBRASSLAMP: 
		lprcat("\nYou find a brass lamp.");
	lprcat("\nDo you want to (r) rub it, (t) take it, or (i) ignore it? ");
		i=0;
		while ((i!='r') && (i!='i') && (i!='t') && (i!=ESC)) 
			i=getcharacter();
		if (i=='r') {
			i=rnd(100);
			if (i>90) {
		lprcat("\nThe magic genie was very upset at being disturbed!");
				lastnum = 286;
				losehp((int)c[HP]/2+1);
				beep();
			}
			/* higher level, better chance of spell */
			else if ( (rnd(100)+c[LEVEL]/2) > 80) {
				int a,b,d;
				lprcat("\nA magic genie appears!");
				cursors();
				lprcat("\n  What spell would you like? : ");
				while ((a=getcharacter())=='D') { 	
					seemagic(99);
					cursors();  
					lprcat("\n  What spell would you like? : ");
				}
				/* to escape casting a spell	*/
				if (a==ESC) goto over; 	
				if ((b=getcharacter())==ESC) 
					goto over;
				if ((d=getcharacter())==ESC) { 
over: 
					lprcat("aborted"); 
					return;
				}
				lprc('\n');
				for (i=0; i<SPNUM; i++)
					if ((spelcode[i][0]==a) 
					    && (spelcode[i][1]==b) 
					    && (spelcode[i][2]==d)) {
						spelknow[i]=1;
						lprintf("\nSpell \"%s\":  %s\n%s",spelcode[i],
								spelname[i],speldescript[i]); 
						lprcat("\nThe genie prefers not to be disturbed "
							   "again.");
						forget();
						bottomline();
						return;
					}
				lprcat("\nThe genie has never heard of such a spell!");
				lprcat("\nThe genie prefers not to be disturbed again.");
				forget();
				bottomline();
				return;
			}
			else lprcat("\nnothing happened.");
			if (rnd(100) < 15) {
				lprcat("\nThe genie prefers not to be disturbed again!");
				forget();
				c[LAMP]=0;  /* chance of finding lamp again */
			}
			bottomline();
		}
		else if (i=='t') {
			lprcat("take.");
			if (take(OBRASSLAMP,0)==0) 
				forget();
		}
		else lprcat("ignore.");
		return;

	case OWWAND:
		if (nearbymonst()) return;
		finditem(i);
		break;

	case OHANDofFEAR:
		if (nearbymonst()) return;
		finditem(i);
		break;

	case OPIT:	
		lprcat("\n\nYou're standing at the top of a pit."); 
		opit(); 
		break;

	case OSTAIRSUP:	
		lprcat("\n\nThere is a circular staircase here."); 
		ostairs(1);  /* up */
		break;

	case OELEVATORUP:
		lprcat("\n\nYou have found an express elevator going up.");
		oelevator(1);  /*  up  */
		break;

	case OELEVATORDOWN:	
		lprcat("\n\nYou have found an express elevator going down.");
		oelevator(-1);	/*	down	*/
		break;

	case OFOUNTAIN:	
		if (nearbymonst()) return;
		lprcat("\n\nThere is a fountain here."); 
		ofountain(); 
		break;

	case OSTATUE:	
		if (nearbymonst()) return;
		lprcat("\n\nYou stand before a statue."); 
		ostatue(); 
		break;

	case OCHEST:	
		lprcat("\n\nThere is a chest here.");  
		ochest();  
		break;

	case OIVTELETRAP:	
		if (rnd(11)<6) return;
		item[playerx][playery] = OTELEPORTER;
		know[playerx][playery] = 1;

	case OTELEPORTER:
		lprcat("\nZaaaappp!  You've been teleported!\n");
		beep(); 
		nap(3000); 
		oteleport(0);
		break; 

	case OSCHOOL:	
		if (nearbymonst()) return;
		lprcat("\n\nYou have found the College of Ularn.");
		lprcat("\nDo you (g) go inside, or (i) stay here? ");
		i=0; 
		while ((i!='g') && (i!='i') && (i!=ESC)) i=getcharacter();
		if (i == 'g') { 
			oschool();  /*	the college of larn	*/
		}
		else	lprcat(" stay here.");
		break;

	case OMIRROR:	
		if (nearbymonst()) return;
		lprcat("\n\nThere is a mirror here.");
		omirror();	
		break;

	case OBANK2:
	case OBANK:	
		if (nearbymonst()) return;
		if (i==OBANK) 
			lprcat("\n\nYou have found the bank of Ularn.");
		else 
		    lprcat("\n\nYou have found a branch office of the bank of Ularn.");
		lprcat("\nDo you (g) go inside, or (i) stay here? ");
		j=0; 
		while ((j!='g') && (j!='i') && (j!=ESC)) 
			j=getcharacter();
		if (j == 'g') {  
			if (i==OBANK) 
				obank(); 
			else 
			    obank2(); /*  the bank of larn  */

		}
		else   
			lprcat(" stay here.");
		break;

	case ODEADFOUNTAIN:	
		if (nearbymonst()) return;
		lprcat("\n\nThere is a dead fountain here.");
		break;

	case ODNDSTORE:	
		if (nearbymonst()) 
			return;
		lprcat("\n\nThere is a DND store here.");
		lprcat("\nDo you (g) go inside, or (i) stay here? ");
		i=0; 
		while ((i!='g') && (i!='i') && (i!=ESC)) i=getcharacter();
		if (i == 'g')
			dndstore();  /*  the dnd adventurers store  */
		else  
			lprcat(" stay here.");
		break;

	case OSTAIRSDOWN:
		lprcat("\n\nThere is a circular staircase here.");
		ostairs(-1); /* down */
		break;

	case OOPENDOOR:		
		lprcat("\nThere is an open door here.");
		break;


	case OCLOSEDDOOR:
		if (dropflag)
			return;
		lprintf("\n\nYou find %s",objectname[i]);
		lprcat("\nDo you (o) try to open it"); 
		iopts();
		i=0; 
		while ((i!='o') && (i!='i') && (i!=ESC)) i=getcharacter();
		if ((i==ESC) || (i=='i')) { 
			ignore();  
			playerx = lastpx;
			playery = lastpy; 
			break; 
		}
		else {
			lprcat("open.");
			if (rnd(11)<7) {
				switch(iarg[playerx][playery]) {
				case 6: 
					c[AGGRAVATE] += rnd(400);	
					break;

				case 7:	
				case 8:
					lprcat("\nYou are jolted by an electric shock!");
					lastnum=274; 
					losehp(rnd(20));  
					bottomline();  
					break;

/* Losing a level is just too harsh... */
/*				case 8:	
					loselevel();  
					break;
*/
				case 9:	
					lprcat("\nYou suddenly feel weaker!");
					if (c[STRENGTH]>3) c[STRENGTH]--;
					bottomline();  
					break;

				default:	
					break;
				}
				playerx = lastpx;  
				playery = lastpy;
			}
			else {
				forget();  
				item[playerx][playery]=OOPENDOOR;
			}
		}
		break;

	case OENTRANCE:	
		lprcat("\nYou have found ");
		lprcat(objectname[OENTRANCE]);
		lprcat("\nDo you (g) go inside"); 
		iopts();
		i=0; 
		while ((i!='g') && (i!='i') && (i!=ESC)) i=getcharacter();
		if (i == 'g')
		{
			newcavelevel(1); 
			playerx=33; 
			playery=MAXY-2;
			item[33][MAXY-1]=know[33][MAXY-1]=mitem[33][MAXY-1].mon=0;
			draws(0,MAXX,0,MAXY); 
			bot_linex(); 
			return;
		}
		else   ignore();
		break;

	case OVOLDOWN:	
		lprcat("\nYou have found "); 
		lprcat(objectname[OVOLDOWN]);
		lprcat("\nDo you (c) climb down"); 
		iopts();
		i=0; 
		while ((i!='c') && (i!='i') && (i!=ESC)) 
			i=getcharacter();
		if ((i==ESC) || (i=='i')) { 
			ignore();  
			break; 
		}
		if (level!=0) { 
			lprcat("\nThe shaft only extends 5 feet downward!"); 
			return; 
		}
		if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) { 
			lprcat("\nYou slip and fall down the shaft.");
			beep();
			lastnum=275;  
			losehp(30+rnd(20)); 
			bottomhp(); 
		}
		else lprcat("climb down.");
		nap(3000); 
		newcavelevel(DBOTTOM+1); /* down to V1 */
		playerx = rnd(MAXX-2);
		playery = rnd(MAXY-2);
		positionplayer(); 
		draws(0,MAXX,0,MAXY); 
		bot_linex(); 
		return;

	case OVOLUP:	
		lprcat("\nYou have found "); 
		lprcat(objectname[OVOLUP]);
		lprcat("\nDo you (c) climb up"); 
		iopts();
		i=0; 
		while ((i!='c') && (i!='i') && (i!=ESC)) i=getcharacter();
		if ((i==ESC) || (i=='i')) { 
			ignore();  
			break; 
		}
	if (packweight() > 40+5*(c[DEXTERITY]+c[STRENGTH]+c[STREXTRA])) { 
			lprcat("\nYou slip and fall down the shaft.");
			beep();
			lastnum=275; 
			losehp(15+rnd(20)); 
			bottomhp(); 
			return; 
		}
		lprcat("climb up.");
		lflush(); 
		nap(3000); 
		newcavelevel(0);
		for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++) /* put player near volcano shaft */
			if (item[j][i]==OVOLDOWN) { 
				playerx=j; 
				playery=i; 
				j=MAXX; 
				i=MAXY; 
				positionplayer(); 
			}
		draws(0,MAXX,0,MAXY); 
		bot_linex(); 
		return;

	case OTRAPARROWIV:	
		if (rnd(17)<13) return;	/* for an arrow trap */
		item[playerx][playery] = OTRAPARROW;
		know[playerx][playery] = 0;
	case OTRAPARROW:	
		lprcat("\nYou are hit by an arrow!");
		beep();	/* for an arrow trap */
		lastnum=259;	
		losehp(rnd(10)+level);
		bottomhp();	
		return;

	case OIVDARTRAP:	
		if (rnd(17)<13) 
			return;		/* for a dart trap */
		item[playerx][playery] = ODARTRAP;
		know[playerx][playery] = 0;
	case ODARTRAP:		
		lprcat("\nYou are hit by a dart!");
		beep();	/* for a dart trap */
		lastnum=260;	
		losehp(rnd(5));
		if ((--c[STRENGTH]) < 3) c[STRENGTH] = 3;
		bottomline();	
		return;

	case OIVTRAPDOOR:	
		if (rnd(17)<13) 
			return;		/* for a trap door */
		item[playerx][playery] = OTRAPDOOR;
		know[playerx][playery] = 1;
	case OTRAPDOOR:		
		lastnum = 272; /* a trap door */
		for (i=0;i<IVENSIZE;i++)
			if (iven[i]==OWWAND) {
				lprcat("\nYou escape a trap door.");
				return;
			}
		if ((level==DBOTTOM)||(level==VBOTTOM)) { 
			lprcat("\nYou fall through a trap door leading straight to HELL!");
			beep();
			lflush();
			nap(3000);
			died(271); 
		}
		lprcat("\nYou fall through a trap door!");
		beep();	
		lflush();
		losehp(rnd(5+level));
		nap(2000);
		newcavelevel(level+1);  
		draws(0,MAXX,0,MAXY); 
		bot_linex();
		return;

	case OTRADEPOST:
		if (nearbymonst()) return;
		lprcat("\nYou have found the Ularn trading Post.");
		lprcat("\nDo you (g) go inside, or (i) stay here? ");
		i=0; 
		while ((i!='g') && (i!='i') && (i!=ESC)) i=getcharacter();
		if (i == 'g')  otradepost();  
		else  lprcat("stay here.");
		return;

	case OHOME:	
		if (nearbymonst()) return;
		lprcat("\nYou have found your way home.");
		lprcat("\nDo you (g) go inside, or (i) stay here? ");
		i=0; 
		while ((i!='g') && (i!='i') && (i!=ESC)) 
			i=getcharacter();
		if (i == 'g')  
			ohome();  
		else  lprcat("stay here.");
		return;
	case OPAD:	
		if (nearbymonst()) return;
		lprcat("\nYou have found Dealer McDope's Hideout!");
		lprcat("\nDo you (c) check it out, or (i) ignore it? ");
		i=0;
		while ((i!='c') && (i!='i') && (i!=ESC)) 
			i=getcharacter();
		if (i == 'c')  
			opad();
		else  lprcat("forget it.");
		return;

	case OSPEED:   	
		lprcat("\nYou find some speed.");
		lprcat("\nDo you (s) snort it, (t) take it, or (i) ignore it? ");
		i=0; 
		while ((i!='s') && (i!='i') && (i!='t') && (i!=ESC)) 
			i=getcharacter();
		if (i=='s') {
			lprcat("snort!");
			lprcat("\nOhwowmanlikethingstotallyseemtoslowdown!");
			c[HASTESELF] += 200 + c[LEVEL];
			c[HALFDAM] += 300 + rnd(200);
			if ((c[INTELLIGENCE]-=2) < 3)
				c[INTELLIGENCE]=3;
			if ((c[WISDOM]-=2) < 3)
				c[WISDOM]=3;
			if ((c[CONSTITUTION]-=2) <3)
				c[CONSTITUTION]=3;
			if ((c[DEXTERITY]-=2) <3)
				c[DEXTERITY]=3;
			if ((c[STRENGTH]-=2) <3)
				c[STRENGTH]=3;
			forget();
			bottomline();
		} 
		else if (i=='t') {
			lprcat("take.");
			if (take(OSPEED,0)==0) forget();
		} 
		else 
		    lprcat("ignore.");
		break;

	case OSHROOMS:	
		lprcat("\nYou find some magic mushrooms.");
		lprcat("\nDo you (e) eat them, (t) take them, or (i) ignore them? ");
		i=0; 
		while ((i!='e') && (i!='i') && (i!='t') && (i!=ESC)) 
			i=getcharacter();
		if (i=='e') {
			lprcat("eat!");
			lprcat("\nThings start to get real spacey...");
			c[HASTEMONST] += rnd(75) + 25;
			c[CONFUSE] += 30+rnd(10);
			c[WISDOM]+=2;
			c[CHARISMA]+=2;
			forget();
			bottomline();
		} 
		else if (i=='t') {
			lprcat("take.");
			if (take(OSHROOMS,0)==0) forget();
		} 
		else
			lprcat("ignore.");
		break;

	case OACID:	
		lprcat("\nYou find some LSD.");
		lprcat("\nDo you (e) eat it, (t) take it, or (i) ignore it? ");
		i=0; 
		while ((i!='e') && (i!='i') && (i!='t') && (i!=ESC)) 
			i=getcharacter();
		if (i=='e') {
			lprcat("eat!");
			lprcat("\nYou are now frying your ass off!");
			c[CONFUSE]+=30+rnd(10);
			c[WISDOM]+=2;
			c[INTELLIGENCE]+=2;
			c[AWARENESS]+=1500;
			c[AGGRAVATE]+=1500;
			{ 	
				int j,k;	/* heal monsters */
				for(j=0;j<MAXY;j++)
					for(k=0;k<MAXX;k++)
						if (mitem[k][j].mon)
							hitp[k][j]=monster[mitem[k][j].mon].hitpoints;
			}
			forget();
			bottomline();
		}
		else if (i=='t') {
			lprcat("take.");
			if (take(OACID,0)==0) forget();
		}
		else lprcat("ignore.");
		break;

	case OHASH:	
		lprcat("\nYou find some hashish.");
		lprcat("\nDo you (s) smoke it, (t) take it, or (i) ignore it? ");
		i=0; 
		while ((i!='s') && (i!='i') && (i!='t') && (i!=ESC)) 
			i=getcharacter();
		if (i=='s') {
			lprcat("smoke!");
			lprcat("\nWOW! You feel stooooooned...");
			c[HASTEMONST]+=rnd(75)+25;
			c[INTELLIGENCE]+=2;
			c[WISDOM]+=2;
			if( (c[CONSTITUTION]-=2) < 3) 
				c[CONSTITUTION]=3;
			if( (c[DEXTERITY]-=2) < 3) 
				c[DEXTERITY]=3;
			c[HALFDAM]+=300+rnd(200);
			c[CLUMSINESS]+=rnd(1800)+200;
			forget();
			bottomline();
		}
		else if (i=='t') {
			lprcat("take.");
			if (take(OHASH,0)==0) forget();
		}
		else lprcat("ignore.");
		break;

	case OCOKE:	
		lprcat("\nYou find some cocaine.");
		lprcat("\nDo you want to (s) snort it, (t) take it, or (i) ignore it? ");
		i=0; 
		while ((i!='s') && (i!='i') && (i!='t') && (i!=ESC)) 
			i=getcharacter();
		if (i=='s') {
			lprcat("snort!");
			lprcat("\nYour nose begins to bleed!");
			if ((c[DEXTERITY]-=2) <3)
				c[DEXTERITY]=3;
			if ((c[CONSTITUTION]-=2) <3)
				c[CONSTITUTION]=3;
			c[CHARISMA]+=3;
			for(i=0;i<6;i++)
				c[i]+=33;
			c[COKED]+=10;
			forget();
			bottomline();
		}
		else if (i=='t') {
			lprcat("take.");
			if (take(OCOKE,0)==0) forget();
		}
		else lprcat("ignore.");
		break;	

	case OWALL:	
		break;

	case OANNIHILATION:
		for (i=0;i<IVENSIZE;i++)
			if (iven[i]==OSPHTALISMAN) {
				lprcat("\nThe Talisman of the Sphere protects you from "
					   "annihilation!");
				return;
			}
		/* annihilated by sphere of annihilation */	
		died(283);
		return;

	case OLRS:	
		if (nearbymonst()) return;
		lprcat("\n\nThere is an LRS office here.");
		lprcat("\nDo you (g) go inside, or (i) stay here? ");
		i=0; 
		while ((i!='g') && (i!='i') && (i!=ESC)) i=getcharacter();
		if (i == 'g')
			olrs();  /*  the larn revenue service */
		else  lprcat(" stay here.");
		break;
	default:	
		finditem(i); 
		break;
	};
}