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

Function catch_lit

src/apply.c:1576–1624  ·  view source on GitHub ↗

Called when potentially lightable object is affected by fire_damage(). Return TRUE if object becomes lit and FALSE otherwise --ALI */

Source from the content-addressed store, hash-verified

1574/* Called when potentially lightable object is affected by fire_damage().
1575 Return TRUE if object becomes lit and FALSE otherwise --ALI */
1576boolean
1577catch_lit(struct obj *obj)
1578{
1579 coordxy x, y;
1580
1581 if (!obj->lamplit && ignitable(obj) && get_obj_location(obj, &x, &y, 0)) {
1582 if (((obj->otyp == MAGIC_LAMP /* spe==0 => no djinni inside */
1583 /* spe==0 => no candles attached */
1584 || obj->otyp == CANDELABRUM_OF_INVOCATION) && obj->spe == 0)
1585 /* age_is_relative && age==0 && still-exists means out of fuel */
1586 || (age_is_relative(obj) && obj->age == 0)
1587 /* lantern is classified as ignitable() but not by fire */
1588 || obj->otyp == BRASS_LANTERN)
1589 return FALSE;
1590 if (obj->otyp == CANDELABRUM_OF_INVOCATION && obj->cursed)
1591 return FALSE;
1592 if ((obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP)
1593 /* once lit, cursed lamp is as good as non-cursed one, so failure
1594 to light is a minor inconvenience to make cursed be worse */
1595 && obj->cursed && !rn2(2))
1596 return FALSE;
1597
1598 if (obj->where == OBJ_INVENT || cansee(x, y)) {
1599 if (obj->where == OBJ_FLOOR && cansee(x, y))
1600 set_msg_xy(x, y);
1601 pline("%s %s %s", Yname2(obj),
1602 /* "catches light!" or "feels warm." */
1603 otense(obj, Blind ? "feel" : "catch"),
1604 Blind ? "warm." : "light!");
1605 }
1606 if (obj->otyp == POT_OIL)
1607 makeknown(obj->otyp);
1608 if (carried(obj) && obj->unpaid && costly_spot(u.ux, u.uy)) {
1609 struct monst *shkp VOICEONLY
1610 = shop_keeper(*in_rooms(u.ux, u.uy, SHOPBASE));
1611
1612 /* if it catches while you have it, then it's your tough luck */
1613 check_unpaid(obj);
1614 SetVoice(shkp, 0, 80, 0);
1615 verbalize("That's in addition to the cost of %s %s, of course.",
1616 yname(obj),
1617 (obj->quan == 1L) ? "itself" : "themselves");
1618 bill_dummy_object(obj);
1619 }
1620 begin_burn(obj, FALSE);
1621 return TRUE;
1622 }
1623 return FALSE;
1624}
1625
1626/* light a lamp or candle */
1627staticfn void

Callers 2

fire_damageFunction · 0.85
ignite_itemsFunction · 0.85

Calls 14

get_obj_locationFunction · 0.85
rn2Function · 0.85
set_msg_xyFunction · 0.85
Yname2Function · 0.85
otenseFunction · 0.85
costly_spotFunction · 0.85
shop_keeperFunction · 0.85
in_roomsFunction · 0.85
check_unpaidFunction · 0.85
verbalizeFunction · 0.85
ynameFunction · 0.85
bill_dummy_objectFunction · 0.85

Tested by

no test coverage detected