| 22 | | |
|---|
| 23 | | /* TRUE if a paragraph break should be output before next p_text_out() */ |
|---|
| 24 | | static bool new_paragraph = FALSE; |
|---|
| 25 | | |
|---|
| 26 | | |
|---|
| 27 | | static void p_text_out(cptr str) |
|---|
| 28 | | { |
|---|
| 29 | | if (new_paragraph) |
|---|
| 30 | | { |
|---|
| 31 | | text_out("\n\n"); |
|---|
| 32 | | new_paragraph = FALSE; |
|---|
| 33 | | } |
|---|
| 34 | | |
|---|
| 35 | | text_out(str); |
|---|
| 36 | | } |
|---|
| 37 | | |
|---|
| 38 | | |
|---|
| 39 | | static void output_list(const char *list[], int num) |
|---|
| 40 | | { |
|---|
| 41 | | int i; |
|---|
| 42 | | const char *conjunction = "and "; |
|---|
| 43 | | |
|---|
| 44 | | if (num < 0) |
|---|
| 45 | | { |
|---|
| 46 | | num = -num; |
|---|
| 47 | | conjunction = "or "; |
|---|
| 48 | | } |
|---|
| 49 | | |
|---|
| 50 | | for (i = 0; i < num; i++) |
|---|
| 51 | | { |
|---|
| 52 | | if (i) |
|---|
| | 22 | /* |
|---|
| | 23 | * Describes a flag-name pair. |
|---|
| | 24 | */ |
|---|
| | 25 | typedef struct |
|---|
| | 26 | { |
|---|
| | 27 | u32b flag; |
|---|
| | 28 | const char *name; |
|---|
| | 29 | } flag_type; |
|---|
| | 30 | |
|---|
| | 31 | |
|---|
| | 32 | |
|---|
| | 33 | /*** Utility code ***/ |
|---|
| | 34 | |
|---|
| | 35 | /* |
|---|
| | 36 | * Given an array of strings, as so: |
|---|
| | 37 | * { "intelligence", "fish", "lens", "prime", "number" }, |
|---|
| | 38 | * |
|---|
| | 39 | * ... output a list like "intelligence, fish, lens, prime, number.\n". |
|---|
| | 40 | */ |
|---|
| | 41 | static inline void info_out_list(const char *list[], size_t count) |
|---|
| | 42 | { |
|---|
| | 43 | size_t i; |
|---|
| | 44 | |
|---|
| | 45 | for (i = 0; i < count; i++) |
|---|
| | 46 | { |
|---|
| | 47 | text_out(list[i]); |
|---|
| | 48 | if (i != (count - 1)) text_out(", "); |
|---|
| | 49 | } |
|---|
| | 50 | |
|---|
| | 51 | text_out(".\n"); |
|---|
| | 52 | } |
|---|
| | 53 | |
|---|
| | 54 | |
|---|
| | 55 | /* |
|---|
| | 56 | * |
|---|
| | 57 | */ |
|---|
| | 58 | size_t info_collect(const flag_type list[], size_t max, u32b flag, const char *recepticle[]) |
|---|
| | 59 | { |
|---|
| | 60 | size_t i, count = 0; |
|---|
| | 61 | |
|---|
| | 62 | for (i = 0; i < max; i++) |
|---|
| | 63 | { |
|---|
| | 64 | if (flag & list[i].flag) |
|---|
| | 65 | recepticle[count++] = list[i].name; |
|---|
| | 66 | } |
|---|
| | 67 | |
|---|
| | 68 | return count; |
|---|
| | 69 | } |
|---|
| | 70 | |
|---|
| | 71 | |
|---|
| | 72 | /*** Big fat data tables ***/ |
|---|
| | 73 | |
|---|
| | 74 | static const flag_type f1_pval[] = |
|---|
| | 75 | { |
|---|
| | 76 | { TR1_STR, "strength" }, |
|---|
| | 77 | { TR1_INT, "intelligence" }, |
|---|
| | 78 | { TR1_WIS, "wisdom" }, |
|---|
| | 79 | { TR1_DEX, "dexterity" }, |
|---|
| | 80 | { TR1_CON, "constitution" }, |
|---|
| | 81 | { TR1_CHR, "charisma" }, |
|---|
| | 82 | { TR1_STEALTH, "stealth" }, |
|---|
| | 83 | { TR1_SEARCH, "searching" }, |
|---|
| | 84 | { TR1_INFRA, "infravision" }, |
|---|
| | 85 | { TR1_TUNNEL, "tunneling" }, |
|---|
| | 86 | { TR1_SPEED, "speed" }, |
|---|
| | 87 | { TR1_BLOWS, "attack speed" }, |
|---|
| | 88 | { TR1_SHOTS, "shooting speed" }, |
|---|
| | 89 | { TR1_MIGHT, "shooting power" }, |
|---|
| | 90 | }; |
|---|
| | 91 | |
|---|
| | 92 | static const flag_type f2_immunity[] = |
|---|
| | 93 | { |
|---|
| | 94 | { TR2_IM_ACID, "acid" }, |
|---|
| | 95 | { TR2_IM_ELEC, "lightning" }, |
|---|
| | 96 | { TR2_IM_FIRE, "fire" }, |
|---|
| | 97 | { TR2_IM_COLD, "cold" }, |
|---|
| | 98 | }; |
|---|
| | 99 | |
|---|
| | 100 | static const flag_type f2_resist[] = |
|---|
| | 101 | { |
|---|
| | 102 | { TR2_RES_ACID, "acid" }, |
|---|
| | 103 | { TR2_RES_ELEC, "lightning" }, |
|---|
| | 104 | { TR2_RES_FIRE, "fire" }, |
|---|
| | 105 | { TR2_RES_COLD, "cold" }, |
|---|
| | 106 | { TR2_RES_POIS, "poison" }, |
|---|
| | 107 | { TR2_RES_FEAR, "fear" }, |
|---|
| | 108 | { TR2_RES_LITE, "light" }, |
|---|
| | 109 | { TR2_RES_DARK, "dark" }, |
|---|
| | 110 | { TR2_RES_BLIND, "blindness" }, |
|---|
| | 111 | { TR2_RES_CONFU, "confusion" }, |
|---|
| | 112 | { TR2_RES_SOUND, "sound" }, |
|---|
| | 113 | { TR2_RES_SHARD, "shards" }, |
|---|
| | 114 | { TR2_RES_NEXUS, "nexus" }, |
|---|
| | 115 | { TR2_RES_NETHR, "nether" }, |
|---|
| | 116 | { TR2_RES_CHAOS, "chaos" }, |
|---|
| | 117 | { TR2_RES_DISEN, "disenchantment" }, |
|---|
| | 118 | }; |
|---|
| | 119 | |
|---|
| | 120 | static const flag_type f3_ignore[] = |
|---|
| | 121 | { |
|---|
| | 122 | { TR3_IGNORE_ACID, "acid" }, |
|---|
| | 123 | { TR3_IGNORE_ELEC, "electricity" }, |
|---|
| | 124 | { TR3_IGNORE_FIRE, "fire" }, |
|---|
| | 125 | { TR3_IGNORE_COLD, "cold" }, |
|---|
| | 126 | }; |
|---|
| | 127 | |
|---|
| | 128 | static const flag_type f2_sustains[] = |
|---|
| | 129 | { |
|---|
| | 130 | { TR2_SUST_STR, "strength" }, |
|---|
| | 131 | { TR2_SUST_INT, "intelligence" }, |
|---|
| | 132 | { TR2_SUST_WIS, "wisdom" }, |
|---|
| | 133 | { TR2_SUST_DEX, "dexterity" }, |
|---|
| | 134 | { TR2_SUST_CON, "constitution" }, |
|---|
| | 135 | { TR2_SUST_CHR, "charisma" }, |
|---|
| | 136 | }; |
|---|
| | 137 | |
|---|
| | 138 | static const flag_type f3_misc[] = |
|---|
| | 139 | { |
|---|
| | 140 | { TR3_BLESSED, "Blessed by the gods" }, |
|---|
| | 141 | { TR3_SLOW_DIGEST, "Slows your metabolism" }, |
|---|
| | 142 | { TR3_FEATHER, "Feather Falling" }, |
|---|
| | 143 | { TR3_REGEN, "Speeds regeneration" }, |
|---|
| | 144 | { TR3_FREE_ACT, "Prevents paralysis" }, |
|---|
| | 145 | { TR3_HOLD_LIFE, "Stops experience drain" }, |
|---|
| | 146 | { TR3_TELEPATHY, "Grants telepathy" }, |
|---|
| | 147 | { TR3_SEE_INVIS, "Grants the ability to see invisible things" }, |
|---|
| | 148 | { TR3_AGGRAVATE, "Aggravates creatures nearby" }, |
|---|
| | 149 | { TR3_DRAIN_EXP, "Drains experience" }, |
|---|
| | 150 | { TR3_TELEPORT, "Induces random teleportation" }, |
|---|
| | 151 | }; |
|---|
| | 152 | |
|---|
| | 153 | |
|---|
| | 154 | /*** Code that makes use of the data tables ***/ |
|---|
| | 155 | |
|---|
| | 156 | /* |
|---|
| | 157 | * Describe stat modifications. |
|---|
| | 158 | */ |
|---|
| | 159 | static bool describe_stats(u32b f1, int pval) |
|---|
| | 160 | { |
|---|
| | 161 | cptr descs[N_ELEMENTS(f1_pval)]; |
|---|
| | 162 | size_t count; |
|---|
| | 163 | |
|---|
| | 164 | if (!pval) return FALSE; |
|---|
| | 165 | |
|---|
| | 166 | count = info_collect(f1_pval, N_ELEMENTS(f1_pval), f1, descs); |
|---|
| | 167 | if (!count) return FALSE; |
|---|
| | 168 | |
|---|
| | 169 | text_out_c((pval > 0) ? TERM_L_GREEN : TERM_RED, "%+i ", pval); |
|---|
| | 170 | info_out_list(descs, count); |
|---|
| | 171 | |
|---|
| | 172 | return TRUE; |
|---|
| | 173 | } |
|---|
| | 174 | |
|---|
| | 175 | |
|---|
| | 176 | /* |
|---|
| | 177 | * Describe immunities granted by an object. |
|---|
| | 178 | */ |
|---|
| | 179 | static bool describe_immune(u32b f2) |
|---|
| | 180 | { |
|---|
| | 181 | const char *descs[N_ELEMENTS(f2_resist)]; |
|---|
| | 182 | size_t count; |
|---|
| | 183 | |
|---|
| | 184 | bool prev = FALSE; |
|---|
| | 185 | |
|---|
| | 186 | /* Immunities */ |
|---|
| | 187 | count = info_collect(f2_immunity, N_ELEMENTS(f2_immunity), f2, descs); |
|---|
| | 188 | if (count) |
|---|
| | 189 | { |
|---|
| | 190 | text_out("Provides immunity to "); |
|---|
| | 191 | info_out_list(descs, count); |
|---|
| | 192 | prev = TRUE; |
|---|
| | 193 | } |
|---|
| | 194 | |
|---|
| | 195 | /* Resistances */ |
|---|
| | 196 | count = info_collect(f2_resist, N_ELEMENTS(f2_resist), f2, descs); |
|---|
| | 197 | if (count) |
|---|
| | 198 | { |
|---|
| | 199 | text_out("Provides resistance to "); |
|---|
| | 200 | info_out_list(descs, count); |
|---|
| | 201 | prev = TRUE; |
|---|
| | 202 | } |
|---|
| | 203 | |
|---|
| | 204 | return prev; |
|---|
| | 205 | } |
|---|
| | 206 | |
|---|
| | 207 | |
|---|
| | 208 | /* |
|---|
| | 209 | * Describe 'ignores' of an object. |
|---|
| | 210 | */ |
|---|
| | 211 | static bool describe_ignores(u32b f3) |
|---|
| | 212 | { |
|---|
| | 213 | const char *descs[N_ELEMENTS(f3_ignore)]; |
|---|
| | 214 | size_t count = info_collect(f3_ignore, N_ELEMENTS(f3_ignore), f3, descs); |
|---|
| | 215 | |
|---|
| | 216 | if (!count) return FALSE; |
|---|
| | 217 | |
|---|
| | 218 | text_out("Cannot be harmed by "); |
|---|
| | 219 | info_out_list(descs, count); |
|---|
| | 220 | |
|---|
| | 221 | return TRUE; |
|---|
| | 222 | } |
|---|
| | 223 | |
|---|
| | 224 | |
|---|
| | 225 | /* |
|---|
| | 226 | * Describe stat sustains. |
|---|
| | 227 | */ |
|---|
| | 228 | static bool describe_sustains(u32b f2) |
|---|
| | 229 | { |
|---|
| | 230 | const char *descs[N_ELEMENTS(f2_sustains)]; |
|---|
| | 231 | size_t count = info_collect(f2_sustains, N_ELEMENTS(f2_sustains), f2, descs); |
|---|
| | 232 | |
|---|
| | 233 | if (!count) return FALSE; |
|---|
| | 234 | |
|---|
| | 235 | text_out("Sustains "); |
|---|
| | 236 | info_out_list(descs, count); |
|---|
| | 237 | |
|---|
| | 238 | return TRUE; |
|---|
| | 239 | } |
|---|
| | 240 | |
|---|
| | 241 | |
|---|
| | 242 | /* |
|---|
| | 243 | * Describe miscellaneous powers. |
|---|
| | 244 | */ |
|---|
| | 245 | static bool describe_misc_magic(u32b f3) |
|---|
| | 246 | { |
|---|
| | 247 | size_t i; |
|---|
| | 248 | bool printed = FALSE; |
|---|
| | 249 | |
|---|
| | 250 | for (i = 0; i < N_ELEMENTS(f3_misc); i++) |
|---|
| | 251 | { |
|---|
| | 252 | if (f3 & f3_misc[i].flag) |
|---|
| 291 | | /* |
|---|
| 292 | | * Describe immunities granted by an object. |
|---|
| 293 | | */ |
|---|
| 294 | | static bool describe_immune(const object_type *o_ptr, u32b f2, u32b f3) |
|---|
| 295 | | { |
|---|
| 296 | | cptr vp[26]; |
|---|
| 297 | | int vn; |
|---|
| 298 | | bool prev = FALSE; |
|---|
| 299 | | |
|---|
| 300 | | /* Unused parameter */ |
|---|
| 301 | | (void)o_ptr; |
|---|
| 302 | | |
|---|
| 303 | | /* Collect immunities */ |
|---|
| 304 | | vn = 0; |
|---|
| 305 | | if (f2 & (TR2_IM_ACID)) vp[vn++] = "acid"; |
|---|
| 306 | | if (f2 & (TR2_IM_ELEC)) vp[vn++] = "lightning"; |
|---|
| 307 | | if (f2 & (TR2_IM_FIRE)) vp[vn++] = "fire"; |
|---|
| 308 | | if (f2 & (TR2_IM_COLD)) vp[vn++] = "cold"; |
|---|
| 309 | | if (f3 & (TR3_FREE_ACT)) vp[vn++] = "paralysis"; |
|---|
| 310 | | |
|---|
| 311 | | /* Describe immunities */ |
|---|
| 312 | | if (vn) |
|---|
| 313 | | { |
|---|
| 314 | | text_out("It provides immunity to "); |
|---|
| 315 | | |
|---|
| 316 | | output_list(vp, vn); |
|---|
| 317 | | prev = TRUE; |
|---|
| 318 | | } |
|---|
| 319 | | |
|---|
| 320 | | /* Collect resistances */ |
|---|
| 321 | | vn = 0; |
|---|
| 322 | | if ((f2 & (TR2_RES_ACID)) && !(f2 & (TR2_IM_ACID))) |
|---|
| 323 | | vp[vn++] = "acid"; |
|---|
| 324 | | if ((f2 & (TR2_RES_ELEC)) && !(f2 & (TR2_IM_ELEC))) |
|---|
| 325 | | vp[vn++] = "lightning"; |
|---|
| 326 | | if ((f2 & (TR2_RES_FIRE)) && !(f2 & (TR2_IM_FIRE))) |
|---|
| 327 | | vp[vn++] = "fire"; |
|---|
| 328 | | if ((f2 & (TR2_RES_COLD)) && !(f2 & (TR2_IM_COLD))) |
|---|
| 329 | | vp[vn++] = "cold"; |
|---|
| 330 | | |
|---|
| 331 | | if (f2 & (TR2_RES_POIS)) vp[vn++] = "poison"; |
|---|
| 332 | | if (f2 & (TR2_RES_FEAR)) vp[vn++] = "fear"; |
|---|
| 333 | | if (f2 & (TR2_RES_LITE)) vp[vn++] = "light"; |
|---|
| 334 | | if (f2 & (TR2_RES_DARK)) vp[vn++] = "dark"; |
|---|
| 335 | | if (f2 & (TR2_RES_BLIND)) vp[vn++] = "blindness"; |
|---|
| 336 | | if (f2 & (TR2_RES_CONFU)) vp[vn++] = "confusion"; |
|---|
| 337 | | if (f2 & (TR2_RES_SOUND)) vp[vn++] = "sound"; |
|---|
| 338 | | if (f2 & (TR2_RES_SHARD)) vp[vn++] = "shards"; |
|---|
| 339 | | if (f2 & (TR2_RES_NEXUS)) vp[vn++] = "nexus" ; |
|---|
| 340 | | if (f2 & (TR2_RES_NETHR)) vp[vn++] = "nether"; |
|---|
| 341 | | if (f2 & (TR2_RES_CHAOS)) vp[vn++] = "chaos"; |
|---|
| 342 | | if (f2 & (TR2_RES_DISEN)) vp[vn++] = "disenchantment"; |
|---|
| 343 | | if (f3 & (TR3_HOLD_LIFE)) vp[vn++] = "life draining"; |
|---|
| 344 | | |
|---|
| 345 | | if (vn) |
|---|
| 346 | | { |
|---|
| 347 | | if (prev) |
|---|
| 348 | | text_out(", and provides resistance to "); |
|---|
| 349 | | else |
|---|
| 350 | | p_text_out("It provides resistance to "); |
|---|
| 351 | | |
|---|
| 352 | | /* Output list */ |
|---|
| 353 | | output_list(vp, vn); |
|---|
| 354 | | prev = TRUE; |
|---|
| 355 | | } |
|---|
| 356 | | |
|---|
| 357 | | /* Parting words */ |
|---|
| 358 | | if (prev) text_out(". "); |
|---|
| 359 | | |
|---|
| 360 | | return prev; |
|---|
| 361 | | } |
|---|
| 362 | | |
|---|
| 363 | | |
|---|
| 364 | | /* |
|---|
| 365 | | * Describe 'ignores' of an object. |
|---|
| 366 | | */ |
|---|
| 367 | | static bool describe_ignores(const object_type *o_ptr, u32b f3) |
|---|
| 368 | | { |
|---|
| 369 | | cptr list[4]; |
|---|
| 370 | | int n = 0; |
|---|
| 371 | | |
|---|
| 372 | | /* Unused parameter */ |
|---|
| 373 | | (void)o_ptr; |
|---|
| 374 | | |
|---|
| 375 | | /* Collect the ignores */ |
|---|
| 376 | | if (f3 & (TR3_IGNORE_ACID)) list[n++] = "acid"; |
|---|
| 377 | | if (f3 & (TR3_IGNORE_ELEC)) list[n++] = "electricity"; |
|---|
| 378 | | if (f3 & (TR3_IGNORE_FIRE)) list[n++] = "fire"; |
|---|
| 379 | | if (f3 & (TR3_IGNORE_COLD)) list[n++] = "cold"; |
|---|
| 380 | | |
|---|
| 381 | | /* Describe ignores */ |
|---|
| 382 | | if (n == 4) |
|---|
| 383 | | p_text_out("It cannot be harmed by the elements. "); |
|---|
| 384 | | else |
|---|
| 385 | | output_desc_list("It cannot be harmed by ", list, -n); |
|---|
| 386 | | |
|---|
| 387 | | return (n ? TRUE : FALSE); |
|---|
| 388 | | } |
|---|
| 389 | | |
|---|
| 390 | | |
|---|
| 391 | | /* |
|---|
| 392 | | * Describe stat sustains. |
|---|
| 393 | | */ |
|---|
| 394 | | static bool describe_sustains(const object_type *o_ptr, u32b f2) |
|---|
| 395 | | { |
|---|
| 396 | | cptr list[A_MAX]; |
|---|
| 397 | | int n = 0; |
|---|
| 398 | | |
|---|
| 399 | | /* Unused parameter */ |
|---|
| 400 | | (void)o_ptr; |
|---|
| 401 | | |
|---|
| 402 | | /* Collect the sustains */ |
|---|
| 403 | | if (f2 & (TR2_SUST_STR)) list[n++] = stat_names_full[A_STR]; |
|---|
| 404 | | if (f2 & (TR2_SUST_INT)) list[n++] = stat_names_full[A_INT]; |
|---|
| 405 | | if (f2 & (TR2_SUST_WIS)) list[n++] = stat_names_full[A_WIS]; |
|---|
| 406 | | if (f2 & (TR2_SUST_DEX)) list[n++] = stat_names_full[A_DEX]; |
|---|
| 407 | | if (f2 & (TR2_SUST_CON)) list[n++] = stat_names_full[A_CON]; |
|---|
| 408 | | if (f2 & (TR2_SUST_CHR)) list[n++] = stat_names_full[A_CHR]; |
|---|
| 409 | | |
|---|
| 410 | | /* Describe immunities */ |
|---|
| 411 | | if (n == A_MAX) |
|---|
| 412 | | p_text_out("It sustains all your stats. "); |
|---|
| 413 | | else |
|---|
| 414 | | output_desc_list("It sustains your ", list, n); |
|---|
| 415 | | |
|---|
| 416 | | /* We are done here */ |
|---|
| 417 | | return (n ? TRUE : FALSE); |
|---|
| 418 | | } |
|---|
| 419 | | |
|---|
| 420 | | |
|---|
| 421 | | /* |
|---|
| 422 | | * Describe miscellaneous powers such as see invisible, free action, |
|---|
| 423 | | * permanent light, etc; also note curses and penalties. |
|---|
| 424 | | */ |
|---|
| 425 | | static bool describe_misc_magic(const object_type *o_ptr, u32b f3) |
|---|
| 426 | | { |
|---|
| 427 | | cptr good[6], bad[4]; |
|---|
| 428 | | int gc = 0, bc = 0; |
|---|
| 429 | | bool something = FALSE; |
|---|
| 430 | | |
|---|
| 431 | | /* Describe lights */ |
|---|
| 432 | | if (o_ptr->tval == TV_LITE || (f3 & TR3_LITE)) |
|---|
| 433 | | { |
|---|
| 434 | | bool artifact = artifact_p(o_ptr); |
|---|
| 435 | | bool no_fuel = (f3 & TR3_NO_FUEL) ? TRUE : FALSE; |
|---|
| 436 | | int rad = 0; |
|---|
| 437 | | |
|---|
| 438 | | if (artifact) |
|---|
| 439 | | rad = 3; |
|---|
| 440 | | else if (o_ptr->tval == TV_LITE) |
|---|
| 441 | | rad = 2; |
|---|
| 442 | | |
|---|
| 443 | | if (f3 & TR3_LITE) rad++; |
|---|
| 444 | | |
|---|
| 445 | | p_text_out("It usually provides light of radius "); |
|---|
| 446 | | text_out_c(TERM_L_GREEN, format("%d", rad)); |
|---|
| 447 | | if (no_fuel && !artifact) |
|---|
| 448 | | text_out(", and never needs refuelling"); |
|---|
| 449 | | else if (o_ptr->tval == TV_LITE && o_ptr->sval == SV_LITE_TORCH) |
|---|
| 450 | | text_out(", though this is reduced when running of out fuel"); |
|---|
| 451 | | text_out(". "); |
|---|
| 452 | | |
|---|
| 453 | | if (o_ptr->tval == TV_LITE) |
|---|
| 454 | | { |
|---|
| 455 | | const char *name = (o_ptr->sval == SV_LITE_TORCH) ? "torch" : "lantern"; |
|---|
| 456 | | int turns = (o_ptr->sval == SV_LITE_TORCH) ? FUEL_TORCH : FUEL_LAMP; |
|---|
| 457 | | |
|---|
| 458 | | text_out("It can refill another %s, up to %d turns of fuel. ", name, turns); |
|---|
| 459 | | } |
|---|
| 460 | | |
|---|
| 461 | | something = TRUE; |
|---|
| 462 | | } |
|---|
| 463 | | |
|---|
| 464 | | /* Collect stuff which can't be categorized */ |
|---|
| 465 | | if (f3 & (TR3_BLESSED)) good[gc++] = "is blessed by the gods"; |
|---|
| 466 | | if (f3 & (TR3_IMPACT)) good[gc++] = "creates earthquakes on impact"; |
|---|
| 467 | | if (f3 & (TR3_SLOW_DIGEST)) good[gc++] = "slows your metabolism"; |
|---|
| 468 | | if (f3 & (TR3_FEATHER)) good[gc++] = "makes you fall like a feather"; |
|---|
| 469 | | if (f3 & (TR3_REGEN)) good[gc++] = "speeds your regeneration"; |
|---|
| 470 | | |
|---|
| 471 | | /* Describe */ |
|---|
| 472 | | if (gc) |
|---|
| 473 | | { |
|---|
| 474 | | output_desc_list("It ", good, gc); |
|---|
| 475 | | something = TRUE; |
|---|
| 476 | | } |
|---|
| 477 | | |
|---|
| 478 | | |
|---|
| 479 | | /* Collect granted powers */ |
|---|
| 480 | | gc = 0; |
|---|
| 481 | | if (f3 & (TR3_TELEPATHY)) good[gc++] = "the power of telepathy"; |
|---|
| 482 | | if (f3 & (TR3_SEE_INVIS)) good[gc++] = "the ability to see invisible things"; |
|---|
| 483 | | |
|---|
| 484 | | /* Collect penalties */ |
|---|
| 485 | | if (f3 & (TR3_AGGRAVATE)) bad[bc++] = "aggravates creatures around you"; |
|---|
| 486 | | if (f3 & (TR3_DRAIN_EXP)) bad[bc++] = "drains experience"; |
|---|
| 487 | | if (f3 & (TR3_TELEPORT)) bad[bc++] = "induces random teleportation"; |
|---|
| 488 | | |
|---|
| 489 | | /* Deal with cursed stuff */ |
|---|
| 490 | | if (cursed_p(o_ptr)) |
|---|
| 491 | | { |
|---|
| 492 | | if (f3 & (TR3_PERMA_CURSE)) bad[bc++] = "is permanently cursed"; |
|---|
| 493 | | else if (f3 & (TR3_HEAVY_CURSE)) bad[bc++] = "is heavily cursed"; |
|---|
| 494 | | else if (object_known_p(o_ptr)) bad[bc++] = "is cursed"; |
|---|
| 495 | | } |
|---|
| 496 | | |
|---|
| 497 | | /* Describe */ |
|---|
| 498 | | if (gc) |
|---|
| 499 | | { |
|---|
| 500 | | /* Output intro */ |
|---|
| 501 | | p_text_out("It grants you "); |
|---|
| 502 | | |
|---|
| 503 | | /* Output list */ |
|---|
| 504 | | output_list(good, gc); |
|---|
| 505 | | |
|---|
| 506 | | /* Output end (if needed) */ |
|---|
| 507 | | if (!bc) p_text_out(". "); |
|---|
| 508 | | } |
|---|
| 509 | | |
|---|
| 510 | | if (bc) |
|---|
| 511 | | { |
|---|
| 512 | | /* Output intro */ |
|---|
| 513 | | if (gc) p_text_out(", but it also "); |
|---|
| 514 | | else p_text_out("It "); |
|---|
| 515 | | |
|---|
| 516 | | /* Output list */ |
|---|
| 517 | | output_list(bad, bc); |
|---|
| 518 | | |
|---|
| 519 | | /* Output end */ |
|---|
| 520 | | p_text_out(". "); |
|---|
| 521 | | } |
|---|
| 522 | | |
|---|
| 523 | | /* Return "something" */ |
|---|
| 524 | | return (gc || bc) ? TRUE : FALSE; |
|---|
| 525 | | } |
|---|
| | 420 | |
|---|
| | 421 | /* |
|---|
| | 422 | * Describe things that look like lights. |
|---|
| | 423 | */ |
|---|
| | 424 | static bool describe_light(const object_type *o_ptr, u32b f3) |
|---|
| | 425 | { |
|---|
| | 426 | int rad = 0; |
|---|
| | 427 | |
|---|
| | 428 | bool artifact = artifact_p(o_ptr); |
|---|
| | 429 | bool no_fuel = (f3 & TR3_NO_FUEL) ? TRUE : FALSE; |
|---|
| | 430 | bool is_lite = (o_ptr->tval == TV_LITE) ? TRUE : FALSE; |
|---|
| | 431 | |
|---|
| | 432 | if ((o_ptr->tval != TV_LITE) && !(f3 & TR3_LITE)) |
|---|
| | 433 | return FALSE; |
|---|
| | 434 | |
|---|
| | 435 | /* Work out radius */ |
|---|
| | 436 | if (artifact) rad = 3; |
|---|
| | 437 | else if (is_lite) rad = 2; |
|---|
| | 438 | if (f3 & TR3_LITE) rad++; |
|---|
| | 439 | |
|---|
| | 440 | /* Describe here */ |
|---|
| | 441 | text_out("Radius "); |
|---|
| | 442 | text_out_c(TERM_L_GREEN, format("%d", rad)); |
|---|
| | 443 | if (no_fuel && !artifact) |
|---|
| | 444 | text_out(" light. No fuel required."); |
|---|
| | 445 | else if (is_lite && o_ptr->sval == SV_LITE_TORCH) |
|---|
| | 446 | text_out(" light, reduced when running of out fuel"); |
|---|
| | 447 | text_out("."); |
|---|
| | 448 | |
|---|
| | 449 | if (is_lite) |
|---|
| | 450 | { |
|---|
| | 451 | const char *name = (o_ptr->sval == SV_LITE_TORCH) ? "torch" : "lantern"; |
|---|
| | 452 | int turns = (o_ptr->sval == SV_LITE_TORCH) ? FUEL_TORCH : FUEL_LAMP; |
|---|
| | 453 | |
|---|
| | 454 | text_out(" Can refill another %s, up to %d turns of fuel.", name, turns); |
|---|
| | 455 | } |
|---|
| | 456 | |
|---|
| | 457 | text_out("\n"); |
|---|
| | 458 | |
|---|
| | 459 | return TRUE; |
|---|
| | 460 | } |
|---|
| | 461 | |
|---|