MCPcopy Create free account
hub / github.com/NetHack/NetHack / dighole

Function dighole

src/dig.c:881–1024  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

879}
880
881RESTORE_WARNING_FORMAT_NONLITERAL
882
883/* return TRUE if digging succeeded, FALSE otherwise */
884boolean
885dighole(boolean pit_only, boolean by_magic, coord *cc)
886{
887 struct trap *ttmp;
888 struct rm *lev;
889 struct obj *boulder_here;
890 schar typ, old_typ;
891 coordxy dig_x, dig_y;
892 boolean nohole, retval = FALSE;
893 enum digcheck_result dig_check_result;
894
895 if (!cc) {
896 dig_x = u.ux;
897 dig_y = u.uy;
898 } else {
899 dig_x = cc->x;
900 dig_y = cc->y;
901 if (!isok(dig_x, dig_y))
902 return FALSE;
903 }
904
905 ttmp = t_at(dig_x, dig_y);
906 lev = &levl[dig_x][dig_y];
907 dig_check_result = dig_check(BY_YOU, dig_x, dig_y);
908 /* nohole = (!Can_dig_down(&u.uz) && !lev->candig); */
909 nohole = (dig_check_result == DIGCHECK_FAIL_CANTDIG
910 || dig_check_result == DIGCHECK_FAIL_TOOHARD);
911 old_typ = lev->typ;
912
913 if ((ttmp && (undestroyable_trap(ttmp->ttyp) || nohole))
914 || (IS_OBSTRUCTED(old_typ) && old_typ != SDOOR
915 && (lev->wall_info & W_NONDIGGABLE) != 0)) {
916 pline_The("%s %shere is too hard to dig in.", surface(dig_x, dig_y),
917 (dig_x != u.ux || dig_y != u.uy) ? "t" : "");
918 } else if (ttmp && is_magical_trap(ttmp->ttyp)) {
919 explode(dig_x, dig_y, 0, 20 + d(3, 6), TRAP_EXPLODE, EXPL_MAGICAL);
920 deltrap(ttmp);
921 newsym(dig_x, dig_y);
922 } else if (is_pool_or_lava(dig_x, dig_y)) {
923 pline_The("%s sloshes furiously for a moment, then subsides.",
924 hliquid(is_lava(dig_x, dig_y) ? "lava" : "water"));
925 wake_nearby(FALSE); /* splashing */
926
927 } else if (old_typ == DRAWBRIDGE_DOWN
928 || (is_drawbridge_wall(dig_x, dig_y) >= 0)) {
929 /* drawbridge_down is the platform crossing the moat when the
930 bridge is extended; drawbridge_wall is the open "doorway" or
931 closed "door" where the portcullis/mechanism is located */
932 if (pit_only) {
933 pline_The("drawbridge seems too hard to dig through.");
934 } else {
935 coordxy x = dig_x, y = dig_y;
936 /* if under the portcullis, the bridge is adjacent */
937 (void) find_drawbridge(&x, &y);
938 destroy_drawbridge(x, y);

Callers 3

digFunction · 0.85
zap_digFunction · 0.85
escape_tombFunction · 0.85

Calls 15

isokFunction · 0.85
t_atFunction · 0.85
dig_checkFunction · 0.85
pline_TheFunction · 0.85
surfaceFunction · 0.85
explodeFunction · 0.85
dFunction · 0.85
deltrapFunction · 0.85
newsymFunction · 0.85
is_pool_or_lavaFunction · 0.85
hliquidFunction · 0.85
is_lavaFunction · 0.85

Tested by

no test coverage detected