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

Function hold_another_object

src/invent.c:1207–1306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1205 * touch_artifact will print its own messages if they are warranted.
1206 */
1207struct obj *
1208hold_another_object(
1209 struct obj *obj, /* object to be held */
1210 const char *drop_fmt, /* format string for message if it can't be held */
1211 const char *drop_arg, /* argument to use when formatting message */
1212 const char *hold_msg) /* message to display if successfully held */
1213{
1214 char buf[BUFSZ];
1215
1216 if (!Blind)
1217 observe_object(obj); /* maximize mergeability */
1218 if (obj->oartifact) {
1219 /* place_object may change these */
1220 boolean crysknife = (obj->otyp == CRYSKNIFE);
1221 int oerode = obj->oerodeproof;
1222 boolean wasUpolyd = Upolyd;
1223
1224 /* in case touching this object turns out to be fatal */
1225 place_object(obj, u.ux, u.uy);
1226
1227 if (!touch_artifact(obj, &gy.youmonst)) {
1228 obj_extract_self(obj); /* remove it from the floor */
1229 dropy(obj); /* now put it back again :-) */
1230 return obj;
1231 } else if (wasUpolyd && !Upolyd) {
1232 /* lose your grip if you revert your form */
1233 if (drop_fmt)
1234 pline(drop_fmt, drop_arg);
1235 obj_extract_self(obj);
1236 dropy(obj);
1237 return obj;
1238 }
1239 obj_extract_self(obj);
1240 if (crysknife) {
1241 obj->otyp = CRYSKNIFE;
1242 obj->oerodeproof = oerode;
1243 }
1244 }
1245 if (Fumbling) {
1246 obj->nomerge = 1;
1247 /* dropping expects obj to be in invent; since it's going to be
1248 dropped, avoid perminv update when temporarily adding it */
1249 obj = addinv_core0(obj, (struct obj *) 0, FALSE);
1250 goto drop_it;
1251 } else if (obj->otyp == CORPSE
1252 && !u_safe_from_fatal_corpse(obj, st_all)
1253 && obj->wishedfor) {
1254 obj->wishedfor = 0;
1255 obj = addinv_core0(obj, (struct obj *) 0, FALSE);
1256 goto drop_it;
1257 } else {
1258 long oquan = obj->quan;
1259 int prev_encumbr = near_capacity(); /* before addinv() */
1260
1261 /* encumbrance limit is max( current_state, pickup_burden );
1262 this used to use hardcoded MOD_ENCUMBER (stressed) instead
1263 of the 'pickup_burden' option (which defaults to stressed) */
1264 if (prev_encumbr < flags.pickup_burden)

Callers 14

hold_potionFunction · 0.85
steal_itFunction · 0.85
invoke_create_ammoFunction · 0.85
newmailFunction · 0.85
engraveFunction · 0.85
loot_monFunction · 0.85
hornoplentyFunction · 0.85
makewishFunction · 0.85
ucatchgemFunction · 0.85
u_catch_thrown_objFunction · 0.85
light_cocktailFunction · 0.85
use_tinning_kitFunction · 0.85

Calls 15

observe_objectFunction · 0.85
place_objectFunction · 0.85
touch_artifactFunction · 0.85
obj_extract_selfFunction · 0.85
dropyFunction · 0.85
addinv_core0Function · 0.85
u_safe_from_fatal_corpseFunction · 0.85
near_capacityFunction · 0.85
inv_cntFunction · 0.85
splitobjFunction · 0.85
setuqwepFunction · 0.85
prinvFunction · 0.85

Tested by

no test coverage detected