returns number of scattered objects */
| 718 | |
| 719 | /* returns number of scattered objects */ |
| 720 | long |
| 721 | scatter( |
| 722 | coordxy sx, coordxy sy, /* location of objects to scatter */ |
| 723 | int blastforce, /* force behind the scattering */ |
| 724 | unsigned int scflags, |
| 725 | struct obj *obj) /* only scatter this obj */ |
| 726 | { |
| 727 | struct obj *otmp; |
| 728 | int tmp; |
| 729 | int farthest = 0; |
| 730 | uchar typ; |
| 731 | long qtmp; |
| 732 | boolean used_up; |
| 733 | boolean individual_object = obj ? TRUE : FALSE; |
| 734 | boolean shop_origin, lostgoods = FALSE; |
| 735 | struct monst *mtmp, *shkp = 0; |
| 736 | struct scatter_chain *stmp, *stmp2 = 0; |
| 737 | struct scatter_chain *schain = (struct scatter_chain *) 0; |
| 738 | long total = 0L; |
| 739 | |
| 740 | if (individual_object && (obj->ox != sx || obj->oy != sy)) |
| 741 | impossible("scattered object <%d,%d> not at scatter site <%d,%d>", |
| 742 | obj->ox, obj->oy, sx, sy); |
| 743 | |
| 744 | shop_origin = ((shkp = shop_keeper(*in_rooms(sx, sy, SHOPBASE))) != 0 |
| 745 | && costly_spot(sx, sy)); |
| 746 | if (shop_origin) |
| 747 | credit_report(shkp, 0, TRUE); /* establish baseline, without msgs */ |
| 748 | |
| 749 | while ((otmp = (individual_object ? obj |
| 750 | : svl.level.objects[sx][sy])) != 0) { |
| 751 | if (otmp == uball || otmp == uchain) { |
| 752 | boolean waschain = (otmp == uchain); |
| 753 | |
| 754 | Soundeffect(se_chain_shatters, 25); |
| 755 | pline_The("chain shatters!"); |
| 756 | unpunish(); |
| 757 | if (waschain) |
| 758 | continue; |
| 759 | } |
| 760 | if (otmp->quan > 1L) { |
| 761 | qtmp = otmp->quan - 1L; |
| 762 | if (qtmp > LARGEST_INT) |
| 763 | qtmp = LARGEST_INT; |
| 764 | qtmp = (long) rnd((int) qtmp); |
| 765 | otmp = splitobj(otmp, qtmp); |
| 766 | } else { |
| 767 | obj = (struct obj *) 0; /* all used */ |
| 768 | } |
| 769 | obj_extract_self(otmp); |
| 770 | used_up = FALSE; |
| 771 | |
| 772 | /* 9 in 10 chance of fracturing boulders or statues */ |
| 773 | if ((scflags & MAY_FRACTURE) != 0 |
| 774 | && (otmp->otyp == BOULDER || otmp->otyp == STATUE) |
| 775 | && rn2(10)) { |
| 776 | if (otmp->otyp == BOULDER) { |
| 777 | if (cansee(sx, sy)) { |
no test coverage detected