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

Function mdrop_obj

src/steal.c:813–846  ·  view source on GitHub ↗

drop one object taken from a (possibly dead) monster's inventory */

Source from the content-addressed store, hash-verified

811
812/* drop one object taken from a (possibly dead) monster's inventory */
813void
814mdrop_obj(
815 struct monst *mon,
816 struct obj *obj,
817 boolean verbosely)
818{
819 coordxy omx = mon->mx, omy = mon->my;
820 long unwornmask = obj->owornmask;
821 /* call distant_name() for its possible side-effects even if the result
822 might not be printed, and do it before extracting obj from minvent */
823 char *obj_name = distant_name(obj, doname);
824
825 extract_from_minvent(mon, obj, FALSE, TRUE);
826 /* don't charge for an owned saddle on dead steed (provided
827 that the hero is within the same shop at the time) */
828 if (unwornmask && mon->mtame && (unwornmask & W_SADDLE) != 0L
829 && !obj->unpaid && costly_spot(omx, omy)
830 /* being at costly_spot guarantees lev->roomno is not 0 */
831 && strchr(in_rooms(u.ux, u.uy, SHOPBASE), levl[omx][omy].roomno)) {
832 obj->no_charge = 1;
833 }
834 /* obj_no_longer_held(obj); -- done by place_object */
835 if (verbosely && cansee(omx, omy))
836 pline_mon(mon, "%s drops %s.", Monnam(mon), obj_name);
837 if (!flooreffects(obj, omx, omy, "fall")) {
838 place_object(obj, omx, omy);
839 stackobj(obj);
840 }
841 /* do this last, after placing obj on floor; removing steed's saddle
842 throws rider, possibly inflicting fatal damage and producing bones; this
843 is why we had to call extract_from_minvent() with do_intrinsics=FALSE */
844 if (!DEADMONSTER(mon) && unwornmask)
845 update_mon_extrinsics(mon, obj, FALSE, TRUE);
846}
847
848/* some monsters bypass the normal rules for moving between levels or
849 even leaving the game entirely; when that happens, prevent them from

Callers 4

mdrop_special_objsFunction · 0.85
relobjFunction · 0.85
bhitmFunction · 0.85
leppie_stashFunction · 0.85

Calls 10

distant_nameFunction · 0.85
extract_from_minventFunction · 0.85
costly_spotFunction · 0.85
in_roomsFunction · 0.85
pline_monFunction · 0.85
MonnamFunction · 0.85
flooreffectsFunction · 0.85
place_objectFunction · 0.85
stackobjFunction · 0.85
update_mon_extrinsicsFunction · 0.85

Tested by

no test coverage detected