light a lamp or candle */
| 1625 | |
| 1626 | /* light a lamp or candle */ |
| 1627 | staticfn void |
| 1628 | use_lamp(struct obj *obj) |
| 1629 | { |
| 1630 | char buf[BUFSZ]; |
| 1631 | const char *lamp = (obj->otyp == OIL_LAMP |
| 1632 | || obj->otyp == MAGIC_LAMP) ? "lamp" |
| 1633 | : (obj->otyp == BRASS_LANTERN) ? "lantern" |
| 1634 | : NULL; |
| 1635 | |
| 1636 | /* |
| 1637 | * When blind, lamps' and candles' on/off state can be distinguished |
| 1638 | * by heat. For brass lantern assume that there is an on/off switch |
| 1639 | * that can be felt. |
| 1640 | */ |
| 1641 | |
| 1642 | if (obj->lamplit) { |
| 1643 | if (lamp) /* lamp or lantern */ |
| 1644 | pline("%s%s is now off.", Shk_Your(buf, obj), lamp); |
| 1645 | else |
| 1646 | You("snuff out %s.", yname(obj)); |
| 1647 | end_burn(obj, TRUE); |
| 1648 | return; |
| 1649 | } |
| 1650 | if (Underwater) { |
| 1651 | pline("%s.", |
| 1652 | !Is_candle(obj) ? "This is not a diving lamp" |
| 1653 | : "Sorry, fire and water don't mix"); |
| 1654 | return; |
| 1655 | } |
| 1656 | /* magic lamps with an spe == 0 (wished for) cannot be lit */ |
| 1657 | if ((!Is_candle(obj) && obj->age == 0) |
| 1658 | || (obj->otyp == MAGIC_LAMP && obj->spe == 0)) { |
| 1659 | if (obj->otyp == BRASS_LANTERN) { |
| 1660 | if (!Blind) |
| 1661 | Your("lantern is out of power."); |
| 1662 | else |
| 1663 | pline("%s", nothing_seems_to_happen); |
| 1664 | } else { |
| 1665 | pline("This %s has no oil.", xname(obj)); |
| 1666 | } |
| 1667 | return; |
| 1668 | } |
| 1669 | if (obj->cursed && !rn2(2)) { |
| 1670 | if ((obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP) && !rn2(3)) { |
| 1671 | pline_The("lamp spills and covers your %s with oil.", |
| 1672 | fingers_or_gloves(TRUE)); |
| 1673 | make_glib((int) (Glib & TIMEOUT) + d(2, 10)); |
| 1674 | } else if (!Blind) { |
| 1675 | pline("%s for a moment, then %s.", Tobjnam(obj, "flicker"), |
| 1676 | otense(obj, "die")); |
| 1677 | } else { |
| 1678 | pline("%s", nothing_seems_to_happen); |
| 1679 | } |
| 1680 | } else { |
| 1681 | if (lamp) { /* lamp or lantern */ |
| 1682 | check_unpaid(obj); |
| 1683 | pline("%s%s is now on.", Shk_Your(buf, obj), lamp); |
| 1684 | } else { /* candle(s) */ |
no test coverage detected