/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Timothy C. Stoehr.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* use.c
*
* This source herein may be modified and/or distributed by anybody who
* so desires, with the following restrictions:
* 1.) No portion of this notice shall be removed.
* 2.) Credit shall not be taken for the creation of this source.
* 3.) This code is not to be traded, sold, or used for personal
* gain or profit.
*
*/
#include "rogue.h"
short halluc = 0;
short blind = 0;
short confused = 0;
short levitate = 0;
short haste_self = 0;
boolean see_invisible = 0;
short extra_hp = 0;
boolean detect_monster = 0;
boolean con_mon = 0;
static const char strange_feeling[] =
"you have a strange feeling for a moment, then it passes";
static void
idntfy(void)
{
short ch;
object *obj;
struct id *id_table;
char desc[DCOLS];
AGAIN:
ch = pack_letter("what would you like to identify?", ALL_OBJECTS);
if (ch == CANCEL) {
return;
}
if (!(obj = get_letter_object(ch))) {
messagef(0, "no such item, try again");
messagef(0, "%s", ""); /* gcc objects to just "" */
check_message();
goto AGAIN;
}
obj->identified = 1;
if (obj->what_is & (SCROL | POTION | WEAPON | ARMOR | WAND | RING)) {
id_table = get_id_table(obj);
id_table[obj->which_kind].id_status = IDENTIFIED;
}
get_desc(obj, desc, sizeof(desc));
messagef(0, "%s", desc);
}
void
eat(void)
{
short ch;
short moves;
object *obj;
ch = pack_letter("eat what?", FOOD);
if (ch == CANCEL) {
return;
}
if (!(obj = get_letter_object(ch))) {
messagef(0, "no such item.");
return;
}
if (obj->what_is != FOOD) {
messagef(0, "you can't eat that");
return;
}
if ((obj->which_kind == FRUIT) || rand_percent(60)) {
moves = get_rand(950, 1150);
if (obj->which_kind == RATION) {
messagef(0, "yum, that tasted good");
} else {
messagef(0, "my, that was a yummy %s", fruit);
}
} else {
moves = get_rand(750, 950);
messagef(0, "yuk, that food tasted awful");
add_exp(2, 1);
}
rogue.moves_left /= 3;
rogue.moves_left += moves;
hunger_str[0] = 0;
print_stats(STAT_HUNGER);
vanish(obj, 1, &rogue.pack);
}
static void
hold_monster(void)
{
short i, j;
short mcount = 0;
object *monster;
short row, col;
for (i = -2; i <= 2; i++) {
for (j = -2; j <= 2; j++) {
row = rogue.row + i;
col = rogue.col + j;
if ((row < MIN_ROW) || (row > (DROWS-2)) || (col < 0) ||
(col > (DCOLS-1))) {
continue;
}
if (dungeon[row][col] & MONSTER) {
monster = object_at(&level_monsters, row, col);
monster->m_flags |= ASLEEP;
monster->m_flags &= (~WAKENS);
mcount++;
}
}
}
if (mcount == 0) {
messagef(0, "you feel a strange sense of loss");
} else if (mcount == 1) {
messagef(0, "the monster freezes");
} else {
messagef(0, "the monsters around you freeze");
}
}