… | |
… | |
1549 | range = spell->range + SP_level_range_adjust (caster, spell); |
1549 | range = spell->range + SP_level_range_adjust (caster, spell); |
1550 | |
1550 | |
1551 | if (!skill) |
1551 | if (!skill) |
1552 | skill = caster; |
1552 | skill = caster; |
1553 | |
1553 | |
1554 | for (x = op->x - range; x <= op->x + range; x++) |
1554 | unordered_mapwalk (op, -range, -range, range, range) |
1555 | for (y = op->y - range; y <= op->y + range; y++) |
|
|
1556 | { |
1555 | { |
1557 | m = op->map; |
|
|
1558 | mflags = get_map_flags (m, &m, x, y, &nx, &ny); |
|
|
1559 | if (mflags & P_OUT_OF_MAP) |
|
|
1560 | continue; |
|
|
1561 | |
|
|
1562 | /* For most of the detections, we only detect objects above the |
1556 | /* For most of the detections, we only detect objects above the |
1563 | * floor. But this is not true for show invisible. |
1557 | * floor. But this is not true for show invisible. |
1564 | * Basically, we just go and find the top object and work |
1558 | * Basically, we just go and find the top object and work |
1565 | * down - that is easier than working up. |
1559 | * down - that is easier than working up. |
1566 | */ |
1560 | */ |
1567 | |
1561 | |
1568 | for (last = NULL, tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above) |
1562 | for (last = NULL, tmp = m->at (nx, ny).bot; tmp; tmp = tmp->above) |
1569 | last = tmp; |
1563 | last = tmp; |
1570 | |
1564 | |
1571 | /* Shouldn't happen, but if there are no objects on a space, this |
1565 | /* Shouldn't happen, but if there are no objects on a space, this |
1572 | * would happen. |
1566 | * would happen. |
1573 | */ |
1567 | */ |
1574 | if (!last) |
1568 | if (!last) |
1575 | continue; |
1569 | continue; |
1576 | |
1570 | |
1577 | done_one = 0; |
1571 | done_one = 0; |
1578 | floor = 0; |
1572 | floor = 0; |
1579 | detect = NULL; |
1573 | detect = NULL; |
1580 | for (tmp = last; tmp; tmp = tmp->below) |
1574 | for (tmp = last; tmp; tmp = tmp->below) |
1581 | { |
1575 | { |
1582 | /* show invisible */ |
1576 | /* show invisible */ |
1583 | if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && |
1577 | if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && |
1584 | /* Might there be other objects that we can make visible? */ |
1578 | /* Might there be other objects that we can make visible? */ |
1585 | (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) || |
1579 | (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) || |
1586 | (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) || |
1580 | (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) |
1587 | tmp->type == CF_HANDLE || |
1581 | || tmp->type == CF_HANDLE |
1588 | tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE || |
1582 | || tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE |
1589 | tmp->type == BUTTON || tmp->type == TELEPORTER || |
1583 | || tmp->type == BUTTON || tmp->type == TELEPORTER |
1590 | tmp->type == GATE || tmp->type == LOCKED_DOOR || |
1584 | || tmp->type == GATE || tmp->type == LOCKED_DOOR |
1591 | tmp->type == WEAPON || tmp->type == ALTAR || tmp->type == SIGN || |
1585 | || tmp->type == WEAPON || tmp->type == ALTAR || tmp->type == SIGN |
1592 | tmp->type == TRIGGER_PEDESTAL || tmp->type == SPECIAL_KEY || |
1586 | || tmp->type == TRIGGER_PEDESTAL || tmp->type == SPECIAL_KEY |
1593 | tmp->type == TREASURE || tmp->type == BOOK || tmp->type == HOLY_ALTAR))) |
1587 | || tmp->type == TREASURE || tmp->type == BOOK || tmp->type == HOLY_ALTAR))) |
1594 | { |
1588 | { |
1595 | if (random_roll (0, skill->level - 1, op, PREFER_HIGH) > level / 4) |
1589 | if (random_roll (0, skill->level - 1, op, PREFER_HIGH) > level / 4) |
1596 | { |
1590 | { |
1597 | tmp->invisible = 0; |
1591 | tmp->invisible = 0; |
1598 | done_one = 1; |
1592 | done_one = 1; |
1599 | } |
1593 | } |
1600 | } |
1594 | } |
1601 | |
1595 | |
1602 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
1596 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
1603 | floor = 1; |
1597 | floor = 1; |
1604 | |
1598 | |
1605 | /* All detections below this point don't descend beneath the floor, |
1599 | /* All detections below this point don't descend beneath the floor, |
1606 | * so just continue on. We could be clever and look at the type of |
1600 | * so just continue on. We could be clever and look at the type of |
1607 | * detection to completely break out if we don't care about objects beneath |
1601 | * detection to completely break out if we don't care about objects beneath |
1608 | * the floor, but once we get to the floor, not likely a very big issue anyways. |
1602 | * the floor, but once we get to the floor, not likely a very big issue anyways. |
1609 | */ |
1603 | */ |
1610 | if (floor) |
1604 | if (floor) |
1611 | continue; |
1605 | continue; |
1612 | |
1606 | |
1613 | /* I had thought about making detect magic and detect curse |
1607 | /* I had thought about making detect magic and detect curse |
1614 | * show the flash the magic item like it does for detect monster. |
1608 | * show the flash the magic item like it does for detect monster. |
1615 | * however, if the object is within sight, this would then make it |
1609 | * however, if the object is within sight, this would then make it |
1616 | * difficult to see what object is magical/cursed, so the |
1610 | * difficult to see what object is magical/cursed, so the |
1617 | * effect wouldn't be as apparant. |
1611 | * effect wouldn't be as apparent. |
1618 | */ |
1612 | */ |
1619 | |
1613 | |
1620 | /* detect magic */ |
1614 | /* detect magic */ |
1621 | if (QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL) && |
1615 | if (QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL) && |
1622 | !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_IDENTIFIED) && is_magical (tmp)) |
1616 | !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_IDENTIFIED) && is_magical (tmp)) |
1623 | { |
1617 | { |
1624 | SET_FLAG (tmp, FLAG_KNOWN_MAGICAL); |
1618 | SET_FLAG (tmp, FLAG_KNOWN_MAGICAL); |
1625 | /* make runes more visibile */ |
1619 | /* make runes more visibile */ |
1626 | if (tmp->type == RUNE && tmp->attacktype & AT_MAGIC) |
1620 | if (tmp->type == RUNE && tmp->attacktype & AT_MAGIC) |
1627 | tmp->stats.Cha /= 4; |
1621 | tmp->stats.Cha /= 4; |
|
|
1622 | |
1628 | done_one = 1; |
1623 | done_one = 1; |
1629 | } |
1624 | } |
|
|
1625 | |
1630 | /* detect monster */ |
1626 | /* detect monster */ |
1631 | if (QUERY_FLAG (spell, FLAG_MONSTER) && (QUERY_FLAG (tmp, FLAG_MONSTER) || tmp->type == PLAYER)) |
1627 | if (QUERY_FLAG (spell, FLAG_MONSTER) && (QUERY_FLAG (tmp, FLAG_MONSTER) || tmp->type == PLAYER)) |
1632 | { |
1628 | { |
1633 | done_one = 2; |
1629 | done_one = 2; |
|
|
1630 | |
1634 | if (!detect) |
1631 | if (!detect) |
1635 | detect = tmp; |
1632 | detect = tmp; |
1636 | } |
1633 | } |
|
|
1634 | |
1637 | /* Basically, if race is set in the spell, then the creatures race must |
1635 | /* Basically, if race is set in the spell, then the creatures race must |
1638 | * match that. if the spell race is set to GOD, then the gods opposing |
1636 | * match that. if the spell race is set to GOD, then the gods opposing |
1639 | * race must match. |
1637 | * race must match. |
1640 | */ |
1638 | */ |
1641 | if (spell->race && QUERY_FLAG (tmp, FLAG_MONSTER) && tmp->race && |
1639 | if (spell->race && QUERY_FLAG (tmp, FLAG_MONSTER) && tmp->race && |
1642 | ((spell->race == shstr_GOD && god && god->slaying.contains (tmp->race)) || |
1640 | ((spell->race == shstr_GOD && god && god->slaying.contains (tmp->race)) || |
1643 | spell->race.contains (tmp->race))) |
1641 | spell->race.contains (tmp->race))) |
1644 | { |
1642 | { |
1645 | done_one = 2; |
1643 | done_one = 2; |
|
|
1644 | |
1646 | if (!detect) |
1645 | if (!detect) |
1647 | detect = tmp; |
1646 | detect = tmp; |
1648 | } |
1647 | } |
|
|
1648 | |
1649 | if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) && |
1649 | if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) && |
1650 | (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))) |
1650 | (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))) |
1651 | { |
1651 | { |
1652 | SET_FLAG (tmp, FLAG_KNOWN_CURSED); |
1652 | SET_FLAG (tmp, FLAG_KNOWN_CURSED); |
1653 | done_one = 1; |
1653 | done_one = 1; |
1654 | } |
1654 | } |
1655 | } /* for stack of objects on this space */ |
1655 | } /* for stack of objects on this space */ |
1656 | |
1656 | |
1657 | /* Code here puts an effect of the spell on the space, so you can see |
1657 | /* Code here puts an effect of the spell on the space, so you can see |
1658 | * where the magic is. |
1658 | * where the magic is. |
1659 | */ |
1659 | */ |
1660 | if (done_one) |
1660 | if (done_one) |
1661 | { |
1661 | { |
1662 | object *detect_ob = arch_to_object (spell->other_arch); |
1662 | object *detect_ob = arch_to_object (spell->other_arch); |
1663 | |
1663 | |
1664 | /* if this is set, we want to copy the face */ |
1664 | /* if this is set, we want to copy the face */ |
1665 | if (done_one == 2 && detect) |
1665 | if (done_one == 2 && detect) |
1666 | { |
1666 | { |
1667 | detect_ob->face = detect->face; |
1667 | detect_ob->face = detect->face; |
1668 | detect_ob->animation_id = detect->animation_id; |
1668 | detect_ob->animation_id = detect->animation_id; |
1669 | detect_ob->anim_speed = detect->anim_speed; |
1669 | detect_ob->anim_speed = detect->anim_speed; |
1670 | detect_ob->last_anim = 0; |
1670 | detect_ob->last_anim = 0; |
1671 | /* by default, the detect_ob is already animated */ |
1671 | /* by default, the detect_ob is already animated */ |
1672 | if (!QUERY_FLAG (detect, FLAG_ANIMATE)) |
1672 | if (!QUERY_FLAG (detect, FLAG_ANIMATE)) |
1673 | CLEAR_FLAG (detect_ob, FLAG_ANIMATE); |
1673 | CLEAR_FLAG (detect_ob, FLAG_ANIMATE); |
1674 | } |
1674 | } |
1675 | |
1675 | |
1676 | m->insert (detect_ob, nx, ny, op); |
1676 | m->insert (detect_ob, nx, ny, op); |
1677 | } |
1677 | } |
1678 | } /* for processing the surrounding spaces */ |
1678 | } /* for processing the surrounding spaces */ |
1679 | |
1679 | |
1680 | |
1680 | |
1681 | /* Now process objects in the players inventory if detect curse or magic */ |
1681 | /* Now process objects in the players inventory if detect curse or magic */ |
1682 | if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) || QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL)) |
1682 | if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) || QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL)) |
1683 | { |
1683 | { |