/* * 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; }
/** * Drop all {squelch}able items. */ extern void squelch_drop(void) { int n; /* Scan through the slots backwards */ for (n = INVEN_PACK - 1; n >= 0; n--) { object_type *o_ptr = &p_ptr->inventory[n]; /* Skip non-objects and unsquelchable objects */ if (!o_ptr->k_idx) continue; if (!squelch_item_ok(o_ptr)) continue; /* Check for curses */ if (cf_has(o_ptr->flags_curse, CF_STICKY_CARRY)) continue; /* Check for !d (no drop) inscription */ if (!check_for_inscrip(o_ptr, "!d") && !check_for_inscrip(o_ptr, "!*")) { /* We're allowed to drop it. */ inven_drop(n, o_ptr->number); } } /* Combine/reorder the pack */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); }
/* * Hack -- allow user to "prevent" certain choices. * * The item can be negative to mean "item on floor". */ static bool get_item_allow(int item, unsigned char ch, bool is_harmless) { object_type *o_ptr; char verify_inscrip[] = "!*"; unsigned n; /* Inventory or floor */ if (item >= 0) o_ptr = &p_ptr->inventory[item]; else o_ptr = object_byid(0 - item); /* Check for a "prevention" inscription */ verify_inscrip[1] = ch; /* Find both sets of inscriptions, add together, and prompt that number of times */ n = check_for_inscrip(o_ptr, verify_inscrip); if (!is_harmless) n += check_for_inscrip(o_ptr, "!*"); while (n--) { if (!verify_item("Really try", item)) return (FALSE); } /* Allow it */ return (TRUE); }
/** * Check no currently worn items are stopping the action 'c' */ bool key_confirm_command(unsigned char c) { int i; /* Hack -- Scan equipment */ for (i = INVEN_WIELD; i < INVEN_TOTAL; i++) { char verify_inscrip[] = "^*"; unsigned n; object_type *o_ptr = &p_ptr->inventory[i]; if (!o_ptr->kind) continue; /* Set up string to look for, e.g. "^d" */ verify_inscrip[1] = c; /* Verify command */ n = check_for_inscrip(o_ptr, "^*") + check_for_inscrip(o_ptr, verify_inscrip); while (n--) { if (!get_check("Are you sure? ")) return FALSE; } } return TRUE; }
/** * 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]; }
/** * Check no currently worn items are stopping the action 'c' */ bool key_confirm_command(unsigned char c) { int i; /* Hack -- Scan equipment */ for (i = 0; i < player->body.count; i++) { char verify_inscrip[] = "^*"; unsigned n; struct object *obj = slot_object(player, i); if (!obj) continue; /* Set up string to look for, e.g. "^d" */ verify_inscrip[1] = c; /* Verify command */ n = check_for_inscrip(obj, "^*") + check_for_inscrip(obj, verify_inscrip); while (n--) { if (!get_check("Are you sure? ")) return false; } } return true; }
/** * Return TRUE if the given object can be automatically picked up */ static bool auto_pickup_okay(object_type * o_ptr) { if (!inven_carry_okay(o_ptr)) return FALSE; if (OPT(pickup_always) || check_for_inscrip(o_ptr, "=g")) return TRUE; if (check_for_inscrip(o_ptr, "@f") || check_for_inscrip(o_ptr, "@v")) return TRUE; if (OPT(pickup_inven) && inven_stack_okay(o_ptr)) return TRUE; return FALSE; }
/** * Drop all {ignore}able items. */ void ignore_drop(void) { struct object *obj; /* Scan through the slots backwards */ for (obj = gear_last_item(); obj; obj = obj->prev) { /* Skip non-objects and unignoreable objects */ assert(obj->kind); if (!ignore_item_ok(obj)) continue; /* Check for !d (no drop) inscription */ if (!check_for_inscrip(obj, "!d") && !check_for_inscrip(obj, "!*")) { /* Confirm the drop if the item is equipped. */ if (object_is_equipped(player->body, obj)) { if (!verify_object("Really take off and drop", obj)) { /* Hack - inscribe the item with !d to prevent repeated * confirmations. */ const char *inscription = quark_str(obj->note); if (inscription == NULL) { obj->note = quark_add("!d"); } else { char buffer[1024]; my_strcpy(buffer, inscription, sizeof(buffer)); my_strcat(buffer, "!d", sizeof(buffer)); obj->note = quark_add(buffer); } continue; } } /* We're allowed to drop it. */ if (!square_isshop(cave, player->py, player->px)) { player->upkeep->dropping = true; cmdq_push(CMD_DROP); cmd_set_arg_item(cmdq_peek(), "item", obj); cmd_set_arg_number(cmdq_peek(), "quantity", obj->number); } } } /* Update the gear */ player->upkeep->update |= (PU_INVEN); /* Combine/reorder the pack */ player->upkeep->notice |= (PN_COMBINE); }
/* * Hack -- prevent certain choices depending on the inscriptions on the item. * * The item can be negative to mean "item on floor". */ bool get_item_allow(int item, unsigned char ch, cmd_code cmd, bool is_harmless) { object_type *o_ptr; char verify_inscrip[] = "!*"; unsigned n; /* Inventory or floor */ if (item >= 0) o_ptr = &p_ptr->inventory[item]; else o_ptr = object_byid(0 - item); /* Hack - Only shift the command key if it actually needs to be shifted. */ if (ch < 0x20) ch = UN_KTRL(ch); /* The inscription to look for */ verify_inscrip[1] = ch; /* Look for the inscription */ n = check_for_inscrip(o_ptr, verify_inscrip); /* Also look for for the inscription '!*' */ if (!is_harmless) n += check_for_inscrip(o_ptr, "!*"); /* Choose string for the prompt */ if (n) { char prompt[1024]; const char *verb = cmd_get_verb(cmd); if (!verb) verb = "do that with"; strnfmt(prompt, sizeof(prompt), "Really %s", verb); /* Promt for confirmation n times */ while (n--) { if (!verify_item(prompt, item)) return (FALSE); } } /* Allow it */ return (TRUE); }
/** * Determine if an object can be picked up automatically. */ static bool auto_pickup_okay(const struct object *obj) { if (!inven_carry_okay(obj)) return FALSE; if (OPT(pickup_always) || check_for_inscrip(obj, "=g")) return TRUE; if (OPT(pickup_inven) && inven_stack_okay(obj)) return TRUE; return FALSE; }
/* * Determine if the object can be picked up automatically. */ static bool auto_pickup_okay(const object_type *o_ptr) { if (!inven_carry_okay(o_ptr)) return false; if (OPT(pickup_always) || check_for_inscrip(o_ptr, "=g")) return true; if (OPT(pickup_inven) && inven_stack_okay(o_ptr)) 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; }
/** * Prevent certain choices depending on the inscriptions on the item. * * The item can be negative to mean "item on floor". */ bool get_item_allow(const struct object *obj, unsigned char ch, cmd_code cmd, bool is_harmless) { char verify_inscrip[] = "!*"; unsigned n; /* Hack - Only shift the command key if it actually needs to be shifted. */ if (ch < 0x20) ch = UN_KTRL(ch); /* The inscription to look for */ verify_inscrip[1] = ch; /* Look for the inscription */ n = check_for_inscrip(obj, verify_inscrip); /* Also look for for the inscription '!*' */ if (!is_harmless) n += check_for_inscrip(obj, "!*"); /* Choose string for the prompt */ if (n) { char prompt_buf[1024]; const char *verb = cmd_verb(cmd); if (!verb) verb = "do that with"; strnfmt(prompt_buf, sizeof(prompt_buf), "Really %s", verb); /* Prompt for confirmation n times */ while (n--) { if (!verify_object(prompt_buf, (struct object *) obj)) return (false); } } /* Allow it */ return (true); }
/* Wield or wear an item */ void do_cmd_wield(cmd_code code, cmd_arg args[]) { object_type *equip_o_ptr; char o_name[80]; unsigned n; int item = args[0].item; int slot = args[1].number; object_type *o_ptr = object_from_item_idx(item); if (!item_is_available(item, NULL, USE_INVEN | USE_FLOOR)) { msg("You do not have that item to wield."); return; } /* Check the slot */ if (!slot_can_wield_item(slot, o_ptr)) { msg("You cannot wield that item there."); return; } equip_o_ptr = &p_ptr->inventory[slot]; /* If the slot is open, wield and be done */ if (!equip_o_ptr->kind) { wield_item(o_ptr, item, slot); return; } /* If the slot is in the quiver and objects can be combined */ if (obj_is_ammo(equip_o_ptr) && object_similar(equip_o_ptr, o_ptr, OSTACK_QUIVER)) { wield_item(o_ptr, item, slot); return; } /* Prevent wielding into a cursed slot */ if (cursed_p(equip_o_ptr->flags)) { object_desc(o_name, sizeof(o_name), equip_o_ptr, ODESC_BASE); msg("The %s you are %s appears to be cursed.", o_name, describe_use(slot)); return; } /* "!t" checks for taking off */ n = check_for_inscrip(equip_o_ptr, "!t"); while (n--) { /* Prompt */ object_desc(o_name, sizeof(o_name), equip_o_ptr, ODESC_PREFIX | ODESC_FULL); /* Forget it */ if (!get_check(format("Really take off %s? ", o_name))) return; } wield_item(o_ptr, item, slot); }
/** * 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; }