curse a few inventory items at random! */
| 566 | |
| 567 | /* curse a few inventory items at random! */ |
| 568 | void |
| 569 | rndcurse(void) |
| 570 | { |
| 571 | int nobj = 0; |
| 572 | int cnt, onum; |
| 573 | struct obj *otmp; |
| 574 | static const char mal_aura[] = "feel a malignant aura surround %s."; |
| 575 | |
| 576 | if (u_wield_art(ART_MAGICBANE) && rn2(20)) { |
| 577 | You(mal_aura, "the magic-absorbing blade"); |
| 578 | return; |
| 579 | } |
| 580 | |
| 581 | if (Antimagic) { |
| 582 | shieldeff(u.ux, u.uy); |
| 583 | } |
| 584 | |
| 585 | You(mal_aura, "you"); |
| 586 | |
| 587 | for (otmp = gi.invent; otmp; otmp = otmp->nobj) { |
| 588 | /* gold isn't subject to being cursed or blessed */ |
| 589 | if (otmp->oclass == COIN_CLASS) |
| 590 | continue; |
| 591 | nobj++; |
| 592 | } |
| 593 | cnt = rnd(6 / ((!!Antimagic) + (!!Half_spell_damage) + 1)); |
| 594 | if (nobj) { |
| 595 | for (; cnt > 0; cnt--) { |
| 596 | onum = rnd(nobj); |
| 597 | for (otmp = gi.invent; otmp; otmp = otmp->nobj) { |
| 598 | /* as above */ |
| 599 | if (otmp->oclass == COIN_CLASS) |
| 600 | continue; |
| 601 | if (--onum == 0) |
| 602 | break; /* found the target */ |
| 603 | } |
| 604 | /* the !otmp case should never happen; picking an already |
| 605 | cursed item happens--avoid "resists" message in that case */ |
| 606 | if (!otmp || otmp->cursed) |
| 607 | continue; /* next target */ |
| 608 | |
| 609 | if (otmp->oartifact && spec_ability(otmp, SPFX_INTEL) |
| 610 | && rn2(10) < 8) { |
| 611 | pline("%s!", Tobjnam(otmp, "resist")); |
| 612 | continue; |
| 613 | } |
| 614 | |
| 615 | if (otmp->blessed) |
| 616 | unbless(otmp); |
| 617 | else |
| 618 | curse(otmp); |
| 619 | } |
| 620 | update_inventory(); |
| 621 | } |
| 622 | |
| 623 | /* treat steed's saddle as extended part of hero's inventory */ |
| 624 | if (u.usteed && !rn2(4) && (otmp = which_armor(u.usteed, W_SADDLE)) != 0 |
| 625 | && !otmp->cursed) { /* skip if already cursed */ |
no test coverage detected