]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - rogue/use.c
1 /* $NetBSD: use.c,v 1.6 2003/08/07 09:37:40 agc Exp $ */
4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/cdefs.h>
38 static char sccsid
[] = "@(#)use.c 8.1 (Berkeley) 5/31/93";
40 __RCSID("$NetBSD: use.c,v 1.6 2003/08/07 09:37:40 agc Exp $");
47 * This source herein may be modified and/or distributed by anybody who
48 * so desires, with the following restrictions:
49 * 1.) No portion of this notice shall be removed.
50 * 2.) Credit shall not be taken for the creation of this source.
51 * 3.) This code is not to be traded, sold, or used for personal
63 boolean see_invisible
= 0;
65 boolean detect_monster
= 0;
67 const char *strange_feeling
= "you have a strange feeling for a moment, then it passes";
76 ch
= pack_letter("quaff what?", POTION
);
81 if (!(obj
= get_letter_object(ch
))) {
82 message("no such item.", 0);
85 if (obj
->what_is
!= POTION
) {
86 message("you can't drink that", 0);
89 switch(obj
->which_kind
) {
90 case INCREASE_STRENGTH
:
91 message("you feel stronger now, what bulging muscles!",
94 if (rogue
.str_current
> rogue
.str_max
) {
95 rogue
.str_max
= rogue
.str_current
;
98 case RESTORE_STRENGTH
:
99 rogue
.str_current
= rogue
.str_max
;
100 message("this tastes great, you feel warm all over", 0);
103 message("you begin to feel better", 0);
107 message("you begin to feel much better", 0);
111 if (!sustain_strength
) {
112 rogue
.str_current
-= get_rand(1, 3);
113 if (rogue
.str_current
< 1) {
114 rogue
.str_current
= 1;
117 message("you feel very sick now", 0);
123 rogue
.exp_points
= level_points
[rogue
.exp
- 1];
124 message("you suddenly feel much more skillful", 0);
131 message("oh wow, everything seems so cosmic", 0);
132 halluc
+= get_rand(500, 800);
136 if (!(level_monsters
.next_monster
)) {
137 message(strange_feeling
, 0);
141 if (level_objects
.next_object
) {
146 message(strange_feeling
, 0);
150 message((halluc
? "what a trippy feeling" :
151 "you feel confused"), 0);
155 message("you start to float in the air", 0);
156 levitate
+= get_rand(15, 30);
157 being_held
= bear_trap
= 0;
160 message("you feel yourself moving much faster", 0);
161 haste_self
+= get_rand(11, 21);
162 if (!(haste_self
% 2)) {
167 sprintf(buf
, "hmm, this potion tastes like %sjuice", fruit
);
176 print_stats((STAT_STRENGTH
| STAT_HP
));
177 if (id_potions
[obj
->which_kind
].id_status
!= CALLED
) {
178 id_potions
[obj
->which_kind
].id_status
= IDENTIFIED
;
180 vanish(obj
, 1, &rogue
.pack
);
190 ch
= pack_letter("read what?", SCROL
);
195 if (!(obj
= get_letter_object(ch
))) {
196 message("no such item.", 0);
199 if (obj
->what_is
!= SCROL
) {
200 message("you can't read that", 0);
203 switch(obj
->which_kind
) {
205 message("you hear a maniacal laughter in the distance",
213 if (rogue
.weapon
->what_is
== WEAPON
) {
214 sprintf(msg
, "your %sglow%s %sfor a moment",
215 name_of(rogue
.weapon
),
216 ((rogue
.weapon
->quantity
<= 1) ? "s" : ""),
220 rogue
.weapon
->hit_enchant
++;
222 rogue
.weapon
->d_enchant
++;
225 rogue
.weapon
->is_cursed
= 0;
227 message("your hands tingle", 0);
232 sprintf(msg
, "your armor glows %sfor a moment",
235 rogue
.armor
->d_enchant
++;
236 rogue
.armor
->is_cursed
= 0;
237 print_stats(STAT_ARMOR
);
239 message("your skin crawls", 0);
243 message("this is a scroll of identify", 0);
245 id_scrolls
[obj
->which_kind
].id_status
= IDENTIFIED
;
252 message("you fall asleep", 0);
257 message( "your armor is covered by a shimmering gold shield",0);
258 rogue
.armor
->is_protected
= 1;
259 rogue
.armor
->is_cursed
= 0;
261 message("your acne seems to have disappeared", 0);
266 "you feel as though someone is watching over you" :
267 "you feel in touch with the universal oneness", 0);
273 case AGGRAVATE_MONSTER
:
277 message("this scroll seems to have a map on it", 0);
282 sprintf(msg
, "your hands glow %sfor a moment", get_ench_color());
286 if (id_scrolls
[obj
->which_kind
].id_status
!= CALLED
) {
287 id_scrolls
[obj
->which_kind
].id_status
= IDENTIFIED
;
289 vanish(obj
, (obj
->which_kind
!= SLEEP
), &rogue
.pack
);
292 /* vanish() does NOT handle a quiver of weapons with more than one
293 * arrow (or whatever) in the quiver. It will only decrement the count.
297 vanish(obj
, rm
, pack
)
302 if (obj
->quantity
> 1) {
305 if (obj
->in_use_flags
& BEING_WIELDED
) {
307 } else if (obj
->in_use_flags
& BEING_WORN
) {
309 } else if (obj
->in_use_flags
& ON_EITHER_HAND
) {
312 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;
375 ch
= pack_letter("what would you like to identify?", ALL_OBJECTS
);
380 if (!(obj
= get_letter_object(ch
))) {
381 message("no such item, try again", 0);
387 if (obj
->what_is
& (SCROL
| POTION
| WEAPON
| ARMOR
| WAND
| RING
)) {
388 id_table
= get_id_table(obj
);
389 id_table
[obj
->which_kind
].id_status
= IDENTIFIED
;
403 ch
= pack_letter("eat what?", FOOD
);
408 if (!(obj
= get_letter_object(ch
))) {
409 message("no such item.", 0);
412 if (obj
->what_is
!= FOOD
) {
413 message("you can't eat that", 0);
416 if ((obj
->which_kind
== FRUIT
) || rand_percent(60)) {
417 moves
= get_rand(950, 1150);
418 if (obj
->which_kind
== RATION
) {
419 message("yum, that tasted good", 0);
421 sprintf(buf
, "my, that was a yummy %s", fruit
);
425 moves
= get_rand(750, 950);
426 message("yuk, that food tasted awful", 0);
429 rogue
.moves_left
/= 3;
430 rogue
.moves_left
+= moves
;
432 print_stats(STAT_HUNGER
);
434 vanish(obj
, 1, &rogue
.pack
);
445 for (i
= -2; i
<= 2; i
++) {
446 for (j
= -2; j
<= 2; j
++) {
449 if ((row
< MIN_ROW
) || (row
> (DROWS
-2)) || (col
< 0) ||
453 if (dungeon
[row
][col
] & MONSTER
) {
454 monster
= object_at(&level_monsters
, row
, col
);
455 monster
->m_flags
|= ASLEEP
;
456 monster
->m_flags
&= (~WAKENS
);
462 message("you feel a strange sense of loss", 0);
463 } else if (mcount
== 1) {
464 message("the monster freezes", 0);
466 message("the monsters around you freeze", 0);
473 mvaddch(rogue
.row
, rogue
.col
, get_dungeon_char(rogue
.row
, rogue
.col
));
476 darken_room(cur_room
);
478 put_player(get_room_number(rogue
.row
, rogue
.col
));
486 object
*obj
, *monster
;
491 obj
= level_objects
.next_object
;
494 ch
= mvinch(obj
->row
, obj
->col
);
495 if (((ch
< 'A') || (ch
> 'Z')) &&
496 ((obj
->row
!= rogue
.row
) || (obj
->col
!= rogue
.col
)))
497 if ((ch
!= ' ') && (ch
!= '.') && (ch
!= '#') && (ch
!= '+')) {
498 addch(gr_obj_char());
500 obj
= obj
->next_object
;
502 monster
= level_monsters
.next_monster
;
505 ch
= mvinch(monster
->row
, monster
->col
);
506 if ((ch
>= 'A') && (ch
<= 'Z')) {
507 addch(get_rand('A', 'Z'));
509 monster
= monster
->next_monster
;
518 message("everything looks SO boring now", 1);
525 message("the veil of darkness lifts", 1);
530 if (detect_monster
) {
538 if (cur_room
== PASSAGE
) {
539 light_passage(rogue
.row
, rogue
.col
);
541 light_up_room(cur_room
);
543 mvaddch(rogue
.row
, rogue
.col
, rogue
.fchar
);
558 message(you_can_move_again
, 0);
567 message("a cloak of darkness falls around you", 0);
569 blind
+= get_rand(500, 800);
571 if (detect_monster
) {
574 monster
= level_monsters
.next_monster
;
577 mvaddch(monster
->row
, monster
->col
, monster
->trail_char
);
578 monster
= monster
->next_monster
;
582 for (i
= rooms
[cur_room
].top_row
+ 1;
583 i
< rooms
[cur_room
].bottom_row
; i
++) {
584 for (j
= rooms
[cur_room
].left_col
+ 1;
585 j
< rooms
[cur_room
].right_col
; j
++) {
590 mvaddch(rogue
.row
, rogue
.col
, rogue
.fchar
);
597 return(id_potions
[get_rand(0, POTIONS
-1)].title
);
598 } else if (con_mon
) {
607 confused
+= get_rand(12, 22);
616 sprintf(msg
, "you feel less %s now", (halluc
? "trippy" : "confused"));
625 obj
= rogue
.pack
.next_object
;
629 obj
= obj
->next_object
;