* Return the first item that is conveying a particular intrinsic. */
| 2373 | * Return the first item that is conveying a particular intrinsic. |
| 2374 | */ |
| 2375 | struct obj * |
| 2376 | what_gives(long *abil) |
| 2377 | { |
| 2378 | struct obj *obj; |
| 2379 | uchar dtyp; |
| 2380 | unsigned long spfx; |
| 2381 | long wornbits; |
| 2382 | long wornmask = (W_ARM | W_ARMC | W_ARMH | W_ARMS |
| 2383 | | W_ARMG | W_ARMF | W_ARMU |
| 2384 | | W_AMUL | W_RINGL | W_RINGR | W_TOOL |
| 2385 | | W_ART | W_ARTI); |
| 2386 | |
| 2387 | if (u.twoweap) |
| 2388 | wornmask |= W_SWAPWEP; |
| 2389 | dtyp = abil_to_adtyp(abil); |
| 2390 | spfx = abil_to_spfx(abil); |
| 2391 | wornbits = (wornmask & *abil); |
| 2392 | |
| 2393 | for (obj = gi.invent; obj; obj = obj->nobj) { |
| 2394 | if (obj->oartifact |
| 2395 | && (abil != &EWarn_of_mon || svc.context.warntype.obj)) { |
| 2396 | const struct artifact *art = get_artifact(obj); |
| 2397 | |
| 2398 | if (art != &artilist[ART_NONARTIFACT]) { |
| 2399 | if (dtyp) { |
| 2400 | if (art->cary.adtyp == dtyp /* carried */ |
| 2401 | || (art->defn.adtyp == dtyp /* defends while worn */ |
| 2402 | && (obj->owornmask & ~(W_ART | W_ARTI)))) |
| 2403 | return obj; |
| 2404 | } |
| 2405 | if (spfx) { |
| 2406 | /* property conferred when carried */ |
| 2407 | if ((art->cspfx & spfx) == spfx) |
| 2408 | return obj; |
| 2409 | /* property conferred when wielded or worn */ |
| 2410 | if ((art->spfx & spfx) == spfx && obj->owornmask) |
| 2411 | return obj; |
| 2412 | } |
| 2413 | if (obj == uwep && abil == &EBlnd_resist |
| 2414 | && (*abil & W_WEP) != 0L) { |
| 2415 | return obj; /* Sunsword */ |
| 2416 | } |
| 2417 | } |
| 2418 | } else { |
| 2419 | if (wornbits && wornbits == (wornmask & obj->owornmask)) |
| 2420 | return obj; |
| 2421 | } |
| 2422 | } |
| 2423 | return (struct obj *) 0; |
| 2424 | } |
| 2425 | |
| 2426 | const char * |
| 2427 | glow_color(int arti_indx) |
no test coverage detected