MCPcopy Create free account
hub / github.com/NetHack/NetHack / candle_light_range

Function candle_light_range

src/light.c:842–877  ·  view source on GitHub ↗

Candlelight is proportional to the number of candles; minimum range is 2 rather than 1 for playability. */

Source from the content-addressed store, hash-verified

840/* Candlelight is proportional to the number of candles;
841 minimum range is 2 rather than 1 for playability. */
842int
843candle_light_range(struct obj *obj)
844{
845 int radius;
846
847 if (obj->otyp == CANDELABRUM_OF_INVOCATION) {
848 /*
849 * The special candelabrum emits more light than the
850 * corresponding number of candles would.
851 * 1..3 candles, range 2 (minimum range);
852 * 4..6 candles, range 3 (normal lamp range);
853 * 7 candles, range 4 (bright).
854 */
855 radius = (obj->spe < 4) ? 2 : (obj->spe < 7) ? 3 : 4;
856 } else if (Is_candle(obj)) {
857 /*
858 * Range is incremented quadratically. You can get the same
859 * amount of light as from a lamp with 4 candles, and
860 * even better light with 9 candles, and so on.
861 * 1..3 candles, range 2;
862 * 4..8 candles, range 3;
863 * 9..15 candles, range 4; &c.
864 */
865 long n = obj->quan;
866
867 radius = 1; /* always incremented at least once */
868 while(radius*radius <= n && radius < MAX_RADIUS) {
869 radius++;
870 }
871 } else {
872 /* we're only called for lit candelabrum or candles */
873 /* impossible("candlelight for %d?", obj->otyp); */
874 radius = 3; /* lamp's value */
875 }
876 return radius;
877}
878
879/* light emitting artifact's range depends upon its curse/bless state */
880int

Callers 3

obj_split_light_sourceFunction · 0.85
obj_merge_light_sourcesFunction · 0.85
begin_burnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected