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

Function mkbox_cnts

src/mkobj.c:303–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303staticfn void
304mkbox_cnts(struct obj *box)
305{
306 int n;
307 struct obj *otmp;
308
309 box->cobj = (struct obj *) 0;
310
311 switch (box->otyp) {
312 case ICE_BOX:
313 n = 20;
314 break;
315 case CHEST:
316 n = box->olocked ? 7 : 5;
317 break;
318 case LARGE_BOX:
319 n = box->olocked ? 5 : 3;
320 break;
321 case SACK:
322 case OILSKIN_SACK:
323 /* initial inventory: sack starts out empty */
324 if (svm.moves <= 1 && !gi.in_mklev) {
325 n = 0;
326 break;
327 }
328 FALLTHROUGH;
329 /*FALLTHRU*/
330 case BAG_OF_HOLDING:
331 n = 1;
332 break;
333 default:
334 n = 0;
335 break;
336 }
337
338 for (n = rn2(n + 1); n > 0; n--) {
339 if (box->otyp == ICE_BOX) {
340 otmp = mksobj(CORPSE, TRUE, FALSE);
341 /* Note: setting age to 0 is correct. Age has a different
342 * from usual meaning for objects stored in ice boxes. -KAA
343 */
344 otmp->age = 0L;
345 if (otmp->timed) {
346 (void) stop_timer(ROT_CORPSE, obj_to_any(otmp));
347 (void) stop_timer(REVIVE_MON, obj_to_any(otmp));
348 (void) stop_timer(SHRINK_GLOB, obj_to_any(otmp));
349 }
350 } else {
351 int tprob;
352 const struct icp *iprobs = boxiprobs;
353
354 for (tprob = rnd(100); (tprob -= iprobs->iprob) > 0; iprobs++)
355 ;
356 if (!(otmp = mkobj(iprobs->iclass, FALSE)))
357 continue;
358
359 /* handle a couple of special cases */
360 if (otmp->oclass == COIN_CLASS) {

Callers 1

mksobj_initFunction · 0.85

Calls 10

rn2Function · 0.85
mksobjFunction · 0.85
stop_timerFunction · 0.85
obj_to_anyFunction · 0.85
rndFunction · 0.85
mkobjFunction · 0.85
level_difficultyFunction · 0.85
weightFunction · 0.85
rnd_classFunction · 0.85
add_to_containerFunction · 0.85

Tested by

no test coverage detected