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

Function worst_cursed_item

src/pray.c:287–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285
286/* select an item for TROUBLE_CURSED_ITEMS */
287staticfn struct obj *
288worst_cursed_item(void)
289{
290 struct obj *otmp;
291
292 /* if strained or worse, check for loadstone first */
293 if (near_capacity() >= HVY_ENCUMBER) {
294 for (otmp = gi.invent; otmp; otmp = otmp->nobj)
295 if (Cursed_obj(otmp, LOADSTONE))
296 return otmp;
297 }
298 /* weapon takes precedence if it is interfering
299 with taking off a ring or putting on a shield */
300 if (welded(uwep) && (uright || bimanual(uwep))) { /* weapon */
301 otmp = uwep;
302 /* gloves come next, due to rings */
303 } else if (uarmg && uarmg->cursed) { /* gloves */
304 otmp = uarmg;
305 /* then shield due to two handed weapons and spells */
306 } else if (uarms && uarms->cursed) { /* shield */
307 otmp = uarms;
308 /* then cloak due to body armor */
309 } else if (uarmc && uarmc->cursed) { /* cloak */
310 otmp = uarmc;
311 } else if (uarm && uarm->cursed) { /* suit */
312 otmp = uarm;
313 /* if worn helmet of opposite alignment is making you an adherent
314 of the current god, he/she/it won't uncurse that for you */
315 } else if (uarmh && uarmh->cursed /* helmet */
316 && uarmh->otyp != HELM_OF_OPPOSITE_ALIGNMENT) {
317 otmp = uarmh;
318 } else if (uarmf && uarmf->cursed) { /* boots */
319 otmp = uarmf;
320 } else if (uarmu && uarmu->cursed) { /* shirt */
321 otmp = uarmu;
322 } else if (uamul && uamul->cursed) { /* amulet */
323 otmp = uamul;
324 } else if (uleft && uleft->cursed) { /* left ring */
325 otmp = uleft;
326 } else if (uright && uright->cursed) { /* right ring */
327 otmp = uright;
328 } else if (ublindf && ublindf->cursed) { /* eyewear */
329 otmp = ublindf; /* must be non-blinding lenses */
330 /* if weapon wasn't handled above, do it now */
331 } else if (welded(uwep)) { /* weapon */
332 otmp = uwep;
333 /* active secondary weapon even though it isn't welded */
334 } else if (uswapwep && uswapwep->cursed && u.twoweap) {
335 otmp = uswapwep;
336 /* all worn items ought to be handled by now */
337 } else {
338 for (otmp = gi.invent; otmp; otmp = otmp->nobj) {
339 if (!otmp->cursed)
340 continue;
341 if (otmp->otyp == LOADSTONE || confers_luck(otmp))
342 break;
343 }
344 }

Callers 2

in_troubleFunction · 0.85
fix_worst_troubleFunction · 0.85

Calls 3

near_capacityFunction · 0.85
weldedFunction · 0.85
confers_luckFunction · 0.85

Tested by

no test coverage detected