]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - rogue/use.c
2 * Copyright (c) 1988 The Regents of the University of California.
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
38 /*static char sccsid[] = "from: @(#)use.c 5.3 (Berkeley) 6/1/90";*/
39 static char rcsid
[] = "$Id: use.c,v 1.2 1993/08/01 18:52:08 mycroft Exp $";
45 * This source herein may be modified and/or distributed by anybody who
46 * so desires, with the following restrictions:
47 * 1.) No portion of this notice shall be removed.
48 * 2.) Credit shall not be taken for the creation of this source.
49 * 3.) This code is not to be traded, sold, or used for personal
61 boolean see_invisible
= 0;
63 boolean detect_monster
= 0;
65 char *strange_feeling
= "you have a strange feeling for a moment, then it passes";
67 extern short bear_trap
;
68 extern char hunger_str
[];
69 extern short cur_room
;
70 extern long level_points
[];
71 extern boolean being_held
;
72 extern char *fruit
, *you_can_move_again
;
73 extern boolean sustain_strength
;
81 ch
= pack_letter("quaff what?", POTION
);
86 if (!(obj
= get_letter_object(ch
))) {
87 message("no such item.", 0);
90 if (obj
->what_is
!= POTION
) {
91 message("you can't drink that", 0);
94 switch(obj
->which_kind
) {
95 case INCREASE_STRENGTH
:
96 message("you feel stronger now, what bulging muscles!",
99 if (rogue
.str_current
> rogue
.str_max
) {
100 rogue
.str_max
= rogue
.str_current
;
103 case RESTORE_STRENGTH
:
104 rogue
.str_current
= rogue
.str_max
;
105 message("this tastes great, you feel warm all over", 0);
108 message("you begin to feel better", 0);
112 message("you begin to feel much better", 0);
116 if (!sustain_strength
) {
117 rogue
.str_current
-= get_rand(1, 3);
118 if (rogue
.str_current
< 1) {
119 rogue
.str_current
= 1;
122 message("you feel very sick now", 0);
128 rogue
.exp_points
= level_points
[rogue
.exp
- 1];
129 message("you suddenly feel much more skillful", 0);
136 message("oh wow, everything seems so cosmic", 0);
137 halluc
+= get_rand(500, 800);
141 if (!(level_monsters
.next_monster
)) {
142 message(strange_feeling
, 0);
146 if (level_objects
.next_object
) {
151 message(strange_feeling
, 0);
155 message((halluc
? "what a trippy feeling" :
156 "you feel confused"), 0);
160 message("you start to float in the air", 0);
161 levitate
+= get_rand(15, 30);
162 being_held
= bear_trap
= 0;
165 message("you feel yourself moving much faster", 0);
166 haste_self
+= get_rand(11, 21);
167 if (!(haste_self
% 2)) {
172 sprintf(buf
, "hmm, this potion tastes like %sjuice", fruit
);
181 print_stats((STAT_STRENGTH
| STAT_HP
));
182 if (id_potions
[obj
->which_kind
].id_status
!= CALLED
) {
183 id_potions
[obj
->which_kind
].id_status
= IDENTIFIED
;
185 vanish(obj
, 1, &rogue
.pack
);
194 ch
= pack_letter("read what?", SCROL
);
199 if (!(obj
= get_letter_object(ch
))) {
200 message("no such item.", 0);
203 if (obj
->what_is
!= SCROL
) {
204 message("you can't read that", 0);
207 switch(obj
->which_kind
) {
209 message("you hear a maniacal laughter in the distance",
217 if (rogue
.weapon
->what_is
== WEAPON
) {
218 sprintf(msg
, "your %sglow%s %sfor a moment",
219 name_of(rogue
.weapon
),
220 ((rogue
.weapon
->quantity
<= 1) ? "s" : ""),
224 rogue
.weapon
->hit_enchant
++;
226 rogue
.weapon
->d_enchant
++;
229 rogue
.weapon
->is_cursed
= 0;
231 message("your hands tingle", 0);
236 sprintf(msg
, "your armor glows %sfor a moment",
239 rogue
.armor
->d_enchant
++;
240 rogue
.armor
->is_cursed
= 0;
241 print_stats(STAT_ARMOR
);
243 message("your skin crawls", 0);
247 message("this is a scroll of identify", 0);
249 id_scrolls
[obj
->which_kind
].id_status
= IDENTIFIED
;
256 message("you fall asleep", 0);
261 message( "your armor is covered by a shimmering gold shield",0);
262 rogue
.armor
->is_protected
= 1;
263 rogue
.armor
->is_cursed
= 0;
265 message("your acne seems to have disappeared", 0);
270 "you feel as though someone is watching over you" :
271 "you feel in touch with the universal oneness", 0);
277 case AGGRAVATE_MONSTER
:
281 message("this scroll seems to have a map on it", 0);
286 sprintf(msg
, "your hands glow %sfor a moment", get_ench_color());
290 if (id_scrolls
[obj
->which_kind
].id_status
!= CALLED
) {
291 id_scrolls
[obj
->which_kind
].id_status
= IDENTIFIED
;
293 vanish(obj
, (obj
->which_kind
!= SLEEP
), &rogue
.pack
);
296 /* vanish() does NOT handle a quiver of weapons with more than one
297 * arrow (or whatever) in the quiver. It will only decrement the count.
300 vanish(obj
, rm
, pack
)
305 if (obj
->quantity
> 1) {
308 if (obj
->in_use_flags
& BEING_WIELDED
) {
310 } else if (obj
->in_use_flags
& BEING_WORN
) {
312 } else if (obj
->in_use_flags
& ON_EITHER_HAND
) {
315 take_from_pack(obj
, pack
);
328 rogue
.hp_current
+= rogue
.exp
;
330 ratio
= ((float)rogue
.hp_current
) / rogue
.hp_max
;
333 rogue
.hp_max
+= (extra
? 2 : 1);
334 extra_hp
+= (extra
? 2 : 1);
335 rogue
.hp_current
= rogue
.hp_max
;
336 } else if (ratio
>= 0.90) {
337 rogue
.hp_max
+= (extra
? 1 : 0);
338 extra_hp
+= (extra
? 1 : 0);
339 rogue
.hp_current
= rogue
.hp_max
;
347 add
= (short)(ratio
* ((float)rogue
.hp_max
- rogue
.hp_current
));
348 rogue
.hp_current
+= add
;
349 if (rogue
.hp_current
> rogue
.hp_max
) {
350 rogue
.hp_current
= rogue
.hp_max
;
356 if (confused
&& extra
) {
358 } else if (confused
) {
359 confused
= (confused
/ 2) + 1;
361 if (halluc
&& extra
) {
364 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
;
402 ch
= pack_letter("eat what?", FOOD
);
407 if (!(obj
= get_letter_object(ch
))) {
408 message("no such item.", 0);
411 if (obj
->what_is
!= FOOD
) {
412 message("you can't eat that", 0);
415 if ((obj
->which_kind
== FRUIT
) || rand_percent(60)) {
416 moves
= get_rand(950, 1150);
417 if (obj
->which_kind
== RATION
) {
418 message("yum, that tasted good", 0);
420 sprintf(buf
, "my, that was a yummy %s", fruit
);
424 moves
= get_rand(750, 950);
425 message("yuk, that food tasted awful", 0);
428 rogue
.moves_left
/= 3;
429 rogue
.moves_left
+= moves
;
431 print_stats(STAT_HUNGER
);
433 vanish(obj
, 1, &rogue
.pack
);
443 for (i
= -2; i
<= 2; i
++) {
444 for (j
= -2; j
<= 2; j
++) {
447 if ((row
< MIN_ROW
) || (row
> (DROWS
-2)) || (col
< 0) ||
451 if (dungeon
[row
][col
] & MONSTER
) {
452 monster
= object_at(&level_monsters
, row
, col
);
453 monster
->m_flags
|= ASLEEP
;
454 monster
->m_flags
&= (~WAKENS
);
460 message("you feel a strange sense of loss", 0);
461 } else if (mcount
== 1) {
462 message("the monster freezes", 0);
464 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
));
482 object
*obj
, *monster
;
487 obj
= level_objects
.next_object
;
490 ch
= mvinch(obj
->row
, obj
->col
);
491 if (((ch
< 'A') || (ch
> 'Z')) &&
492 ((obj
->row
!= rogue
.row
) || (obj
->col
!= rogue
.col
)))
493 if ((ch
!= ' ') && (ch
!= '.') && (ch
!= '#') && (ch
!= '+')) {
494 addch(gr_obj_char());
496 obj
= obj
->next_object
;
498 monster
= level_monsters
.next_monster
;
501 ch
= mvinch(monster
->row
, monster
->col
);
502 if ((ch
>= 'A') && (ch
<= 'Z')) {
503 addch(get_rand('A', 'Z'));
505 monster
= monster
->next_monster
;
513 message("everything looks SO boring now", 1);
519 message("the veil of darkness lifts", 1);
524 if (detect_monster
) {
531 if (cur_room
== PASSAGE
) {
532 light_passage(rogue
.row
, rogue
.col
);
534 light_up_room(cur_room
);
536 mvaddch(rogue
.row
, rogue
.col
, rogue
.fchar
);
550 message(you_can_move_again
, 0);
558 message("a cloak of darkness falls around you", 0);
560 blind
+= get_rand(500, 800);
562 if (detect_monster
) {
565 monster
= level_monsters
.next_monster
;
568 mvaddch(monster
->row
, monster
->col
, monster
->trail_char
);
569 monster
= monster
->next_monster
;
573 for (i
= rooms
[cur_room
].top_row
+ 1;
574 i
< rooms
[cur_room
].bottom_row
; i
++) {
575 for (j
= rooms
[cur_room
].left_col
+ 1;
576 j
< rooms
[cur_room
].right_col
; j
++) {
581 mvaddch(rogue
.row
, rogue
.col
, rogue
.fchar
);
588 return(id_potions
[get_rand(0, POTIONS
-1)].title
);
589 } else if (con_mon
) {
597 confused
+= get_rand(12, 22);
605 sprintf(msg
, "you feel less %s now", (halluc
? "trippy" : "confused"));
613 obj
= rogue
.pack
.next_object
;
617 obj
= obj
->next_object
;