| 1351 | | * Armor is worth an extra 100 gold per bonus point to armor class. |
| 1352 | | * |
| 1353 | | * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD). |
| 1354 | | * |
| 1355 | | * Missiles are only worth 5 gold per bonus point, since they |
| 1356 | | * usually appear in groups of 20, and we want the player to get |
| 1357 | | * the same amount of cash for any "equivalent" item. Note that |
| 1358 | | * missiles never have any of the "pval" flags, and in fact, they |
| 1359 | | * only have a few of the available flags, primarily of the "slay" |
| 1360 | | * and "brand" and "ignore" variety. |
| 1361 | | * |
| 1362 | | * Weapons with negative hit+damage bonuses are worthless. |
| 1363 | | * |
| 1364 | | * Every wearable item with a "pval" bonus is worth extra (see below). |
| | 1351 | * Wearable items (weapons, launchers, jewelry, lights, armour) and ammo |
| | 1352 | * are priced according to their power rating. All ammo, and normal (non-ego) |
| | 1353 | * torches are scaled down by AMMO_RESCALER to reflect their impermanence. |
| 1434 | | |
| 1435 | | |
| 1436 | | /* Artifact */ |
| 1437 | | if (o_ptr->name1) |
| 1438 | | { |
| 1439 | | artifact_type *a_ptr = &a_info[o_ptr->name1]; |
| 1440 | | |
| 1441 | | /* Hack -- "worthless" artifacts */ |
| 1442 | | if (!a_ptr->cost) return (0L); |
| 1443 | | |
| 1444 | | /* Hack -- Use the artifact cost instead */ |
| 1445 | | value = a_ptr->cost; |
| 1446 | | } |
| 1447 | | |
| 1448 | | /* Ego-Item */ |
| 1449 | | else if (o_ptr->name2) |
| 1450 | | { |
| 1451 | | ego_item_type *e_ptr = &e_info[o_ptr->name2]; |
| 1452 | | |
| 1453 | | /* Hack -- "worthless" ego-items */ |
| 1454 | | if (!e_ptr->cost) return (0L); |
| 1455 | | |
| 1456 | | /* Hack -- Reward the ego-item with a bonus */ |
| 1457 | | value += e_ptr->cost; |
| 1458 | | } |
| 1459 | | |
| 1460 | | |
| 1461 | | /* Analyze pval bonus */ |
| 1462 | | switch (o_ptr->tval) |
| 1463 | | { |
| 1464 | | case TV_SHOT: |
| 1465 | | case TV_ARROW: |
| 1466 | | case TV_BOLT: |
| 1467 | | case TV_BOW: |
| 1468 | | case TV_DIGGING: |
| 1469 | | case TV_HAFTED: |
| 1470 | | case TV_POLEARM: |
| 1471 | | case TV_SWORD: |
| 1472 | | case TV_BOOTS: |
| 1473 | | case TV_GLOVES: |
| 1474 | | case TV_HELM: |
| 1475 | | case TV_CROWN: |
| 1476 | | case TV_SHIELD: |
| 1477 | | case TV_CLOAK: |
| 1478 | | case TV_SOFT_ARMOR: |
| 1479 | | case TV_HARD_ARMOR: |
| 1480 | | case TV_DRAG_ARMOR: |
| 1481 | | case TV_LITE: |
| 1482 | | case TV_AMULET: |
| 1483 | | case TV_RING: |
| 1484 | | { |
| 1485 | | /* Hack -- Negative "pval" is always bad */ |
| 1486 | | if (o_ptr->pval < 0) return (0L); |
| 1487 | | |
| 1488 | | /* No pval */ |
| 1489 | | if (!o_ptr->pval) break; |
| 1490 | | |
| 1491 | | /* Give credit for stat bonuses */ |
| 1492 | | if (f[0] & (TR0_STR)) value += (o_ptr->pval * 200L); |
| 1493 | | if (f[0] & (TR0_INT)) value += (o_ptr->pval * 200L); |
| 1494 | | if (f[0] & (TR0_WIS)) value += (o_ptr->pval * 200L); |
| 1495 | | if (f[0] & (TR0_DEX)) value += (o_ptr->pval * 200L); |
| 1496 | | if (f[0] & (TR0_CON)) value += (o_ptr->pval * 200L); |
| 1497 | | if (f[0] & (TR0_CHR)) value += (o_ptr->pval * 200L); |
| 1498 | | |
| 1499 | | /* Give credit for stealth and searching */ |
| 1500 | | if (f[0] & (TR0_STEALTH)) value += (o_ptr->pval * 100L); |
| 1501 | | if (f[0] & (TR0_SEARCH)) value += (o_ptr->pval * 100L); |
| 1502 | | |
| 1503 | | /* Give credit for infra-vision and tunneling */ |
| 1504 | | if (f[0] & (TR0_INFRA)) value += (o_ptr->pval * 50L); |
| 1505 | | if (f[0] & (TR0_TUNNEL)) value += (o_ptr->pval * 50L); |
| 1506 | | |
| 1507 | | /* Give credit for extra attacks */ |
| 1508 | | if (f[0] & (TR0_BLOWS)) value += (o_ptr->pval * 2000L); |
| 1509 | | |
| 1510 | | /* Give credit for speed bonus */ |
| 1511 | | if (f[0] & (TR0_SPEED)) value += (o_ptr->pval * 30000L); |
| 1512 | | |
| 1513 | | break; |
| 1514 | | } |
| 1515 | | } |
| 1516 | | |
| 1540 | | /* Rings/Amulets, Lites */ |
| 1541 | | case TV_RING: |
| 1542 | | case TV_AMULET: |
| 1543 | | { |
| 1544 | | /* Hack -- negative bonuses are bad */ |
| 1545 | | if (o_ptr->to_a < 0) return (0L); |
| 1546 | | if (o_ptr->to_h < 0) return (0L); |
| 1547 | | if (o_ptr->to_d < 0) return (0L); |
| 1548 | | |
| 1549 | | /* Give credit for bonuses */ |
| 1550 | | value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L); |
| 1551 | | |
| 1552 | | /* Calculate total value */ |
| 1553 | | total_value = value * qty; |
| 1554 | | |
| 1555 | | /* Done */ |
| 1556 | | break; |
| 1557 | | } |
| 1558 | | |
| 1559 | | /* Armor */ |
| 1560 | | case TV_BOOTS: |
| 1561 | | case TV_GLOVES: |
| 1562 | | case TV_CLOAK: |
| 1563 | | case TV_CROWN: |
| 1564 | | case TV_HELM: |
| 1565 | | case TV_SHIELD: |
| 1566 | | case TV_SOFT_ARMOR: |
| 1567 | | case TV_HARD_ARMOR: |
| 1568 | | case TV_DRAG_ARMOR: |
| 1569 | | { |
| 1570 | | /* Give credit for hit bonus */ |
| 1571 | | value += ((o_ptr->to_h - k_ptr->to_h) * 100L); |
| 1572 | | |
| 1573 | | /* Give credit for damage bonus */ |
| 1574 | | value += ((o_ptr->to_d - k_ptr->to_d) * 100L); |
| 1575 | | |
| 1576 | | /* Give credit for armor bonus */ |
| 1577 | | value += (o_ptr->to_a * 100L); |
| 1578 | | |
| 1579 | | /* Calculate total value */ |
| 1580 | | total_value = value * qty; |
| 1581 | | |
| 1582 | | /* Done */ |
| 1583 | | break; |
| 1584 | | } |
| 1585 | | |
| 1586 | | /* Bows/Weapons */ |
| 1587 | | case TV_BOW: |
| 1588 | | case TV_DIGGING: |
| 1589 | | case TV_HAFTED: |
| 1590 | | case TV_SWORD: |
| 1591 | | case TV_POLEARM: |
| 1592 | | { |
| 1593 | | /* Hack -- negative hit/damage bonuses */ |
| 1594 | | if (o_ptr->to_h + o_ptr->to_d < 0) return (0L); |
| 1595 | | |
| 1596 | | /* Factor in the bonuses */ |
| 1597 | | value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L); |
| 1598 | | |
| 1599 | | /* Hack -- Factor in extra damage dice */ |
| 1600 | | if ((o_ptr->dd > k_ptr->dd) && (o_ptr->ds == k_ptr->ds)) |
| 1601 | | { |
| 1602 | | value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 100L; |
| 1603 | | } |
| 1604 | | |
| 1605 | | /* Calculate total value */ |
| 1606 | | total_value = value * qty; |
| 1607 | | |
| 1608 | | /* Done */ |
| 1609 | | break; |
| 1610 | | } |
| 1611 | | |
| 1612 | | /* Ammo */ |
| 1613 | | case TV_SHOT: |
| 1614 | | case TV_ARROW: |
| 1615 | | case TV_BOLT: |
| 1616 | | { |
| 1617 | | /* Hack -- negative hit/damage bonuses */ |
| 1618 | | if (o_ptr->to_h + o_ptr->to_d < 0) return (0L); |
| 1619 | | |
| 1620 | | /* Factor in the bonuses */ |
| 1621 | | value += ((o_ptr->to_h + o_ptr->to_d) * 5L); |
| 1622 | | |
| 1623 | | /* Hack -- Factor in extra damage dice */ |
| 1624 | | if ((o_ptr->dd > k_ptr->dd) && (o_ptr->ds == k_ptr->ds)) |
| 1625 | | { |
| 1626 | | value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L; |
| 1627 | | } |
| 1628 | | |
| 1629 | | /* Calculate total value */ |
| 1630 | | total_value = value * qty; |
| 1631 | | |
| 1632 | | /* Done */ |
| 1633 | | break; |
| 1634 | | } |
| 1635 | | |