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. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * @(#)ring.c 8.1 (Berkeley) 5/31/93
33 * $FreeBSD: src/games/rogue/ring.c,v 1.3 1999/11/30 03:49:26 billf Exp $
34 * $DragonFly: src/games/rogue/ring.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $
40 * This source herein may be modified and/or distributed by anybody who
41 * so desires, with the following restrictions:
42 * 1.) No portion of this notice shall be removed.
43 * 2.) Credit shall not be taken for the creation of this source.
44 * 3.) This code is not to be traded, sold, or used for personal
51 const char *left_or_right = "left or right hand?";
52 const char *no_ring = "there's no ring on that hand";
61 boolean r_see_invisible;
62 boolean sustain_strength;
63 boolean maintain_armor;
65 extern char *curse_message;
66 extern boolean wizard;
76 message("wearing two rings already", 0);
79 if ((ch = pack_letter("put on what?", RING)) == CANCEL) {
82 if (!(ring = get_letter_object(ch))) {
83 message("no such item.", 0);
86 if (!(ring->what_is & RING)) {
87 message("that's not a ring", 0);
90 if (ring->in_use_flags & (ON_LEFT_HAND | ON_RIGHT_HAND)) {
91 message("that ring is already being worn", 0);
95 ch = (rogue.left_ring ? 'r' : 'l');
97 message(left_or_right, 0);
100 } while ((ch != CANCEL) && (ch != 'l') && (ch != 'r') && (ch != '\n') &&
103 if ((ch != 'l') && (ch != 'r')) {
107 if (((ch == 'l') && rogue.left_ring)||((ch == 'r') && rogue.right_ring)) {
109 message("there's already a ring on that hand", 0);
119 get_desc(ring, desc);
125 * Do not call ring_stats() from within do_put_on(). It will cause
126 * serious problems when do_put_on() is called from read_pack() in restore().
130 do_put_on(object *ring, boolean on_left)
133 ring->in_use_flags |= ON_LEFT_HAND;
134 rogue.left_ring = ring;
136 ring->in_use_flags |= ON_RIGHT_HAND;
137 rogue.right_ring = ring;
144 boolean left = 0, right = 0;
152 } else if (rogue.left_ring && !rogue.right_ring) {
154 } else if (!rogue.left_ring && rogue.right_ring) {
157 message(left_or_right, 0);
160 } while ((ch != CANCEL) && (ch != 'l') && (ch != 'r') &&
161 (ch != '\n') && (ch != '\r'));
168 if (rogue.left_ring) {
169 ring = rogue.left_ring;
174 if (rogue.right_ring) {
175 ring = rogue.right_ring;
180 if (ring->is_cursed) {
181 message(curse_message, 0);
184 strcpy(buf, "removed ");
185 get_desc(ring, buf + 8);
193 un_put_on(object *ring)
195 if (ring && (ring->in_use_flags & ON_LEFT_HAND)) {
196 ring->in_use_flags &= (~ON_LEFT_HAND);
197 rogue.left_ring = NULL;
198 } else if (ring && (ring->in_use_flags & ON_RIGHT_HAND)) {
199 ring->in_use_flags &= (~ON_RIGHT_HAND);
200 rogue.right_ring = NULL;
206 gr_ring(object *ring, boolean assign_wk)
208 ring->what_is = RING;
210 ring->which_kind = get_rand(0, (RINGS - 1));
214 switch(ring->which_kind) {
220 while ((ring->class = (get_rand(0, 4) - 2)) == 0)
222 ring->is_cursed = (ring->class < 0);
225 ring->is_cursed = coin_toss();
236 message("not wearing any rings", 0);
238 if (rogue.left_ring) {
239 get_desc(rogue.left_ring, buf);
242 if (rogue.right_ring) {
243 get_desc(rogue.right_ring, buf);
248 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",
249 stealthy, r_rings, e_rings, r_teleport, sustain_strength,
250 add_strength, regeneration, ring_exp, r_see_invisible,
251 maintain_armor, auto_search);
257 ring_stats(boolean pr)
266 sustain_strength = 0;
274 for (i = 0; i < 2; i++) {
275 if (!(ring = ((i == 0) ? rogue.left_ring : rogue.right_ring))) {
280 switch(ring->which_kind) {
294 add_strength += ring->class;
296 case SUSTAIN_STRENGTH:
297 sustain_strength = 1;
300 ring_exp += ring->class;
304 case R_SEE_INVISIBLE:
316 print_stats(STAT_STRENGTH);