2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
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
39 static char sccsid[] = "@(#)ring.c 8.1 (Berkeley) 5/31/93";
41 static const char rcsid[] =
48 * This source herein may be modified and/or distributed by anybody who
49 * so desires, with the following restrictions:
50 * 1.) No portion of this notice shall be removed.
51 * 2.) Credit shall not be taken for the creation of this source.
52 * 3.) This code is not to be traded, sold, or used for personal
59 const char *left_or_right = "left or right hand?";
60 const char *no_ring = "there's no ring on that hand";
69 boolean r_see_invisible;
70 boolean sustain_strength;
71 boolean maintain_armor;
73 extern char *curse_message;
74 extern boolean wizard;
83 message("wearing two rings already", 0);
86 if ((ch = pack_letter("put on what?", RING)) == CANCEL) {
89 if (!(ring = get_letter_object(ch))) {
90 message("no such item.", 0);
93 if (!(ring->what_is & RING)) {
94 message("that's not a ring", 0);
97 if (ring->in_use_flags & (ON_LEFT_HAND | ON_RIGHT_HAND)) {
98 message("that ring is already being worn", 0);
102 ch = (rogue.left_ring ? 'r' : 'l');
104 message(left_or_right, 0);
107 } while ((ch != CANCEL) && (ch != 'l') && (ch != 'r') && (ch != '\n') &&
110 if ((ch != 'l') && (ch != 'r')) {
114 if (((ch == 'l') && rogue.left_ring)||((ch == 'r') && rogue.right_ring)) {
116 message("there's already a ring on that hand", 0);
126 get_desc(ring, desc);
132 * Do not call ring_stats() from within do_put_on(). It will cause
133 * serious problems when do_put_on() is called from read_pack() in restore().
136 do_put_on(ring, on_left)
141 ring->in_use_flags |= ON_LEFT_HAND;
142 rogue.left_ring = ring;
144 ring->in_use_flags |= ON_RIGHT_HAND;
145 rogue.right_ring = ring;
151 boolean left = 0, right = 0;
158 } else if (rogue.left_ring && !rogue.right_ring) {
160 } else if (!rogue.left_ring && rogue.right_ring) {
163 message(left_or_right, 0);
166 } while ((ch != CANCEL) && (ch != 'l') && (ch != 'r') &&
167 (ch != '\n') && (ch != '\r'));
174 if (rogue.left_ring) {
175 ring = rogue.left_ring;
180 if (rogue.right_ring) {
181 ring = rogue.right_ring;
186 if (ring->is_cursed) {
187 message(curse_message, 0);
190 (void) strcpy(buf, "removed ");
191 get_desc(ring, buf + 8);
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;
211 gr_ring(ring, assign_wk)
215 ring->what_is = RING;
217 ring->which_kind = get_rand(0, (RINGS - 1));
221 switch(ring->which_kind) {
229 case R_SEE_INVISIBLE:
231 case SUSTAIN_STRENGTH:
233 case R_MAINTAIN_ARMOR:
243 while ((ring->class = (get_rand(0, 4) - 2)) == 0) ;
244 ring->is_cursed = (ring->class < 0);
247 ring->is_cursed = coin_toss();
257 message("not wearing any rings", 0);
259 if (rogue.left_ring) {
260 get_desc(rogue.left_ring, buf);
263 if (rogue.right_ring) {
264 get_desc(rogue.right_ring, buf);
269 sprintf(buf, "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",
270 stealthy, r_rings, e_rings, r_teleport, sustain_strength,
271 add_strength, regeneration, ring_exp, r_see_invisible,
272 maintain_armor, auto_search);
287 sustain_strength = 0;
295 for (i = 0; i < 2; i++) {
296 if (!(ring = ((i == 0) ? rogue.left_ring : rogue.right_ring))) {
301 switch(ring->which_kind) {
315 add_strength += ring->class;
317 case SUSTAIN_STRENGTH:
318 sustain_strength = 1;
321 ring_exp += ring->class;
325 case R_SEE_INVISIBLE:
337 print_stats(STAT_STRENGTH);