]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - rogue/ring.c
321fd493e1b810a10bef28c94ab697cdfc2e46fe
1 /* $NetBSD: ring.c,v 1.7 2007/12/27 23:53:00 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
[] = "@(#)ring.c 8.1 (Berkeley) 5/31/93";
40 __RCSID("$NetBSD: ring.c,v 1.7 2007/12/27 23:53:00 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
58 const char *left_or_right
= "left or right hand?";
59 const char *no_ring
= "there's no ring on that hand";
68 boolean r_see_invisible
;
69 boolean sustain_strength
;
70 boolean maintain_armor
;
80 messagef(0, "wearing two rings already");
83 if ((ch
= pack_letter("put on what?", RING
)) == CANCEL
) {
86 if (!(ring
= get_letter_object(ch
))) {
87 messagef(0, "no such item.");
90 if (!(ring
->what_is
& RING
)) {
91 messagef(0, "that's not a ring");
94 if (ring
->in_use_flags
& (ON_LEFT_HAND
| ON_RIGHT_HAND
)) {
95 messagef(0, "that ring is already being worn");
99 ch
= (rogue
.left_ring
? 'r' : 'l');
101 messagef(0, "%s", left_or_right
);
104 } while ((ch
!= CANCEL
) && (ch
!= 'l') && (ch
!= 'r') && (ch
!= '\n') &&
107 if ((ch
!= 'l') && (ch
!= 'r')) {
111 if (((ch
== 'l') && rogue
.left_ring
)||((ch
== 'r') && rogue
.right_ring
)) {
113 messagef(0, "there's already a ring on that hand");
123 get_desc(ring
, desc
, sizeof(desc
));
124 messagef(0, "%s", desc
);
129 * Do not call ring_stats() from within do_put_on(). It will cause
130 * serious problems when do_put_on() is called from read_pack() in restore().
134 do_put_on(ring
, on_left
)
139 ring
->in_use_flags
|= ON_LEFT_HAND
;
140 rogue
.left_ring
= ring
;
142 ring
->in_use_flags
|= ON_RIGHT_HAND
;
143 rogue
.right_ring
= ring
;
150 boolean left
= 0, right
= 0;
158 } else if (rogue
.left_ring
&& !rogue
.right_ring
) {
160 } else if (!rogue
.left_ring
&& rogue
.right_ring
) {
163 messagef(0, "%s", left_or_right
);
166 } while ((ch
!= CANCEL
) && (ch
!= 'l') && (ch
!= 'r') &&
167 (ch
!= '\n') && (ch
!= '\r'));
174 if (rogue
.left_ring
) {
175 ring
= rogue
.left_ring
;
177 messagef(0, "%s", no_ring
);
180 if (rogue
.right_ring
) {
181 ring
= rogue
.right_ring
;
183 messagef(0, "%s", no_ring
);
186 if (ring
->is_cursed
) {
187 messagef(0, "%s", curse_message
);
190 get_desc(ring
, buf
, sizeof(buf
));
191 messagef(0, "removed %s", buf
);
201 if (ring
&& (ring
->in_use_flags
& ON_LEFT_HAND
)) {
202 ring
->in_use_flags
&= (~ON_LEFT_HAND
);
204 } else if (ring
&& (ring
->in_use_flags
& ON_RIGHT_HAND
)) {
205 ring
->in_use_flags
&= (~ON_RIGHT_HAND
);
206 rogue
.right_ring
= 0;
212 gr_ring(ring
, assign_wk
)
216 ring
->what_is
= RING
;
218 ring
->which_kind
= get_rand(0, (RINGS
- 1));
222 switch(ring
->which_kind
) {
230 case R_SEE_INVISIBLE:
232 case SUSTAIN_STRENGTH:
234 case R_MAINTAIN_ARMOR:
244 while ((ring
->class = (get_rand(0, 4) - 2)) == 0) ;
245 ring
->is_cursed
= (ring
->class < 0);
248 ring
->is_cursed
= coin_toss();
259 messagef(0, "not wearing any rings");
261 if (rogue
.left_ring
) {
262 get_desc(rogue
.left_ring
, buf
, sizeof(buf
));
263 messagef(0, "%s", buf
);
265 if (rogue
.right_ring
) {
266 get_desc(rogue
.right_ring
, buf
, sizeof(buf
));
267 messagef(0, "%s", buf
);
271 messagef(0, "ste %d, r_r %d, e_r %d, r_t %d, s_s %d, a_s %d, reg %d, r_e %d, s_i %d, m_a %d, aus %d",
272 stealthy
, r_rings
, e_rings
, r_teleport
, sustain_strength
,
273 add_strength
, regeneration
, ring_exp
, r_see_invisible
,
274 maintain_armor
, auto_search
);
289 sustain_strength
= 0;
297 for (i
= 0; i
< 2; i
++) {
298 if (!(ring
= ((i
== 0) ? rogue
.left_ring
: rogue
.right_ring
))) {
303 switch(ring
->which_kind
) {
317 add_strength
+= ring
->class;
319 case SUSTAIN_STRENGTH
:
320 sustain_strength
= 1;
323 ring_exp
+= ring
->class;
327 case R_SEE_INVISIBLE
:
339 print_stats(STAT_STRENGTH
);