2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * @(#)use.c 8.1 (Berkeley) 5/31/93
33 * $FreeBSD: src/games/rogue/use.c,v 1.4 1999/11/30 03:49:29 billf Exp $
39 * This source herein may be modified and/or distributed by anybody who
40 * so desires, with the following restrictions:
41 * 1.) No portion of this notice shall be removed.
42 * 2.) Credit shall not be taken for the creation of this source.
43 * 3.) This code is not to be traded, sold, or used for personal
55 boolean see_invisible = 0;
57 boolean detect_monster = 0;
60 static const char strange_feeling[] =
61 "you have a strange feeling for a moment, then it passes";
63 static const char *get_ench_color(void);
64 static void go_blind(void);
65 static void hold_monster(void);
66 static void idntfy(void);
67 static void potion_heal(boolean);
68 static void uncurse_all(void);
77 ch = pack_letter("quaff what?", POTION);
82 if (!(obj = get_letter_object(ch))) {
83 message("no such item.", 0);
86 if (obj->what_is != POTION) {
87 message("you can't drink that", 0);
90 switch(obj->which_kind) {
91 case INCREASE_STRENGTH:
92 message("you feel stronger now, what bulging muscles!",
95 if (rogue.str_current > rogue.str_max) {
96 rogue.str_max = rogue.str_current;
99 case RESTORE_STRENGTH:
100 rogue.str_current = rogue.str_max;
101 message("this tastes great, you feel warm all over", 0);
104 message("you begin to feel better", 0);
108 message("you begin to feel much better", 0);
112 if (!sustain_strength) {
113 rogue.str_current -= get_rand(1, 3);
114 if (rogue.str_current < 1) {
115 rogue.str_current = 1;
118 message("you feel very sick now", 0);
124 rogue.exp_points = level_points[rogue.exp - 1];
125 message("you suddenly feel much more skillful", 0);
132 message("oh wow, everything seems so cosmic", 0);
133 halluc += get_rand(500, 800);
137 if (!(level_monsters.next_monster)) {
138 message(strange_feeling, 0);
142 if (level_objects.next_object) {
147 message(strange_feeling, 0);
151 message((halluc ? "what a trippy feeling" :
152 "you feel confused"), 0);
156 message("you start to float in the air", 0);
157 levitate += get_rand(15, 30);
158 bear_trap = being_held = 0;
161 message("you feel yourself moving much faster", 0);
162 haste_self += get_rand(11, 21);
163 if (!(haste_self % 2)) {
168 sprintf(buf, "hmm, this potion tastes like %sjuice", fruit);
177 print_stats((STAT_STRENGTH | STAT_HP));
178 if (id_potions[obj->which_kind].id_status != CALLED) {
179 id_potions[obj->which_kind].id_status = IDENTIFIED;
181 vanish(obj, 1, &rogue.pack);
191 ch = pack_letter("read what?", SCROL);
196 if (!(obj = get_letter_object(ch))) {
197 message("no such item.", 0);
200 if (obj->what_is != SCROL) {
201 message("you can't read that", 0);
204 switch(obj->which_kind) {
206 message("you hear a maniacal laughter in the distance",
214 if (rogue.weapon->what_is == WEAPON) {
215 sprintf(msg, "your %sglow%s %sfor a moment",
216 name_of(rogue.weapon),
217 ((rogue.weapon->quantity <= 1) ? "s" : ""),
221 rogue.weapon->hit_enchant++;
223 rogue.weapon->d_enchant++;
226 rogue.weapon->is_cursed = 0;
228 message("your hands tingle", 0);
233 sprintf(msg, "your armor glows %sfor a moment",
236 rogue.armor->d_enchant++;
237 rogue.armor->is_cursed = 0;
238 print_stats(STAT_ARMOR);
240 message("your skin crawls", 0);
244 message("this is a scroll of identify", 0);
246 id_scrolls[obj->which_kind].id_status = IDENTIFIED;
253 message("you fall asleep", 0);
258 message( "your armor is covered by a shimmering gold shield",0);
259 rogue.armor->is_protected = 1;
260 rogue.armor->is_cursed = 0;
262 message("your acne seems to have disappeared", 0);
267 "you feel as though someone is watching over you" :
268 "you feel in touch with the universal oneness", 0);
274 case AGGRAVATE_MONSTER:
278 message("this scroll seems to have a map on it", 0);
283 sprintf(msg, "your hands glow %sfor a moment", get_ench_color());
287 if (id_scrolls[obj->which_kind].id_status != CALLED) {
288 id_scrolls[obj->which_kind].id_status = IDENTIFIED;
290 vanish(obj, (obj->which_kind != SLEEP), &rogue.pack);
293 /* vanish() does NOT handle a quiver of weapons with more than one
294 * arrow (or whatever) in the quiver. It will only decrement the count.
298 vanish(object *obj, short rm, object *pack)
300 if (obj->quantity > 1) {
303 if (obj->in_use_flags & BEING_WIELDED) {
305 } else if (obj->in_use_flags & BEING_WORN) {
307 } else if (obj->in_use_flags & ON_EITHER_HAND) {
310 take_from_pack(obj, pack);
319 potion_heal(boolean extra)
324 rogue.hp_current += rogue.exp;
326 ratio = ((float)rogue.hp_current) / rogue.hp_max;
329 rogue.hp_max += (extra ? 2 : 1);
330 extra_hp += (extra ? 2 : 1);
331 rogue.hp_current = rogue.hp_max;
332 } else if (ratio >= 0.90) {
333 rogue.hp_max += (extra ? 1 : 0);
334 extra_hp += (extra ? 1 : 0);
335 rogue.hp_current = rogue.hp_max;
343 add = (short)(ratio * ((float)rogue.hp_max - rogue.hp_current));
344 rogue.hp_current += add;
345 if (rogue.hp_current > rogue.hp_max) {
346 rogue.hp_current = rogue.hp_max;
352 if (confused && extra) {
354 } else if (confused) {
355 confused = (confused / 2) + 1;
357 if (halluc && extra) {
360 halluc = (halluc / 2) + 1;
372 ch = pack_letter("what would you like to identify?", ALL_OBJECTS);
377 if (!(obj = get_letter_object(ch))) {
378 message("no such item, try again", 0);
384 if (obj->what_is & (SCROL | POTION | WEAPON | ARMOR | WAND | RING)) {
385 id_table = get_id_table(obj);
386 id_table[obj->which_kind].id_status = IDENTIFIED;
400 ch = pack_letter("eat what?", FOOD);
405 if (!(obj = get_letter_object(ch))) {
406 message("no such item.", 0);
409 if (obj->what_is != FOOD) {
410 message("you can't eat that", 0);
413 if ((obj->which_kind == FRUIT) || rand_percent(60)) {
414 moves = get_rand(950, 1150);
415 if (obj->which_kind == RATION) {
416 message("yum, that tasted good", 0);
418 sprintf(buf, "my, that was a yummy %s", fruit);
422 moves = get_rand(750, 950);
423 message("yuk, that food tasted awful", 0);
426 rogue.moves_left /= 3;
427 rogue.moves_left += moves;
429 print_stats(STAT_HUNGER);
431 vanish(obj, 1, &rogue.pack);
442 for (i = -2; i <= 2; i++) {
443 for (j = -2; j <= 2; j++) {
446 if ((row < MIN_ROW) || (row > (DROWS-2)) || (col < 0) ||
450 if (dungeon[row][col] & MONSTER) {
451 monster = object_at(&level_monsters, row, col);
452 monster->m_flags |= ASLEEP;
453 monster->m_flags &= (~WAKENS);
459 message("you feel a strange sense of loss", 0);
460 } else if (mcount == 1) {
461 message("the monster freezes", 0);
463 message("the monsters around you freeze", 0);
470 mvaddch(rogue.row, rogue.col, get_dungeon_char(rogue.row, rogue.col));
473 darken_room(cur_room);
475 put_player(get_room_number(rogue.row, rogue.col));
483 object *obj, *monster;
488 obj = level_objects.next_object;
491 ch = mvinch(obj->row, obj->col);
492 if (((ch < 'A') || (ch > 'Z')) &&
493 ((obj->row != rogue.row) || (obj->col != rogue.col)))
495 if ((ch != ' ') && (ch != '.') && (ch != '#') &&
498 addch(gr_obj_char());
501 obj = obj->next_object;
503 monster = level_monsters.next_monster;
506 ch = mvinch(monster->row, monster->col);
507 if ((ch >= 'A') && (ch <= 'Z')) {
508 addch(get_rand('A', 'Z'));
510 monster = monster->next_monster;
519 message("everything looks SO boring now", 1);
526 message("the veil of darkness lifts", 1);
531 if (detect_monster) {
539 if (cur_room == PASSAGE) {
540 light_passage(rogue.row, rogue.col);
542 light_up_room(cur_room);
544 mvaddch(rogue.row, rogue.col, rogue.fchar);
559 message(you_can_move_again, 0);
568 message("a cloak of darkness falls around you", 0);
570 blind += get_rand(500, 800);
572 if (detect_monster) {
575 monster = level_monsters.next_monster;
578 mvaddch(monster->row, monster->col, monster->trail_char);
579 monster = monster->next_monster;
583 for (i = rooms[cur_room].top_row + 1;
584 i < rooms[cur_room].bottom_row; i++) {
585 for (j = rooms[cur_room].left_col + 1;
586 j < rooms[cur_room].right_col; j++) {
591 mvaddch(rogue.row, rogue.col, rogue.fchar);
598 return(id_potions[get_rand(0, POTIONS-1)].title);
599 } else if (con_mon) {
608 confused += get_rand(12, 22);
617 sprintf(msg, "you feel less %s now", (halluc ? "trippy" : "confused"));
626 obj = rogue.pack.next_object;
630 obj = obj->next_object;