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

Function start_glob_timeout

src/mkobj.c:1472–1491  ·  view source on GitHub ↗

schedule a timer that will shrink the target glob by 1 unit of weight */

Source from the content-addressed store, hash-verified

1470
1471/* schedule a timer that will shrink the target glob by 1 unit of weight */
1472void
1473start_glob_timeout(
1474 struct obj *obj, /* glob */
1475 long when) /* when to shrink; if 0L, use random value close to 25 */
1476{
1477 if (!obj->globby) {
1478 impossible("start_glob_timeout for non-glob [%d: %s]?",
1479 obj->otyp, simpleonames(obj));
1480 return; /* skip timer creation */
1481 }
1482 /* sanity precaution */
1483 if (obj->timed)
1484 (void) stop_timer(SHRINK_GLOB, obj_to_any(obj));
1485
1486 if (when < 1L) /* caller usually passes 0L; should never be negative */
1487 when = 25L + (long) rn2(5) - 2L; /* 25+[0..4]-2 => 23..27, avg 25 */
1488 /* 1 new glob weighs 20 units and loses 1 unit every 25 turns,
1489 so lasts for 500 turns, twice as long as the average corpse */
1490 (void) start_timer(when, TIMER_OBJECT, SHRINK_GLOB, obj_to_any(obj));
1491}
1492
1493/* globs have quantity 1 and size which varies by multiples of 20 in owt;
1494 they don't become tainted with age, but every 25 turns this timer runs

Callers 4

removed_from_iceboxFunction · 0.85
mksobj_initFunction · 0.85
shrink_globFunction · 0.85
obj_absorbFunction · 0.85

Calls 6

simpleonamesFunction · 0.85
stop_timerFunction · 0.85
obj_to_anyFunction · 0.85
rn2Function · 0.85
start_timerFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected