static size_t obj_desc_combat(const object_type *o_ptr, char *buf, size_t max, size_t end, bool spoil) { bitflag flags[OF_SIZE]; bitflag flags_known[OF_SIZE]; object_flags(o_ptr, flags); object_flags_known(o_ptr, flags_known); if (of_has(flags, OF_SHOW_DICE)) { /* Only display the real damage dice if the combat stats are known */ if (spoil || object_attack_plusses_are_visible(o_ptr)) strnfcat(buf, max, &end, " (%dd%d)", o_ptr->dd, o_ptr->ds); else strnfcat(buf, max, &end, " (%dd%d)", o_ptr->kind->dd, o_ptr->kind->ds); } if (of_has(flags, OF_SHOW_MULT)) { /* Display shooting power as part of the multiplier */ if (of_has(flags, OF_MIGHT) && (spoil || object_flag_is_known(o_ptr, OF_MIGHT))) strnfcat(buf, max, &end, " (x%d)", (o_ptr->sval % 10) + o_ptr->pval[which_pval(o_ptr, OF_MIGHT)]); else strnfcat(buf, max, &end, " (x%d)", o_ptr->sval % 10); } /* Show weapon bonuses */ if (spoil || object_attack_plusses_are_visible(o_ptr)) { if (wield_slot(o_ptr) == INVEN_WIELD || wield_slot(o_ptr) == INVEN_BOW || obj_is_ammo(o_ptr) || o_ptr->to_d || o_ptr->to_h) { /* Make an exception for body armor with only a to-hit penalty */ if (o_ptr->to_h < 0 && o_ptr->to_d == 0 && (o_ptr->tval == TV_SOFT_ARMOR || o_ptr->tval == TV_HARD_ARMOR || o_ptr->tval == TV_DRAG_ARMOR)) strnfcat(buf, max, &end, " (%+d)", o_ptr->to_h); /* Otherwise, always use the full tuple */ else strnfcat(buf, max, &end, " (%+d,%+d)", o_ptr->to_h, o_ptr->to_d); } } /* Show armor bonuses */ if (spoil || object_defence_plusses_are_visible(o_ptr)) { if (obj_desc_show_armor(o_ptr)) strnfcat(buf, max, &end, " [%d,%+d]", o_ptr->ac, o_ptr->to_a); else if (o_ptr->to_a) strnfcat(buf, max, &end, " [%+d]", o_ptr->to_a); } else if (obj_desc_show_armor(o_ptr)) strnfcat(buf, max, &end, " [%d]", object_was_sensed(o_ptr) ? o_ptr->ac : o_ptr->kind->ac); return end; }
/** * Describe combat properties of an item - damage dice, to-hit, to-dam, armor * class, missile multipler */ static size_t obj_desc_combat(const struct object *obj, char *buf, size_t max, size_t end, bool spoil) { bitflag flags_known[OF_SIZE]; object_flags_known(obj, flags_known); if (kf_has(obj->kind->kind_flags, KF_SHOW_DICE)) { /* Only display the real damage dice if the combat stats are known */ if (spoil || object_attack_plusses_are_visible(obj)) strnfcat(buf, max, &end, " (%dd%d)", obj->dd, obj->ds); else strnfcat(buf, max, &end, " (%dd%d)", obj->kind->dd, obj->kind->ds); } if (kf_has(obj->kind->kind_flags, KF_SHOW_MULT)) { /* Display shooting power as part of the multiplier */ if ((obj->modifiers[OBJ_MOD_MIGHT] > 0) && (spoil || object_this_mod_is_visible(obj, OBJ_MOD_MIGHT))) strnfcat(buf, max, &end, " (x%d)", obj->pval + obj->modifiers[OBJ_MOD_MIGHT]); else strnfcat(buf, max, &end, " (x%d)", obj->pval); } /* Show weapon bonuses */ if (spoil || object_attack_plusses_are_visible(obj)) { if (tval_is_weapon(obj) || obj->to_d || obj->to_h) { /* Make an exception for body armor with only a to-hit penalty */ if (obj->to_h < 0 && obj->to_d == 0 && tval_is_body_armor(obj)) strnfcat(buf, max, &end, " (%+d)", obj->to_h); /* Otherwise, always use the full tuple */ else strnfcat(buf, max, &end, " (%+d,%+d)", obj->to_h, obj->to_d); } } /* Show armor bonuses */ if (spoil || object_defence_plusses_are_visible(obj)) { if (obj_desc_show_armor(obj)) strnfcat(buf, max, &end, " [%d,%+d]", obj->ac, obj->to_a); else if (obj->to_a) strnfcat(buf, max, &end, " [%+d]", obj->to_a); } else if (obj_desc_show_armor(obj)) strnfcat(buf, max, &end, " [%d]", object_was_sensed(obj) ? obj->ac : obj->kind->ac); return end; }
static size_t obj_desc_combat(const object_type *o_ptr, char *buf, size_t max, size_t end, bool spoil) { object_kind *k_ptr = &k_info[o_ptr->k_idx]; u32b f1, f2, f3, fn, knownf1, knownf2, knownf3, knownfn; object_flags(o_ptr, &f1, &f2, &f3, &fn); object_flags_known(o_ptr, &knownf1, &knownf2, &knownf3, &knownfn); /* Dump base weapon info */ switch (o_ptr->tval) { /* Weapons */ case TV_SHOT: case TV_BOLT: case TV_ARROW: case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING: { /* Only display the real damage dice if the combat stats are known */ if ((spoil) || (object_known_p(o_ptr))) strnfcat(buf, max, &end, " (%dd%d)", o_ptr->dd, o_ptr->ds); else strnfcat(buf, max, &end, " (%dd%d)", k_ptr->dd, k_ptr->ds); break; } /* Missile launchers */ case TV_BOW: { /* Display shooting power as part of the multiplier */ if ((f1 & TR1_MIGHT) && (spoil || (knownf1 & TR1_MIGHT))) strnfcat(buf, max, &end, " (x%d)", (o_ptr->sval % 10) + o_ptr->pval); else strnfcat(buf, max, &end, " (x%d)", o_ptr->sval % 10); break; } } /* Show weapon bonuses */ if (spoil || object_known_p(o_ptr)) { if (obj_desc_show_weapon(o_ptr) || o_ptr->to_d || o_ptr->to_h) { /* Make an exception for body armor with only a to-hit penalty */ if (o_ptr->to_h < 0 && o_ptr->to_d == 0 && (o_ptr->tval == TV_SOFT_ARMOR || o_ptr->tval == TV_HARD_ARMOR || o_ptr->tval == TV_DRAG_ARMOR || o_ptr->tval == TV_DRAG_SHIELD)) strnfcat(buf, max, &end, " (%+d)", o_ptr->to_h); /* Otherwise, always use the full tuple */ else strnfcat(buf, max, &end, " (%+d,%+d)", o_ptr->to_h, o_ptr->to_d); } } /* Show armor bonuses */ if (spoil || object_known_p(o_ptr)) { if (obj_desc_show_armor(o_ptr)) strnfcat(buf, max, &end, " [%d,%+d]", o_ptr->ac, o_ptr->to_a); else if (o_ptr->to_a) strnfcat(buf, max, &end, " [%+d]", o_ptr->to_a); } else if (obj_desc_show_armor(o_ptr)) { strnfcat(buf, max, &end, " [%d]", o_ptr->ac); } return end; }
static size_t obj_desc_combat(const object_type * o_ptr, char *buf, size_t max, size_t end, bool spoil) { bool worn = (o_ptr->ident & IDENT_WORN); /* Dump base weapon info */ switch (o_ptr->tval) { /* Weapons */ case TV_SHOT: case TV_BOLT: case TV_ARROW: case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING: { /* Only display the damage dice if known */ if (spoil || if_has(o_ptr->id_other, IF_DD_DS)) strnfcat(buf, max, &end, " (%dd%d)", o_ptr->dd, o_ptr->ds); break; } /* Missile launchers */ case TV_BOW: { /* Extract the "base power", using the weapon's damage dice. */ int power = (o_ptr->dd); /* Modify the power, if the weapon is known. */ if (worn) { power += o_ptr->bonus_other[P_BONUS_MIGHT]; } /* Append a "power" string */ if (if_has(o_ptr->id_other, IF_DD_DS)) strnfcat(buf, max, &end, " (x%d)", power); break; } } /* Show weapon bonuses */ if (obj_desc_show_weapon(o_ptr)) { if (spoil || (if_has(o_ptr->id_other, IF_TO_H) && if_has(o_ptr->id_other, IF_TO_D))) strnfcat(buf, max, &end, " (%+d,%+d)", o_ptr->to_h, o_ptr->to_d); else if (if_has(o_ptr->id_other, IF_TO_H)) strnfcat(buf, max, &end, " (%+d,?)", o_ptr->to_h); else if (if_has(o_ptr->id_other, IF_TO_D)) strnfcat(buf, max, &end, " (?,%+d)", o_ptr->to_d); else strnfcat(buf, max, &end, " (?,?)"); } else if (obj_desc_show_to_hit(o_ptr)) { if (spoil || if_has(o_ptr->id_other, IF_TO_H)) strnfcat(buf, max, &end, " (%+d)", o_ptr->to_h); else strnfcat(buf, max, &end, " (?)"); } else if (obj_desc_show_to_dam(o_ptr)) { if (spoil || if_has(o_ptr->id_other, IF_TO_D)) strnfcat(buf, max, &end, " (%+d)", o_ptr->to_d); else strnfcat(buf, max, &end, " (?)"); } /* Show armor bonuses */ if (obj_desc_show_armor(o_ptr)){ bool back = p_ptr->state.shield_on_back && (wield_slot(o_ptr) == INVEN_ARM); int ac, to_a; ac = back ? o_ptr->ac / 3 : o_ptr->ac; to_a = back ? o_ptr->to_a / 2 : o_ptr->to_a; if (spoil || (if_has(o_ptr->id_other, IF_AC) && if_has(o_ptr->id_other, IF_TO_A))) strnfcat(buf, max, &end, " [%d,%+d]", ac, to_a); else if (if_has(o_ptr->id_other, IF_AC)) strnfcat(buf, max, &end, " [%d,?]", ac); else if (if_has(o_ptr->id_other, IF_TO_A)) strnfcat(buf, max, &end, " [?,%+d]", to_a); else strnfcat(buf, max, &end, " [?,?]"); } /* No base armor, but does increase armor */ else if (spoil || if_has(o_ptr->id_other, IF_TO_A)) strnfcat(buf, max, &end, " [%+d]", o_ptr->to_a); return end; }