/* * Generates a random dungeon level -RAK- * * Hack -- regenerate any "overflow" levels */ void generate_cave(void) { int num; /* Fill the arrays of floors and walls in the good proportions */ set_floor_and_wall(dungeon_type); /* Generate */ for (num = 0; TRUE; num++) { bool okay = TRUE; cptr why = NULL; clear_cave(); /* Build the arena -KMW- */ if (p_ptr->inside_arena) { arena_gen(); } /* Build the battle -KMW- */ else if (p_ptr->inside_battle) { battle_gen(); } /* Enter a special quest level from the wilderness (QUEST_ENTER(id)) */ else if (enter_quest) { quests_generate(enter_quest); enter_quest = 0; } /* Build the town */ else if (!dun_level) { /* Make the wilderness */ if (p_ptr->wild_mode) wilderness_gen_small(); else wilderness_gen(); } /* Build a real level, possibly a quest level. * The quest level might want to generate itself * or it might simply need to 'place quest monsters' */ else { quest_ptr q; quests_on_generate(dungeon_type, dun_level); q = quests_get_current(); if (q && (q->flags & QF_GENERATE)) quest_generate(q); else { okay = level_gen(&why); if (okay && q) okay = quest_post_generate(q); } } if (o_max >= max_o_idx) { why = "too many objects"; okay = FALSE; } else if (m_max >= max_m_idx) { why = "too many monsters"; okay = FALSE; } if (okay) break; if (why) msg_format("Generation restarted (%s)", why); wipe_o_list(); wipe_m_list(); } glow_deep_lava_and_bldg(); p_ptr->enter_dungeon = FALSE; wipe_generate_cave_flags(); #if 0 wiz_lite(FALSE); detect_all(255); if (1) { int i, ct = 0; char buf[MAX_NLEN]; for (i = 0; i < max_o_idx; i++) { if (!o_list[i].k_idx) continue; ct++; identify_item(&o_list[i]); o_list[i].ident |= IDENT_MENTAL; if (o_list[i].name1 || o_list[i].name2) { object_desc(buf, &o_list[i], 0); msg_print(buf); } } msg_format("Objects=%d", ct); } { int i; int lvl = 0, ct = 0, uniques = 0, ct_drops = 0; for (i = 1; i < max_m_idx; i++) { monster_type *m_ptr = &m_list[i]; monster_race *r_ptr; if (!m_ptr->r_idx) continue; r_ptr = real_r_ptr(m_ptr); ct++; ct_drops += m_ptr->drop_ct; lvl += r_ptr->level; if (r_ptr->flags1 & RF1_UNIQUE) uniques++; } msg_format("DL=%d, Monsters=%d, Drops=%d, <ML>= %d, Uniques=%d", dun_level, ct, ct_drops, lvl/MAX(ct, 1), uniques); for (i = 0; i < ct_drops; i++) { object_type forge; char buf[MAX_NLEN]; make_object(&forge, 0); /* TODO: DROP_GOOD? */ /*if (forge.name1 || forge.name2)*/ if (forge.curse_flags) { identify_item(&forge); forge.ident |= IDENT_MENTAL; object_desc(buf, &forge, 0); msg_print(buf); } } } #endif }
/* * Generates a random dungeon level -RAK- * * Hack -- regenerate any "overflow" levels * * Hack -- allow auto-scumming via a gameplay option. */ void generate_cave(void) { int y, x, num; /* Hack - Reset the object theme */ dun_theme.treasure = 20; dun_theme.combat = 20; dun_theme.magic = 20; dun_theme.tools = 20; /* Build the wilderness */ if (!p_ptr->depth) { /* Hack XXX XXX */ /* Exit, information is already in other data type. */ p_ptr->px = (s16b)p_ptr->wilderness_x; p_ptr->py = (s16b)p_ptr->wilderness_y; /* The "dungeon" is ready */ character_dungeon = TRUE; /* Reset map panels */ map_panel_size(); /* Add monsters to the wilderness */ repopulate_wilderness(); return; } /* The dungeon is not ready */ character_dungeon = FALSE; /* Generate */ for (num = 0; TRUE; num++) { bool okay = TRUE; cptr why = NULL; /* * Start with a blank cave */ for (y = 0; y < MAX_HGT; y++) { (void) C_WIPE(cave[y], MAX_WID, cave_type); } /* * XXX XXX XXX XXX * Perhaps we should simply check for no monsters / objects * and complain if any exist. That way these two lines * could eventually be removed. */ o_max = 1; m_max = 1; /* Set the base level */ base_level = p_ptr->depth; /* Reset the monster generation level */ monster_level = base_level; /* Reset the object generation level */ object_level = base_level; /* Nothing special here yet */ good_item_flag = FALSE; /* Nothing good here yet */ rating = 0; #ifdef USE_SCRIPT if (!generate_level_callback(p_ptr->depth)) #endif /* USE_SCRIPT */ { okay = level_gen(&why); } /* Extract the feeling */ feeling = extract_feeling(); /* Prevent object over-flow */ if (o_max >= max_o_idx) { /* Message */ why = "too many objects"; /* Message */ okay = FALSE; } /* Prevent monster over-flow */ else if (m_max >= max_m_idx) { /* Message */ why = "too many monsters"; /* Message */ okay = FALSE; } /* Mega-Hack -- "auto-scum" */ else if ((auto_scum || ironman_autoscum) && (num < 100) && !p_ptr->inside_quest) { /* Require "goodness" */ if ((feeling > 9) || ((p_ptr->depth >= 7) && (feeling > 8)) || ((p_ptr->depth >= 15) && (feeling > 7)) || ((p_ptr->depth >= 35) && (feeling > 6)) || ((p_ptr->depth >= 70) && (feeling > 5))) { /* Give message to cheaters */ if (cheat_room || cheat_hear || cheat_peek || cheat_xtra) { /* Message */ why = "boring level"; } /* Try again */ okay = FALSE; } } /* Accept */ if (okay) break; /* Message */ if (why) msg_format("Generation restarted (%s)", why); /* Wipe the objects */ wipe_o_list(); /* Wipe the monsters */ wipe_m_list(); /* Wipe the fields */ wipe_f_list(); } /* The dungeon is ready */ character_dungeon = TRUE; /* Reset map panels */ map_panel_size(); /* Verify the panel */ verify_panel(); /* Remove the CAVE_ROOM flags... reused as CAVE_MNLT */ for (x = min_wid; x < max_wid; x++) { for (y = min_hgt; y < max_hgt; y++) { /* Clear the flag */ cave[y][x].info &= ~(CAVE_ROOM); } } /* Remember when this level was "created" */ old_turn = turn; }
/* * Generates a random dungeon level -RAK- * * Hack -- regenerate any "overflow" levels */ void generate_cave(void) { int num; /* Fill the arrays of floors and walls in the good proportions */ set_floor_and_wall(dungeon_type); /* Generate */ for (num = 0; TRUE; num++) { bool okay = TRUE; cptr why = NULL; /* Clear and empty the cave */ clear_cave(); /* Build the arena -KMW- */ if (p_ptr->inside_arena) { /* Small arena */ arena_gen(); } /* Build the battle -KMW- */ else if (p_ptr->inside_battle) { /* Small arena */ battle_gen(); } else if (p_ptr->inside_quest) { quest_gen(); } /* Build the town */ else if (!dun_level) { /* Make the wilderness */ if (p_ptr->wild_mode) wilderness_gen_small(); else wilderness_gen(); } /* Build a real level */ else { okay = level_gen(&why); } /* Prevent object over-flow */ if (o_max >= max_o_idx) { /* Message */ #ifdef JP why = "アイテムが多すぎる"; #else why = "too many objects"; #endif /* Message */ okay = FALSE; } /* Prevent monster over-flow */ else if (m_max >= max_m_idx) { /* Message */ #ifdef JP why = "モンスターが多すぎる"; #else why = "too many monsters"; #endif /* Message */ okay = FALSE; } /* Accept */ if (okay) break; /* Message */ #ifdef JP if (why) msg_format("生成やり直し(%s)", why); #else if (why) msg_format("Generation restarted (%s)", why); #endif /* Wipe the objects */ wipe_o_list(); /* Wipe the monsters */ wipe_m_list(); } /* Glow deep lava and building entrances */ glow_deep_lava_and_bldg(); /* Reset flag */ p_ptr->enter_dungeon = FALSE; wipe_generate_cave_flags(); }