/** * Perform the basic "tunnel" command * * Assumes that no monster is blocking the destination. * Uses twall() (above) to do all "terrain feature changing". * Returns true if repeated commands may continue. */ static bool do_cmd_tunnel_aux(int y, int x) { bool more = false; int digging_chances[DIGGING_MAX]; bool okay = false; bool gold = square_hasgoldvein(cave, y, x); bool rubble = square_isrubble(cave, y, x); /* Verify legality */ if (!do_cmd_tunnel_test(y, x)) return (false); calc_digging_chances(&player->state, digging_chances); /* Do we succeed? */ okay = (digging_chances[square_digging(cave, y, x) - 1] > randint0(1600)); /* Success */ if (okay && twall(y, x)) { /* Rubble is a special case - could be handled more generally NRM */ if (rubble) { /* Message */ msg("You have removed the rubble."); /* Place an object (except in town) */ if ((randint0(100) < 10) && player->depth) { /* Create a simple object */ place_object(cave, y, x, player->depth, false, false, ORIGIN_RUBBLE, 0); /* Observe the new object */ if (!ignore_item_ok(square_object(cave, y, x)) && square_isseen(cave, y, x)) msg("You have found something!"); } } else if (gold) { /* Found treasure */ place_gold(cave, y, x, player->depth, ORIGIN_FLOOR); msg("You have found something!"); } else { msg("You have finished the tunnel."); } } else { /* Failure, continue digging */ if (rubble) msg("You dig in the rubble."); else msg("You tunnel into the %s.", square_apparent_name(cave, player, y, x)); more = true; if (square_issecretdoor(cave, y, x)) /* Occasional Search XXX XXX */ if (randint0(100) < 25) search(false); } /* Result */ return (more); }
/* * Perform the basic "tunnel" command * * Assumes that no monster is blocking the destination * * Uses "twall" (above) to do all "terrain feature changing". * * Returns TRUE if repeated commands may continue */ static bool do_cmd_tunnel_aux(int y, int x) { bool more = FALSE; /* Verify legality */ if (!do_cmd_tunnel_test(y, x)) return (FALSE); /* Sound XXX XXX XXX */ /* sound(MSG_DIG); */ /* Titanium */ if (cave_feat[y][x] >= FEAT_PERM_EXTRA) { msg_print("This seems to be permanent rock."); } /* Granite */ else if (cave_feat[y][x] >= FEAT_WALL_EXTRA) { /* Tunnel */ if ((p_ptr->state.skills[SKILL_DIGGING] > 40 + randint0(1600)) && twall(y, x)) { msg_print("You have finished the tunnel."); } /* Keep trying */ else { /* We may continue tunelling */ msg_print("You tunnel into the granite wall."); more = TRUE; } } /* Quartz / Magma */ else if (cave_feat[y][x] >= FEAT_MAGMA) { bool okay = FALSE; bool gold = FALSE; bool hard = FALSE; /* Found gold */ if (cave_feat[y][x] >= FEAT_MAGMA_H) { gold = TRUE; } /* Extract "quartz" flag XXX XXX XXX */ if ((cave_feat[y][x] - FEAT_MAGMA) & 0x01) { hard = TRUE; } /* Quartz */ if (hard) { okay = (p_ptr->state.skills[SKILL_DIGGING] > 20 + randint0(800)); } /* Magma */ else { okay = (p_ptr->state.skills[SKILL_DIGGING] > 10 + randint0(400)); } /* Success */ if (okay && twall(y, x)) { /* Found treasure */ if (gold) { /* Place some gold */ place_gold(y, x, p_ptr->depth); /* Message */ msg_print("You have found something!"); } /* Found nothing */ else { /* Message */ msg_print("You have finished the tunnel."); } } /* Failure (quartz) */ else if (hard) { /* Message, continue digging */ msg_print("You tunnel into the quartz vein."); more = TRUE; } /* Failure (magma) */ else { /* Message, continue digging */ msg_print("You tunnel into the magma vein."); more = TRUE; } } /* Rubble */ else if (cave_feat[y][x] == FEAT_RUBBLE) { /* Remove the rubble */ if ((p_ptr->state.skills[SKILL_DIGGING] > randint0(200)) && twall(y, x)) { /* Message */ msg_print("You have removed the rubble."); /* Hack -- place an object */ if (randint0(100) < 10) { /* Create a simple object */ place_object(y, x, p_ptr->depth, FALSE, FALSE); /* Observe the new object */ if (!squelch_item_ok(&o_list[cave_o_idx[y][x]]) && player_can_see_bold(y, x)) { msg_print("You have found something!"); } } } else { /* Message, keep digging */ msg_print("You dig in the rubble."); more = TRUE; } } /* Secret doors */ else if (cave_feat[y][x] >= FEAT_SECRET) { /* Tunnel */ if ((p_ptr->state.skills[SKILL_DIGGING] > 30 + randint0(1200)) && twall(y, x)) { msg_print("You have finished the tunnel."); } /* Keep trying */ else { /* We may continue tunelling */ msg_print("You tunnel into the granite wall."); more = TRUE; /* Occasional Search XXX XXX */ if (randint0(100) < 25) search(FALSE); } } /* Doors */ else { /* Tunnel */ if ((p_ptr->state.skills[SKILL_DIGGING] > 30 + randint0(1200)) && twall(y, x)) { msg_print("You have finished the tunnel."); } /* Keep trying */ else { /* We may continue tunelling */ msg_print("You tunnel into the door."); more = TRUE; } } /* Result */ return (more); }
/* * Perform the basic "tunnel" command * * Assumes that no monster is blocking the destination * * Uses "twall" (above) to do all "terrain feature changing". * * Returns TRUE if repeated commands may continue */ static bool do_cmd_tunnel_aux(int y, int x) { bool more = FALSE; /* Verify legality */ if (!do_cmd_tunnel_test(y, x)) return (FALSE); /* Sound XXX XXX XXX */ /* sound(MSG_DIG); */ /* Titanium */ if (cave_isperm(cave, y, x)) { msg("This seems to be permanent rock."); } /* Granite */ else if (cave_isrock(cave, y, x)) { /* Tunnel */ if ((p_ptr->state.skills[SKILL_DIGGING] > 40 + randint0(1600)) && twall(y, x)) { msg("You have finished the tunnel."); } /* Keep trying */ else { /* We may continue tunelling */ msg("You tunnel into the granite wall."); more = TRUE; } } /* Quartz / Magma */ else if (cave_ismagma(cave, y, x) || cave_isquartz(cave, y, x)) { bool okay = FALSE; bool gold = FALSE; bool hard = FALSE; /* Found gold */ if (cave_hasgoldvein(cave, y, x)) gold = TRUE; /* Extract "quartz" flag XXX XXX XXX */ if (cave_isquartz(cave, y, x)) hard = TRUE; /* Quartz */ if (hard) okay = (p_ptr->state.skills[SKILL_DIGGING] > 20 + randint0(800)); /* Magma */ else okay = (p_ptr->state.skills[SKILL_DIGGING] > 10 + randint0(400)); /* Success */ if (okay && twall(y, x)) { /* Found treasure */ if (gold) { /* Place some gold */ place_gold(cave, y, x, p_ptr->depth, ORIGIN_FLOOR); /* Message */ msg("You have found something!"); } /* Found nothing */ else { /* Message */ msg("You have finished the tunnel."); } } /* Failure (quartz) */ else if (hard) { /* Message, continue digging */ msg("You tunnel into the quartz vein."); more = TRUE; } /* Failure (magma) */ else { /* Message, continue digging */ msg("You tunnel into the magma vein."); more = TRUE; } } /* Rubble */ else if (cave_isrubble(cave, y, x)) { /* Remove the rubble */ if ((p_ptr->state.skills[SKILL_DIGGING] > randint0(200)) && twall(y, x)) { /* Message */ msg("You have removed the rubble."); /* Hack -- place an object */ if (randint0(100) < 10) { /* Create a simple object */ place_object(cave, y, x, p_ptr->depth, FALSE, FALSE, ORIGIN_RUBBLE, 0); /* Observe the new object */ if (!squelch_item_ok(object_byid(cave->o_idx[y][x])) && player_can_see_bold(y, x)) msg("You have found something!"); } } else { /* Message, keep digging */ msg("You dig in the rubble."); more = TRUE; } } /* Secret doors */ else if (cave_issecretdoor(cave, y, x)) { /* Tunnel */ if ((p_ptr->state.skills[SKILL_DIGGING] > 30 + randint0(1200)) && twall(y, x)) { msg("You have finished the tunnel."); } /* Keep trying */ else { /* We may continue tunelling */ msg("You tunnel into the granite wall."); more = TRUE; /* Occasional Search XXX XXX */ if (randint0(100) < 25) search(FALSE); } } /* Doors */ else { /* Tunnel */ if ((p_ptr->state.skills[SKILL_DIGGING] > 30 + randint0(1200)) && twall(y, x)) { msg("You have finished the tunnel."); } /* Keep trying */ else { /* We may continue tunelling */ msg("You tunnel into the door."); more = TRUE; } } /* Result */ return (more); }