/* * Count the number of "corridor" grids adjacent to the given grid. * * Note -- Assumes "in_bounds(y1, x1)" * * XXX XXX This routine currently only counts actual "empty floor" * grids which are not in rooms. We might want to also count stairs, * open doors, closed doors, etc. */ static int next_to_corr(int y1, int x1) { int i, y, x, k = 0; cave_type *c_ptr; /* Scan adjacent grids */ for (i = 0; i < 4; i++) { /* Extract the location */ y = y1 + ddy_ddd[i]; x = x1 + ddx_ddd[i]; /* Access the grid */ c_ptr = &cave[y][x]; /* Skip non floors */ if (cave_have_flag_grid(c_ptr, FF_WALL)) continue; /* Skip non "empty floor" grids */ if (!is_floor_grid(c_ptr)) continue; /* Skip grids inside rooms */ if (c_ptr->info & (CAVE_ROOM)) continue; /* Count these grids */ k++; } /* Return the number of corridors */ return (k); }
static bool _create_shots(void) { int x, y, dir, slot; cave_type *c_ptr; object_type forge; if (!get_rep_dir(&dir, FALSE)) return FALSE; y = py + ddy[dir]; x = px + ddx[dir]; c_ptr = &cave[y][x]; if (!have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_CAN_DIG)) { msg_print("You need pile of rubble."); return FALSE; } if (!cave_have_flag_grid(c_ptr, FF_CAN_DIG) || !cave_have_flag_grid(c_ptr, FF_HURT_ROCK)) { msg_print("You failed to make ammo."); return FALSE; } object_prep(&forge, lookup_kind(TV_SHOT, m_bonus(1, p_ptr->lev) + 1)); forge.number = (byte)rand_range(15,30); apply_magic(&forge, p_ptr->lev, AM_NO_FIXED_ART); obj_identify(&forge); forge.discount = 99; msg_print("You make some ammo."); slot = inven_carry(&forge); if (slot >= 0) autopick_alter_item(slot, FALSE); cave_alter_feat(y, x, FF_HURT_ROCK); p_ptr->update |= PU_FLOW; return TRUE; }