Exemplo n.º 1
0
void
item_dump_attr(struct item *item, struct map *map, FILE *out)
{
	struct attr attr;
	fprintf(out,"type=%s", item_to_name(item->type));
	while (item_attr_get(item, attr_any, &attr)) 
		fprintf(out," %s='%s'", attr_to_name(attr.type), attr_to_text(&attr, map, 1));
}
Exemplo n.º 2
0
static void
popup_show_attr_val(struct map *map, void *menu, struct attr *attr)
{
	char *attr_name=attr_to_name(attr->type);
	char *str;

	str=attr_to_text(attr, /*map,*/ 1);
	popup_printf(menu, menu_type_menu, "%s: %s", attr_name, str);
	g_free(str);
}
Exemplo n.º 3
0
void
item_bin_dump(struct item_bin *ib, FILE *out)
{
	struct coord *c;
	struct attr_bin *a;
	struct attr attr;
	int *attr_start;
	int *attr_end;
	int i;
	char *str;

	c=(struct coord *)(ib+1);
	if (ib->type < type_line) {
		dump_coord(c,out);
		fprintf(out, " ");
	}
	attr_start=(int *)(ib+1)+ib->clen;
	attr_end=(int *)ib+ib->len+1;
	fprintf(out,"type=%s", item_to_name(ib->type));
	while (attr_start < attr_end) {
		a=(struct attr_bin *)(attr_start);
		attr_start+=a->len+1;
		attr.type=a->type;
		attr_data_set(&attr, (a+1));
		str=attr_to_text(&attr, NULL, 1);
		fprintf(out," %s=\"%s\"", attr_to_name(a->type), str);
		g_free(str);
	}
	fprintf(out," debug=\"length=%d\"", ib->len);
	fprintf(out,"\n");
	if (ib->type >= type_line) {
		for (i = 0 ; i < ib->clen/2 ; i++) {
			dump_coord(c+i,out);
			fprintf(out,"\n");
		}
	}
}
Exemplo n.º 4
0
/*
 * Create a spoiler file for monsters (-SHAWN-)
 */
static void spoil_mon_info(const char *fname)
{
	char buf[1024];
	int i, n;
	u16b *who;
	int count = 0;


	/* Open the file */
	path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
	fh = file_open(buf, MODE_WRITE, FTYPE_TEXT);

	/* Oops */
	if (!fh)
	{
		msg("Cannot create spoiler file.");
		return;
	}

	/* Dump to the spoiler file */
	text_out_hook = text_out_to_file;
	text_out_file = fh;

	/* Dump the header */
	text_out("Monster Spoilers for %s\n", buildid);
	text_out("------------------------------------------\n\n");

	/* Allocate the "who" array */
	who = C_ZNEW(z_info->r_max, u16b);

	/* Scan the monsters */
	for (i = 1; i < z_info->r_max; i++)
	{
		monster_race *r_ptr = &r_info[i];

		/* Use that monster */
		if (r_ptr->name) who[count++] = (u16b)i;
	}

	sort(who, count, sizeof(*who), cmp_monsters);

	/*
	 * List all monsters in order (except the ghost).
	 */
	for (n = 0; n < count; n++)
	{
		int r_idx = who[n];
		monster_race *r_ptr = &r_info[r_idx];

		/* Prefix */
		if (rf_has(r_ptr->flags, RF_QUESTOR))
		{
			text_out("[Q] ");
		}
		else if (rf_has(r_ptr->flags, RF_UNIQUE))
		{
			text_out("[U] ");
		}
		else
		{
			text_out("The ");
		}

		/* Name */
		text_out("%s  (",  r_ptr->name);	/* ---)--- */

		/* Color */
		text_out(attr_to_text(r_ptr->d_attr));

		/* Symbol --(-- */
		text_out(" '%c')\n", r_ptr->d_char);


		/* Indent */
		text_out("=== ");

		/* Number */
		text_out("Num:%d  ", r_idx);

		/* Level */
		text_out("Lev:%d  ", r_ptr->level);

		/* Rarity */
		text_out("Rar:%d  ", r_ptr->rarity);

		/* Speed */
		if (r_ptr->speed >= 110)
		{
			text_out("Spd:+%d  ", (r_ptr->speed - 110));
		}
		else
		{
			text_out("Spd:-%d  ", (110 - r_ptr->speed));
		}

		/* Hitpoints */
		text_out("Hp:%d  ", r_ptr->avg_hp);

		/* Armor Class */
		text_out("Ac:%d  ", r_ptr->ac);

		/* Experience */
		text_out("Exp:%ld\n", (long)(r_ptr->mexp));

		/* Describe */
		describe_monster(r_idx, TRUE);

		/* Terminate the entry */
		text_out("\n");
	}

	/* Free the "who" array */
	FREE(who);

	/* Check for errors */
	if (!file_close(fh))
	{
		msg("Cannot close spoiler file.");
		return;
	}

	msg("Successfully created a spoiler file.");
}
Exemplo n.º 5
0
/*
 * Create a spoiler file for monsters
 */
static void spoil_mon_desc(const char *fname)
{
	int i, n = 0;

	char buf[1024];

	char nam[80];
	char lev[80];
	char rar[80];
	char spd[80];
	char ac[80];
	char hp[80];
	char exp[80];

	u16b *who;

	/* We use either ascii or system-specific encoding */
 	int encoding = (OPT(xchars_to_file)) ? SYSTEM_SPECIFIC : ASCII;

	/* Build the filename */
	path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
	fh = file_open(buf, MODE_WRITE, FTYPE_TEXT);

	/* Oops */
	if (!fh)
	{
		msg("Cannot create spoiler file.");
		return;
	}

	/* Dump the header */
	x_file_putf(fh, encoding, "Monster Spoilers for %s\n", buildid);
	x_file_putf(fh, encoding, "------------------------------------------\n\n");

	/* Dump the header */
	x_file_putf(fh, encoding, "%-40.40s%4s%4s%6s%8s%4s  %11.11s\n",
	        "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
	x_file_putf(fh, encoding, "%-40.40s%4s%4s%6s%8s%4s  %11.11s\n",
	        "----", "---", "---", "---", "--", "--", "-----------");

	/* Allocate the "who" array */
	who = C_ZNEW(z_info->r_max, u16b);

	/* Scan the monsters (except the ghost) */
	for (i = 1; i < z_info->r_max - 1; i++)
	{
		monster_race *r_ptr = &r_info[i];

		/* Use that monster */
		if (r_ptr->name) who[n++] = (u16b)i;
	}

	/* Sort the array by dungeon depth of monsters */
	sort(who, n, sizeof(*who), cmp_monsters);

	/* Scan again */
	for (i = 0; i < n; i++)
	{
		monster_race *r_ptr = &r_info[who[i]];

		const char *name = r_ptr->name;

		/* Get the "name" */
		if (rf_has(r_ptr->flags, RF_QUESTOR))
		{
			strnfmt(nam, sizeof(nam), "[Q] %s", name);
		}
		else if (rf_has(r_ptr->flags, RF_UNIQUE))
		{
			strnfmt(nam, sizeof(nam), "[U] %s", name);
		}
		else
		{
			strnfmt(nam, sizeof(nam), "The %s", name);
		}


		/* Level */
		strnfmt(lev, sizeof(lev), "%d", r_ptr->level);

		/* Rarity */
		strnfmt(rar, sizeof(rar), "%d", r_ptr->rarity);

		/* Speed */
		if (r_ptr->speed >= 110)
			strnfmt(spd, sizeof(spd), "+%d", (r_ptr->speed - 110));
		else
			strnfmt(spd, sizeof(spd), "-%d", (110 - r_ptr->speed));

		/* Armor Class */
		strnfmt(ac, sizeof(ac), "%d", r_ptr->ac);

		/* Hitpoints */
		strnfmt(hp, sizeof(hp), "%d", r_ptr->avg_hp);


		/* Experience */
		strnfmt(exp, sizeof(exp), "%ld", (long)(r_ptr->mexp));

		/* Hack -- use visual instead */
		strnfmt(exp, sizeof(exp), "%s '%c'", attr_to_text(r_ptr->d_attr), r_ptr->d_char);

		/* Dump the info */
		x_file_putf(fh, encoding, "%-40.40s%4s%4s%6s%8s%4s  %11.11s\n",
		        nam, lev, rar, spd, hp, ac, exp);
	}

	/* End it */
	file_putf(fh, "\n");

	/* Free the "who" array */
	FREE(who);


	/* Check for errors */
	if (!file_close(fh))
	{
		msg("Cannot close spoiler file.");
		return;
	}

	/* Worked */
	msg("Successfully created a spoiler file.");
}
Exemplo n.º 6
0
/**
 * Create a spoiler file for monsters (-SHAWN-)
 */
static void spoil_mon_info(const char *fname)
{
	char buf[1024];
	int i, n;
	u16b *who;
	int count = 0;
	textblock *tb = NULL;

	/* Open the file */
	path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
	fh = file_open(buf, MODE_WRITE, FTYPE_TEXT);

	if (!fh) {
		msg("Cannot create spoiler file.");
		return;
	}

	/* Dump the header */
	tb = textblock_new();
	textblock_append(tb, "Monster Spoilers for %s\n", buildid);
	textblock_append(tb, "------------------------------------------\n\n");
	textblock_to_file(tb, fh, 0, 75);
	textblock_free(tb);
	tb = NULL;

	/* Allocate the "who" array */
	who = mem_zalloc(z_info->r_max * sizeof(u16b));

	/* Scan the monsters */
	for (i = 1; i < z_info->r_max; i++) {
		struct monster_race *race = &r_info[i];

		/* Use that monster */
		if (race->name) who[count++] = (u16b)i;
	}

	sort(who, count, sizeof(*who), cmp_monsters);

	/* List all monsters in order. */
	for (n = 0; n < count; n++) {
		int r_idx = who[n];
		const struct monster_race *race = &r_info[r_idx];
		const struct monster_lore *lore = &l_list[r_idx];
		tb = textblock_new();

		/* Line 1: prefix, name, color, and symbol */
		if (rf_has(race->flags, RF_QUESTOR))
			textblock_append(tb, "[Q] ");
		else if (rf_has(race->flags, RF_UNIQUE))
			textblock_append(tb, "[U] ");
		else
			textblock_append(tb, "The ");

		/* As of 3.5, race->name and race->text are stored as UTF-8 strings;
		 * there is no conversion from the source edit files. */
		textblock_append_utf8(tb, race->name);
		textblock_append(tb, "  (");	/* ---)--- */
		textblock_append(tb, attr_to_text(race->d_attr));
		textblock_append(tb, " '%c')\n", race->d_char);

		/* Line 2: number, level, rarity, speed, HP, AC, exp */
		textblock_append(tb, "=== ");
		textblock_append(tb, "Num:%d  ", r_idx);
		textblock_append(tb, "Lev:%d  ", race->level);
		textblock_append(tb, "Rar:%d  ", race->rarity);

		if (race->speed >= 110)
			textblock_append(tb, "Spd:+%d  ", (race->speed - 110));
		else
			textblock_append(tb, "Spd:-%d  ", (110 - race->speed));

		textblock_append(tb, "Hp:%d  ", race->avg_hp);
		textblock_append(tb, "Ac:%d  ", race->ac);
		textblock_append(tb, "Exp:%ld\n", (long)(race->mexp));

		/* Normal description (with automatic line breaks) */
		lore_description(tb, race, lore, true);
		textblock_append(tb, "\n");

		textblock_to_file(tb, fh, 0, 75);
		textblock_free(tb);
		tb = NULL;
	}

	/* Free the "who" array */
	mem_free(who);

	/* Check for errors */
	if (!file_close(fh)) {
		msg("Cannot close spoiler file.");
		return;
	}

	msg("Successfully created a spoiler file.");
}
Exemplo n.º 7
0
/*
 * Create a spoiler file for monsters (-SHAWN-)
 */
static void spoil_mon_info(void)
{
	int n, x, y;
	bool breath, magic;
	u32b flags1, flags2, flags3, flags4, flags5, flags6;

	const bool old_spoil_mon = spoil_mon;

	byte a;
	char c, c2;
	byte old_moncol[MAX_MONCOL];

	/* Give full information. */
	spoil_mon = TRUE;

	for (n = 0; n < MAX_MONCOL; n++) old_moncol[n] = moncol[n].gfx.xa;

	/* Hack - hide some information. */
	moncol[0].gfx.xa = moncol[8].gfx.xa = moncol[18].gfx.xa = TERM_DARK;

	/* Dump the header */
	spoil_out("Monster Spoilers for %s Version %s\n",
		GAME_NAME, GAME_VERSION);
	spoil_out("------------------------------------------\n\n");

	/*
	 * List all monsters in order (except the ghost).
	 */
	for (n = 1; n < MAX_R_IDX; n++)
	{

		monster_race *r_ptr = &r_info[n];

		/* Skip "fake" monsters. */
		if (is_fake_monster(r_ptr)) continue;

		/* Extract the flags */
		flags1 = r_ptr->flags1;
		flags2 = r_ptr->flags2;
		flags3 = r_ptr->flags3;
		flags4 = r_ptr->flags4;
		flags5 = r_ptr->flags5;
		flags6 = r_ptr->flags6;
		breath = FALSE;
		magic = FALSE;


		/* Prefix */
		if (flags1 & (RF1_GUARDIAN))
		{
			spoil_out("[G] ");
		}
		else if (flags1 & (RF1_UNIQUE))
		{
			spoil_out("[U] ");
		}
		else
		{
			spoil_out("The ");
		}

		/* Name */
		spoil_out("%v  (", monster_desc_aux_f3, r_ptr, 1, 0);

		/* Color */
		spoil_out(attr_to_text(r_ptr->gfx.da));

		/* Symbol --(-- */
		spoil_out(" '%c')\n", r_ptr->gfx.dc);


		/* Indent */
		spoil_out("=== ");

		/* Number */
		spoil_out("Num:%d  ", n);

		/* Level */
		spoil_out("Lev:%d  ", r_ptr->level);

		/* Rarity */
		spoil_out("Rar:%d  ", r_ptr->rarity);

		/* Speed */
		spoil_out("Spd:%+d  ", (r_ptr->speed - 110));

		/* Hitpoints */
		if ((flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
		{
			spoil_out("Hp:%d  ", r_ptr->hdice * r_ptr->hside);
		}
		else
		{
			spoil_out("Hp:%dd%d  ", r_ptr->hdice, r_ptr->hside);
		}

		/* Armor Class */
		spoil_out("Ac:%d  ", r_ptr->ac);

		/* Power */
		spoil_out("Power:%ld\n", (long)(r_ptr->mexp));

		/* Clear the screen before every monster. */
		Term_clear();

		/* Display the monster on screen. */
		screen_roff(n);

		/* Dump the on-screen display (excluding the title). */
		for (c2 = 0, y = 1; y < Term->hgt; y++)
		{
			for (x = 0; x < Term->wid; x++)
			{
				/* Check the character. */
				Term_what(x, y, &a, &c);

				/* Ignore blanked text. */
				if (a == TERM_DARK) continue;

				/* Ignore repeated spaces. */
				if (c == ' ' && c2 == ' ') continue;

				/* Dump the character. */
				spoil_out("%c", c);

				/* Remember the character. */
				c2 = c;
			}

			/* Put a space at the end of every line. */
			if (c2 != ' ') spoil_out(" ");
		}

		spoil_out(NULL);
	}

	/* Restore spoil_mon. */
	spoil_mon = old_spoil_mon;

	/* Restore moncol[]. */
	for (n = 0; n < MAX_MONCOL; n++) moncol[n].gfx.xa = old_moncol[n];

	/* Don't leave a monster display lying around. */
	Term_clear();
}
Exemplo n.º 8
0
/*
 * Create a spoiler file for monsters   -BEN-
 */
static void spoil_mon_desc(void)
{
	int i, n = 0;

	C_TNEW(who, MAX_R_IDX, s16b);

	char nam[80];
	char lev[80];
	char rar[80];
	char spd[80];
	char ac[80];
	char hp[80];
	char exp[80];


	/* Dump the header */

	fprintf(fff, "Monster Spoilers for %s Version %s\n", GAME_NAME,
		GAME_VERSION);
	fprintf(fff, "------------------------------------------\n\n");

	/* Dump the header */
	fprintf(fff, "%-40.40s%4s%4s%6s%8s%4s  %11.11s\n",
		"Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
	fprintf(fff, "%-40.40s%4s%4s%6s%8s%4s  %11.11s\n",
		"----", "---", "---", "---", "--", "--", "-----------");

	/* Scan the monsters (except the ghost) */
	for (i = 1; i < MAX_R_IDX; i++)
	{
		monster_race *r_ptr = &r_info[i];

		/* Hack - skip "fake" monsters. */
		if (is_fake_monster(r_ptr)) continue;

		/* Use that monster */
		if (r_ptr->name) who[n++] = i;
	}


	/* Scan again */
	for (i = 0; i < n; i++)
	{
		monster_race *r_ptr = &r_info[who[i]];
		cptr pre;

		/* Get the "name" */
		if (r_ptr->flags1 & (RF1_GUARDIAN)) pre = "[G]";
		else if (r_ptr->flags1 & (RF1_UNIQUE)) pre = "[U]";
		else pre = "The";

		strnfmt(nam, N_ELEMENTS(nam), "%s %.*v", pre,
			N_ELEMENTS(nam)-strlen(pre)-1, monster_desc_aux_f3, r_ptr, 1, 0);

		/* Level */
		sprintf(lev, "%d", r_ptr->level);

		/* Rarity */
		sprintf(rar, "%d", r_ptr->rarity);

		/* Speed */
		if (r_ptr->speed >= 110)
		{
			sprintf(spd, "+%d", (r_ptr->speed - 110));
		}
		else
		{
			sprintf(spd, "-%d", (110 - r_ptr->speed));
		}

		/* Armor Class */
		sprintf(ac, "%d", r_ptr->ac);

		/* Hitpoints */
		if ((r_ptr->flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
		{
			sprintf(hp, "%d", r_ptr->hdice * r_ptr->hside);
		}
		else
		{
			sprintf(hp, "%dd%d", r_ptr->hdice, r_ptr->hside);
		}


		/* Power */
		sprintf(exp, "%ld", (long)(r_ptr->mexp));

		/* Hack -- use visual instead */
		sprintf(exp, "%s '%c'", attr_to_text(r_ptr->gfx.da), r_ptr->gfx.dc);

		/* Dump the info */
		fprintf(fff, "%-40.40s%4s%4s%6s%8s%4s  %11.11s\n",
			nam, lev, rar, spd, hp, ac, exp);
	}

	/* End it */
	fprintf(fff, "\n");

	/* Free the "who" array */
	TFREE(who);
}
Exemplo n.º 9
0
/*
 * Create a spoiler file for monsters
 */
static void spoil_mon_desc(cptr fname)
{
	int i, n = 0;

	char buf[1024];

	/* We use either ascii or system-specific encoding */
	int encoding = (xchars_to_file) ? SYSTEM_SPECIFIC : ASCII;

	char nam[DESC_LEN];
	char lev[32];
	char rar[32];
	char spd[32];
	char ac[32];
	char hp[32];
	char exp[32];

	u16b *who;
	u16b why = 2;

	/* Build the filename */
	(void)path_build(buf, sizeof(buf), ANGBAND_DIR_INFO, fname);

	/* File type is "TEXT" */
	FILE_TYPE(FILE_TYPE_TEXT);

	/* Open the file */
	fff = my_fopen(buf, "w");

	/* Oops */
	if (!fff)
	{
		msg_print("Cannot create spoiler file.");
		return;
	}

	/* Dump to the spoiler file */
	text_out_hook = text_out_to_file;
	text_out_file = fff;

	/* Print header */
	print_header("Brief Monster");

	/* Dump the header */
	fprintf(fff, "%-40.40s%4s%4s%6s%8s%4s  %11.11s\n",
		"Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
	fprintf(fff, "%-40.40s%4s%4s%6s%8s%4s  %11.11s\n",
		"----", "---", "---", "---", "--", "--", "-----------");


	/* Allocate the "who" array */
	C_MAKE(who, z_info->r_max, u16b);

	/* Scan the monsters */
	for (i = 1; i < z_info->r_max; i++)
	{
		monster_race *r_ptr = &r_info[i];

		/* Use that monster */
		if (r_ptr->name) who[n++] = (u16b)i;
	}

	/* Select the sort method */
	ang_sort_comp = ang_sort_comp_hook;
	ang_sort_swap = ang_sort_swap_hook;

	/* Sort the array by dungeon depth of monsters */
	ang_sort(who, &why, n);

	/* Scan again */
	for (i = 0; i < n; i++)
	{
		monster_race *r_ptr = &r_info[who[i]];

		cptr name = (r_name + r_ptr->name);

		/* Get the "name" */
		if (r_ptr->flags1 & (RF1_QUESTOR))
		{
			(void)strnfmt(nam, sizeof(nam), "[Q] %s", name);
		}
		else if (r_ptr->flags1 & (RF1_UNIQUE))
		{
			(void)strnfmt(nam, sizeof(nam), "[U] %s", name);
		}
		else
		{
			(void)strnfmt(nam, sizeof(nam), "The %s", name);
		}


		/* Level */
		(void)strnfmt(lev, sizeof(lev), "%d", r_ptr->level);

		/* Rarity */
		(void)strnfmt(rar, sizeof(rar), "%d", r_ptr->rarity);

		/* Speed */
		(void)strnfmt(spd, sizeof(spd), "%+d", (r_ptr->speed - 110));


		/* Armor Class */
		(void)strnfmt(ac, sizeof(ac), "%d", r_ptr->ac);

		/* Hitpoints */
		if (r_ptr->flags1 & (RF1_FIXED_HPS))
		{
			(void)strnfmt(hp, sizeof(hp), "%d", (int)r_ptr->hitpoints);
		}
		else
		{
			(void)strnfmt(hp, sizeof(hp), "~%d", (int)r_ptr->hitpoints);
		}


		/* Experience */
		(void)strnfmt(exp, sizeof(exp), "%ld", (long)(r_ptr->mexp));

		/* Hack -- use visual instead */
		(void)strnfmt(exp, sizeof(exp), "%s '%c'", attr_to_text(r_ptr->d_attr),
		        r_ptr->d_char);

		/* Dump the info */
		x_fprintf(fff, encoding, "%-40.40s%4s%4s%6s%8s%4s  %11.11s\n",
			nam, lev, rar, spd, hp, ac, exp);
	}

	/* End it */
	fprintf(fff, "\n");

	/* Free the "who" array */
	FREE(who);

	/* Check for errors */
	if (ferror(fff) || my_fclose(fff))
	{
		msg_print("Cannot close spoiler file.");
		return;
	}

	/* Worked */
	msg_print("Successfully created a spoiler file.");
}
Exemplo n.º 10
0
/*
 * Create a spoiler file for monsters
 * [email protected] (Shawn McHorse)
 */
static void spoil_mon_info(cptr fname)
{
	char buf[1024];
	int i, n;
	u16b why = 2;
	u16b *who;
	int count = 0;


	/* Build the filename */
	(void)path_build(buf, sizeof(buf), ANGBAND_DIR_INFO, fname);

	/* File type is "TEXT" */
	FILE_TYPE(FILE_TYPE_TEXT);

	/* Open the file */
	fff = my_fopen(buf, "w");

	/* Oops */
	if (!fff)
	{
		msg_print("Cannot create spoiler file.");
		return;
	}

	/* Dump to the spoiler file */
	text_out_hook = text_out_to_file;
	text_out_file = fff;

	/* Print header */
	print_header("Full Monster");

	/* Allocate the "who" array */
	C_MAKE(who, z_info->r_max, u16b);

	/* Scan the monsters */
	for (i = 1; i < z_info->r_max; i++)
	{
		monster_race *r_ptr = &r_info[i];

		/* Use that monster */
		if (r_ptr->name) who[count++] = (u16b)i;
	}

	/* Select the sort method */
	ang_sort_comp = ang_sort_comp_hook;
	ang_sort_swap = ang_sort_swap_hook;

	/* Sort the array by dungeon depth of monsters */
	ang_sort(who, &why, count);

	/*
	 * List all monsters in order.
	 */
	for (n = 0; n < count; n++)
	{
		int r_idx = who[n];
		monster_race *r_ptr = &r_info[r_idx];

		/* Prefix */
		if (r_ptr->flags1 & RF1_QUESTOR)
		{
			text_out("[Q] ");
		}
		else if (r_ptr->flags1 & RF1_UNIQUE)
		{
			text_out("[U] ");
		}
		else
		{
			text_out("The ");
		}

		/* Name */
		(void)strnfmt(buf, sizeof(buf), "%s  (", (r_name + r_ptr->name));	/* ---)--- */
		text_out(buf);

		/* Color */
		text_out(attr_to_text(r_ptr->d_attr));

		/* Symbol --(-- */
		(void)strnfmt(buf, sizeof(buf), " '%c')\n", r_ptr->d_char);
		text_out(buf);


		/* Indent */
		(void)strnfmt(buf, sizeof(buf), "=== ");
		text_out(buf);

		/* Number */
		(void)strnfmt(buf, sizeof(buf), "Num:%d  ", r_idx);
		text_out(buf);

		/* Level */
		(void)strnfmt(buf, sizeof(buf), "Lev:%d  ", r_ptr->level);
		text_out(buf);

		/* Rarity */
		(void)strnfmt(buf, sizeof(buf), "Rar:%d  ", r_ptr->rarity);
		text_out(buf);

		/* Speed */
		if (r_ptr->speed >= 110)
		{
			(void)strnfmt(buf, sizeof(buf), "Spd:+%d  ", (r_ptr->speed - 110));
		}
		else
		{
			(void)strnfmt(buf, sizeof(buf), "Spd:-%d  ", (110 - r_ptr->speed));
		}
		text_out(buf);

		/* Hitpoints */
		if (r_ptr->flags1 & (RF1_FIXED_HPS))
		{
			(void)strnfmt(buf, sizeof(buf), "%d", r_ptr->hitpoints);
		}
		else
		{
			(void)strnfmt(buf, sizeof(buf), "~%d", r_ptr->hitpoints);
		}
		text_out(buf);

		/* Armor Class */
		(void)strnfmt(buf, sizeof(buf), "Ac:%d  ", r_ptr->ac);
		text_out(buf);

		/* Experience */
		(void)strnfmt(buf, sizeof(buf), "Exp:%ld\n", (long)(r_ptr->mexp));
		text_out(buf);

		/* Describe */
		describe_monster(r_idx, TRUE);

		/* Terminate the entry */
		text_out("\n");
	}

	/* Free the "who" array */
	FREE(who);

	/* Check for errors */
	if (ferror(fff) || my_fclose(fff))
	{
		msg_print("Cannot close spoiler file.");
		return;
	}

	msg_print("Successfully created a spoiler file.");
}
Exemplo n.º 11
0
/*
 * Create a spoiler file for monsters   -BEN-
 */
static void spoil_mon_desc(cptr fname)
{
    int i, n = 0;

    u16b why = 2;
    s16b *who;

    char buf[1024];

    char nam[80];
    char lev[80];
    char rar[80];
    char spd[80];
    char ac[80];
    char hp[80];
    char exp[80];

    /* Build the filename */
    path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);

    /* File type is "TEXT" */
    FILE_TYPE(FILE_TYPE_TEXT);

    /* Open the file */
    fff = my_fopen(buf, "w");

    /* Oops */
    if (!fff)
    {
        msg_print("Cannot create spoiler file.");
        return;
    }

    /* Allocate the "who" array */
    C_MAKE(who, max_r_idx, s16b);

    /* Dump the header */
    fprintf(fff, "Spoiler File -- Monsters (PosChengband %d.%d.%d)\n\n\n",
        VER_MAJOR, VER_MINOR, VER_PATCH);
    fprintf(fff, "------------------------------------------\n\n");

    /* Dump the header */
    fprintf(fff, "    %-38.38s%4s%4s%4s%7s%5s  %11.11s\n",
        "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
    fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s  %11.11s\n",
        "--------", "---", "---", "---", "--", "--", "-----------");


    /* Scan the monsters */
    for (i = 1; i < max_r_idx; i++)
    {
        monster_race *r_ptr = &r_info[i];

        /* Use that monster */
        if (r_ptr->name) who[n++] = i;
    }

    /* Select the sort method */
    ang_sort_comp = ang_sort_comp_hook;
    ang_sort_swap = ang_sort_swap_hook;

    /* Sort the array by dungeon depth of monsters */
    ang_sort(who, &why, n);

    /* Scan again */
    for (i = 0; i < n; i++)
    {
        monster_race *r_ptr = &r_info[who[i]];

        cptr name = (r_name + r_ptr->name);
        if (r_ptr->flags7 & (RF7_KAGE)) continue;

        /* Get the "name" */
        /*
        else if (r_ptr->flags1 & (RF1_QUESTOR))
        {
            sprintf(nam, "[Q] %s", name);
        }
        */
        else if (r_ptr->flags1 & (RF1_UNIQUE))
        {
            sprintf(nam, "[U] %s", name);
        }
        else
        {
            sprintf(nam, "The %s", name);
        }


        /* Level */
        sprintf(lev, "%d", r_ptr->level);

        /* Rarity */
        sprintf(rar, "%d", r_ptr->rarity);

        /* Speed */
        if (r_ptr->speed >= 110)
        {
            sprintf(spd, "+%d", (r_ptr->speed - 110));
        }
        else
        {
            sprintf(spd, "-%d", (110 - r_ptr->speed));
        }

        /* Armor Class */
        sprintf(ac, "%d", r_ptr->ac);

        /* Hitpoints */
        if ((r_ptr->flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
        {
            sprintf(hp, "%d", r_ptr->hdice * r_ptr->hside);
        }
        else
        {
            sprintf(hp, "%dd%d", r_ptr->hdice, r_ptr->hside);
        }


        /* Experience */
        sprintf(exp, "%d", r_ptr->mexp);

        /* Hack -- use visual instead */
        sprintf(exp, "%s '%c'", attr_to_text(r_ptr), r_ptr->d_char);

        /* Dump the info */
        fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s  %11.11s\n",
            nam, lev, rar, spd, hp, ac, exp);
    }

    /* End it */
    fprintf(fff, "\n");


    /* Free the "who" array */
    C_KILL(who, max_r_idx, s16b);

    /* Check for errors */
    if (ferror(fff) || my_fclose(fff))
    {
        msg_print("Cannot close spoiler file.");
        return;
    }

    /* Worked */
    msg_print("Successfully created a spoiler file.");
}