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. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * @(#)use.c 8.1 (Berkeley) 5/31/93
37 * $FreeBSD: src/games/rogue/use.c,v 1.4 1999/11/30 03:49:29 billf Exp $
38 * $DragonFly: src/games/rogue/use.c,v 1.2 2003/06/17 04:25:25 dillon Exp $
44 * This source herein may be modified and/or distributed by anybody who
45 * so desires, with the following restrictions:
46 * 1.) No portion of this notice shall be removed.
47 * 2.) Credit shall not be taken for the creation of this source.
48 * 3.) This code is not to be traded, sold, or used for personal
60 boolean see_invisible = 0;
62 boolean detect_monster = 0;
64 const char *strange_feeling = "you have a strange feeling for a moment, then it passes";
66 extern short bear_trap;
67 extern char hunger_str[];
68 extern short cur_room;
69 extern long level_points[];
70 extern boolean being_held;
71 extern char *fruit, *you_can_move_again;
72 extern boolean sustain_strength;
80 ch = pack_letter("quaff what?", POTION);
85 if (!(obj = get_letter_object(ch))) {
86 message("no such item.", 0);
89 if (obj->what_is != POTION) {
90 message("you can't drink that", 0);
93 switch(obj->which_kind) {
94 case INCREASE_STRENGTH:
95 message("you feel stronger now, what bulging muscles!",
98 if (rogue.str_current > rogue.str_max) {
99 rogue.str_max = rogue.str_current;
102 case RESTORE_STRENGTH:
103 rogue.str_current = rogue.str_max;
104 message("this tastes great, you feel warm all over", 0);
107 message("you begin to feel better", 0);
111 message("you begin to feel much better", 0);
115 if (!sustain_strength) {
116 rogue.str_current -= get_rand(1, 3);
117 if (rogue.str_current < 1) {
118 rogue.str_current = 1;
121 message("you feel very sick now", 0);
127 rogue.exp_points = level_points[rogue.exp - 1];
128 message("you suddenly feel much more skillful", 0);
135 message("oh wow, everything seems so cosmic", 0);
136 halluc += get_rand(500, 800);
140 if (!(level_monsters.next_monster)) {
141 message(strange_feeling, 0);
145 if (level_objects.next_object) {
150 message(strange_feeling, 0);
154 message((halluc ? "what a trippy feeling" :
155 "you feel confused"), 0);
159 message("you start to float in the air", 0);
160 levitate += get_rand(15, 30);
161 being_held = bear_trap = 0;
164 message("you feel yourself moving much faster", 0);
165 haste_self += get_rand(11, 21);
166 if (!(haste_self % 2)) {
171 sprintf(buf, "hmm, this potion tastes like %sjuice", fruit);
180 print_stats((STAT_STRENGTH | STAT_HP));
181 if (id_potions[obj->which_kind].id_status != CALLED) {
182 id_potions[obj->which_kind].id_status = IDENTIFIED;
184 vanish(obj, 1, &rogue.pack);
193 ch = pack_letter("read what?", SCROL);
198 if (!(obj = get_letter_object(ch))) {
199 message("no such item.", 0);
202 if (obj->what_is != SCROL) {
203 message("you can't read that", 0);
206 switch(obj->which_kind) {
208 message("you hear a maniacal laughter in the distance",
216 if (rogue.weapon->what_is == WEAPON) {
217 sprintf(msg, "your %sglow%s %sfor a moment",
218 name_of(rogue.weapon),
219 ((rogue.weapon->quantity <= 1) ? "s" : ""),
223 rogue.weapon->hit_enchant++;
225 rogue.weapon->d_enchant++;
228 rogue.weapon->is_cursed = 0;
230 message("your hands tingle", 0);
235 sprintf(msg, "your armor glows %sfor a moment",
238 rogue.armor->d_enchant++;
239 rogue.armor->is_cursed = 0;
240 print_stats(STAT_ARMOR);
242 message("your skin crawls", 0);
246 message("this is a scroll of identify", 0);
248 id_scrolls[obj->which_kind].id_status = IDENTIFIED;
255 message("you fall asleep", 0);
260 message( "your armor is covered by a shimmering gold shield",0);
261 rogue.armor->is_protected = 1;
262 rogue.armor->is_cursed = 0;
264 message("your acne seems to have disappeared", 0);
269 "you feel as though someone is watching over you" :
270 "you feel in touch with the universal oneness", 0);
276 case AGGRAVATE_MONSTER:
280 message("this scroll seems to have a map on it", 0);
285 sprintf(msg, "your hands glow %sfor a moment", get_ench_color());
289 if (id_scrolls[obj->which_kind].id_status != CALLED) {
290 id_scrolls[obj->which_kind].id_status = IDENTIFIED;
292 vanish(obj, (obj->which_kind != SLEEP), &rogue.pack);
295 /* vanish() does NOT handle a quiver of weapons with more than one
296 * arrow (or whatever) in the quiver. It will only decrement the count.
299 vanish(obj, rm, pack)
304 if (obj->quantity > 1) {
307 if (obj->in_use_flags & BEING_WIELDED) {
309 } else if (obj->in_use_flags & BEING_WORN) {
311 } else if (obj->in_use_flags & ON_EITHER_HAND) {
314 take_from_pack(obj, pack);
327 rogue.hp_current += rogue.exp;
329 ratio = ((float)rogue.hp_current) / rogue.hp_max;
332 rogue.hp_max += (extra ? 2 : 1);
333 extra_hp += (extra ? 2 : 1);
334 rogue.hp_current = rogue.hp_max;
335 } else if (ratio >= 0.90) {
336 rogue.hp_max += (extra ? 1 : 0);
337 extra_hp += (extra ? 1 : 0);
338 rogue.hp_current = rogue.hp_max;
346 add = (short)(ratio * ((float)rogue.hp_max - rogue.hp_current));
347 rogue.hp_current += add;
348 if (rogue.hp_current > rogue.hp_max) {
349 rogue.hp_current = rogue.hp_max;
355 if (confused && extra) {
357 } else if (confused) {
358 confused = (confused / 2) + 1;
360 if (halluc && extra) {
363 halluc = (halluc / 2) + 1;
374 ch = pack_letter("what would you like to identify?", ALL_OBJECTS);
379 if (!(obj = get_letter_object(ch))) {
380 message("no such item, try again", 0);
386 if (obj->what_is & (SCROL | POTION | WEAPON | ARMOR | WAND | RING)) {
387 id_table = get_id_table(obj);
388 id_table[obj->which_kind].id_status = IDENTIFIED;
401 ch = pack_letter("eat what?", FOOD);
406 if (!(obj = get_letter_object(ch))) {
407 message("no such item.", 0);
410 if (obj->what_is != FOOD) {
411 message("you can't eat that", 0);
414 if ((obj->which_kind == FRUIT) || rand_percent(60)) {
415 moves = get_rand(950, 1150);
416 if (obj->which_kind == RATION) {
417 message("yum, that tasted good", 0);
419 sprintf(buf, "my, that was a yummy %s", fruit);
423 moves = get_rand(750, 950);
424 message("yuk, that food tasted awful", 0);
427 rogue.moves_left /= 3;
428 rogue.moves_left += moves;
430 print_stats(STAT_HUNGER);
432 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);
469 mvaddch(rogue.row, rogue.col, get_dungeon_char(rogue.row, rogue.col));
472 darken_room(cur_room);
474 put_player(get_room_number(rogue.row, rogue.col));
481 object *obj, *monster;
486 obj = level_objects.next_object;
489 ch = mvinch(obj->row, obj->col);
490 if (((ch < 'A') || (ch > 'Z')) &&
491 ((obj->row != rogue.row) || (obj->col != rogue.col)))
492 if ((ch != ' ') && (ch != '.') && (ch != '#') && (ch != '+')) {
493 addch(gr_obj_char());
495 obj = obj->next_object;
497 monster = level_monsters.next_monster;
500 ch = mvinch(monster->row, monster->col);
501 if ((ch >= 'A') && (ch <= 'Z')) {
502 addch(get_rand('A', 'Z'));
504 monster = monster->next_monster;
512 message("everything looks SO boring now", 1);
518 message("the veil of darkness lifts", 1);
523 if (detect_monster) {
530 if (cur_room == PASSAGE) {
531 light_passage(rogue.row, rogue.col);
533 light_up_room(cur_room);
535 mvaddch(rogue.row, rogue.col, rogue.fchar);
549 message(you_can_move_again, 0);
557 message("a cloak of darkness falls around you", 0);
559 blind += get_rand(500, 800);
561 if (detect_monster) {
564 monster = level_monsters.next_monster;
567 mvaddch(monster->row, monster->col, monster->trail_char);
568 monster = monster->next_monster;
572 for (i = rooms[cur_room].top_row + 1;
573 i < rooms[cur_room].bottom_row; i++) {
574 for (j = rooms[cur_room].left_col + 1;
575 j < rooms[cur_room].right_col; j++) {
580 mvaddch(rogue.row, rogue.col, rogue.fchar);
587 return(id_potions[get_rand(0, POTIONS-1)].title);
588 } else if (con_mon) {
596 confused += get_rand(12, 22);
604 sprintf(msg, "you feel less %s now", (halluc ? "trippy" : "confused"));
612 obj = rogue.pack.next_object;
616 obj = obj->next_object;