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

Function monstone

src/mon.c:3286–3373  ·  view source on GitHub ↗

drop a statue or rock and remove monster */

Source from the content-addressed store, hash-verified

3284
3285/* drop a statue or rock and remove monster */
3286void
3287monstone(struct monst *mdef)
3288{
3289 struct obj *otmp, *obj, *oldminvent;
3290 coordxy x = mdef->mx, y = mdef->my;
3291 boolean wasinside = FALSE;
3292
3293 /* vampshifter reverts to vampire;
3294 3.6.3: also used to unshift shape-changed sandestin */
3295 if (!vamp_stone(mdef))
3296 return;
3297
3298 /* we have to make the statue before calling mondead, to be able to
3299 * put inventory in it, and we have to check for lifesaving before
3300 * making the statue....
3301 */
3302 mdef->mhp = 0; /* in case caller hasn't done this */
3303 lifesaved_monster(mdef);
3304 if (!DEADMONSTER(mdef))
3305 return;
3306
3307 mdef->mtrapped = 0; /* (see m_detach) */
3308
3309 if ((int) mdef->data->msize > MZ_TINY
3310 || !rn2(2 + ((int) (mdef->data->geno & G_FREQ) > 2))) {
3311 unsigned corpstatflags = CORPSTAT_NONE;
3312
3313 oldminvent = 0;
3314 /* some objects may end up outside the statue */
3315 while ((obj = mdef->minvent) != 0) {
3316 extract_from_minvent(mdef, obj, TRUE, TRUE);
3317 if (obj->otyp == BOULDER
3318#if 0 /* monsters don't carry statues */
3319 || (obj->otyp == STATUE
3320 && mons[obj->corpsenm].msize >= mdef->data->msize)
3321#endif
3322 /* invocation tools resist even with 0% resistance */
3323 || obj_resists(obj, 0, 0)) {
3324 if (flooreffects(obj, x, y, "fall"))
3325 continue;
3326 place_object(obj, x, y);
3327 } else {
3328 if (obj->lamplit)
3329 end_burn(obj, TRUE);
3330 obj->nobj = oldminvent;
3331 oldminvent = obj;
3332 }
3333 }
3334 /* defer statue creation until after inventory removal
3335 so that saved monster traits won't retain any stale
3336 item-conferred attributes */
3337 if (mdef->female)
3338 corpstatflags |= CORPSTAT_FEMALE;
3339 else if (!is_neuter(mdef->data))
3340 corpstatflags |= CORPSTAT_MALE;
3341 /* Archeologists should not break unique statues */
3342 if (mdef->data->geno & G_UNIQ)
3343 corpstatflags |= CORPSTAT_HISTORIC;

Callers 8

do_stone_monFunction · 0.85
mdisplacemFunction · 0.85
gazemmFunction · 0.85
mdamagemFunction · 0.85
eat_brainsFunction · 0.85
m_consume_objFunction · 0.85
xkilledFunction · 0.85
minstapetrifyFunction · 0.85

Calls 15

vamp_stoneFunction · 0.85
lifesaved_monsterFunction · 0.85
rn2Function · 0.85
extract_from_minventFunction · 0.85
obj_resistsFunction · 0.85
flooreffectsFunction · 0.85
place_objectFunction · 0.85
end_burnFunction · 0.85
mkcorpstatFunction · 0.85
onameFunction · 0.85
add_to_containerFunction · 0.85
weightFunction · 0.85

Tested by

no test coverage detected