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

Function lay_an_egg

src/sit.c:357–396  ·  view source on GitHub ↗

hero lays an egg */

Source from the content-addressed store, hash-verified

355
356/* hero lays an egg */
357staticfn int
358lay_an_egg(void)
359{
360 struct obj *uegg;
361
362 if (!flags.female) {
363 pline("%s can't lay eggs!",
364 Hallucination
365 ? "You may think you are a platypus, but a male still"
366 : "Males");
367 return ECMD_OK;
368 } else if (u.uhunger < (int) objects[EGG].oc_nutrition) {
369 You("don't have enough energy to lay an egg.");
370 return ECMD_OK;
371 } else if (eggs_in_water(gy.youmonst.data)) {
372 if (!(Underwater || Is_waterlevel(&u.uz))) {
373 pline("A splash tetra you are not.");
374 return ECMD_OK;
375 }
376 if (Upolyd
377 && (gy.youmonst.data == &mons[PM_GIANT_EEL]
378 || gy.youmonst.data == &mons[PM_ELECTRIC_EEL])) {
379 You("yearn for the Sargasso Sea.");
380 return ECMD_OK;
381 }
382 }
383 uegg = mksobj(EGG, FALSE, FALSE);
384 uegg->spe = 1;
385 uegg->quan = 1L;
386 uegg->owt = weight(uegg);
387 /* this sets hatch timers if appropriate */
388 set_corpsenm(uegg, egg_type_from_parent(u.umonnum, FALSE));
389 uegg->known = 1;
390 observe_object(uegg);
391 You("%s an egg.", eggs_in_water(gy.youmonst.data) ? "spawn" : "lay");
392 dropy(uegg);
393 stackobj(uegg);
394 morehungry((int) objects[EGG].oc_nutrition);
395 return ECMD_TIME;
396}
397
398/* #sit command */
399int

Callers 1

dositFunction · 0.85

Calls 10

YouFunction · 0.85
mksobjFunction · 0.85
weightFunction · 0.85
set_corpsenmFunction · 0.85
egg_type_from_parentFunction · 0.85
observe_objectFunction · 0.85
dropyFunction · 0.85
stackobjFunction · 0.85
morehungryFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected