]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - rogue/use.c
1 /* $NetBSD: use.c,v 1.9 2008/01/14 03:50:03 dholland 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.9 2008/01/14 03:50:03 dholland 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;
68 static const char strange_feeling
[] =
69 "you have a strange feeling for a moment, then it passes";
77 ch
= pack_letter("quaff what?", POTION
);
82 if (!(obj
= get_letter_object(ch
))) {
83 messagef(0, "no such item.");
86 if (obj
->what_is
!= POTION
) {
87 messagef(0, "you can't drink that");
90 switch(obj
->which_kind
) {
91 case INCREASE_STRENGTH
:
92 messagef(0, "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 messagef(0, "this tastes great, you feel warm all over");
103 messagef(0, "you begin to feel better");
107 messagef(0, "you begin to feel much better");
111 if (!sustain_strength
) {
112 rogue
.str_current
-= get_rand(1, 3);
113 if (rogue
.str_current
< 1) {
114 rogue
.str_current
= 1;
117 messagef(0, "you feel very sick now");
123 rogue
.exp_points
= level_points
[rogue
.exp
- 1];
124 messagef(0, "you suddenly feel much more skillful");
131 messagef(0, "oh wow, everything seems so cosmic");
132 halluc
+= get_rand(500, 800);
136 if (!(level_monsters
.next_monster
)) {
137 messagef(0, "%s", strange_feeling
);
141 if (level_objects
.next_object
) {
146 messagef(0, "%s", strange_feeling
);
150 messagef(0, (halluc
? "what a trippy feeling" :
151 "you feel confused"));
155 messagef(0, "you start to float in the air");
156 levitate
+= get_rand(15, 30);
157 being_held
= bear_trap
= 0;
160 messagef(0, "you feel yourself moving much faster");
161 haste_self
+= get_rand(11, 21);
162 if (!(haste_self
% 2)) {
167 messagef(0, "hmm, this potion tastes like %sjuice",
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
);
189 ch
= pack_letter("read what?", SCROL
);
194 if (!(obj
= get_letter_object(ch
))) {
195 messagef(0, "no such item.");
198 if (obj
->what_is
!= SCROL
) {
199 messagef(0, "you can't read that");
202 switch(obj
->which_kind
) {
204 messagef(0, "you hear a maniacal laughter in the distance");
211 if (rogue
.weapon
->what_is
== WEAPON
) {
212 messagef(0, "your %sglow%s %sfor a moment",
213 name_of(rogue
.weapon
),
214 ((rogue
.weapon
->quantity
<= 1) ? "s" : ""),
217 rogue
.weapon
->hit_enchant
++;
219 rogue
.weapon
->d_enchant
++;
222 rogue
.weapon
->is_cursed
= 0;
224 messagef(0, "your hands tingle");
229 messagef(0, "your armor glows %sfor a moment",
231 rogue
.armor
->d_enchant
++;
232 rogue
.armor
->is_cursed
= 0;
233 print_stats(STAT_ARMOR
);
235 messagef(0, "your skin crawls");
239 messagef(0, "this is a scroll of identify");
241 id_scrolls
[obj
->which_kind
].id_status
= IDENTIFIED
;
248 messagef(0, "you fall asleep");
253 messagef(0, "your armor is covered by a shimmering gold shield");
254 rogue
.armor
->is_protected
= 1;
255 rogue
.armor
->is_cursed
= 0;
257 messagef(0, "your acne seems to have disappeared");
261 messagef(0, (!halluc
) ?
262 "you feel as though someone is watching over you" :
263 "you feel in touch with the universal oneness");
269 case AGGRAVATE_MONSTER
:
273 messagef(0, "this scroll seems to have a map on it");
278 messagef(0, "your hands glow %sfor a moment",
282 if (id_scrolls
[obj
->which_kind
].id_status
!= CALLED
) {
283 id_scrolls
[obj
->which_kind
].id_status
= IDENTIFIED
;
285 vanish(obj
, (obj
->which_kind
!= SLEEP
), &rogue
.pack
);
288 /* vanish() does NOT handle a quiver of weapons with more than one
289 * arrow (or whatever) in the quiver. It will only decrement the count.
293 vanish(object
*obj
, short rm
, object
*pack
)
295 if (obj
->quantity
> 1) {
298 if (obj
->in_use_flags
& BEING_WIELDED
) {
300 } else if (obj
->in_use_flags
& BEING_WORN
) {
302 } else if (obj
->in_use_flags
& ON_EITHER_HAND
) {
305 take_from_pack(obj
, pack
);
314 potion_heal(int extra
)
319 rogue
.hp_current
+= rogue
.exp
;
321 ratio
= ((float)rogue
.hp_current
) / rogue
.hp_max
;
324 rogue
.hp_max
+= (extra
? 2 : 1);
325 extra_hp
+= (extra
? 2 : 1);
326 rogue
.hp_current
= rogue
.hp_max
;
327 } else if (ratio
>= 0.90) {
328 rogue
.hp_max
+= (extra
? 1 : 0);
329 extra_hp
+= (extra
? 1 : 0);
330 rogue
.hp_current
= rogue
.hp_max
;
338 add
= (short)(ratio
* (rogue
.hp_max
- rogue
.hp_current
));
339 rogue
.hp_current
+= add
;
340 if (rogue
.hp_current
> rogue
.hp_max
) {
341 rogue
.hp_current
= rogue
.hp_max
;
347 if (confused
&& extra
) {
349 } else if (confused
) {
350 confused
= (confused
/ 2) + 1;
352 if (halluc
&& extra
) {
355 halluc
= (halluc
/ 2) + 1;
367 ch
= pack_letter("what would you like to identify?", ALL_OBJECTS
);
372 if (!(obj
= get_letter_object(ch
))) {
373 messagef(0, "no such item, try again");
374 messagef(0, "%s", ""); /* gcc objects to just "" */
379 if (obj
->what_is
& (SCROL
| POTION
| WEAPON
| ARMOR
| WAND
| RING
)) {
380 id_table
= get_id_table(obj
);
381 id_table
[obj
->which_kind
].id_status
= IDENTIFIED
;
383 get_desc(obj
, desc
, sizeof(desc
));
384 messagef(0, "%s", desc
);
394 ch
= pack_letter("eat what?", FOOD
);
399 if (!(obj
= get_letter_object(ch
))) {
400 messagef(0, "no such item.");
403 if (obj
->what_is
!= FOOD
) {
404 messagef(0, "you can't eat that");
407 if ((obj
->which_kind
== FRUIT
) || rand_percent(60)) {
408 moves
= get_rand(950, 1150);
409 if (obj
->which_kind
== RATION
) {
410 messagef(0, "yum, that tasted good");
412 messagef(0, "my, that was a yummy %s", fruit
);
415 moves
= get_rand(750, 950);
416 messagef(0, "yuk, that food tasted awful");
419 rogue
.moves_left
/= 3;
420 rogue
.moves_left
+= moves
;
422 print_stats(STAT_HUNGER
);
424 vanish(obj
, 1, &rogue
.pack
);
435 for (i
= -2; i
<= 2; i
++) {
436 for (j
= -2; j
<= 2; j
++) {
439 if ((row
< MIN_ROW
) || (row
> (DROWS
-2)) || (col
< 0) ||
443 if (dungeon
[row
][col
] & MONSTER
) {
444 monster
= object_at(&level_monsters
, row
, col
);
445 monster
->m_flags
|= ASLEEP
;
446 monster
->m_flags
&= (~WAKENS
);
452 messagef(0, "you feel a strange sense of loss");
453 } else if (mcount
== 1) {
454 messagef(0, "the monster freezes");
456 messagef(0, "the monsters around you freeze");
463 mvaddch(rogue
.row
, rogue
.col
, get_dungeon_char(rogue
.row
, rogue
.col
));
466 darken_room(cur_room
);
468 put_player(get_room_number(rogue
.row
, rogue
.col
));
476 object
*obj
, *monster
;
481 obj
= level_objects
.next_object
;
484 ch
= mvinch(obj
->row
, obj
->col
);
485 if (((ch
< 'A') || (ch
> 'Z')) &&
486 ((obj
->row
!= rogue
.row
) || (obj
->col
!= rogue
.col
)))
487 if ((ch
!= ' ') && (ch
!= '.') && (ch
!= '#') && (ch
!= '+')) {
488 addch(gr_obj_char());
490 obj
= obj
->next_object
;
492 monster
= level_monsters
.next_monster
;
495 ch
= mvinch(monster
->row
, monster
->col
);
496 if ((ch
>= 'A') && (ch
<= 'Z')) {
497 addch(get_rand('A', 'Z'));
499 monster
= monster
->next_monster
;
508 messagef(1, "everything looks SO boring now");
515 messagef(1, "the veil of darkness lifts");
520 if (detect_monster
) {
528 if (cur_room
== PASSAGE
) {
529 light_passage(rogue
.row
, rogue
.col
);
531 light_up_room(cur_room
);
533 mvaddch(rogue
.row
, rogue
.col
, rogue
.fchar
);
548 messagef(0, "%s", you_can_move_again
);
557 messagef(0, "a cloak of darkness falls around you");
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
) {
597 confused
+= get_rand(12, 22);
604 messagef(1, "you feel less %s now", (halluc
? "trippy" : "confused"));
612 obj
= rogue
.pack
.next_object
;
616 obj
= obj
->next_object
;