/* File: wizard1.c */
+/*
+ * Copyright (c) 1997 Ben Harrison, and others
+ *
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies. Other copyrights may also apply.
+ */
+
/* Purpose: Spoiler generation -BEN- */
#include "angband.h"
#endif
#ifdef JP
-{ TV_PARCHEMENT, "ÍÓÈé»æ" },
+{ TV_PARCHMENT, "ÍÓÈé»æ" },
#else
-{ TV_PARCHEMENT, "Parchement" },
+{ TV_PARCHMENT, "Parchment" },
#endif
#ifdef JP
/* Description (too brief) */
- object_desc_store(buf, q_ptr, FALSE, 0);
+ object_desc(buf, q_ptr, (OD_NAME_ONLY | OD_STORE));
/* Misc info */
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
{ TR_DRAIN_EXP, "Drains Experience" },
{ TR_AGGRAVATE, "Aggravates" },
{ TR_BLESSED, "Blessed Blade" },
- { TR_DEC_MANA, "Decrease Shouhi Mana" },
+ { TR_DEC_MANA, "Decrease Mana Consumption Rate" },
#endif
};
+ 1 /* type of curse */
+ 1]; /* sentinel NULL */
+ /* Additional ability or resistance */
+ char addition[80];
+
/* A string describing an artifact's activation */
cptr activation;
/*
* Acquire a "basic" description "The Cloak of Death [1,+10]"
*/
-static void analyze_general (object_type *o_ptr, char *desc_ptr)
+static void analyze_general(object_type *o_ptr, char *desc_ptr)
{
/* Get a "useful" description of the object */
- object_desc_store(desc_ptr, o_ptr, TRUE, 1);
+ object_desc(desc_ptr, o_ptr, (OD_NAME_AND_ENCHANT | OD_STORE));
}
* List "player traits" altered by an artifact's pval. These include stats,
* speed, infravision, tunneling, stealth, searching, and extra attacks.
*/
-static void analyze_pval (object_type *o_ptr, pval_info_type *p_ptr)
+static void analyze_pval(object_type *o_ptr, pval_info_type *p_ptr)
{
u32b flgs[TR_FLAG_SIZE];
/* Note the slaying specialties of a weapon */
-static void analyze_slay (object_type *o_ptr, cptr *slay_list)
+static void analyze_slay(object_type *o_ptr, cptr *slay_list)
{
u32b flgs[TR_FLAG_SIZE];
}
/* Note an object's elemental brands */
-static void analyze_brand (object_type *o_ptr, cptr *brand_list)
+static void analyze_brand(object_type *o_ptr, cptr *brand_list)
{
u32b flgs[TR_FLAG_SIZE];
/* Note the resistances granted by an object */
-static void analyze_resist (object_type *o_ptr, cptr *resist_list)
+static void analyze_resist(object_type *o_ptr, cptr *resist_list)
{
u32b flgs[TR_FLAG_SIZE];
/* Note the immunities granted by an object */
-static void analyze_immune (object_type *o_ptr, cptr *immune_list)
+static void analyze_immune(object_type *o_ptr, cptr *immune_list)
{
u32b flgs[TR_FLAG_SIZE];
*immune_list = NULL;
}
-/* Note which stats an object sustains */
-static void analyze_sustains (object_type *o_ptr, cptr *sustain_list)
+/* Note which stats an object sustains */
+static void analyze_sustains(object_type *o_ptr, cptr *sustain_list)
{
u32b flgs[TR_FLAG_SIZE];
* Note miscellaneous powers bestowed by an artifact such as see invisible,
* free action, permanent light, etc.
*/
-static void analyze_misc_magic (object_type *o_ptr, cptr *misc_list)
+static void analyze_misc_magic(object_type *o_ptr, cptr *misc_list)
{
u32b flgs[TR_FLAG_SIZE];
*/
/* if (cursed_p(o_ptr)) */
- if (1)
{
if (have_flag(flgs, TR_TY_CURSE))
{
}
+/*
+ * Note additional ability and/or resistance of fixed artifacts
+ */
+static void analyze_addition(object_type *o_ptr, char *addition)
+{
+ artifact_type *a_ptr = &a_info[o_ptr->name1];
+
+ /* Init */
+ strcpy(addition, "");
+
+#ifdef JP
+ if ((a_ptr->gen_flags & TRG_XTRA_POWER) && (a_ptr->gen_flags & TRG_XTRA_H_RES)) strcat(addition, "ǽÎÏandÂÑÀ");
+ else if (a_ptr->gen_flags & TRG_XTRA_POWER)
+ {
+ strcat(addition, "ǽÎÏ");
+ if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "(1/2¤ÇandÂÑÀ)");
+ }
+ else if (a_ptr->gen_flags & TRG_XTRA_H_RES)
+ {
+ strcat(addition, "ÂÑÀ");
+ if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "(1/2¤ÇandǽÎÏ)");
+ }
+ else if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "ǽÎÏorÂÑÀ");
+#else
+ if ((a_ptr->gen_flags & TRG_XTRA_POWER) && (a_ptr->gen_flags & TRG_XTRA_H_RES)) strcat(addition, "Ability and Resistance");
+ else if (a_ptr->gen_flags & TRG_XTRA_POWER)
+ {
+ strcat(addition, "Ability");
+ if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "(plus Resistance about 1/2)");
+ }
+ else if (a_ptr->gen_flags & TRG_XTRA_H_RES)
+ {
+ strcat(addition, "Resistance");
+ if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "(plus Ability about 1/2)");
+ }
+ else if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "Ability or Resistance");
+#endif
+}
/*
* Determine the minimum depth an artifact can appear, its rarity, its weight,
* and its value in gold pieces
*/
-static void analyze_misc (object_type *o_ptr, char *misc_desc)
+static void analyze_misc(object_type *o_ptr, char *misc_desc)
{
artifact_type *a_ptr = &a_info[o_ptr->name1];
static void object_analyze(object_type *o_ptr, obj_desc_list *desc_ptr)
{
analyze_general(o_ptr, desc_ptr->description);
-
analyze_pval(o_ptr, &desc_ptr->pval_info);
-
analyze_brand(o_ptr, desc_ptr->brands);
-
analyze_slay(o_ptr, desc_ptr->slays);
-
analyze_immune(o_ptr, desc_ptr->immunities);
-
analyze_resist(o_ptr, desc_ptr->resistances);
-
analyze_sustains(o_ptr, desc_ptr->sustains);
-
analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
-
+ analyze_addition(o_ptr, desc_ptr->addition);
analyze_misc(o_ptr, desc_ptr->misc_desc);
-
desc_ptr->activation = item_activation(o_ptr);
}
char buf[80];
sprintf(buf, "Artifact Spoilers for Hengband Version %d.%d.%d",
- FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
+ FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
spoiler_underline(buf);
}
#ifdef JP
spoiler_outlist("ÂÐ:", art_ptr->slays, ITEM_SEP);
-
spoiler_outlist("Éð´ï°À:", art_ptr->brands, LIST_SEP);
-
spoiler_outlist("ÌȱÖ:", art_ptr->immunities, ITEM_SEP);
-
spoiler_outlist("ÂÑÀ:", art_ptr->resistances, ITEM_SEP);
-
spoiler_outlist("°Ý»ý:", art_ptr->sustains, ITEM_SEP);
#else
spoiler_outlist("Slay", art_ptr->slays, ITEM_SEP);
-
spoiler_outlist("", art_ptr->brands, LIST_SEP);
-
spoiler_outlist("Immunity to", art_ptr->immunities, ITEM_SEP);
-
spoiler_outlist("Resist", art_ptr->resistances, ITEM_SEP);
-
spoiler_outlist("Sustain", art_ptr->sustains, ITEM_SEP);
#endif
spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
+ if (art_ptr->addition[0])
+ {
+#ifdef JP
+ fprintf(fff, "%sÄɲÃ: %s\n", INDENT1, art_ptr->addition);
+#else
+ fprintf(fff, "%sAdditional %s\n", INDENT1, art_ptr->addition);
+#endif
+ }
/* Write out the possible activation at the primary indention level */
if (art_ptr->activation)
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
char exp[80];
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
/* Dump the header */
fprintf(fff, "Monster Spoilers for Hengband Version %d.%d.%d\n",
- FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
+ FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
fprintf(fff, "------------------------------------------\n\n");
/* Dump the header */
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;
+ /* 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);
+ /* Sort the array by dungeon depth of monsters */
+ ang_sort(who, &why, n);
/* Scan again */
for (i = 0; i < n; i++)
if (r_ptr->flags7 & (RF7_KAGE)) continue;
/* Get the "name" */
-/* if (r_ptr->flags1 & (RF1_QUESTOR)) */
- if (0)
+ /*
+ else if (r_ptr->flags1 & (RF1_QUESTOR))
{
sprintf(nam, "[Q] %s", name);
}
+ */
else if (r_ptr->flags1 & (RF1_UNIQUE))
{
sprintf(nam, "[U] %s", name);
for (; *str; str++)
{
#ifdef JP
- char cbak;
- int k_flag = iskanji((unsigned char)(*str));
+ char cbak;
+ int k_flag = iskanji((unsigned char)(*str));
#endif
char ch = *str;
int wrap = (ch == '\n');
#ifdef JP
- if (!isprint(ch) && !k_flag && !iskanji2) ch = ' ';
+ if (!isprint(ch) && !k_flag && !iskanji2) ch = ' ';
if(k_flag && !iskanji2)iskanji2=1;else iskanji2=0;
#else
if (!isprint(ch)) ch = ' ';
#endif
#ifdef JP
- if ( roff_p >= roff_buf+( (k_flag) ? 74 : 75) ) wrap=1;
+ if ( roff_p >= roff_buf+( (k_flag) ? 74 : 75) ) wrap=1;
if ((ch == ' ') && (roff_p + 2 >= roff_buf + ((k_flag) ? 74 : 75))) wrap = 1;
#else
if (roff_p >= roff_buf + 75) wrap = 1;
*roff_p = '\0';
r = roff_p;
#ifdef JP
- cbak=' ';
+ cbak=' ';
#endif
if (roff_s && (ch != ' '))
{
#ifdef JP
- cbak=*roff_s;
+ cbak=*roff_s;
#endif
*roff_s = '\0';
r = roff_s + 1;
}
else{
if( iskanji2 &&
- strncmp(str, "¡£", 2) != 0 &&
+ strncmp(str, "¡£", 2) != 0 &&
strncmp(str, "¡¢", 2) != 0 &&
- strncmp(str, "¥£", 2) != 0 &&
+ strncmp(str, "¥£", 2) != 0 &&
strncmp(str, "¡¼", 2) != 0) roff_s = roff_p;
}
#else
*/
static void roff_func(byte attr, cptr str)
{
+ /* Unused */
+ (void)attr;
+
spoil_out(str);
}
static void spoil_mon_info(cptr fname)
{
char buf[1024];
- int msex, i, l, n=0;
- bool breath, magic;
- u32b flags1, flags2, flags3, flags4, flags5, flags6, flags7;
+ int i, l, n = 0;
+ u32b flags1;
u16b why = 2;
s16b *who;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
/* 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;
- flags7 = r_ptr->flags7;
- breath = FALSE;
- magic = FALSE;
-
- /* Extract a gender (if applicable) */
- if (flags1 & (RF1_FEMALE)) msex = 2;
- else if (flags1 & (RF1_MALE)) msex = 1;
- else msex = 0;
-
/* Prefix */
+ /*
if (flags1 & (RF1_QUESTOR))
{
spoil_out("[Q] ");
}
- else if (flags1 & (RF1_UNIQUE))
+ else
+ */
+ if (flags1 & (RF1_UNIQUE))
{
spoil_out("[U] ");
}
+#define MAX_EVOL_DEPTH 64
+
+
+/*
+ * Compare two int-type array like strncmp() and return TRUE if equals
+ */
+static bool int_n_cmp(int *a, int *b, int length)
+{
+ /* Null-string comparation is always TRUE */
+ if (!length) return TRUE;
+
+ do
+ {
+ if (*a != *(b++)) return FALSE;
+ if (!(*(a++))) break;
+ }
+ while (--length);
+
+ return TRUE;
+}
+
+
+/*
+ * Returns TRUE if an evolution tree is "partial tree"
+ */
+static bool is_partial_tree(int *tree, int *partial_tree)
+{
+ int pt_head = *(partial_tree++);
+ int pt_len = 0;
+
+ while (partial_tree[pt_len]) pt_len++;
+
+ while (*tree)
+ {
+ if (*(tree++) == pt_head)
+ {
+ if (int_n_cmp(tree, partial_tree, pt_len)) return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
+/*
+ * Sorting hook -- Comp function
+ */
+static bool ang_sort_comp_evol_tree(vptr u, vptr v, int a, int b)
+{
+ int **evol_tree = (int **)u;
+
+ int w1 = evol_tree[a][0];
+ int w2 = evol_tree[b][0];
+ monster_race *r1_ptr = &r_info[w1];
+ monster_race *r2_ptr = &r_info[w2];
+
+ /* Unused */
+ (void)v;
+
+ /* Used tree first */
+ if (w1 && !w2) return TRUE;
+ if (!w1 && w2) return FALSE;
+
+ /* Sort by monster level */
+ if (r1_ptr->level < r2_ptr->level) return TRUE;
+ if (r1_ptr->level > r2_ptr->level) return FALSE;
+
+ /* Sort by monster experience */
+ if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
+ if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
+
+ /* Compare indexes */
+ return w1 <= w2;
+}
+
+
+/*
+ * Sorting hook -- Swap function
+ */
+static void ang_sort_swap_evol_tree(vptr u, vptr v, int a, int b)
+{
+ int **evol_tree = (int **)u;
+ int *holder;
+
+ /* Unused */
+ (void)v;
+
+ /* Swap */
+ holder = evol_tree[a];
+ evol_tree[a] = evol_tree[b];
+ evol_tree[b] = holder;
+}
+
+
+/*
+ * Print monsters' evolution information to file
+ */
+static void spoil_mon_evol(cptr fname)
+{
+ char buf[1024];
+ monster_race *r_ptr;
+ int **evol_tree, i, j, n, r_idx;
+ int *evol_tree_zero; /* For C_KILL() */
+
+ /* 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;
+ }
+
+ /* Dump the header */
+ sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
+ FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
+
+ spoil_out(buf);
+ spoil_out("------------------------------------------\n\n");
+
+ /* Allocate the "evol_tree" array (2-dimension) */
+ C_MAKE(evol_tree, max_r_idx, int *);
+ C_MAKE(*evol_tree, max_r_idx * (MAX_EVOL_DEPTH + 1), int);
+ for (i = 1; i < max_r_idx; i++) evol_tree[i] = *evol_tree + i * (MAX_EVOL_DEPTH + 1);
+ evol_tree_zero = *evol_tree;
+
+ /* Step 1: Build the evolution tree */
+ for (i = 1; i < max_r_idx; i++)
+ {
+ r_ptr = &r_info[i];
+
+ /* No evolution */
+ if (!r_ptr->next_exp) continue;
+
+ /* Trace evolution */
+ n = 0;
+ evol_tree[i][n++] = i;
+ do
+ {
+ evol_tree[i][n++] = r_ptr->next_r_idx;
+ r_ptr = &r_info[r_ptr->next_r_idx];
+ }
+ while (r_ptr->next_exp && (n < MAX_EVOL_DEPTH));
+ }
+
+ /* Step 2: Scan the evolution trees and remove "partial tree" */
+ for (i = 1; i < max_r_idx; i++)
+ {
+ /* Not evolution tree */
+ if (!evol_tree[i][0]) continue;
+
+ for (j = 1; j < max_r_idx; j++)
+ {
+ /* Same tree */
+ if (i == j) continue;
+
+ /* Not evolution tree */
+ if (!evol_tree[j][0]) continue;
+
+ /* Is evolution tree[i] is part of [j]? */
+ if (is_partial_tree(evol_tree[j], evol_tree[i]))
+ {
+ /* Remove this evolution tree */
+ evol_tree[i][0] = 0;
+ break;
+ }
+ }
+ }
+
+ /* Step 3: Sort the evolution trees */
+
+ /* Select the sort method */
+ ang_sort_comp = ang_sort_comp_evol_tree;
+ ang_sort_swap = ang_sort_swap_evol_tree;
+
+ /* Sort the array */
+ ang_sort(evol_tree, NULL, max_r_idx);
+
+ /* Step 4: Print the evolution trees */
+ for (i = 0; i < max_r_idx; i++)
+ {
+ r_idx = evol_tree[i][0];
+
+ /* No evolution or removed evolution tree */
+ if (!r_idx) continue;
+
+ /* Trace the evolution tree */
+ r_ptr = &r_info[r_idx];
+#ifdef JP
+ fprintf(fff, "[%d]: %s (¥ì¥Ù¥ë%d, '%c')\n", r_idx,
+ r_name + r_ptr->name, r_ptr->level, r_ptr->d_char);
+#else
+ fprintf(fff, "[%d]: %s (Level %d, '%c')\n", r_idx,
+ r_name + r_ptr->name, r_ptr->level, r_ptr->d_char);
+#endif
+ for (n = 1; r_ptr->next_exp; n++)
+ {
+ fprintf(fff, "%*s-(%ld)-> ", n * 2, "", r_ptr->next_exp);
+ fprintf(fff, "[%d]: ", r_ptr->next_r_idx);
+ r_ptr = &r_info[r_ptr->next_r_idx];
+#ifdef JP
+ fprintf(fff, "%s (¥ì¥Ù¥ë%d, '%c')\n",
+ r_name + r_ptr->name, r_ptr->level, r_ptr->d_char);
+#else
+ fprintf(fff, "%s (Level %d, '%c')\n",
+ r_name + r_ptr->name, r_ptr->level, r_ptr->d_char);
+#endif
+ }
+
+ /* End of evolution tree */
+ fputc('\n', fff);
+ }
+
+ /* Free the "evol_tree" array (2-dimension) */
+ C_KILL(evol_tree_zero, max_r_idx * (MAX_EVOL_DEPTH + 1), int);
+ C_KILL(evol_tree, max_r_idx, int *);
+
+ /* Check for errors */
+ if (ferror(fff) || my_fclose(fff))
+ {
+ msg_print("Cannot close spoiler file.");
+ return;
+ }
+
+ /* Message */
+ msg_print("Successfully created a spoiler file.");
+}
+
+
+
/*
* Forward declare
*/
*/
void do_cmd_spoilers(void)
{
- int i;
-
-
/* Save the screen */
screen_save();
-
- /* Drop priv's */
- safe_setuid_drop();
-
-
/* Interact */
while (1)
{
prt("(2) Brief Artifact Info (artifact.spo)", 6, 5);
prt("(3) Brief Monster Info (mon-desc.spo)", 7, 5);
prt("(4) Full Monster Info (mon-info.spo)", 8, 5);
+ prt("(5) Monster Evolution Info (mon-evol.spo)", 9, 5);
/* Prompt */
#ifdef JP
-prt("¥³¥Þ¥ó¥É:", 18, 0);
+ prt("¥³¥Þ¥ó¥É:", 18, 0);
#else
prt("Command: ", 12, 0);
#endif
-
/* Get a choice */
- i = inkey();
-
- /* Escape */
- if (i == ESCAPE)
+ switch (inkey())
{
- break;
- }
+ /* Escape */
+ case ESCAPE:
+ /* Restore the screen */
+ screen_load();
+ return;
/* Option (1) */
- else if (i == '1')
- {
+ case '1':
spoil_obj_desc("obj-desc.spo");
- }
+ break;
/* Option (2) */
- else if (i == '2')
- {
+ case '2':
spoil_artifact("artifact.spo");
- }
+ break;
/* Option (3) */
- else if (i == '3')
- {
+ case '3':
spoil_mon_desc("mon-desc.spo");
- }
+ break;
/* Option (4) */
- else if (i == '4')
- {
+ case '4':
spoil_mon_info("mon-info.spo");
- }
+ break;
+
+ /* Option (5) */
+ case '5':
+ spoil_mon_evol("mon-evol.spo");
+ break;
/* Oops */
- else
- {
+ default:
bell();
+ break;
}
/* Flush messages */
msg_print(NULL);
}
-
-
- /* Grab priv's */
- safe_setuid_grab();
-
-
- /* Restore the screen */
- screen_load();
}
/*
#endif
spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
}
-
+
/* Now deal with the description lists */
#ifdef JP
char buf[1024];
- /* Drop priv's */
- safe_setuid_drop();
-
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
return;
}
- /* Grab priv's */
- safe_setuid_grab();
-
/* Message */
msg_print("Successfully created a list file.");
}