]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - rogue/use.c
1 /* $NetBSD: use.c,v 1.7 2007/12/27 23:53:01 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.7 2007/12/27 23:53:01 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;
67 const char *strange_feeling
= "you have a strange feeling for a moment, then it passes";
75 ch
= pack_letter("quaff what?", POTION
);
80 if (!(obj
= get_letter_object(ch
))) {
81 messagef(0, "no such item.");
84 if (obj
->what_is
!= POTION
) {
85 messagef(0, "you can't drink that");
88 switch(obj
->which_kind
) {
89 case INCREASE_STRENGTH
:
90 messagef(0, "you feel stronger now, what bulging muscles!");
92 if (rogue
.str_current
> rogue
.str_max
) {
93 rogue
.str_max
= rogue
.str_current
;
96 case RESTORE_STRENGTH
:
97 rogue
.str_current
= rogue
.str_max
;
98 messagef(0, "this tastes great, you feel warm all over");
101 messagef(0, "you begin to feel better");
105 messagef(0, "you begin to feel much better");
109 if (!sustain_strength
) {
110 rogue
.str_current
-= get_rand(1, 3);
111 if (rogue
.str_current
< 1) {
112 rogue
.str_current
= 1;
115 messagef(0, "you feel very sick now");
121 rogue
.exp_points
= level_points
[rogue
.exp
- 1];
122 messagef(0, "you suddenly feel much more skillful");
129 messagef(0, "oh wow, everything seems so cosmic");
130 halluc
+= get_rand(500, 800);
134 if (!(level_monsters
.next_monster
)) {
135 messagef(0, "%s", strange_feeling
);
139 if (level_objects
.next_object
) {
144 messagef(0, "%s", strange_feeling
);
148 messagef(0, (halluc
? "what a trippy feeling" :
149 "you feel confused"));
153 messagef(0, "you start to float in the air");
154 levitate
+= get_rand(15, 30);
155 being_held
= bear_trap
= 0;
158 messagef(0, "you feel yourself moving much faster");
159 haste_self
+= get_rand(11, 21);
160 if (!(haste_self
% 2)) {
165 messagef(0, "hmm, this potion tastes like %sjuice",
174 print_stats((STAT_STRENGTH
| STAT_HP
));
175 if (id_potions
[obj
->which_kind
].id_status
!= CALLED
) {
176 id_potions
[obj
->which_kind
].id_status
= IDENTIFIED
;
178 vanish(obj
, 1, &rogue
.pack
);
187 ch
= pack_letter("read what?", SCROL
);
192 if (!(obj
= get_letter_object(ch
))) {
193 messagef(0, "no such item.");
196 if (obj
->what_is
!= SCROL
) {
197 messagef(0, "you can't read that");
200 switch(obj
->which_kind
) {
202 messagef(0, "you hear a maniacal laughter in the distance");
209 if (rogue
.weapon
->what_is
== WEAPON
) {
210 messagef(0, "your %sglow%s %sfor a moment",
211 name_of(rogue
.weapon
),
212 ((rogue
.weapon
->quantity
<= 1) ? "s" : ""),
215 rogue
.weapon
->hit_enchant
++;
217 rogue
.weapon
->d_enchant
++;
220 rogue
.weapon
->is_cursed
= 0;
222 messagef(0, "your hands tingle");
227 messagef(0, "your armor glows %sfor a moment",
229 rogue
.armor
->d_enchant
++;
230 rogue
.armor
->is_cursed
= 0;
231 print_stats(STAT_ARMOR
);
233 messagef(0, "your skin crawls");
237 messagef(0, "this is a scroll of identify");
239 id_scrolls
[obj
->which_kind
].id_status
= IDENTIFIED
;
246 messagef(0, "you fall asleep");
251 messagef(0, "your armor is covered by a shimmering gold shield");
252 rogue
.armor
->is_protected
= 1;
253 rogue
.armor
->is_cursed
= 0;
255 messagef(0, "your acne seems to have disappeared");
259 messagef(0, (!halluc
) ?
260 "you feel as though someone is watching over you" :
261 "you feel in touch with the universal oneness");
267 case AGGRAVATE_MONSTER
:
271 messagef(0, "this scroll seems to have a map on it");
276 messagef(0, "your hands glow %sfor a moment",
280 if (id_scrolls
[obj
->which_kind
].id_status
!= CALLED
) {
281 id_scrolls
[obj
->which_kind
].id_status
= IDENTIFIED
;
283 vanish(obj
, (obj
->which_kind
!= SLEEP
), &rogue
.pack
);
286 /* vanish() does NOT handle a quiver of weapons with more than one
287 * arrow (or whatever) in the quiver. It will only decrement the count.
291 vanish(obj
, rm
, pack
)
296 if (obj
->quantity
> 1) {
299 if (obj
->in_use_flags
& BEING_WIELDED
) {
301 } else if (obj
->in_use_flags
& BEING_WORN
) {
303 } else if (obj
->in_use_flags
& ON_EITHER_HAND
) {
306 take_from_pack(obj
, pack
);
321 rogue
.hp_current
+= rogue
.exp
;
323 ratio
= ((float)rogue
.hp_current
) / rogue
.hp_max
;
326 rogue
.hp_max
+= (extra
? 2 : 1);
327 extra_hp
+= (extra
? 2 : 1);
328 rogue
.hp_current
= rogue
.hp_max
;
329 } else if (ratio
>= 0.90) {
330 rogue
.hp_max
+= (extra
? 1 : 0);
331 extra_hp
+= (extra
? 1 : 0);
332 rogue
.hp_current
= rogue
.hp_max
;
340 add
= (short)(ratio
* ((float)rogue
.hp_max
- rogue
.hp_current
));
341 rogue
.hp_current
+= add
;
342 if (rogue
.hp_current
> rogue
.hp_max
) {
343 rogue
.hp_current
= rogue
.hp_max
;
349 if (confused
&& extra
) {
351 } else if (confused
) {
352 confused
= (confused
/ 2) + 1;
354 if (halluc
&& extra
) {
357 halluc
= (halluc
/ 2) + 1;
369 ch
= pack_letter("what would you like to identify?", ALL_OBJECTS
);
374 if (!(obj
= get_letter_object(ch
))) {
375 messagef(0, "no such item, try again");
376 messagef(0, "%s", ""); /* gcc objects to just "" */
381 if (obj
->what_is
& (SCROL
| POTION
| WEAPON
| ARMOR
| WAND
| RING
)) {
382 id_table
= get_id_table(obj
);
383 id_table
[obj
->which_kind
].id_status
= IDENTIFIED
;
385 get_desc(obj
, desc
, sizeof(desc
));
386 messagef(0, "%s", desc
);
396 ch
= pack_letter("eat what?", FOOD
);
401 if (!(obj
= get_letter_object(ch
))) {
402 messagef(0, "no such item.");
405 if (obj
->what_is
!= FOOD
) {
406 messagef(0, "you can't eat that");
409 if ((obj
->which_kind
== FRUIT
) || rand_percent(60)) {
410 moves
= get_rand(950, 1150);
411 if (obj
->which_kind
== RATION
) {
412 messagef(0, "yum, that tasted good");
414 messagef(0, "my, that was a yummy %s", fruit
);
417 moves
= get_rand(750, 950);
418 messagef(0, "yuk, that food tasted awful");
421 rogue
.moves_left
/= 3;
422 rogue
.moves_left
+= moves
;
424 print_stats(STAT_HUNGER
);
426 vanish(obj
, 1, &rogue
.pack
);
437 for (i
= -2; i
<= 2; i
++) {
438 for (j
= -2; j
<= 2; j
++) {
441 if ((row
< MIN_ROW
) || (row
> (DROWS
-2)) || (col
< 0) ||
445 if (dungeon
[row
][col
] & MONSTER
) {
446 monster
= object_at(&level_monsters
, row
, col
);
447 monster
->m_flags
|= ASLEEP
;
448 monster
->m_flags
&= (~WAKENS
);
454 messagef(0, "you feel a strange sense of loss");
455 } else if (mcount
== 1) {
456 messagef(0, "the monster freezes");
458 messagef(0, "the monsters around you freeze");
465 mvaddch(rogue
.row
, rogue
.col
, get_dungeon_char(rogue
.row
, rogue
.col
));
468 darken_room(cur_room
);
470 put_player(get_room_number(rogue
.row
, rogue
.col
));
478 object
*obj
, *monster
;
483 obj
= level_objects
.next_object
;
486 ch
= mvinch(obj
->row
, obj
->col
);
487 if (((ch
< 'A') || (ch
> 'Z')) &&
488 ((obj
->row
!= rogue
.row
) || (obj
->col
!= rogue
.col
)))
489 if ((ch
!= ' ') && (ch
!= '.') && (ch
!= '#') && (ch
!= '+')) {
490 addch(gr_obj_char());
492 obj
= obj
->next_object
;
494 monster
= level_monsters
.next_monster
;
497 ch
= mvinch(monster
->row
, monster
->col
);
498 if ((ch
>= 'A') && (ch
<= 'Z')) {
499 addch(get_rand('A', 'Z'));
501 monster
= monster
->next_monster
;
510 messagef(1, "everything looks SO boring now");
517 messagef(1, "the veil of darkness lifts");
522 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
);
550 messagef(0, "%s", you_can_move_again
);
559 messagef(0, "a cloak of darkness falls around you");
561 blind
+= get_rand(500, 800);
563 if (detect_monster
) {
566 monster
= level_monsters
.next_monster
;
569 mvaddch(monster
->row
, monster
->col
, monster
->trail_char
);
570 monster
= monster
->next_monster
;
574 for (i
= rooms
[cur_room
].top_row
+ 1;
575 i
< rooms
[cur_room
].bottom_row
; i
++) {
576 for (j
= rooms
[cur_room
].left_col
+ 1;
577 j
< rooms
[cur_room
].right_col
; j
++) {
582 mvaddch(rogue
.row
, rogue
.col
, rogue
.fchar
);
589 return(id_potions
[get_rand(0, POTIONS
-1)].title
);
590 } else if (con_mon
) {
599 confused
+= get_rand(12, 22);
606 messagef(1, "you feel less %s now", (halluc
? "trippy" : "confused"));
614 obj
= rogue
.pack
.next_object
;
618 obj
= obj
->next_object
;