Esempio n. 1
0
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;
}
Esempio n. 2
0
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;
}