Mercurial > hg > early-roguelike
comparison rogue4/rings.c @ 12:9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
| author | edwarj4 |
|---|---|
| date | Sat, 24 Oct 2009 16:52:52 +0000 |
| parents | |
| children | 1b73a8641b37 |
comparison
equal
deleted
inserted
replaced
| 11:949d558c2162 | 12:9535a08ddc39 |
|---|---|
| 1 /* | |
| 2 * Routines dealing specifically with rings | |
| 3 * | |
| 4 * @(#)rings.c 4.13 (Berkeley) 1/28/82 | |
| 5 * | |
| 6 * Rogue: Exploring the Dungeons of Doom | |
| 7 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman | |
| 8 * All rights reserved. | |
| 9 * | |
| 10 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 11 */ | |
| 12 | |
| 13 #include <curses.h> | |
| 14 #include <string.h> | |
| 15 #include "rogue.h" | |
| 16 | |
| 17 /* | |
| 18 * ring_on: | |
| 19 * Put a ring on a hand | |
| 20 */ | |
| 21 ring_on() | |
| 22 { | |
| 23 register THING *obj; | |
| 24 register int ring; | |
| 25 | |
| 26 obj = get_item("put on", RING); | |
| 27 /* | |
| 28 * Make certain that it is somethings that we want to wear | |
| 29 */ | |
| 30 if (obj == NULL) | |
| 31 return; | |
| 32 if (obj->o_type != RING) | |
| 33 { | |
| 34 if (!terse) | |
| 35 msg("it would be difficult to wrap that around a finger"); | |
| 36 else | |
| 37 msg("not a ring"); | |
| 38 return; | |
| 39 } | |
| 40 | |
| 41 /* | |
| 42 * find out which hand to put it on | |
| 43 */ | |
| 44 if (is_current(obj)) | |
| 45 return; | |
| 46 | |
| 47 if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) | |
| 48 { | |
| 49 if ((ring = gethand()) < 0) | |
| 50 return; | |
| 51 } | |
| 52 else if (cur_ring[LEFT] == NULL) | |
| 53 ring = LEFT; | |
| 54 else if (cur_ring[RIGHT] == NULL) | |
| 55 ring = RIGHT; | |
| 56 else | |
| 57 { | |
| 58 if (!terse) | |
| 59 msg("you already have a ring on each hand"); | |
| 60 else | |
| 61 msg("wearing two"); | |
| 62 return; | |
| 63 } | |
| 64 cur_ring[ring] = obj; | |
| 65 | |
| 66 /* | |
| 67 * Calculate the effect it has on the poor guy. | |
| 68 */ | |
| 69 switch (obj->o_which) | |
| 70 { | |
| 71 case R_ADDSTR: | |
| 72 chg_str(obj->o_ac); | |
| 73 break; | |
| 74 case R_SEEINVIS: | |
| 75 invis_on(); | |
| 76 break; | |
| 77 case R_AGGR: | |
| 78 aggravate(); | |
| 79 break; | |
| 80 } | |
| 81 | |
| 82 if (!terse) | |
| 83 addmsg("you are now wearing "); | |
| 84 msg("%s (%c)", inv_name(obj, TRUE), pack_char(obj)); | |
| 85 } | |
| 86 | |
| 87 /* | |
| 88 * ring_off: | |
| 89 * Take off a ring | |
| 90 */ | |
| 91 ring_off() | |
| 92 { | |
| 93 register int ring; | |
| 94 register THING *obj; | |
| 95 register char packchar; | |
| 96 | |
| 97 if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) | |
| 98 { | |
| 99 if (terse) | |
| 100 msg("no rings"); | |
| 101 else | |
| 102 msg("you aren't wearing any rings"); | |
| 103 return; | |
| 104 } | |
| 105 else if (cur_ring[LEFT] == NULL) | |
| 106 ring = RIGHT; | |
| 107 else if (cur_ring[RIGHT] == NULL) | |
| 108 ring = LEFT; | |
| 109 else | |
| 110 if ((ring = gethand()) < 0) | |
| 111 return; | |
| 112 mpos = 0; | |
| 113 obj = cur_ring[ring]; | |
| 114 if (obj == NULL) | |
| 115 { | |
| 116 msg("not wearing such a ring"); | |
| 117 return; | |
| 118 } | |
| 119 packchar = pack_char(obj); | |
| 120 if (dropcheck(obj)) | |
| 121 msg("was wearing %s(%c)", inv_name(obj, TRUE), packchar); | |
| 122 } | |
| 123 | |
| 124 /* | |
| 125 * gethand: | |
| 126 * Which hand is the hero interested in? | |
| 127 */ | |
| 128 gethand() | |
| 129 { | |
| 130 register int c; | |
| 131 | |
| 132 for (;;) | |
| 133 { | |
| 134 if (terse) | |
| 135 msg("left or right ring? "); | |
| 136 else | |
| 137 msg("left hand or right hand? "); | |
| 138 if ((c = readchar()) == ESCAPE) | |
| 139 return -1; | |
| 140 mpos = 0; | |
| 141 if (c == 'l' || c == 'L') | |
| 142 return LEFT; | |
| 143 else if (c == 'r' || c == 'R') | |
| 144 return RIGHT; | |
| 145 if (terse) | |
| 146 msg("L or R"); | |
| 147 else | |
| 148 msg("please type L or R"); | |
| 149 } | |
| 150 } | |
| 151 | |
| 152 /* | |
| 153 * ring_eat: | |
| 154 * How much food does this ring use up? | |
| 155 */ | |
| 156 ring_eat(hand) | |
| 157 register int hand; | |
| 158 { | |
| 159 if (cur_ring[hand] == NULL) | |
| 160 return 0; | |
| 161 switch (cur_ring[hand]->o_which) | |
| 162 { | |
| 163 case R_REGEN: | |
| 164 return 2; | |
| 165 case R_SUSTSTR: | |
| 166 case R_SUSTARM: | |
| 167 case R_PROTECT: | |
| 168 case R_ADDSTR: | |
| 169 case R_STEALTH: | |
| 170 return 1; | |
| 171 case R_SEARCH: | |
| 172 case R_ADDHIT: | |
| 173 case R_ADDDAM: | |
| 174 return (rnd(3) == 0); | |
| 175 case R_DIGEST: | |
| 176 return -rnd(2); | |
| 177 case R_SEEINVIS: | |
| 178 return (rnd(5) == 0); | |
| 179 default: | |
| 180 return 0; | |
| 181 } | |
| 182 } | |
| 183 | |
| 184 /* | |
| 185 * ring_num: | |
| 186 * Print ring bonuses | |
| 187 */ | |
| 188 char * | |
| 189 ring_num(obj) | |
| 190 register THING *obj; | |
| 191 { | |
| 192 static char buf[5]; | |
| 193 | |
| 194 if (!(obj->o_flags & ISKNOW)) | |
| 195 return ""; | |
| 196 switch (obj->o_which) | |
| 197 { | |
| 198 case R_PROTECT: | |
| 199 case R_ADDSTR: | |
| 200 case R_ADDDAM: | |
| 201 case R_ADDHIT: | |
| 202 buf[0] = ' '; | |
| 203 strcpy(&buf[1], num(obj->o_ac, 0, RING)); | |
| 204 otherwise: | |
| 205 return ""; | |
| 206 } | |
| 207 return buf; | |
| 208 } |
