MCPcopy Index your code
hub / github.com/NetHack/NetHack / begin_burn

Function begin_burn

src/timeout.c:1711–1797  ·  view source on GitHub ↗

* Start a burn timeout on the given object. If not "already lit" then * create a light source for the vision system. There had better not * be a burn already running on the object. * * Magic lamps stay lit as long as there's a genie inside, so don't start * a timer. * * Burn rules: * potions of oil, lamps & candles: * age = # of turns of fuel left * spe =

Source from the content-addressed store, hash-verified

1709 * This is a "silent" routine - it should not print anything out.
1710 */
1711void
1712begin_burn(struct obj *obj, boolean already_lit)
1713{
1714 int radius = 3;
1715 long turns = 0;
1716 boolean do_timer = TRUE;
1717
1718 if (obj->age == 0 && obj->otyp != MAGIC_LAMP && !artifact_light(obj))
1719 return;
1720
1721 switch (obj->otyp) {
1722 case MAGIC_LAMP:
1723 obj->lamplit = 1;
1724 do_timer = FALSE;
1725 break;
1726
1727 case POT_OIL:
1728 turns = obj->age;
1729 if (obj->odiluted)
1730 turns = (3L * turns + 2L) / 4L;
1731 radius = 1; /* very dim light */
1732 break;
1733
1734 case BRASS_LANTERN:
1735 case OIL_LAMP:
1736 /* magic times are 150, 100, 50, 25, and 0 */
1737 if (obj->age > 150L)
1738 turns = obj->age - 150L;
1739 else if (obj->age > 100L)
1740 turns = obj->age - 100L;
1741 else if (obj->age > 50L)
1742 turns = obj->age - 50L;
1743 else if (obj->age > 25L)
1744 turns = obj->age - 25L;
1745 else
1746 turns = obj->age;
1747 break;
1748
1749 case CANDELABRUM_OF_INVOCATION:
1750 case TALLOW_CANDLE:
1751 case WAX_CANDLE:
1752 /* magic times are 75, 15, and 0 */
1753 if (obj->age > 75L)
1754 turns = obj->age - 75L;
1755 else if (obj->age > 15L)
1756 turns = obj->age - 15L;
1757 else
1758 turns = obj->age;
1759 radius = candle_light_range(obj);
1760 break;
1761
1762 default:
1763 /* [ALI] Support artifact light sources */
1764 if (artifact_light(obj)) {
1765 obj->lamplit = 1;
1766 do_timer = FALSE;
1767 radius = arti_light_radius(obj);
1768 } else {

Callers 15

ready_weaponFunction · 0.85
Armor_onFunction · 0.85
readobjnamFunction · 0.85
mon_wield_itemFunction · 0.85
burn_objectFunction · 0.85
m_dowear_typeFunction · 0.85
m_initinvFunction · 0.85
muse_unslimeFunction · 0.85
mktrap_victimFunction · 0.85
use_candelabrumFunction · 0.85
catch_litFunction · 0.85
use_lampFunction · 0.85

Calls 10

artifact_lightFunction · 0.85
candle_light_rangeFunction · 0.85
arti_light_radiusFunction · 0.85
xnameFunction · 0.85
start_timerFunction · 0.85
obj_to_anyFunction · 0.85
update_inventoryFunction · 0.85
get_obj_locationFunction · 0.85
new_light_sourceFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected