Mercurial > hg > early-roguelike
comparison xrogue/things.c @ 133:e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
| author | John "Elwin" Edwards |
|---|---|
| date | Tue, 21 Apr 2015 08:55:20 -0400 |
| parents | |
| children | ce0cf824c192 |
comparison
equal
deleted
inserted
replaced
| 124:d10fc4a065ac | 133:e6179860cb76 |
|---|---|
| 1 /* | |
| 2 things.c - functions for dealing with things like potions and scrolls | |
| 3 | |
| 4 XRogue: Expeditions into the Dungeons of Doom | |
| 5 Copyright (C) 1991 Robert Pietkivitch | |
| 6 All rights reserved. | |
| 7 | |
| 8 Based on "Advanced Rogue" | |
| 9 Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T | |
| 10 All rights reserved. | |
| 11 | |
| 12 Based on "Rogue: Exploring the Dungeons of Doom" | |
| 13 Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
| 14 All rights reserved. | |
| 15 | |
| 16 See the file LICENSE.TXT for full copyright and licensing information. | |
| 17 */ | |
| 18 | |
| 19 #include <curses.h> | |
| 20 #include <ctype.h> | |
| 21 #include "rogue.h" | |
| 22 | |
| 23 /* | |
| 24 * print out the number of charges on a stick | |
| 25 */ | |
| 26 | |
| 27 char * | |
| 28 charge_str(obj) | |
| 29 register struct object *obj; | |
| 30 { | |
| 31 static char buf[20]; | |
| 32 | |
| 33 if (!(obj->o_flags & ISKNOW)) | |
| 34 buf[0] = '\0'; | |
| 35 else if (terse) | |
| 36 sprintf(buf, " [%d]", obj->o_charges); | |
| 37 else | |
| 38 sprintf(buf, " [%d charges]", obj->o_charges); | |
| 39 return buf; | |
| 40 } | |
| 41 | |
| 42 /* | |
| 43 * inv_name: | |
| 44 * return the name of something as it would appear in an | |
| 45 * inventory. | |
| 46 */ | |
| 47 | |
| 48 char * | |
| 49 inv_name(obj, drop) | |
| 50 register struct object *obj; | |
| 51 bool drop; | |
| 52 { | |
| 53 register char *pb; | |
| 54 | |
| 55 pb = prbuf; | |
| 56 pb[0] = '\0'; | |
| 57 switch(obj->o_type) { | |
| 58 case SCROLL: | |
| 59 if (obj->o_count == 1) | |
| 60 sprintf(pb, "A %sscroll ", blesscurse(obj->o_flags)); | |
| 61 else | |
| 62 sprintf(pb, "%d %sscrolls ", | |
| 63 obj->o_count, blesscurse(obj->o_flags)); | |
| 64 pb = &pb[strlen(pb)]; | |
| 65 if (s_know[obj->o_which] || (obj->o_flags & ISPOST)) | |
| 66 sprintf(pb, "of %s", s_magic[obj->o_which].mi_name); | |
| 67 else if (s_guess[obj->o_which]) | |
| 68 sprintf(pb, "named %s", s_guess[obj->o_which]); | |
| 69 else | |
| 70 sprintf(pb, "titled '%s'", s_names[obj->o_which]); | |
| 71 when POTION: | |
| 72 if (obj->o_count == 1) | |
| 73 sprintf(pb, "A %spotion ", blesscurse(obj->o_flags)); | |
| 74 else | |
| 75 sprintf(pb, "%d %spotions ", | |
| 76 obj->o_count, blesscurse(obj->o_flags)); | |
| 77 pb = &pb[strlen(pb)]; | |
| 78 if (p_know[obj->o_which]) | |
| 79 sprintf(pb, "of %s (%s)", p_magic[obj->o_which].mi_name, | |
| 80 p_kind(obj)); | |
| 81 else if (obj->o_flags & ISPOST) | |
| 82 sprintf(pb, "of %s", p_magic[obj->o_which].mi_name); | |
| 83 else if (p_guess[obj->o_which]) | |
| 84 sprintf(pb, "named %s (%s)", p_guess[obj->o_which], | |
| 85 p_colors[obj->o_which]); | |
| 86 else { | |
| 87 pb = prbuf; | |
| 88 if (obj->o_count == 1) | |
| 89 sprintf(pb, "A%s %s potion", | |
| 90 vowelstr(p_colors[obj->o_which]), | |
| 91 p_colors[obj->o_which]); | |
| 92 else | |
| 93 sprintf(pb, "%d %s potions", | |
| 94 obj->o_count, p_colors[obj->o_which]); | |
| 95 } | |
| 96 when FOOD: | |
| 97 if (obj->o_count == 1) | |
| 98 sprintf(pb, "A%s %s", vowelstr(foods[obj->o_which].mi_name), | |
| 99 foods[obj->o_which].mi_name); | |
| 100 else | |
| 101 sprintf(pb, "%d %ss", obj->o_count,foods[obj->o_which].mi_name); | |
| 102 when WEAPON: | |
| 103 if (obj->o_count > 1) | |
| 104 sprintf(pb, "%d ", obj->o_count); | |
| 105 else | |
| 106 strcpy(pb, "A "); | |
| 107 pb = &pb[strlen(pb)]; | |
| 108 if (obj->o_flags & ISKNOW) { | |
| 109 strcat(pb, num(obj->o_hplus, obj->o_dplus)); | |
| 110 strcat (pb, " "); | |
| 111 } | |
| 112 strcat(pb, weaps[obj->o_which].w_name); | |
| 113 if (obj->o_count > 1) | |
| 114 strcat(pb, "s"); | |
| 115 if (obj == cur_weapon) | |
| 116 strcat(pb, " (weapon in hand)"); | |
| 117 if (obj->o_flags & ISPOISON) | |
| 118 strcat(pb, " {Poisoned}"); | |
| 119 when ARMOR: | |
| 120 if (obj->o_flags & ISKNOW) { | |
| 121 strcat(pb, num(armors[obj->o_which].a_class - obj->o_ac, 0)); | |
| 122 strcat(pb, " "); | |
| 123 } | |
| 124 strcat(pb, armors[obj->o_which].a_name); | |
| 125 if (obj == cur_armor) | |
| 126 strcat(pb, " (being worn)"); | |
| 127 when STICK: | |
| 128 sprintf(pb, "A %s%s ", | |
| 129 blesscurse(obj->o_flags), ws_type[obj->o_which]); | |
| 130 pb = &pb[strlen(pb)]; | |
| 131 if (ws_know[obj->o_which] || obj->o_flags & ISKNOW) | |
| 132 sprintf(pb, "of %s%s (%s)", ws_magic[obj->o_which].mi_name, | |
| 133 charge_str(obj), ws_made[obj->o_which]); | |
| 134 else if (obj->o_flags & ISPOST) | |
| 135 sprintf(pb, "of %s", ws_magic[obj->o_which].mi_name); | |
| 136 else if (ws_guess[obj->o_which]) | |
| 137 sprintf(pb, "named %s (%s)", ws_guess[obj->o_which], | |
| 138 ws_made[obj->o_which]); | |
| 139 else { | |
| 140 pb = prbuf; | |
| 141 sprintf(pb, "A %s %s", ws_made[obj->o_which], | |
| 142 ws_type[obj->o_which]); | |
| 143 } | |
| 144 if (obj == cur_weapon) | |
| 145 strcat(prbuf, " (weapon in hand)"); | |
| 146 when RING: | |
| 147 if (r_know[obj->o_which] || obj->o_flags & ISKNOW) | |
| 148 sprintf(pb, "A%s ring of %s (%s)", ring_num(obj), | |
| 149 r_magic[obj->o_which].mi_name, r_stones[obj->o_which]); | |
| 150 else if (obj->o_flags & ISPOST) | |
| 151 sprintf(pb, "A ring of %s", r_magic[obj->o_which].mi_name); | |
| 152 else if (r_guess[obj->o_which]) | |
| 153 sprintf(pb, "A ring named %s (%s)", | |
| 154 r_guess[obj->o_which], r_stones[obj->o_which]); | |
| 155 else | |
| 156 sprintf(pb, "A%s %s ring", vowelstr(r_stones[obj->o_which]), | |
| 157 r_stones[obj->o_which]); | |
| 158 if (obj == cur_ring[LEFT_1] || obj == cur_ring[LEFT_2] || | |
| 159 obj == cur_ring[LEFT_3] || obj == cur_ring[LEFT_4]) | |
| 160 strcat(pb, " (on left hand)"); | |
| 161 if (obj == cur_ring[RIGHT_1] || obj == cur_ring[RIGHT_2] || | |
| 162 obj == cur_ring[RIGHT_3] || obj == cur_ring[RIGHT_4]) | |
| 163 strcat(pb, " (on right hand)"); | |
| 164 when RELIC: | |
| 165 if (obj->o_flags & ISKNOW) | |
| 166 switch(obj->o_which) { | |
| 167 case QUILL_NAGROM: | |
| 168 sprintf(pb, "%s%s", rel_magic[obj->o_which].mi_name, | |
| 169 charge_str(obj)); | |
| 170 otherwise: | |
| 171 strcpy(pb, rel_magic[obj->o_which].mi_name); | |
| 172 } | |
| 173 else switch(obj->o_which) { | |
| 174 case MUSTY_DAGGER: | |
| 175 strcpy(pb, "Two very fine daggers marked MDDE"); | |
| 176 when EMORI_CLOAK: | |
| 177 strcpy(pb, "A silk cloak"); | |
| 178 when HEIL_ANKH: | |
| 179 strcpy(pb, "A golden ankh"); | |
| 180 when MING_STAFF: | |
| 181 strcpy(pb, "A finely carved staff"); | |
| 182 when ORCUS_WAND: | |
| 183 strcpy(pb, "A sparkling ivory wand"); | |
| 184 when ASMO_ROD: | |
| 185 strcpy(pb, "A glistening ebony rod"); | |
| 186 when YENDOR_AMULET: | |
| 187 strcpy(pb, "A silver amulet"); | |
| 188 when STONEBONES_AMULET: | |
| 189 strcpy(pb, "A stone amulet"); | |
| 190 when BRIAN_MANDOLIN: | |
| 191 strcpy(pb, "A gleaming mandolin"); | |
| 192 when HRUGGEK_MSTAR: | |
| 193 strcpy(pb, "A silvery morning star"); | |
| 194 when AXE_AKLAD: | |
| 195 strcpy(pb, "A jewel encrusted axe"); | |
| 196 when QUILL_NAGROM: | |
| 197 strcpy(pb, "A bright white feather"); | |
| 198 when GERYON_HORN: | |
| 199 strcpy(pb, "A jet black horn"); | |
| 200 when YEENOGHU_FLAIL: | |
| 201 strcpy(pb, "A shimmering flail"); | |
| 202 when SURTUR_RING: | |
| 203 strcpy(pb, "A fiery red ring"); | |
| 204 when ALTERAN_CARD: | |
| 205 strcpy(pb, "A rectangular piece of wood"); | |
| 206 otherwise: | |
| 207 strcpy(pb, "A wholly magical item"); | |
| 208 } | |
| 209 | |
| 210 /* Take care of wielding and wearing */ | |
| 211 switch (obj->o_which) { | |
| 212 case EMORI_CLOAK: | |
| 213 if (cur_armor == NULL && cur_misc[WEAR_CLOAK] == NULL) | |
| 214 strcat(pb, " (being worn)"); | |
| 215 if (obj->o_charges) | |
| 216 strcat(pb, " [charged]"); | |
| 217 else | |
| 218 strcat(pb, " [discharged]"); | |
| 219 when HEIL_ANKH: | |
| 220 if (cur_relic[HEIL_ANKH]) strcat(pb, " (in palm)"); | |
| 221 when EYE_VECNA: | |
| 222 if (cur_relic[EYE_VECNA]) strcat(pb, " (in forehead)"); | |
| 223 when STONEBONES_AMULET: | |
| 224 if (cur_relic[STONEBONES_AMULET]) | |
| 225 strcat(pb, " (in chest)"); | |
| 226 when YENDOR_AMULET: | |
| 227 if (cur_relic[YENDOR_AMULET]) | |
| 228 strcat(pb, " (in chest)"); | |
| 229 when MUSTY_DAGGER: | |
| 230 case HRUGGEK_MSTAR: | |
| 231 case AXE_AKLAD: | |
| 232 case YEENOGHU_FLAIL: | |
| 233 case MING_STAFF: | |
| 234 case ASMO_ROD: | |
| 235 case ORCUS_WAND: | |
| 236 if (cur_weapon == obj) strcat(pb, " (weapon in hand)"); | |
| 237 when SURTUR_RING: | |
| 238 if (cur_relic[SURTUR_RING]) | |
| 239 strcat(pb, " (in nose)"); | |
| 240 } | |
| 241 when MM: | |
| 242 if (m_know[obj->o_which]) | |
| 243 { | |
| 244 misc_name(pb,obj); | |
| 245 } | |
| 246 else { | |
| 247 switch (obj->o_which) { | |
| 248 case MM_JUG: | |
| 249 case MM_BEAKER: | |
| 250 case MM_KEOGHTOM: | |
| 251 strcpy(pb, "A crystalline jar"); | |
| 252 when MM_BOOK: | |
| 253 case MM_SKILLS: | |
| 254 strcpy(pb, "A dusty book"); | |
| 255 when MM_ELF_BOOTS: | |
| 256 case MM_DANCE: | |
| 257 strcpy(pb, "A pair of old boots"); | |
| 258 when MM_BRACERS: | |
| 259 strcpy(pb, "A set of bracers"); | |
| 260 when MM_OPEN: | |
| 261 case MM_HUNGER: | |
| 262 strcpy(pb, "A mysterious chime"); | |
| 263 when MM_DISP: | |
| 264 case MM_R_POWERLESS: | |
| 265 case MM_PROTECT: | |
| 266 strcpy(pb, "A dark looking cloak"); | |
| 267 when MM_DRUMS: | |
| 268 strcpy(pb, "A drum set"); | |
| 269 when MM_DISAPPEAR: | |
| 270 case MM_CHOKE: | |
| 271 strcpy(pb, "A small pouch of dust"); | |
| 272 when MM_G_DEXTERITY: | |
| 273 case MM_G_OGRE: | |
| 274 case MM_FUMBLE: | |
| 275 strcpy(pb, "A set of gauntlets"); | |
| 276 when MM_ADAPTION: | |
| 277 case MM_JEWEL: | |
| 278 case MM_STRANGLE: | |
| 279 strcpy(pb, "A little necklace"); | |
| 280 when MM_CRYSTAL: | |
| 281 strcpy(pb, "An unusual looking rock"); | |
| 282 otherwise: | |
| 283 strcpy(pb, "A magical item"); | |
| 284 } | |
| 285 if (m_guess[obj->o_which]) { | |
| 286 strcat(pb, " named: "); | |
| 287 strcat(pb, m_guess[obj->o_which]); | |
| 288 } | |
| 289 } | |
| 290 if (obj == cur_misc[WEAR_BOOTS] || | |
| 291 obj == cur_misc[WEAR_BRACERS] || | |
| 292 obj == cur_misc[WEAR_CLOAK] || | |
| 293 obj == cur_misc[WEAR_GAUNTLET] || | |
| 294 obj == cur_misc[WEAR_NECKLACE] || | |
| 295 obj == cur_misc[WEAR_JEWEL]) | |
| 296 strcat(pb, " (being worn)"); | |
| 297 when GOLD: | |
| 298 sprintf(pb, "%d Pieces of Gold", obj->o_count); | |
| 299 otherwise: | |
| 300 debug("Picked up something funny"); | |
| 301 sprintf(pb, "Something totally bizarre %s", unctrl(obj->o_type)); | |
| 302 wait_for(' '); | |
| 303 } | |
| 304 | |
| 305 /* Is it marked? */ | |
| 306 if (obj->o_mark[0]) { | |
| 307 pb = &pb[strlen(pb)]; | |
| 308 sprintf(pb, " <%s>", obj->o_mark); | |
| 309 } | |
| 310 | |
| 311 if (obj->o_flags & ISPROT) | |
| 312 strcat(pb, " [protected]"); | |
| 313 if (drop && isupper(prbuf[0])) | |
| 314 prbuf[0] = tolower(prbuf[0]); | |
| 315 else if (!drop && islower(*prbuf)) | |
| 316 *prbuf = toupper(*prbuf); | |
| 317 if (!drop) | |
| 318 strcat(pb, "."); | |
| 319 /* | |
| 320 * Truncate if long. Use cols-4 to offset the "pack letter" of a normal | |
| 321 * inventory listing. | |
| 322 */ | |
| 323 prbuf[cols-4] = '\0'; | |
| 324 return prbuf; | |
| 325 } | |
| 326 | |
| 327 /* | |
| 328 * weap_name: | |
| 329 * Return the name of a weapon. | |
| 330 */ | |
| 331 | |
| 332 char * | |
| 333 weap_name(obj) | |
| 334 register struct object *obj; | |
| 335 { | |
| 336 switch (obj->o_type) { | |
| 337 case WEAPON: | |
| 338 return(weaps[obj->o_which].w_name); | |
| 339 when MISSILE: | |
| 340 return(ws_magic[obj->o_which].mi_name); | |
| 341 when RELIC: | |
| 342 switch (obj->o_which) { | |
| 343 case MUSTY_DAGGER: | |
| 344 return("daggers"); | |
