예제 #1
0
void player_birth(void)
{
    birth_hack = TRUE;
    playtime = 0;

    wipe_m_list();
    player_wipe();

    /* Create a new character */
    if (py_birth() != UI_OK)
        quit(NULL);

    /* Here's a bunch of crap that py_birth() shouldn't need to know */
    init_turn();

    /* Generate the random seeds for the wilderness */
    seed_wilderness();

    birth_hack = FALSE;
}
예제 #2
0
/**
 * Clear the dungeon, ready for generation to begin.
 */
static void clear_cave(void)
{
	int x, y;

	wipe_o_list();
	wipe_m_list();

	/* Clear flags and flow information. */
	for (y = 0; y < DUNGEON_HGT; y++)
	{
		for (x = 0; x < DUNGEON_WID; x++)
		{
			/* No features */
			cave_feat[y][x] = 0;

			/* No flags */
			cave_info[y][x] = 0;
			cave_info2[y][x] = 0;

			/* No flow */
			cave_cost[y][x] = 0;
			cave_when[y][x] = 0;

			/* Clear any left-over monsters (should be none) and the player. */
			cave_m_idx[y][x] = 0;
		}
	}

	/* Mega-Hack -- no player in dungeon yet */
	p_ptr->px = p_ptr->py = 0;

	/* Hack -- illegal panel */
	Term->offset_y = DUNGEON_HGT;
	Term->offset_x = DUNGEON_WID;


	/* Nothing good here yet */
	rating = 0;
}
예제 #3
0
/*
 * 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;
}
예제 #4
0
/**
 * Generate a random dungeon level
 *
 * Hack -- regenerate any "overflow" levels
 *
 * Hack -- allow auto-scumming via a gameplay option.
 *
 * Note that this function resets flow data and grid flags directly.
 * Note that this function does not reset features, monsters, or objects.  
 * Features are left to the town and dungeon generation functions, and 
 * wipe_m_list() and wipe_o_list() handle monsters and objects.
 */
void generate_cave(void)
{
	int y, x, num;

	level_hgt = DUNGEON_HGT;
	level_wid = DUNGEON_WID;
	clear_cave();

	/* The dungeon is not ready */
	character_dungeon = FALSE;

	/* Don't know feeling yet */
	do_feeling = FALSE;

	/* Assume level is not themed. */
	p_ptr->themed_level = 0;

	/* Generate */
	for (num = 0; TRUE; num++) {
		int max = 2;
		bool okay = TRUE;
		const char *why = NULL;

		/* Reset monsters and objects */
		o_max = 1;
		m_max = 1;


		/* Clear flags and flow information. */
		for (y = 0; y < DUNGEON_HGT; y++) {
			for (x = 0; x < DUNGEON_WID; x++) {
				/* No flags */
				sqinfo_wipe(cave_info[y][x]);

				/* No flow */
				cave_cost[y][x] = 0;
				cave_when[y][x] = 0;

			}
		}


		/* Mega-Hack -- no player in dungeon yet */
		cave_m_idx[p_ptr->py][p_ptr->px] = 0;
		p_ptr->px = p_ptr->py = 0;

		/* Reset the monster generation level */
		monster_level = p_ptr->depth;

		/* Reset the object generation level */
		object_level = p_ptr->depth;

		/* Nothing good here yet */
		rating = 0;

		/* Only group is the player */
		group_id = 1;

		/* Set the number of wilderness "vaults" */
		wild_vaults = 0;
		if (OPT(night_mare))
			max += 2;

		if (p_ptr->depth > 10)
			wild_vaults += randint0(max);
		if (p_ptr->depth > 20)
			wild_vaults += randint0(max);
		if (p_ptr->depth > 30)
			wild_vaults += randint0(max);
		if (p_ptr->depth > 40)
			wild_vaults += randint0(max);

		if (no_vault())
			wild_vaults = 0;

		/* Build the town */
		if (!p_ptr->depth) {
			/* Make a town */
			town_gen();
		}

		/* Not town */
		else {
			/* It is possible for levels to be themed. */
			if ((randint0(THEMED_LEVEL_CHANCE) == 0)
				&& build_themed_level()) {
				/* Message. */
				if (OPT(cheat_room))
					msg("Themed level");
			}

			/* Build a real stage */
			else {
				switch (stage_map[p_ptr->stage][STAGE_TYPE]) {
				case CAVE:
					{
						cave_gen();
						break;
					}

				case VALLEY:
					{
						valley_gen();
						break;
					}

				case MOUNTAIN:
					{
						mtn_gen();
						break;
					}

				case MOUNTAINTOP:
					{
						mtntop_gen();
						break;
					}

				case FOREST:
					{
						forest_gen();
						break;
					}

				case SWAMP:
					{
						swamp_gen();
						break;
					}

				case RIVER:
					{
						river_gen();
						break;
					}

				case DESERT:
					{
						desert_gen();
						break;
					}

				case PLAIN:
					{
						plain_gen();
					}
				}
			}
		}

		okay = TRUE;


		/* Extract the feeling */
		if (rating > 50 + p_ptr->depth)
			feeling = 2;
		else if (rating > 40 + 4 * p_ptr->depth / 5)
			feeling = 3;
		else if (rating > 30 + 3 * p_ptr->depth / 5)
			feeling = 4;
		else if (rating > 20 + 2 * p_ptr->depth / 5)
			feeling = 5;
		else if (rating > 15 + 1 * p_ptr->depth / 3)
			feeling = 6;
		else if (rating > 10 + 1 * p_ptr->depth / 5)
			feeling = 7;
		else if (rating > 5 + 1 * p_ptr->depth / 10)
			feeling = 8;
		else if (rating > 0)
			feeling = 9;
		else
			feeling = 10;

		/* Hack -- no feeling in the town */
		if (!p_ptr->depth)
			feeling = 0;


		/* Prevent object over-flow */
		if (o_max >= z_info->o_max) {
			/* Message */
			why = "too many objects";

			/* Message */
			okay = FALSE;
		}

		/* Prevent monster over-flow */
		if (m_max >= z_info->m_max) {
			/* Message */
			why = "too many monsters";

			/* Message */
			okay = FALSE;
		}

		/* Mega-Hack -- "auto-scum" */
		if (OPT(auto_scum) && (num < 100) && !(p_ptr->themed_level)) {
			int fudge = (no_vault()? 3 : 0);

			/* Require "goodness" */
			if ((feeling > fudge + 9)
				|| ((p_ptr->depth >= 5) && (feeling > fudge + 8))
				|| ((p_ptr->depth >= 10) && (feeling > fudge + 7))
				|| ((p_ptr->depth >= 20) && (feeling > fudge + 6))) {
				/* Give message to cheaters */
				if (OPT(cheat_room) || OPT(cheat_hear) || OPT(cheat_peek)
					|| OPT(cheat_xtra)) {
					/* Message */
					why = "boring level";
				}

				/* Try again */
				okay = FALSE;
			}
		}

		/* Message */
		if ((OPT(cheat_room)) && (why))
			msg("Generation restarted (%s)", why);

		/* Accept */
		if (okay)
			break;

		/* Wipe the objects */
		wipe_o_list();

		/* Wipe the monsters */
		wipe_m_list();

		/* A themed level was generated */
		if (p_ptr->themed_level) {
			/* Allow the themed level to be generated again */
			p_ptr->themed_level_appeared &=
				~(1L << (p_ptr->themed_level - 1));

			/* This is not a themed level */
			p_ptr->themed_level = 0;
		}
	}


	/* The dungeon is ready */
	character_dungeon = TRUE;

	/* Reset path_coord */
	p_ptr->path_coord = 0;

	/* Verify the panel */
	verify_panel();

	/* Apply illumination */
	illuminate();

	/* Reset the number of traps, runes, and thefts on the level. */
	num_trap_on_level = 0;
	number_of_thefts_on_level = 0;
	for (num = 0; num < RUNE_TAIL; num++)
		num_runes_on_level[num] = 0;
}
/*
 * 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
}
/*
 *  Clear and empty the cave
 */
void clear_cave(void)
{
    int x, y;

    /* Very simplified version of wipe_o_list() */
    C_WIPE(o_list, o_max, object_type);
    o_max = 1;
    o_cnt = 0;
    unique_count = 0;

    /* Note, when I replaced the above with wipe_o_list(), artifacts started spawning
       multiple times!
      wipe_o_list();*/

    wipe_m_list();

    /* Pre-calc cur_num of pets in party_mon[] */
    precalc_cur_num_of_pet();

    /* Start with a blank cave */
    for (y = 0; y < MAX_HGT; y++)
    {
        for (x = 0; x < MAX_WID; x++)
        {
            cave_type *c_ptr = &cave[y][x];

            /* No flags */
            c_ptr->info = 0;

            /* No features */
            c_ptr->feat = 0;

            /* No objects */
            c_ptr->o_idx = 0;

            /* No monsters */
            c_ptr->m_idx = 0;

            /* No special */
            c_ptr->special = 0;

            /* No mimic */
            c_ptr->mimic = 0;

            /* No flow */
            c_ptr->cost = 0;
            c_ptr->dist = 0;
            c_ptr->when = 0;
        }
    }

    /* Mega-Hack -- no player yet */
    px = py = 0;

    /* Set the base level */
    base_level = dun_level;

    /* Reset the monster generation level */
    monster_level = base_level;

    /* Reset the object generation level */
    object_level = base_level;
}
예제 #7
0
/*
 * 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();
}