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

Function drop_upon_death

src/bones.c:258–303  ·  view source on GitHub ↗

called by savebones(); also by finish_paybill(shk.c) */

Source from the content-addressed store, hash-verified

256
257/* called by savebones(); also by finish_paybill(shk.c) */
258void
259drop_upon_death(
260 struct monst *mtmp, /* monster if hero rises as one (non ghost) */
261 struct obj *cont, /* container if hero is turned into a statue */
262 coordxy x, coordxy y)
263{
264 struct obj *otmp;
265
266 /* when dual-wielding, the second weapon gets dropped rather than
267 welded if it becomes cursed; ensure that that won't happen here
268 by ending dual-wield */
269 u.twoweap = FALSE; /* bypass set_twoweap() */
270
271 /* all inventory is dropped (for the normal case), even non-droppable
272 things like worn armor and accessories, welded weapon, or cursed
273 loadstones */
274 while ((otmp = gi.invent) != 0) {
275 obj_extract_self(otmp);
276 /* when turning into green slime, all gear remains held;
277 other types "arise from the dead" do aren't holding
278 equipment during their brief interval as a corpse */
279 if (!mtmp || is_undead(mtmp->data))
280 obj_no_longer_held(otmp);
281
282 /* lamps don't go out when dropped */
283 if ((cont || artifact_light(otmp)) && obj_is_burning(otmp))
284 end_burn(otmp, TRUE); /* smother in statue */
285 otmp->owornmask = 0L;
286
287 if (otmp->otyp == SLIME_MOLD)
288 goodfruit(otmp->spe);
289
290 if (rn2(5))
291 curse(otmp);
292 if (mtmp)
293 (void) add_to_minv(mtmp, otmp);
294 else if (cont)
295 (void) add_to_container(cont, otmp);
296 else if (!rn2(8))
297 give_to_nearby_mon(otmp, x, y);
298 else
299 place_object(otmp, x, y);
300 }
301 if (cont)
302 cont->owt = weight(cont);
303}
304
305/* possibly restore oracle's room and/or put her back inside it; returns
306 False if she's on the wrong level and should be removed, True otherwise */

Callers 2

savebonesFunction · 0.85
finish_paybillFunction · 0.85

Calls 13

obj_extract_selfFunction · 0.85
obj_no_longer_heldFunction · 0.85
artifact_lightFunction · 0.85
obj_is_burningFunction · 0.85
end_burnFunction · 0.85
goodfruitFunction · 0.85
rn2Function · 0.85
curseFunction · 0.85
add_to_minvFunction · 0.85
add_to_containerFunction · 0.85
give_to_nearby_monFunction · 0.85
place_objectFunction · 0.85

Tested by

no test coverage detected