Use up at least minwt number of things made of material mat. * There's also a chance that other stuff will be used up. Finally, * there's a random factor here to keep from always using the stuff * at the top of the pile. */
| 1502 | * at the top of the pile. |
| 1503 | */ |
| 1504 | staticfn void |
| 1505 | polyuse(struct obj *objhdr, int mat, int minwt) |
| 1506 | { |
| 1507 | struct obj *otmp, *otmp2; |
| 1508 | |
| 1509 | for (otmp = objhdr; minwt > 0 && otmp; otmp = otmp2) { |
| 1510 | otmp2 = otmp->nexthere; |
| 1511 | if (svc.context.bypasses && otmp->bypass) |
| 1512 | continue; |
| 1513 | if (otmp == uball || otmp == uchain) |
| 1514 | continue; |
| 1515 | if (obj_resists(otmp, 0, 0)) |
| 1516 | continue; /* preserve unique objects */ |
| 1517 | #ifdef MAIL_STRUCTURES |
| 1518 | if (otmp->otyp == SCR_MAIL) |
| 1519 | continue; |
| 1520 | #endif |
| 1521 | |
| 1522 | if (((int) objects[otmp->otyp].oc_material == mat) |
| 1523 | == (rn2(minwt + 1) != 0)) { |
| 1524 | /* appropriately add damage to bill */ |
| 1525 | if (costly_spot(otmp->ox, otmp->oy)) { |
| 1526 | if (*u.ushops) |
| 1527 | addtobill(otmp, FALSE, FALSE, FALSE); |
| 1528 | else |
| 1529 | (void) stolen_value(otmp, otmp->ox, otmp->oy, FALSE, |
| 1530 | FALSE); |
| 1531 | } |
| 1532 | if (otmp->quan < LARGEST_INT) |
| 1533 | minwt -= (int) otmp->quan; |
| 1534 | else |
| 1535 | minwt = 0; |
| 1536 | delobj(otmp); |
| 1537 | } |
| 1538 | } |
| 1539 | } |
| 1540 | |
| 1541 | /* |
| 1542 | * Polymorph some of the stuff in this pile into a monster, preferably |
no test coverage detected