/** * Notice random effect curses */ void notice_curse(int curse_flag, int item) { object_type *o_ptr; int i; bool already_ego = FALSE; if (item) { if (item > 0) o_ptr = &p_ptr->inventory[item - 1]; else o_ptr = &o_list[0 - item]; already_ego = has_ego_properties(o_ptr); if (cf_has(o_ptr->flags_curse, curse_flag)) { cf_on(o_ptr->id_curse, curse_flag); o_ptr->ident |= IDENT_CURSED; /* Ego item? */ if (already_ego != has_ego_properties(o_ptr)) label_as_ego(o_ptr, item); } /* Fully identified now? */ if (known_really(o_ptr)) identify_object(o_ptr); return; } for (i = INVEN_WIELD; i <= INVEN_FEET; i++) { o_ptr = &p_ptr->inventory[i]; already_ego = has_ego_properties(o_ptr); /* Look for curses */ if (cf_has(o_ptr->flags_curse, curse_flag)) { /* Found one */ cf_on(o_ptr->id_curse, curse_flag); o_ptr->ident |= IDENT_CURSED; /* Ego item? */ if (already_ego != has_ego_properties(o_ptr)) label_as_ego(o_ptr, item); } /* Fully identified now? */ if (known_really(o_ptr)) identify_object(o_ptr); } }
bool describe_ego(textblock * tb, const object_type * o_ptr) { struct ego_item *ego = &e_info[o_ptr->name2]; int num = 0, i; /* Count ego flags */ for (i = 0; i < 7; i++) { if (kf_has(ego->flags_kind, KF_RAND_RES_NEG + i)) num++; } if (has_ego_properties(o_ptr) && num) { const char *xtra[] = { "vulnerability", "pair of small resistances", "resistance", "high resistance", "sustain", "ability", "curse" }; const char *punct[] = { ", ", ".", " and " }; textblock_append(tb, "It provides "); for (i = 0; i < 7; i++) { if (kf_has(ego->flags_kind, KF_RAND_RES_NEG + i)) { textblock_append(tb, "at least one random %s%s", xtra[i], (num > 2) ? punct[0] : punct[num]); num--; } } return TRUE; } return FALSE; }
static void describe_flavor_text(textblock * tb, const object_type * o_ptr) { /* Display the known artifact description */ if (o_ptr->name1 && object_known_p(o_ptr) && a_info[o_ptr->name1].text) { textblock_append(tb, "%s\n\n", a_info[o_ptr->name1].text); } /* Display the known object description */ else if (object_aware_p(o_ptr) || object_known_p(o_ptr)) { bool did_desc = FALSE; if (k_info[o_ptr->k_idx].text) { textblock_append(tb, "%s", k_info[o_ptr->k_idx].text); did_desc = TRUE; } /* Display an additional ego-item description */ if (has_ego_properties(o_ptr) && e_info[o_ptr->name2].text) { if (did_desc) textblock_append(tb, " "); textblock_append(tb, "%s\n\n", e_info[o_ptr->name2].text); } else if (did_desc) { textblock_append(tb, "\n\n"); } } }
/** * Determines if an object is eligable for squelching. */ extern bool squelch_item_ok(const object_type * o_ptr) { size_t i; int num = -1; object_kind *k_ptr = &k_info[o_ptr->k_idx]; bool fullid = object_known_p(o_ptr); bool sensed = (o_ptr->ident & IDENT_SENSE) || fullid; byte feel = fullid ? value_check_aux1((object_type *) o_ptr) : o_ptr->feel; int quality_squelch = SQUELCH_NONE; /* Don't squelch artifacts */ if (artifact_p(o_ptr)) return FALSE; /* Don't squelch stuff inscribed not to be destroyed (!k) */ if (check_for_inscrip(o_ptr, "!k") || check_for_inscrip(o_ptr, "!*")) { return FALSE; } /* Auto-squelch dead chests */ if (o_ptr->tval == TV_CHEST && o_ptr->pval == 0) return TRUE; /* Do squelching by sval, if we 'know' the flavour. */ if (k_ptr->squelch && (k_ptr->flavor == 0 || k_ptr->aware)) { if (squelch_tval(k_info[o_ptr->k_idx].tval)) return TRUE; } /* Squelch some ego items if known */ if (has_ego_properties(o_ptr) && (e_info[o_ptr->name2].squelch)) { return TRUE; } /* Don't check pseudo-ID for nonsensed things */ if (!sensed) return FALSE; /* Find the appropriate squelch group */ for (i = 0; i < N_ELEMENTS(quality_choices); i++) { if (quality_choices[i].tval == o_ptr->tval) { num = i; break; } } /* Never squelched */ if (num == -1) return FALSE; /* Get result based on the feeling and the squelch_profile */ quality_squelch = feel_to_squelch_level(feel); if (quality_squelch == SQUELCH_NONE) return FALSE; else return squelch_profile[num][quality_squelch]; }
/** * Notice object flags */ void notice_obj(int obj_flag, int item) { object_type *o_ptr; int i; bool already_ego = FALSE; if (item) { if (item > 0) o_ptr = &p_ptr->inventory[item - 1]; else o_ptr = &o_list[0 - item]; already_ego = has_ego_properties(o_ptr); /* Add properties */ if (of_has(o_ptr->flags_obj, obj_flag)) of_on(o_ptr->id_obj, obj_flag); /* Ego item? */ if (already_ego != has_ego_properties(o_ptr)) label_as_ego(o_ptr, item); /* Fully identified now? */ if (known_really(o_ptr)) identify_object(o_ptr); return; } for (i = INVEN_WIELD; i <= INVEN_FEET; i++) { o_ptr = &p_ptr->inventory[i]; already_ego = has_ego_properties(o_ptr); /* Add properties */ if (of_has(o_ptr->flags_obj, obj_flag)) of_on(o_ptr->id_obj, obj_flag); /* Ego item? */ if (already_ego != has_ego_properties(o_ptr)) label_as_ego(o_ptr, item); /* Fully identified now? */ if (known_really(o_ptr)) identify_object(o_ptr); } }
/** * Notice other properties */ void notice_other(int other_flag, int item) { int i, j; bool already_ego = FALSE; object_type *o_ptr; if (item) { if (item > 0) o_ptr = &p_ptr->inventory[item - 1]; else o_ptr = &o_list[0 - item]; already_ego = has_ego_properties(o_ptr); /* Resists */ for (j = 0; j < MAX_P_RES; j++) { if (other_flag != OBJECT_ID_BASE_RESIST + j) continue; if (o_ptr->percent_res[j] != RES_LEVEL_BASE) { if_on(o_ptr->id_other, other_flag); } } /* Slays */ for (j = 0; j < MAX_P_SLAY; j++) { if (other_flag != OBJECT_ID_BASE_SLAY + j) continue; if (o_ptr->multiple_slay[j] != MULTIPLE_BASE) { if_on(o_ptr->id_other, other_flag); } } /* Brands */ for (j = 0; j < MAX_P_BRAND; j++) { if (other_flag != OBJECT_ID_BASE_BRAND + j) continue; if (o_ptr->multiple_brand[j] != MULTIPLE_BASE) { if_on(o_ptr->id_other, other_flag); } } /* Others */ if ((other_flag == IF_TO_H) && ((o_ptr->to_h) || is_weapon(o_ptr))) if_on(o_ptr->id_other, IF_TO_H); if ((other_flag == IF_TO_D) && ((o_ptr->to_d) || is_weapon(o_ptr))) if_on(o_ptr->id_other, IF_TO_D); if ((other_flag == IF_TO_A) && ((o_ptr->ac) || is_armour(o_ptr))) if_on(o_ptr->id_other, IF_TO_A); if ((other_flag == IF_AC) && ((o_ptr->ac) || is_armour(o_ptr))) if_on(o_ptr->id_other, IF_AC); if ((other_flag == IF_DD_DS)) if_on(o_ptr->id_other, IF_DD_DS); /* Ego item? */ if (already_ego != has_ego_properties(o_ptr)) label_as_ego(o_ptr, item); /* Fully identified now? */ if (known_really(o_ptr)) identify_object(o_ptr); return; } for (i = INVEN_WIELD; i <= INVEN_FEET; i++) { o_ptr = &p_ptr->inventory[i]; already_ego = has_ego_properties(o_ptr); /* Resists */ for (j = 0; j < MAX_P_RES; j++) { if (other_flag != OBJECT_ID_BASE_RESIST + j) continue; if (o_ptr->percent_res[j] != RES_LEVEL_BASE) { if_on(o_ptr->id_other, other_flag); if ((j == INVEN_RIGHT) || (j == INVEN_LEFT) || (j == INVEN_NECK)) { if_on(o_ptr->id_other, other_flag); } } } /* Slays */ for (j = 0; j < MAX_P_SLAY; j++) { if (other_flag != OBJECT_ID_BASE_SLAY + j) continue; if (o_ptr->multiple_slay[j] != MULTIPLE_BASE) { if_on(o_ptr->id_other, other_flag); if ((j == INVEN_RIGHT) || (j == INVEN_LEFT) || (j == INVEN_NECK)) { if_on(o_ptr->id_other, other_flag); } } } /* Brands */ for (j = 0; j < MAX_P_BRAND; j++) { if (other_flag != OBJECT_ID_BASE_BRAND + j) continue; if (o_ptr->multiple_brand[j] != MULTIPLE_BASE) { if_on(o_ptr->id_other, other_flag); if ((j == INVEN_RIGHT) || (j == INVEN_LEFT) || (j == INVEN_NECK)) { if_on(o_ptr->id_other, other_flag); } } } /* Others */ if ((other_flag == IF_TO_H) && ((o_ptr->to_h) || is_weapon(o_ptr))) if_on(o_ptr->id_other, IF_TO_H); if ((other_flag == IF_TO_D) && ((o_ptr->to_d) || is_weapon(o_ptr))) if_on(o_ptr->id_other, IF_TO_D); if ((other_flag == IF_TO_A) && ((o_ptr->ac) || is_armour(o_ptr))) if_on(o_ptr->id_other, IF_TO_A); if ((other_flag == IF_AC) && ((o_ptr->ac) || is_armour(o_ptr))) if_on(o_ptr->id_other, IF_AC); if ((other_flag == IF_DD_DS)) if_on(o_ptr->id_other, IF_DD_DS); /* Ego item? */ if (already_ego != has_ego_properties(o_ptr)) label_as_ego(o_ptr, item); /* Fully identified now? */ if (known_really(o_ptr)) identify_object(o_ptr); } }
/** * Determines if an object is eligable for squelching. */ extern bool squelch_item_ok(const object_type * o_ptr) { size_t i; int num = -1; object_kind *k_ptr = &k_info[o_ptr->k_idx]; bool fullid = object_known_p(o_ptr); bool sensed = (o_ptr->ident & IDENT_SENSE) || fullid; byte feel = fullid ? value_check_aux1((object_type *) o_ptr) : o_ptr->feel; /* Don't squelch artifacts */ if (artifact_p(o_ptr)) return FALSE; /* Don't squelch stuff inscribed not to be destroyed (!k) */ if (check_for_inscrip(o_ptr, "!k") || check_for_inscrip(o_ptr, "!*")) { return FALSE; } /* Auto-squelch dead chests */ if (o_ptr->tval == TV_CHEST && o_ptr->pval == 0) return TRUE; /* Do squelching by sval, if we 'know' the flavour. */ if (k_ptr->squelch && (k_ptr->flavor == 0 || k_ptr->aware)) { if (squelch_tval(k_info[o_ptr->k_idx].tval)) return TRUE; } /* Squelch some ego items if known */ if (has_ego_properties(o_ptr) && (e_info[o_ptr->name2].squelch)) { return TRUE; } /* Don't check pseudo-ID for nonsensed things */ if (!sensed) return FALSE; /* Find the appropriate squelch group */ for (i = 0; i < N_ELEMENTS(quality_choices); i++) { if (quality_choices[i].enum_val == o_ptr->tval) { num = i; break; } } /* Never squelched */ if (num == -1) return FALSE; /* Get result based on the feeling and the squelch_level */ switch (squelch_level[num]) { case SQUELCH_CURSED: { if (o_ptr->ident & IDENT_CURSED) { return TRUE; } break; } case SQUELCH_DUBIOUS: { if ((feel == FEEL_DUBIOUS_WEAK) || (feel == FEEL_PERILOUS) || (feel == FEEL_DUBIOUS_STRONG)) { return TRUE; } break; } case SQUELCH_DUBIOUS_NON: { if (feel == FEEL_DUBIOUS_STRONG) { return TRUE; } break; } case SQUELCH_NON_EGO: { if ((feel == FEEL_DUBIOUS_STRONG) || (feel == FEEL_AVERAGE) || (feel == FEEL_GOOD_STRONG)) { return TRUE; } break; } case SQUELCH_AVERAGE: { if ((feel == FEEL_DUBIOUS_WEAK) || (feel == FEEL_PERILOUS) || (feel == FEEL_DUBIOUS_STRONG) || (feel == FEEL_AVERAGE)) { return TRUE; } break; } case SQUELCH_GOOD_STRONG: { if ((feel == FEEL_PERILOUS) || (feel == FEEL_DUBIOUS_STRONG) || (feel == FEEL_AVERAGE) || (feel == FEEL_GOOD_STRONG)) { return TRUE; } break; } case SQUELCH_GOOD_WEAK: { if ((feel == FEEL_PERILOUS) || (feel == FEEL_DUBIOUS_STRONG) || (feel == FEEL_AVERAGE) || (feel == FEEL_GOOD_WEAK) || (feel == FEEL_GOOD_STRONG)) { return TRUE; } break; } case SQUELCH_ALL: { return TRUE; break; } } /* Failure */ return FALSE; }
/* * Copy 'src' into 'buf, replacing '#' with 'modstr' (if found), putting a plural * in the place indicated by '~' if required, or using alterate... */ static size_t obj_desc_name(char *buf, size_t max, size_t end, const object_type * o_ptr, bool prefix, odesc_detail_t mode, bool spoil) { object_kind *k_ptr = &k_info[o_ptr->k_idx]; bool known = object_known_p(o_ptr) || spoil; bool aware = object_aware_p(o_ptr) || spoil; const char *basename = obj_desc_get_basename(o_ptr, aware); const char *modstr = obj_desc_get_modstr(o_ptr); bool pluralise = (mode & ODESC_PLURAL) ? TRUE : FALSE; if (aware && !k_ptr->everseen) k_ptr->everseen = TRUE; if (o_ptr->number > 1) pluralise = TRUE; if (mode & ODESC_SINGULAR) pluralise = FALSE; /* Add a pseudo-numerical prefix if desired */ if (prefix) { if (o_ptr->number <= 0) { strnfcat(buf, max, &end, "no more "); /* Pluralise for grammatical correctness */ pluralise = TRUE; } else if (o_ptr->number > 1) strnfcat(buf, max, &end, "%d ", o_ptr->number); else if ((known) && artifact_p(o_ptr)) strnfcat(buf, max, &end, "The "); else if (*basename == '&') { bool an = FALSE; const char *lookahead = basename + 1; while (*lookahead == ' ') lookahead++; if (*lookahead == '#') { if (modstr && is_a_vowel(*modstr)) an = TRUE; } else if (is_a_vowel(*lookahead)) { an = TRUE; } if (an) strnfcat(buf, max, &end, "an "); else strnfcat(buf, max, &end, "a "); } } /* * Names have the following elements: * * '~' indicates where to place an 's' or an 'es'. Other plural forms should * be handled with the syntax '|singular|plural|', e.g. "kni|fe|ves|". * * '#' indicates the position of the "modifier", e.g. the flavour or spellbook * name. */ /* Copy the string */ while (*basename) { if (*basename == '&') { while (*basename == ' ' || *basename == '&') basename++; continue; } /* Pluralizer (regular English plurals) */ else if (*basename == '~') { char prev = *(basename - 1); if (!pluralise) { basename++; continue; } /* e.g. cutlass-e-s, torch-e-s, box-e-s */ if (prev == 's' || prev == 'h' || prev == 'x') strnfcat(buf, max, &end, "es"); else strnfcat(buf, max, &end, "s"); } /* Special plurals */ else if (*basename == '|') { /* e.g. & Wooden T|o|e|rch~ ^ ^^ */ const char *singular = basename + 1; const char *plural = strchr(singular, '|'); const char *endmark = NULL; if (plural) { plural++; endmark = strchr(plural, '|'); } if (!singular || !plural || !endmark) return end; if (!pluralise) strnfcat(buf, max, &end, "%.*s", plural - singular - 1, singular); else strnfcat(buf, max, &end, "%.*s", endmark - plural, plural); basename = endmark; } /* Handle pluralisation in the modifier XXX */ else if (*basename == '#') { const char *basename = modstr; while (basename && *basename && (end < max - 1)) { /* Special plurals */ if (*basename == '|') { /* e.g. & Wooden T|o|e|rch~ ^ ^^ */ const char *singular = basename + 1; const char *plural = strchr(singular, '|'); const char *endmark = NULL; if (plural) { plural++; endmark = strchr(plural, '|'); } if (!singular || !plural || !endmark) return end; if (!pluralise) strnfcat(buf, max, &end, "%.*s", plural - singular - 1, singular); else strnfcat(buf, max, &end, "%.*s", endmark - plural, plural); basename = endmark; } else buf[end++] = *basename; basename++; } } else buf[end++] = *basename; basename++; } /* 0-terminate, just in case XXX */ buf[end] = 0; /** Append extra names of various kinds **/ if ((known) && o_ptr->name1) strnfcat(buf, max, &end, " %s", a_info[o_ptr->name1].name); else if ((spoil && o_ptr->name2) || has_ego_properties(o_ptr)) strnfcat(buf, max, &end, " %s", e_info[o_ptr->name2].name); else if (aware && !artifact_p(o_ptr) && (k_ptr->flavor || k_ptr->tval == TV_SCROLL) && ((k_ptr->tval != TV_FOOD) || (k_ptr->sval < SV_FOOD_MIN_FOOD))) strnfcat(buf, max, &end, " of %s", k_ptr->name); return end; }