MCPcopy Index your code
hub / github.com/NetHack/NetHack / scatter

Function scatter

src/explode.c:720–947  ·  view source on GitHub ↗

returns number of scattered objects */

Source from the content-addressed store, hash-verified

718
719/* returns number of scattered objects */
720long
721scatter(
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)) {

Callers 7

do_boh_explosionFunction · 0.85
blow_up_landmineFunction · 0.85
launch_objFunction · 0.85
really_kick_objectFunction · 0.85
kick_nondoorFunction · 0.85
obj_deliveryFunction · 0.85
destroy_drawbridgeFunction · 0.85

Calls 15

shop_keeperFunction · 0.85
in_roomsFunction · 0.85
costly_spotFunction · 0.85
credit_reportFunction · 0.85
pline_TheFunction · 0.85
unpunishFunction · 0.85
rndFunction · 0.85
splitobjFunction · 0.85
obj_extract_selfFunction · 0.85
rn2Function · 0.85
TobjnamFunction · 0.85
You_hearFunction · 0.85

Tested by

no test coverage detected