| 1456 | | * Help determine an "enchantment bonus" for an object. |
|---|
| 1457 | | * |
|---|
| 1458 | | * To avoid floating point but still provide a smooth distribution of bonuses, |
|---|
| 1459 | | * we simply round the results of division in such a way as to "average" the |
|---|
| 1460 | | * correct floating point value. |
|---|
| 1461 | | * |
|---|
| 1462 | | * This function has been changed. It uses "Rand_normal()" to choose values |
|---|
| 1463 | | * from a normal distribution, whose mean moves from zero towards the max as |
|---|
| 1464 | | * the level increases, and whose standard deviation is equal to 1/4 of the |
|---|
| 1465 | | * max, and whose values are forced to lie between zero and the max, inclusive. |
|---|
| 1466 | | * |
|---|
| 1467 | | * Since the "level" rarely passes 100 before Morgoth is dead, it is very |
|---|
| 1468 | | * rare to get the "full" enchantment on an object, even a deep levels. |
|---|
| 1469 | | * |
|---|
| 1470 | | * It is always possible (albeit unlikely) to get the "full" enchantment. |
|---|
| 1471 | | * |
|---|
| 1472 | | * A sample distribution of values from "m_bonus(10, N)" is shown below: |
|---|
| 1473 | | * |
|---|
| 1474 | | * N 0 1 2 3 4 5 6 7 8 9 10 |
|---|
| 1475 | | * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- |
|---|
| 1476 | | * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03 |
|---|
| 1477 | | * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05 |
|---|
| 1478 | | * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05 |
|---|
| 1479 | | * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11 |
|---|
| 1480 | | * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41 |
|---|
| 1481 | | * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65 |
|---|
| 1482 | | * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94 |
|---|
| 1483 | | * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78 |
|---|
| 1484 | | * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64 |
|---|
| 1485 | | * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62 |
|---|
| 1486 | | * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33 |
|---|
| 1487 | | * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38 |
|---|
| 1488 | | * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53 |
|---|
| 1489 | | * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53 |
|---|
| 1490 | | * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27 |
|---|
| 1491 | | * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72 |
|---|
| 1492 | | * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07 |
|---|
| 1493 | | */ |
|---|
| 1494 | | static s16b m_bonus(int max, int level) |
|---|
| 1495 | | { |
|---|
| 1496 | | int bonus, stand, extra, value; |
|---|
| 1497 | | |
|---|
| 1498 | | |
|---|
| 1499 | | /* Paranoia -- enforce maximal "level" */ |
|---|
| 1500 | | if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1; |
|---|
| 1501 | | |
|---|
| 1502 | | |
|---|
| 1503 | | /* The "bonus" moves towards the max */ |
|---|
| 1504 | | bonus = ((max * level) / MAX_DEPTH); |
|---|
| 1505 | | |
|---|
| 1506 | | /* Hack -- determine fraction of error */ |
|---|
| 1507 | | extra = ((max * level) % MAX_DEPTH); |
|---|
| 1508 | | |
|---|
| 1509 | | /* Hack -- simulate floating point computations */ |
|---|
| 1510 | | if (rand_int(MAX_DEPTH) < extra) bonus++; |
|---|
| 1511 | | |
|---|
| 1512 | | |
|---|
| 1513 | | /* The "stand" is equal to one quarter of the max */ |
|---|
| 1514 | | stand = (max / 4); |
|---|
| 1515 | | |
|---|
| 1516 | | /* Hack -- determine fraction of error */ |
|---|
| 1517 | | extra = (max % 4); |
|---|
| 1518 | | |
|---|
| 1519 | | /* Hack -- simulate floating point computations */ |
|---|
| 1520 | | if (rand_int(4) < extra) stand++; |
|---|
| 1521 | | |
|---|
| 1522 | | |
|---|
| 1523 | | /* Choose an "interesting" value */ |
|---|
| 1524 | | value = Rand_normal(bonus, stand); |
|---|
| 1525 | | |
|---|
| 1526 | | /* Enforce the minimum value */ |
|---|
| 1527 | | if (value < 0) return (0); |
|---|
| 1528 | | |
|---|
| 1529 | | /* Enforce the maximum value */ |
|---|
| 1530 | | if (value > max) return (max); |
|---|
| 1531 | | |
|---|
| 1532 | | /* Result */ |
|---|
| 1533 | | return (value); |
|---|
| 1534 | | } |
|---|
| 1535 | | |
|---|
| 1536 | | |
|---|
| 1537 | | |
|---|
| 1538 | | |
|---|
| 1539 | | /* |
|---|
| 1540 | | * Cheat -- describe a created object for the user |
|---|
| 1541 | | */ |
|---|
| 1542 | | static void object_mention(const object_type *o_ptr) |
|---|
| 1543 | | { |
|---|
| 1544 | | char o_name[80]; |
|---|
| 1545 | | |
|---|
| 1546 | | /* Describe */ |
|---|
| 1547 | | object_desc_spoil(o_name, sizeof(o_name), o_ptr, FALSE, 0); |
|---|
| 1548 | | |
|---|
| 1549 | | /* Artifact */ |
|---|
| 1550 | | if (artifact_p(o_ptr)) |
|---|
| 1551 | | { |
|---|
| 1552 | | /* Silly message */ |
|---|
| 1553 | | msg_format("Artifact (%s)", o_name); |
|---|
| 1554 | | } |
|---|
| 1555 | | |
|---|
| 1556 | | /* Ego-item */ |
|---|
| 1557 | | else if (ego_item_p(o_ptr)) |
|---|
| 1558 | | { |
|---|
| 1559 | | /* Silly message */ |
|---|
| 1560 | | msg_format("Ego-item (%s)", o_name); |
|---|
| 1561 | | } |
|---|
| 1562 | | |
|---|
| 1563 | | /* Normal item */ |
|---|
| 1564 | | else |
|---|
| 1565 | | { |
|---|
| 1566 | | /* Silly message */ |
|---|
| 1567 | | msg_format("Object (%s)", o_name); |
|---|
| 1568 | | } |
|---|
| 1569 | | } |
|---|
| 1570 | | |
|---|
| 1571 | | |
|---|
| 1572 | | /* |
|---|
| 1573 | | * Attempt to change an object into an ego-item -MWK- |
|---|
| 1574 | | * Better only called by apply_magic(). |
|---|
| 1575 | | * The return value says if we picked a cursed item (if allowed) and is |
|---|
| 1576 | | * passed on to a_m_aux1/2(). |
|---|
| 1577 | | * If no legal ego item is found, this routine returns 0, resulting in |
|---|
| 1578 | | * an unenchanted item. |
|---|
| 1579 | | */ |
|---|
| 1580 | | static int make_ego_item(object_type *o_ptr, int level, bool only_good) |
|---|
| 1581 | | { |
|---|
| 1582 | | int i, j; |
|---|
| 1583 | | |
|---|
| 1584 | | int e_idx; |
|---|
| 1585 | | |
|---|
| 1586 | | long value, total; |
|---|
| 1587 | | |
|---|
| 1588 | | ego_item_type *e_ptr; |
|---|
| 1589 | | |
|---|
| 1590 | | alloc_entry *table = alloc_ego_table; |
|---|
| 1591 | | |
|---|
| 1592 | | |
|---|
| 1593 | | /* Fail if object already is ego or artifact */ |
|---|
| 1594 | | if (o_ptr->name1) return (FALSE); |
|---|
| 1595 | | if (o_ptr->name2) return (FALSE); |
|---|
| 1596 | | |
|---|
| 1597 | | /* Boost level (like with object base types) */ |
|---|
| 1598 | | if (level > 0) |
|---|
| 1599 | | { |
|---|
| 1600 | | /* Occasional "boost" */ |
|---|
| 1601 | | if (rand_int(GREAT_EGO) == 0) |
|---|
| 1602 | | { |
|---|
| 1603 | | /* The bizarre calculation again */ |
|---|
| 1604 | | level = 1 + (level * MAX_DEPTH / randint(MAX_DEPTH)); |
|---|
| 1605 | | } |
|---|
| 1606 | | } |
|---|
| 1607 | | |
|---|
| 1608 | | /* Reset total */ |
|---|
| 1609 | | total = 0L; |
|---|
| 1610 | | |
|---|
| 1611 | | /* Process probabilities */ |
|---|
| 1612 | | for (i = 0; i < alloc_ego_size; i++) |
|---|
| 1613 | | { |
|---|
| 1614 | | /* Default */ |
|---|
| 1615 | | table[i].prob3 = 0; |
|---|
| 1616 | | |
|---|
| 1617 | | /* Objects are sorted by depth */ |
|---|
| 1618 | | if (table[i].level > level) continue; |
|---|
| 1619 | | |
|---|
| 1620 | | /* Get the index */ |
|---|
| 1621 | | e_idx = table[i].index; |
|---|
| 1622 | | |
|---|
| 1623 | | /* Get the actual kind */ |
|---|
| 1624 | | e_ptr = &e_info[e_idx]; |
|---|
| 1625 | | |
|---|
| 1626 | | /* If we force good/great, don't create cursed */ |
|---|
| 1627 | | if (only_good && (e_ptr->flags3 & TR3_LIGHT_CURSE)) continue; |
|---|
| 1628 | | |
|---|
| 1629 | | /* Test if this is a legal ego-item type for this object */ |
|---|
| 1630 | | for (j = 0; j < EGO_TVALS_MAX; j++) |
|---|
| 1631 | | { |
|---|
| 1632 | | /* Require identical base type */ |
|---|
| 1633 | | if (o_ptr->tval == e_ptr->tval[j]) |
|---|
| 1634 | | { |
|---|
| 1635 | | /* Require sval in bounds, lower */ |
|---|
| 1636 | | if (o_ptr->sval >= e_ptr->min_sval[j]) |
|---|
| 1637 | | { |
|---|
| 1638 | | /* Require sval in bounds, upper */ |
|---|
| 1639 | | if (o_ptr->sval <= e_ptr->max_sval[j]) |
|---|
| 1640 | | { |
|---|
| 1641 | | /* Accept */ |
|---|
| 1642 | | table[i].prob3 = table[i].prob2; |
|---|
| 1643 | | } |
|---|
| 1644 | | } |
|---|
| 1645 | | } |
|---|
| 1646 | | } |
|---|
| 1647 | | |
|---|
| 1648 | | /* Total */ |
|---|
| 1649 | | total += table[i].prob3; |
|---|
| 1650 | | } |
|---|
| 1651 | | |
|---|
| 1652 | | /* No legal ego-items -- create a normal unenchanted one */ |
|---|
| 1653 | | if (total == 0) return (0); |
|---|
| 1654 | | |
|---|
| 1655 | | |
|---|
| 1656 | | /* Pick an ego-item */ |
|---|
| 1657 | | value = rand_int(total); |
|---|
| 1658 | | |
|---|
| 1659 | | /* Find the object */ |
|---|
| 1660 | | for (i = 0; i < alloc_ego_size; i++) |
|---|
| 1661 | | { |
|---|
| 1662 | | /* Found the entry */ |
|---|
| 1663 | | if (value < table[i].prob3) break; |
|---|
| 1664 | | |
|---|
| 1665 | | /* Decrement */ |
|---|
| 1666 | | value = value - table[i].prob3; |
|---|
| 1667 | | } |
|---|
| 1668 | | |
|---|
| 1669 | | /* We have one */ |
|---|
| 1670 | | e_idx = (byte)table[i].index; |
|---|
| 1671 | | o_ptr->name2 = e_idx; |
|---|
| 1672 | | |
|---|
| 1673 | | return ((e_info[e_idx].flags3 & TR3_LIGHT_CURSE) ? -2 : 2); |
|---|
| 1674 | | } |
|---|
| 1675 | | |
|---|
| 1676 | | |
|---|
| 1677 | | /* |
|---|
| 1678 | | * Mega-Hack -- Attempt to create one of the "Special Objects". |
|---|
| 1679 | | * |
|---|
| 1680 | | * We are only called from "make_object()", and we assume that |
|---|
| 1681 | | * "apply_magic()" is called immediately after we return. |
|---|
| 1682 | | * |
|---|
| 1683 | | * Note -- see "make_artifact()" and "apply_magic()". |
|---|
| 1684 | | * |
|---|
| 1685 | | * We *prefer* to create the special artifacts in order, but this is |
|---|
| 1686 | | * normally outweighed by the "rarity" rolls for those artifacts. The |
|---|
| 1687 | | * only major effect of this logic is that the Phial (with rarity one) |
|---|
| 1688 | | * is always the first special artifact created. |
|---|
| 1689 | | */ |
|---|
| 1690 | | static bool make_artifact_special(object_type *o_ptr, int level) |
|---|
| 1691 | | { |
|---|
| 1692 | | int i; |
|---|
| 1693 | | |
|---|
| 1694 | | int k_idx; |
|---|
| 1695 | | |
|---|
| 1696 | | |
|---|
| 1697 | | /* No artifacts, do nothing */ |
|---|
| 1698 | | if (adult_no_artifacts) return (FALSE); |
|---|
| 1699 | | |
|---|
| 1700 | | /* No artifacts in the town */ |
|---|
| 1701 | | if (!p_ptr->depth) return (FALSE); |
|---|
| 1702 | | |
|---|
| 1703 | | /* Check the special artifacts */ |
|---|
| 1704 | | for (i = 0; i < ART_MIN_NORMAL; ++i) |
|---|
| 1705 | | { |
|---|
| 1706 | | artifact_type *a_ptr = &a_info[i]; |
|---|
| 1707 | | |
|---|
| 1708 | | /* Skip "empty" artifacts */ |
|---|
| 1709 | | if (!a_ptr->name) continue; |
|---|
| 1710 | | |
|---|
| 1711 | | /* Cannot make an artifact twice */ |
|---|
| 1712 | | if (a_ptr->cur_num) continue; |
|---|
| 1713 | | |
|---|
| 1714 | | /* Enforce minimum "depth" (loosely) */ |
|---|
| 1715 | | if (a_ptr->level > p_ptr->depth) |
|---|
| 1716 | | { |
|---|
| 1717 | | /* Get the "out-of-depth factor" */ |
|---|
| 1718 | | int d = (a_ptr->level - p_ptr->depth) * 2; |
|---|
| 1719 | | |
|---|
| 1720 | | /* Roll for out-of-depth creation */ |
|---|
| 1721 | | if (rand_int(d) != 0) continue; |
|---|
| 1722 | | } |
|---|
| 1723 | | |
|---|
| 1724 | | /* Artifact "rarity roll" */ |
|---|
| 1725 | | if (rand_int(a_ptr->rarity) != 0) continue; |
|---|
| 1726 | | |
|---|
| 1727 | | /* Find the base object */ |
|---|
| 1728 | | k_idx = lookup_kind(a_ptr->tval, a_ptr->sval); |
|---|
| 1729 | | |
|---|
| 1730 | | /* Enforce minimum "object" level (loosely) */ |
|---|
| 1731 | | if (k_info[k_idx].level > level) |
|---|
| 1732 | | { |
|---|
| 1733 | | /* Get the "out-of-depth factor" */ |
|---|
| 1734 | | int d = (k_info[k_idx].level - level) * 5; |
|---|
| 1735 | | |
|---|
| 1736 | | /* Roll for out-of-depth creation */ |
|---|
| 1737 | | if (rand_int(d) != 0) continue; |
|---|
| 1738 | | } |
|---|
| 1739 | | |
|---|
| 1740 | | /* Assign the template */ |
|---|
| 1741 | | object_prep(o_ptr, k_idx); |
|---|
| 1742 | | |
|---|
| 1743 | | /* Mark the item as an artifact */ |
|---|
| 1744 | | o_ptr->name1 = i; |
|---|
| 1745 | | |
|---|
| 1746 | | /* Success */ |
|---|
| 1747 | | return (TRUE); |
|---|
| 1748 | | } |
|---|
| 1749 | | |
|---|
| 1750 | | /* Failure */ |
|---|
| 1751 | | return (FALSE); |
|---|
| 1752 | | } |
|---|
| 1753 | | |
|---|
| 1754 | | |
|---|
| 1755 | | /* |
|---|
| 1756 | | * Attempt to change an object into an artifact |
|---|
| 1757 | | * |
|---|
| 1758 | | * This routine should only be called by "apply_magic()" |
|---|
| 1759 | | * |
|---|
| 1760 | | * Note -- see "make_artifact_special()" and "apply_magic()" |
|---|
| 1761 | | */ |
|---|
| 1762 | | static bool make_artifact(object_type *o_ptr) |
|---|
| 1763 | | { |
|---|
| 1764 | | int i; |
|---|
| 1765 | | |
|---|
| 1766 | | |
|---|
| 1767 | | /* No artifacts, do nothing */ |
|---|
| 1768 | | if (adult_no_artifacts) return (FALSE); |
|---|
| 1769 | | |
|---|
| 1770 | | /* No artifacts in the town */ |
|---|
| 1771 | | if (!p_ptr->depth) return (FALSE); |
|---|
| 1772 | | |
|---|
| 1773 | | /* Paranoia -- no "plural" artifacts */ |
|---|
| 1774 | | if (o_ptr->number != 1) return (FALSE); |
|---|
| 1775 | | |
|---|
| 1776 | | /* Check the artifact list (skip the "specials") */ |
|---|
| 1777 | | for (i = ART_MIN_NORMAL; i < z_info->a_max; i++) |
|---|
| 1778 | | { |
|---|
| 1779 | | artifact_type *a_ptr = &a_info[i]; |
|---|
| 1780 | | |
|---|
| 1781 | | /* Skip "empty" items */ |
|---|
| 1782 | | if (!a_ptr->name) continue; |
|---|
| 1783 | | |
|---|
| 1784 | | /* Cannot make an artifact twice */ |
|---|
| 1785 | | if (a_ptr->cur_num) continue; |
|---|
| 1786 | | |
|---|
| 1787 | | /* Must have the correct fields */ |
|---|
| 1788 | | if (a_ptr->tval != o_ptr->tval) continue; |
|---|
| 1789 | | if (a_ptr->sval != o_ptr->sval) continue; |
|---|
| 1790 | | |
|---|
| 1791 | | /* XXX XXX Enforce minimum "depth" (loosely) */ |
|---|
| 1792 | | if (a_ptr->level > p_ptr->depth) |
|---|
| 1793 | | { |
|---|
| 1794 | | /* Get the "out-of-depth factor" */ |
|---|
| 1795 | | int d = (a_ptr->level - p_ptr->depth) * 2; |
|---|
| 1796 | | |
|---|
| 1797 | | /* Roll for out-of-depth creation */ |
|---|
| 1798 | | if (rand_int(d) != 0) continue; |
|---|
| 1799 | | } |
|---|
| 1800 | | |
|---|
| 1801 | | /* We must make the "rarity roll" */ |
|---|
| 1802 | | if (rand_int(a_ptr->rarity) != 0) continue; |
|---|
| 1803 | | |
|---|
| 1804 | | /* Mark the item as an artifact */ |
|---|
| 1805 | | o_ptr->name1 = i; |
|---|
| 1806 | | |
|---|
| 1807 | | /* Success */ |
|---|
| 1808 | | return (TRUE); |
|---|
| 1809 | | } |
|---|
| 1810 | | |
|---|
| 1811 | | /* Failure */ |
|---|
| 1812 | | return (FALSE); |
|---|
| 1813 | | } |
|---|
| 1814 | | |
|---|
| 1815 | | |
|---|
| 1816 | | |
|---|
| 1817 | | |
|---|
| 1818 | | /* |
|---|
| 1819 | | * Apply magic to an item known to be a "weapon" |
|---|
| 1820 | | * |
|---|
| 1821 | | * Hack -- note special base damage dice boosting |
|---|
| 1822 | | * Hack -- note special processing for weapon/digger |
|---|
| 1823 | | * Hack -- note special rating boost for dragon scale mail |
|---|
| 1824 | | */ |
|---|
| 1825 | | static void a_m_aux_1(object_type *o_ptr, int level, int power) |
|---|
| 1826 | | { |
|---|
| 1827 | | int tohit1 = randint(5) + m_bonus(5, level); |
|---|
| 1828 | | int todam1 = randint(5) + m_bonus(5, level); |
|---|
| 1829 | | |
|---|
| 1830 | | int tohit2 = m_bonus(10, level); |
|---|
| 1831 | | int todam2 = m_bonus(10, level); |
|---|
| 1832 | | |
|---|
| 1833 | | |
|---|
| 1834 | | /* Good */ |
|---|
| 1835 | | if (power > 0) |
|---|
| 1836 | | { |
|---|
| 1837 | | /* Enchant */ |
|---|
| 1838 | | o_ptr->to_h += tohit1; |
|---|
| 1839 | | o_ptr->to_d += todam1; |
|---|
| 1840 | | |
|---|
| 1841 | | /* Very good */ |
|---|
| 1842 | | if (power > 1) |
|---|
| 1843 | | { |
|---|
| 1844 | | /* Enchant again */ |
|---|
| 1845 | | o_ptr->to_h += tohit2; |
|---|
| 1846 | | o_ptr->to_d += todam2; |
|---|
| 1847 | | } |
|---|
| 1848 | | } |
|---|
| 1849 | | |
|---|
| 1850 | | /* Cursed */ |
|---|
| 1851 | | else if (power < 0) |
|---|
| 1852 | | { |
|---|
| 1853 | | /* Penalize */ |
|---|
| 1854 | | o_ptr->to_h -= tohit1; |
|---|
| 1855 | | o_ptr->to_d -= todam1; |
|---|
| 1856 | | |
|---|
| 1857 | | /* Very cursed */ |
|---|
| 1858 | | if (power < -1) |
|---|
| 1859 | | { |
|---|
| 1860 | | /* Penalize again */ |
|---|
| 1861 | | o_ptr->to_h -= tohit2; |
|---|
| 1862 | | o_ptr->to_d -= todam2; |
|---|
| 1863 | | } |
|---|
| 1864 | | |
|---|
| 1865 | | /* Cursed (if "bad") */ |
|---|
| 1866 | | if (o_ptr->to_h + o_ptr->to_d < 0) |
|---|
| 1867 | | o_ptr->flags3 |= TR3_LIGHT_CURSE; |
|---|
| 1868 | | } |
|---|
| 1869 | | |
|---|
| 1870 | | |
|---|
| 1871 | | /* Analyze type */ |
|---|
| 1872 | | switch (o_ptr->tval) |
|---|
| 1873 | | { |
|---|
| 1874 | | case TV_DIGGING: |
|---|
| 1875 | | { |
|---|
| 1876 | | /* Very bad */ |
|---|
| 1877 | | if (power < -1) |
|---|
| 1878 | | { |
|---|
| 1879 | | /* Hack -- Horrible digging bonus */ |
|---|
| 1880 | | o_ptr->pval = 0 - (5 + randint(5)); |
|---|
| 1881 | | } |
|---|
| 1882 | | |
|---|
| 1883 | | /* Bad */ |
|---|
| 1884 | | else if (power < 0) |
|---|
| 1885 | | { |
|---|
| 1886 | | /* Hack -- Reverse digging bonus */ |
|---|
| 1887 | | o_ptr->pval = 0 - (o_ptr->pval); |
|---|
| 1888 | | } |
|---|
| 1889 | | |
|---|
| 1890 | | break; |
|---|
| 1891 | | } |
|---|
| 1892 | | |
|---|
| 1893 | | |
|---|
| 1894 | | case TV_HAFTED: |
|---|
| 1895 | | case TV_POLEARM: |
|---|
| 1896 | | case TV_SWORD: |
|---|
| 1897 | | { |
|---|
| 1898 | | /* Very Good */ |
|---|
| 1899 | | if (power > 1) |
|---|
| 1900 | | { |
|---|
| 1901 | | /* Hack -- Super-charge the damage dice */ |
|---|
| 1902 | | while ((o_ptr->dd * o_ptr->ds > 0) && |
|---|
| 1903 | | (rand_int(10L * o_ptr->dd * o_ptr->ds) == 0)) |
|---|
| 1904 | | { |
|---|
| 1905 | | o_ptr->dd++; |
|---|
| 1906 | | } |
|---|
| 1907 | | |
|---|
| 1908 | | /* Hack -- Lower the damage dice */ |
|---|
| 1909 | | if (o_ptr->dd > 9) o_ptr->dd = 9; |
|---|
| 1910 | | } |
|---|
| 1911 | | |
|---|
| 1912 | | break; |
|---|
| 1913 | | } |
|---|
| 1914 | | |
|---|
| 1915 | | |
|---|
| 1916 | | case TV_BOLT: |
|---|
| 1917 | | case TV_ARROW: |
|---|
| 1918 | | case TV_SHOT: |
|---|
| 1919 | | { |
|---|
| 1920 | | /* Very good */ |
|---|
| 1921 | | if (power > 1) |
|---|
| 1922 | | { |
|---|
| 1923 | | /* Hack -- super-charge the damage dice */ |
|---|
| 1924 | | while ((o_ptr->dd * o_ptr->ds > 0) && |
|---|
| 1925 | | (rand_int(10L * o_ptr->dd * o_ptr->ds) == 0)) |
|---|
| 1926 | | { |
|---|
| 1927 | | o_ptr->dd++; |
|---|
| 1928 | | } |
|---|
| 1929 | | |
|---|
| 1930 | | /* Hack -- restrict the damage dice */ |
|---|
| 1931 | | if (o_ptr->dd > 9) o_ptr->dd = 9; |
|---|
| 1932 | | } |
|---|
| 1933 | | |
|---|
| 1934 | | break; |
|---|
| 1935 | | } |
|---|
| 1936 | | } |
|---|
| 1937 | | } |
|---|
| 1938 | | |
|---|
| 1939 | | |
|---|
| 1940 | | /* |
|---|
| 1941 | | * Apply magic to an item known to be "armor" |
|---|
| 1942 | | * |
|---|
| 1943 | | * Hack -- note special processing for crown/helm |
|---|
| 1944 | | * Hack -- note special processing for robe of permanence |
|---|
| 1945 | | */ |
|---|
| 1946 | | static void a_m_aux_2(object_type *o_ptr, int level, int power) |
|---|
| 1947 | | { |
|---|
| 1948 | | int toac1 = randint(5) + m_bonus(5, level); |
|---|
| 1949 | | |
|---|
| 1950 | | int toac2 = m_bonus(10, level); |
|---|
| 1951 | | |
|---|
| 1952 | | |
|---|
| 1953 | | /* Good */ |
|---|
| 1954 | | if (power > 0) |
|---|
| 1955 | | { |
|---|
| 1956 | | /* Enchant */ |
|---|
| 1957 | | o_ptr->to_a += toac1; |
|---|
| 1958 | | |
|---|
| 1959 | | /* Very good */ |
|---|
| 1960 | | if (power > 1) |
|---|
| 1961 | | { |
|---|
| 1962 | | /* Enchant again */ |
|---|
| 1963 | | o_ptr->to_a += toac2; |
|---|
| 1964 | | } |
|---|
| 1965 | | } |
|---|
| 1966 | | |
|---|
| 1967 | | /* Cursed */ |
|---|
| 1968 | | else if (power < 0) |
|---|
| 1969 | | { |
|---|
| 1970 | | /* Penalize */ |
|---|
| 1971 | | o_ptr->to_a -= toac1; |
|---|
| 1972 | | |
|---|
| 1973 | | /* Very cursed */ |
|---|
| 1974 | | if (power < -1) |
|---|
| 1975 | | { |
|---|
| 1976 | | /* Penalize again */ |
|---|
| 1977 | | o_ptr->to_a -= toac2; |
|---|
| 1978 | | } |
|---|
| 1979 | | |
|---|
| 1980 | | /* Cursed (if "bad") */ |
|---|
| 1981 | | if (o_ptr->to_a < 0) |
|---|
| 1982 | | o_ptr->flags3 |= TR3_LIGHT_CURSE; |
|---|
| 1983 | | } |
|---|
| 1984 | | |
|---|
| 1985 | | |
|---|
| 1986 | | /* Analyze type */ |
|---|
| 1987 | | switch (o_ptr->tval) |
|---|
| 1988 | | { |
|---|
| 1989 | | case TV_DRAG_ARMOR: |
|---|
| 1990 | | { |
|---|
| 1991 | | /* Rating boost */ |
|---|
| 1992 | | rating += 30; |
|---|
| 1993 | | |
|---|
| 1994 | | /* Mention the item */ |
|---|
| 1995 | | if (cheat_peek) object_mention(o_ptr); |
|---|
| 1996 | | |
|---|
| 1997 | | break; |
|---|
| 1998 | | } |
|---|
| 1999 | | } |
|---|
| 2000 | | } |
|---|
| 2001 | | |
|---|
| 2002 | | |
|---|
| 2003 | | |
|---|
| 2004 | | /* |
|---|
| 2005 | | * Apply magic to an item known to be a "ring" or "amulet" |
|---|
| 2006 | | * |
|---|
| 2007 | | * Hack -- note special rating boost for ring of speed |
|---|
| 2008 | | * Hack -- note special rating boost for certain amulets |
|---|
| 2009 | | * Hack -- note special "pval boost" code for ring of speed |
|---|
| 2010 | | * Hack -- note that some items must be cursed (or blessed) |
|---|
| 2011 | | */ |
|---|
| 2012 | | static void a_m_aux_3(object_type *o_ptr, int level, int power) |
|---|
| 2013 | | { |
|---|
| 2014 | | /* Apply magic (good or bad) according to type */ |
|---|
| 2015 | | switch (o_ptr->tval) |
|---|
| 2016 | | { |
|---|
| 2017 | | case TV_RING: |
|---|
| 2018 | | { |
|---|
| 2019 | | /* Analyze */ |
|---|
| 2020 | | switch (o_ptr->sval) |
|---|
| 2021 | | { |
|---|
| 2022 | | /* Strength, Constitution, Dexterity, Intelligence */ |
|---|
| 2023 | | case SV_RING_STR: |
|---|
| 2024 | | case SV_RING_CON: |
|---|
| 2025 | | case SV_RING_DEX: |
|---|
| 2026 | | case SV_RING_INT: |
|---|
| 2027 | | { |
|---|
| 2028 | | /* Stat bonus */ |
|---|
| 2029 | | o_ptr->pval = 1 + m_bonus(5, level); |
|---|
| 2030 | | |
|---|
| 2031 | | /* Cursed */ |
|---|
| 2032 | | if (power < 0) |
|---|
| 2033 | | { |
|---|
| 2034 | | /* Broken */ |
|---|
| 2035 | | o_ptr->ident |= (IDENT_BROKEN); |
|---|
| 2036 | | |
|---|
| 2037 | | /* Cursed */ |
|---|
| 2038 | | o_ptr->flags3 |= TR3_LIGHT_CURSE; |
|---|
| 2039 | | |
|---|
| 2040 | | /* Reverse pval */ |
|---|
| 2041 | | o_ptr->pval = 0 - (o_ptr->pval); |
|---|
| 2042 | | } |
|---|
| 2043 | | |
|---|
| 2044 | | break; |
|---|
| 2045 | | } |
|---|
| 2046 | | |
|---|
| 2047 | | /* Ring of Speed! */ |
|---|
| 2048 | | case SV_RING_SPEED: |
|---|
| 2049 | | { |
|---|
| 2050 | | /* Base speed (1 to 10) */ |
|---|
| 2051 | | o_ptr->pval = randint(5) + m_bonus(5, level); |
|---|
| 2052 | | |
|---|
| 2053 | | /* Super-charge the ring */ |
|---|
| 2054 | | while (rand_int(100) < 50) o_ptr->pval++; |
|---|
| 2055 | | |
|---|
| 2056 | | /* Cursed Ring */ |
|---|
| 2057 | | if (power < 0) |
|---|
| 2058 | | { |
|---|
| 2059 | | /* Broken */ |
|---|
| 2060 | | o_ptr->ident |= (IDENT_BROKEN); |
|---|
| 2061 | | |
|---|
| 2062 | | /* Cursed */ |
|---|
| 2063 | | o_ptr->flags3 |= TR3_LIGHT_CURSE; |
|---|
| 2064 | | |
|---|
| 2065 | | /* Reverse pval */ |
|---|
| 2066 | | o_ptr->pval = 0 - (o_ptr->pval); |
|---|
| 2067 | | |
|---|
| 2068 | | break; |
|---|
| 2069 | | } |
|---|
| 2070 | | else |
|---|
| 2071 | | { |
|---|
| 2072 | | /* Rating boost */ |
|---|
| 2073 | | rating += 25; |
|---|
| 2074 | | } |
|---|
| 2075 | | |
|---|
| 2076 | | /* Mention the item */ |
|---|
| 2077 | | if (cheat_peek) object_mention(o_ptr); |
|---|
| 2078 | | |
|---|
| 2079 | | break; |
|---|
| 2080 | | } |
|---|
| 2081 | | |
|---|
| 2082 | | /* Searching */ |
|---|
| 2083 | | case SV_RING_SEARCHING: |
|---|
| 2084 | | { |
|---|
| 2085 | | /* Bonus to searching */ |
|---|
| 2086 | | o_ptr->pval = 1 + m_bonus(5, level); |
|---|
| 2087 | | |
|---|
| 2088 | | |
|---|