/** * Creates magical stairs after finishing a quest monster. */ static void build_quest_stairs(int y, int x) { int ny, nx; /* Stagger around */ while (!cave_valid_bold(y, x)) { int d = 1; /* Pick a location */ scatter(&ny, &nx, y, x, d, FALSE); /* Stagger */ y = ny; x = nx; } /* Destroy any objects */ delete_object(y, x); /* Explain the staircase */ msg("A magical staircase appears..."); /* Create stairs down */ /* XXX: fake depth = 0 to always produce downstairs */ cave_add_stairs(cave, y, x, 0); /* Update the visuals */ p_ptr->update |= (PU_UPDATE_VIEW | PU_MONSTERS); /* Fully update the flow */ p_ptr->update |= (PU_FORGET_FLOW | PU_UPDATE_FLOW); }
/*! * @brief プレイヤーの手による能動的な階段生成処理 / * Create stairs at or move previously created stairs into the player location. * @return なし */ void stair_creation(void) { saved_floor_type *sf_ptr; saved_floor_type *dest_sf_ptr; bool up = TRUE; bool down = TRUE; s16b dest_floor_id = 0; /* Forbid up staircases on Ironman mode */ if (ironman_downward) up = FALSE; /* Forbid down staircases on quest level */ if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth)) down = FALSE; /* No effect out of standard dungeon floor */ if (!dun_level || (!up && !down) || (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || p_ptr->inside_arena || p_ptr->inside_battle) { /* arena or quest */ #ifdef JP msg_print("効果がありません!"); #else msg_print("There is no effect!"); #endif return; } /* Artifacts resists */ if (!cave_valid_bold(p_ptr->y, p_ptr->x)) { #ifdef JP msg_print("床上のアイテムが呪文を跳ね返した。"); #else msg_print("The object resists the spell."); #endif return; } /* Destroy all objects in the grid */ delete_object(p_ptr->y, p_ptr->x); /* Extract current floor data */ sf_ptr = get_sf_ptr(p_ptr->floor_id); /* Paranoia */ if (!sf_ptr) { /* No floor id? -- Create now! */ p_ptr->floor_id = get_new_floor_id(); sf_ptr = get_sf_ptr(p_ptr->floor_id); } /* Choose randomly */ if (up && down) { if (randint0(100) < 50) up = FALSE; else down = FALSE; } /* Destination is already fixed */ if (up) { if (sf_ptr->upper_floor_id) dest_floor_id = sf_ptr->upper_floor_id; } else { if (sf_ptr->lower_floor_id) dest_floor_id = sf_ptr->lower_floor_id; } /* Search old stairs leading to the destination */ if (dest_floor_id) { int x, y; for (y = 0; y < cur_hgt; y++) { for (x = 0; x < cur_wid; x++) { cave_type *c_ptr = &cave[y][x]; if (!c_ptr->special) continue; if (feat_uses_special(c_ptr->feat)) continue; if (c_ptr->special != dest_floor_id) continue; /* Remove old stairs */ c_ptr->special = 0; cave_set_feat(y, x, floor_type[randint0(100)]); } } } /* No old destination -- Get new one now */ else { dest_floor_id = get_new_floor_id(); /* Fix it */ if (up) sf_ptr->upper_floor_id = dest_floor_id; else sf_ptr->lower_floor_id = dest_floor_id; } /* Extract destination floor data */ dest_sf_ptr = get_sf_ptr(dest_floor_id); /* Create a staircase */ if (up) { cave_set_feat(p_ptr->y, p_ptr->x, (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= dun_level - 2)) ? feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair); } else { cave_set_feat(p_ptr->y, p_ptr->x, (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= dun_level + 2)) ? feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair); } /* Connect this stairs to the destination */ cave[p_ptr->y][p_ptr->x].special = dest_floor_id; }