/* * Determines if an object is already squelched. Same as squelch_item_ok above, * without the first (p_ptr->unignoring) test. */ bool object_is_squelched(const object_type *o_ptr) { byte type; /* Do squelch individual objects that marked ignore */ if (o_ptr->ignore) return TRUE; /* Don't squelch artifacts unless marked to be squelched */ if (o_ptr->artifact || check_for_inscrip(o_ptr, "!k") || check_for_inscrip(o_ptr, "!*")) return FALSE; /* Do squelching by kind */ if (object_flavor_is_aware(o_ptr) ? kind_is_squelched_aware(o_ptr->kind) : kind_is_squelched_unaware(o_ptr->kind)) return TRUE; type = squelch_type_of(o_ptr); if (type == TYPE_MAX) return FALSE; /* Squelch items known not to be special */ if (object_is_known_not_artifact(o_ptr) && squelch_level[type] == SQUELCH_ALL) return TRUE; /* Get result based on the feeling and the squelch_level */ if (squelch_level_of(o_ptr) <= squelch_level[type]) return TRUE; else return FALSE; }
/* * Inquire whether the player wishes to squelch items similar to an object * * Returns whether the item is now squelched. */ bool squelch_interactive(const object_type *o_ptr) { char out_val[70]; if (squelch_tval(o_ptr->tval)) { char sval_name[50]; /* Obtain plural form without a quantity */ object_desc(sval_name, sizeof sval_name, o_ptr, ODESC_BASE | ODESC_PLURAL); /* XXX Eddie while correct in a sense, to squelch all torches on torch of brightness you get the message "Ignore Wooden Torches of Brightness in future? " */ strnfmt(out_val, sizeof out_val, "Ignore %s in future? ", sval_name); if (!artifact_p(o_ptr) || !object_flavor_is_aware(o_ptr)) { if (get_check(out_val)) { object_squelch_flavor_of(o_ptr); msg_format("Ignoring %s from now on.", sval_name); return TRUE; } } /* XXX Eddie need to add generalized squelching, e.g. con rings with pval < 3 */ if (!object_is_jewelry(o_ptr) || (squelch_level_of(o_ptr) != SQUELCH_BAD)) return FALSE; } if (object_was_sensed(o_ptr) || object_was_worn(o_ptr) || object_is_known_not_artifact(o_ptr)) { byte value = squelch_level_of(o_ptr); int type = squelch_type_of(o_ptr); /* XXX Eddie on pseudoed cursed artifact, only showed {cursed}, asked to ignore artifacts */ if ((value != SQUELCH_MAX) && ((value == SQUELCH_BAD) || !object_is_jewelry(o_ptr))) { strnfmt(out_val, sizeof out_val, "Ignore all %s that are %s in future? ", quality_choices[type].name, quality_values[value].name); if (get_check(out_val)) { squelch_level[type] = value; return TRUE; } } } return FALSE; }
/* * Determines if an object is eligible for squelching. */ bool squelch_item_ok(const object_type *o_ptr) { object_kind *k_ptr = &k_info[o_ptr->k_idx]; byte type; /* Don't squelch artifacts unless marked to be squelched */ 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; /* check option for worthless kinds */ if (OPT(squelch_worthless) && o_ptr->tval != TV_GOLD) { if (object_flavor_is_aware(o_ptr) && k_ptr->cost == 0) return TRUE; if (object_is_known_cursed(o_ptr)) return TRUE; } /* Do squelching by kind */ if (object_flavor_is_aware(o_ptr) ? kind_is_squelched_aware(k_ptr) : kind_is_squelched_unaware(k_ptr)) return TRUE; type = squelch_type_of(o_ptr); if (type == TYPE_MAX) return FALSE; /* Squelch items known not to be special */ if (object_is_known_not_artifact(o_ptr) && squelch_level[type] == SQUELCH_ALL) return TRUE; /* Get result based on the feeling and the squelch_level */ if (squelch_level_of(o_ptr) <= squelch_level[type]) return TRUE; else return FALSE; }
/** * Determines if an object is already ignored. */ bool object_is_ignored(const struct object *obj) { byte type; /* Objects that aren't yet known can't be ignored */ if (!obj->known) return false; /* Do ignore individual objects that marked ignore */ if (obj->known->notice & OBJ_NOTICE_IGNORE) return true; /* Don't ignore artifacts unless marked to be ignored */ if (obj->artifact || check_for_inscrip(obj, "!k") || check_for_inscrip(obj, "!*")) return false; /* Do ignoring by kind */ if (object_flavor_is_aware(obj) ? kind_is_ignored_aware(obj->kind) : kind_is_ignored_unaware(obj->kind)) return true; /* Ignore ego items if known */ if (object_ego_is_visible(obj) && ego_is_ignored(obj->ego->eidx, ignore_type_of(obj))) return true; type = ignore_type_of(obj); if (type == ITYPE_MAX) return false; /* Ignore items known not to be special */ if (object_is_known_not_artifact(obj) && ignore_level[type] == IGNORE_ALL) return true; /* Get result based on the feeling and the ignore_level */ if (ignore_level_of(obj) <= ignore_level[type]) return true; else return false; }
/* * Determine the squelch level of an object, which is similar to its pseudo. * * The main point is when the value is undetermined given current info, * return the maximum possible value. */ byte squelch_level_of(const object_type *o_ptr) { byte value; bitflag f[OF_SIZE], f2[OF_SIZE]; int i; object_flags_known(o_ptr, f); /* Deal with jewelry specially. */ if (object_is_jewelry(o_ptr)) { /* CC: average jewelry has at least one known positive pval */ for (i = 0; i < o_ptr->num_pvals; i++) if ((object_this_pval_is_visible(o_ptr, i)) && (o_ptr->pval[i] > 0)) return SQUELCH_AVERAGE; if ((o_ptr->to_h > 0) || (o_ptr->to_d > 0) || (o_ptr->to_a > 0)) return SQUELCH_AVERAGE; if ((object_attack_plusses_are_visible(o_ptr) && ((o_ptr->to_h < 0) || (o_ptr->to_d < 0))) || (object_defence_plusses_are_visible(o_ptr) && o_ptr->to_a < 0)) return SQUELCH_BAD; return SQUELCH_AVERAGE; } /* And lights */ if (o_ptr->tval == TV_LIGHT) { create_mask(f2, TRUE, OFID_WIELD, OFT_MAX); if (of_is_inter(f, f2)) return SQUELCH_ALL; if ((o_ptr->to_h > 0) || (o_ptr->to_d > 0) || (o_ptr->to_a > 0)) return SQUELCH_GOOD; if ((o_ptr->to_h < 0) || (o_ptr->to_d < 0) || (o_ptr->to_a < 0)) return SQUELCH_BAD; return SQUELCH_AVERAGE; } /* CC: we need to redefine "bad" with multiple pvals * At the moment we use "all pvals known and negative" */ for (i = 0; i < o_ptr->num_pvals; i++) { if (!object_this_pval_is_visible(o_ptr, i) || (o_ptr->pval[i] > 0)) break; if (i == (o_ptr->num_pvals - 1)) return SQUELCH_BAD; } if (object_was_sensed(o_ptr)) { obj_pseudo_t pseudo = object_pseudo(o_ptr); switch (pseudo) { case INSCRIP_AVERAGE: { value = SQUELCH_AVERAGE; break; } case INSCRIP_EXCELLENT: { /* have to assume splendid until you have tested it */ if (object_was_worn(o_ptr)) { if (object_high_resist_is_possible(o_ptr)) value = SQUELCH_EXCELLENT_NO_SPL; else value = SQUELCH_EXCELLENT_NO_HI; } else { value = SQUELCH_ALL; } break; } case INSCRIP_SPLENDID: value = SQUELCH_ALL; break; case INSCRIP_NULL: case INSCRIP_SPECIAL: value = SQUELCH_MAX; break; /* This is the interesting case */ case INSCRIP_STRANGE: case INSCRIP_MAGICAL: { value = SQUELCH_GOOD; if ((object_attack_plusses_are_visible(o_ptr) || randcalc_valid(o_ptr->kind->to_h, o_ptr->to_h) || randcalc_valid(o_ptr->kind->to_d, o_ptr->to_d)) && (object_defence_plusses_are_visible(o_ptr) || randcalc_valid(o_ptr->kind->to_a, o_ptr->to_a))) { int isgood = is_object_good(o_ptr); if (isgood > 0) { value = SQUELCH_GOOD; } else if (isgood < 0) { value = SQUELCH_BAD; } else { value = SQUELCH_AVERAGE; } } break; } default: /* do not handle any other possible pseudo values */ assert(0); } } else { if (object_was_worn(o_ptr)) value = SQUELCH_EXCELLENT_NO_SPL; /* object would be sensed if it were splendid */ else if (object_is_known_not_artifact(o_ptr)) value = SQUELCH_ALL; else value = SQUELCH_MAX; } return value; }
void textui_cmd_ignore_menu(struct object *obj) { char out_val[160]; struct menu *m; region r; int selected; if (!obj) return; m = menu_dynamic_new(); m->selections = lower_case; /* Basic ignore option */ if (!obj->ignore) { menu_dynamic_add(m, "This item only", IGNORE_THIS_ITEM); } else { menu_dynamic_add(m, "Unignore this item", UNIGNORE_THIS_ITEM); } /* Flavour-aware ignore */ if (ignore_tval(obj->tval) && (!obj->artifact || !object_flavor_is_aware(obj))) { bool ignored = kind_is_ignored_aware(obj->kind) || kind_is_ignored_unaware(obj->kind); char tmp[70]; object_desc(tmp, sizeof(tmp), obj, ODESC_BASE | ODESC_PLURAL); if (!ignored) { strnfmt(out_val, sizeof out_val, "All %s", tmp); menu_dynamic_add(m, out_val, IGNORE_THIS_FLAVOR); } else { strnfmt(out_val, sizeof out_val, "Unignore all %s", tmp); menu_dynamic_add(m, out_val, UNIGNORE_THIS_FLAVOR); } } /* Ego ignoring */ if (object_ego_is_visible(obj)) { ego_desc choice; struct ego_item *ego = obj->ego; char tmp[80] = ""; choice.e_idx = ego->eidx; choice.itype = ignore_type_of(obj); choice.short_name = ""; (void) ego_item_name(tmp, sizeof(tmp), &choice); if (!ego_is_ignored(choice.e_idx, choice.itype)) { strnfmt(out_val, sizeof out_val, "All %s", tmp + 4); menu_dynamic_add(m, out_val, IGNORE_THIS_EGO); } else { strnfmt(out_val, sizeof out_val, "Unignore all %s", tmp + 4); menu_dynamic_add(m, out_val, UNIGNORE_THIS_EGO); } } /* Quality ignoring */ if (object_was_sensed(obj) || object_was_worn(obj) || object_is_known_not_artifact(obj)) { byte value = ignore_level_of(obj); int type = ignore_type_of(obj); if (tval_is_jewelry(obj) && ignore_level_of(obj) != IGNORE_BAD) value = IGNORE_MAX; if (value != IGNORE_MAX && type != ITYPE_MAX) { strnfmt(out_val, sizeof out_val, "All %s %s", quality_values[value].name, ignore_name_for_type(type)); menu_dynamic_add(m, out_val, IGNORE_THIS_QUALITY); } } /* Work out display region */ r.width = menu_dynamic_longest_entry(m) + 3 + 2; /* +3 for tag, 2 for pad */ r.col = 80 - r.width; r.row = 1; r.page_rows = m->count; screen_save(); menu_layout(m, &r); region_erase_bordered(&r); prt("(Enter to select, ESC) Ignore:", 0, 0); selected = menu_dynamic_select(m); screen_load(); if (selected == IGNORE_THIS_ITEM) { obj->ignore = TRUE; } else if (selected == UNIGNORE_THIS_ITEM) { obj->ignore = FALSE; } else if (selected == IGNORE_THIS_FLAVOR) { object_ignore_flavor_of(obj); } else if (selected == UNIGNORE_THIS_FLAVOR) { kind_ignore_clear(obj->kind); } else if (selected == IGNORE_THIS_EGO) { ego_ignore(obj); } else if (selected == UNIGNORE_THIS_EGO) { ego_ignore_clear(obj); } else if (selected == IGNORE_THIS_QUALITY) { byte value = ignore_level_of(obj); int type = ignore_type_of(obj); ignore_level[type] = value; } player->upkeep->notice |= PN_IGNORE; menu_dynamic_free(m); }
/** * Determine the ignore level of an object, which is similar to its pseudo. * * The main point is when the value is undetermined given current info, * return the maximum possible value. */ byte ignore_level_of(const struct object *obj) { byte value = 0; bitflag f[OF_SIZE], f2[OF_SIZE]; int i; bool negative_mod = FALSE; object_flags_known(obj, f); /* Deal with jewelry specially. */ if (tval_is_jewelry(obj)) { /* CC: average jewelry has at least one known positive modifier */ for (i = 0; i < OBJ_MOD_MAX; i++) if ((object_this_mod_is_visible(obj, i)) && (obj->modifiers[i] > 0)) return IGNORE_AVERAGE; if ((obj->to_h > 0) || (obj->to_d > 0) || (obj->to_a > 0)) return IGNORE_AVERAGE; if ((object_attack_plusses_are_visible(obj) && ((obj->to_h < 0) || (obj->to_d < 0))) || (object_defence_plusses_are_visible(obj) && obj->to_a < 0)) return IGNORE_BAD; return IGNORE_AVERAGE; } /* And lights */ if (tval_is_light(obj)) { create_mask(f2, TRUE, OFID_WIELD, OFT_MAX); if (of_is_inter(f, f2)) return IGNORE_ALL; if ((obj->to_h > 0) || (obj->to_d > 0) || (obj->to_a > 0)) return IGNORE_GOOD; if ((obj->to_h < 0) || (obj->to_d < 0) || (obj->to_a < 0)) return IGNORE_BAD; return IGNORE_AVERAGE; } /* We need to redefine "bad" * At the moment we use "all modifiers known and negative" */ for (i = 0; i < OBJ_MOD_MAX; i++) { if (!object_this_mod_is_visible(obj, i) || (obj->modifiers[i] > 0)) break; if (obj->modifiers[i] < 0) negative_mod = TRUE; } if ((i == OBJ_MOD_MAX) && negative_mod) return IGNORE_BAD; if (object_was_sensed(obj)) { obj_pseudo_t pseudo = object_pseudo(obj); switch (pseudo) { case INSCRIP_AVERAGE: { value = IGNORE_AVERAGE; break; } case INSCRIP_EXCELLENT: { /* have to assume splendid until you have tested it */ if (object_was_worn(obj)) { if (object_high_resist_is_possible(obj)) value = IGNORE_EXCELLENT_NO_SPL; else value = IGNORE_EXCELLENT_NO_HI; } else { value = IGNORE_ALL; } break; } case INSCRIP_SPLENDID: value = IGNORE_ALL; break; case INSCRIP_NULL: case INSCRIP_SPECIAL: value = IGNORE_MAX; break; /* This is the interesting case */ case INSCRIP_STRANGE: case INSCRIP_MAGICAL: { value = IGNORE_GOOD; if ((object_attack_plusses_are_visible(obj) || randcalc_valid(obj->kind->to_h, obj->to_h) || randcalc_valid(obj->kind->to_d, obj->to_d)) && (object_defence_plusses_are_visible(obj) || randcalc_valid(obj->kind->to_a, obj->to_a))) { int isgood = is_object_good(obj); if (isgood > 0) { value = IGNORE_GOOD; } else if (isgood < 0) { value = IGNORE_BAD; } else { value = IGNORE_AVERAGE; } } break; } default: /* do not handle any other possible pseudo values */ assert(0); } } else { if (object_was_worn(obj)) value = IGNORE_EXCELLENT_NO_SPL; /* object would be sensed if it were splendid */ else if (object_is_known_not_artifact(obj)) value = IGNORE_ALL; else value = IGNORE_MAX; } return value; }
/* * Determine the squelch level of an object, which is similar to its pseudo. * * The main point is when the value is undetermined given current info, * return the maximum possible value. */ static byte squelch_level_of(const object_type *o_ptr) { object_kind *k_ptr = &k_info[o_ptr->k_idx]; byte value; bitflag f[OF_SIZE]; object_flags_known(o_ptr, f); if ((object_pval_is_visible(o_ptr)) && (o_ptr->pval < 0)) return SQUELCH_BAD; /* Deal with jewelry specially. */ if (object_is_jewelry(o_ptr)) { if ((object_pval_is_visible(o_ptr)) && (o_ptr->pval > 0)) return SQUELCH_AVERAGE; if ((o_ptr->to_h > 0) || (o_ptr->to_d > 0) || (o_ptr->to_a > 0)) return SQUELCH_AVERAGE; if ((o_ptr->to_h < 0) || (o_ptr->to_d < 0) || (o_ptr->to_a < 0)) return SQUELCH_BAD; return SQUELCH_AVERAGE; } /* And lights */ if (o_ptr->tval == TV_LIGHT) { if (flags_test(f, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END)) return SQUELCH_ALL; if ((o_ptr->to_h > 0) || (o_ptr->to_d > 0) || (o_ptr->to_a > 0)) return SQUELCH_GOOD; if ((o_ptr->to_h < 0) || (o_ptr->to_d < 0) || (o_ptr->to_a < 0)) return SQUELCH_BAD; return SQUELCH_AVERAGE; } if (object_was_sensed(o_ptr)) { obj_pseudo_t pseudo = object_pseudo(o_ptr); switch (pseudo) { case INSCRIP_AVERAGE: value = SQUELCH_AVERAGE; break; case INSCRIP_EXCELLENT: /* have to assume splendid until you have tested it */ if (object_was_worn(o_ptr)) { if (object_high_resist_is_possible(o_ptr)) value = SQUELCH_EXCELLENT_NO_SPL; else value = SQUELCH_EXCELLENT_NO_HI; } else { value = SQUELCH_ALL; } break; case INSCRIP_STRANGE: /* XXX Eddie perhaps some strange count as something else */ case INSCRIP_SPLENDID: value = SQUELCH_ALL; break; case INSCRIP_NULL: case INSCRIP_SPECIAL: value = SQUELCH_MAX; break; /* This is the interesting case */ case INSCRIP_MAGICAL: value = SQUELCH_GOOD; if ((object_attack_plusses_are_visible(o_ptr) || (randcalc_valid(k_ptr->to_h, o_ptr->to_h) && randcalc_valid(k_ptr->to_d, o_ptr->to_d))) && (object_defence_plusses_are_visible(o_ptr) || (randcalc_valid(k_ptr->to_a, o_ptr->to_a))) && (o_ptr->to_h <= randcalc(k_ptr->to_h, 0, MINIMISE)) && (o_ptr->to_d <= randcalc(k_ptr->to_d, 0, MINIMISE)) && (o_ptr->to_a <= randcalc(k_ptr->to_a, 0, MINIMISE))) value = SQUELCH_BAD; break; default: /* do not handle any other possible pseudo values */ assert(0); } } else { if (object_was_worn(o_ptr)) value = SQUELCH_EXCELLENT_NO_SPL; /* object would be sensed if it were splendid */ else if (object_is_known_not_artifact(o_ptr)) value = SQUELCH_ALL; else value = SQUELCH_MAX; } return value; }
void textui_cmd_destroy(void) { int item; object_type *o_ptr; char out_val[160]; menu_type *m; region r; int selected; /* Get an item */ const char *q = "Ignore which item? "; const char *s = "You have nothing to ignore."; if (!get_item(&item, q, s, CMD_DESTROY, USE_INVEN | USE_EQUIP | USE_FLOOR)) return; o_ptr = object_from_item_idx(item); m = menu_dynamic_new(); m->selections = lower_case; /* Basic ignore option */ if (!o_ptr->ignore) { menu_dynamic_add(m, "This item only", IGNORE_THIS_ITEM); } else { menu_dynamic_add(m, "Unignore this item", UNIGNORE_THIS_ITEM); } /* Flavour-aware squelch */ if (squelch_tval(o_ptr->tval) && (!o_ptr->artifact || !object_flavor_is_aware(o_ptr))) { bool squelched = kind_is_squelched_aware(o_ptr->kind) || kind_is_squelched_unaware(o_ptr->kind); char tmp[70]; object_desc(tmp, sizeof(tmp), o_ptr, ODESC_BASE | ODESC_PLURAL); if (!squelched) { strnfmt(out_val, sizeof out_val, "All %s", tmp); menu_dynamic_add(m, out_val, IGNORE_THIS_FLAVOR); } else { strnfmt(out_val, sizeof out_val, "Unignore all %s", tmp); menu_dynamic_add(m, out_val, UNIGNORE_THIS_FLAVOR); } } /* Quality squelching */ if (object_was_sensed(o_ptr) || object_was_worn(o_ptr) || object_is_known_not_artifact(o_ptr)) { byte value = squelch_level_of(o_ptr); int type = squelch_type_of(o_ptr); if (object_is_jewelry(o_ptr) && squelch_level_of(o_ptr) != SQUELCH_BAD) value = SQUELCH_MAX; if (value != SQUELCH_MAX && type != TYPE_MAX) { strnfmt(out_val, sizeof out_val, "All %s %s", quality_values[value].name, quality_choices[type].name); menu_dynamic_add(m, out_val, IGNORE_THIS_QUALITY); } } /* work out display region */ r.width = menu_dynamic_longest_entry(m) + 3 + 2; /* +3 for tag, 2 for pad */ r.col = 80 - r.width; r.row = 1; r.page_rows = m->count; screen_save(); menu_layout(m, &r); region_erase_bordered(&r); prt("(Enter to select, ESC) Ignore:", 0, 0); selected = menu_dynamic_select(m); screen_load(); if (selected == IGNORE_THIS_ITEM) { cmd_insert(CMD_DESTROY); cmd_set_arg_item(cmd_get_top(), 0, item); } else if (selected == UNIGNORE_THIS_ITEM) { o_ptr->ignore = FALSE; } else if (selected == IGNORE_THIS_FLAVOR) { object_squelch_flavor_of(o_ptr); } else if (selected == UNIGNORE_THIS_FLAVOR) { kind_squelch_clear(o_ptr->kind); } else if (selected == IGNORE_THIS_QUALITY) { byte value = squelch_level_of(o_ptr); int type = squelch_type_of(o_ptr); squelch_level[type] = value; } p_ptr->notice |= PN_SQUELCH; menu_dynamic_free(m); }