called by savebones(); also by finish_paybill(shk.c) */
| 256 | |
| 257 | /* called by savebones(); also by finish_paybill(shk.c) */ |
| 258 | void |
| 259 | drop_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 */ |
no test coverage detected