MCPcopy Create free account
hub / github.com/NetHack/NetHack / ready_ok

Function ready_ok

src/wield.c:293–327  ·  view source on GitHub ↗

getobj callback for object to ready for throwing/shooting; this filter lets worn items through so that caller can reject them */

Source from the content-addressed store, hash-verified

291/* getobj callback for object to ready for throwing/shooting;
292 this filter lets worn items through so that caller can reject them */
293staticfn int
294ready_ok(struct obj *obj)
295{
296 if (!obj) /* '-', will empty quiver slot if chosen */
297 return uquiver ? GETOBJ_SUGGEST : GETOBJ_DOWNPLAY;
298
299 /* downplay when wielded, unless more than one */
300 if (obj == uwep || (obj == uswapwep && u.twoweap))
301 return (obj->quan == 1) ? GETOBJ_DOWNPLAY : GETOBJ_SUGGEST;
302
303 if (is_ammo(obj)) {
304 return ((uwep && ammo_and_launcher(obj, uwep))
305 || (uswapwep && ammo_and_launcher(obj, uswapwep)))
306 ? GETOBJ_SUGGEST
307 : GETOBJ_DOWNPLAY;
308 } else if (is_launcher(obj)) { /* part of 'possible extension' below */
309 return GETOBJ_DOWNPLAY;
310 } else {
311 if (obj->oclass == WEAPON_CLASS || obj->oclass == COIN_CLASS)
312 return GETOBJ_SUGGEST;
313 /* Possible extension: exclude weapons that make no sense to throw,
314 such as whips, bows, slings, rubber hoses. */
315 }
316
317#if 0 /* superseded by ammo_and_launcher handling above */
318 /* Include gems/stones as likely candidates if either primary
319 or secondary weapon is a sling. */
320 if (obj->oclass == GEM_CLASS
321 && (uslinging()
322 || (uswapwep && objects[uswapwep->otyp].oc_skill == P_SLING)))
323 return GETOBJ_SUGGEST;
324#endif
325
326 return GETOBJ_DOWNPLAY;
327}
328
329/* getobj callback for object to wield */
330staticfn int

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected