/** * Add base power for jewelry */ static int jewelry_power(const object_type *obj, int p) { if (tval_is_jewelry(obj)) { p += BASE_JEWELRY_POWER; log_obj(format("Adding %d power for jewelry, total is %d\n", BASE_JEWELRY_POWER, p)); } return p; }
/** * 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; int i; if (!obj->known) return IGNORE_MAX; /* Deal with jewelry specially - only bad or average */ if (tval_is_jewelry(obj)) { /* One positive modifier means not bad*/ for (i = 0; i < OBJ_MOD_MAX; i++) if (obj->known->modifiers[i] > 0) return IGNORE_AVERAGE; /* One positive combat value means not bad, one negative means bad */ if ((obj->known->to_h > 0) || (obj->known->to_d > 0) || (obj->known->to_a > 0)) return IGNORE_AVERAGE; if ((obj->known->to_h < 0) || (obj->known->to_d < 0) || (obj->known->to_a < 0)) return IGNORE_BAD; return IGNORE_AVERAGE; } /* Now just do bad, average, good, ego */ if (object_fully_known(obj)) { int isgood = is_object_good(obj); /* Values for items not egos or artifacts, may be updated */ if (isgood > 0) { value = IGNORE_GOOD; } else if (isgood < 0) { value = IGNORE_BAD; } else { value = IGNORE_AVERAGE; } if (obj->ego) value = IGNORE_ALL; else if (obj->artifact) value = IGNORE_MAX; } else { if ((obj->known->notice & OBJ_NOTICE_ASSESSED) && !obj->artifact) value = IGNORE_ALL; else value = IGNORE_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 if an item can "absorb" a second item * * See "object_absorb()" for the actual "absorption" code. * * If permitted, we allow weapons/armor to stack, if "known". * * Missiles will combine if both stacks have the same "known" status. * This is done to make unidentified stacks of missiles useful. * * Food, potions, scrolls, and "easy know" items always stack. * * Chests, and activatable items, except rods, never stack (for various * reasons). */ bool object_stackable(const struct object *obj1, const struct object *obj2, object_stack_t mode) { int i; /* Equipment items don't stack */ if (object_is_equipped(player->body, obj1)) return false; if (object_is_equipped(player->body, obj2)) return false; /* If either item is unknown, do not stack */ if (mode & OSTACK_LIST && obj1->kind != obj1->known->kind) return false; if (mode & OSTACK_LIST && obj2->kind != obj2->known->kind) return false; /* Hack -- identical items cannot be stacked */ if (obj1 == obj2) return false; /* Require identical object kinds */ if (obj1->kind != obj2->kind) return false; /* Different flags don't stack */ if (!of_is_equal(obj1->flags, obj2->flags)) return false; /* Different elements don't stack */ for (i = 0; i < ELEM_MAX; i++) { if (obj1->el_info[i].res_level != obj2->el_info[i].res_level) return false; if ((obj1->el_info[i].flags & (EL_INFO_HATES | EL_INFO_IGNORE)) != (obj2->el_info[i].flags & (EL_INFO_HATES | EL_INFO_IGNORE))) return false; } /* Artifacts never stack */ if (obj1->artifact || obj2->artifact) return false; /* Analyze the items */ if (tval_is_chest(obj1)) { /* Chests never stack */ return false; } else if (tval_is_edible(obj1) || tval_is_potion(obj1) || tval_is_scroll(obj1) || tval_is_rod(obj1)) { /* Food, potions, scrolls and rods all stack nicely, since the kinds are identical, either both will be aware or both will be unaware */ } else if (tval_can_have_charges(obj1) || tval_is_money(obj1)) { /* Gold, staves and wands stack most of the time */ /* Too much gold or too many charges */ if (obj1->pval + obj2->pval > MAX_PVAL) return false; /* ... otherwise ok */ } else if (tval_is_weapon(obj1) || tval_is_armor(obj1) || tval_is_jewelry(obj1) || tval_is_light(obj1)) { bool obj1_is_known = object_fully_known((struct object *)obj1); bool obj2_is_known = object_fully_known((struct object *)obj2); /* Require identical values */ if (obj1->ac != obj2->ac) return false; if (obj1->dd != obj2->dd) return false; if (obj1->ds != obj2->ds) return false; /* Require identical bonuses */ if (obj1->to_h != obj2->to_h) return false; if (obj1->to_d != obj2->to_d) return false; if (obj1->to_a != obj2->to_a) return false; /* Require all identical modifiers */ for (i = 0; i < OBJ_MOD_MAX; i++) if (obj1->modifiers[i] != obj2->modifiers[i]) return (false); /* Require identical ego-item types */ if (obj1->ego != obj2->ego) return false; /* Require identical curses */ if (!curses_are_equal(obj1->curses, obj2->curses)) return false; /* Hack - Never stack recharging wearables ... */ if ((obj1->timeout || obj2->timeout) && !tval_is_light(obj1)) return false; /* ... and lights must have same amount of fuel */ else if ((obj1->timeout != obj2->timeout) && tval_is_light(obj1)) return false; /* Prevent unIDd items stacking with IDd items in the object list */ if (mode & OSTACK_LIST && (obj1_is_known != obj2_is_known)) return false; } else { /* Anything else probably okay */ } /* Require compatible inscriptions */ if (obj1->note && obj2->note && (obj1->note != obj2->note)) return false; /* They must be similar enough */ return true; }
/** * 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; }