From ad28eb79386e3c5956975fccf7a3d8cf4e620d82 Mon Sep 17 00:00:00 2001 From: mogami Date: Tue, 18 Jun 2002 15:45:59 +0000 Subject: [PATCH] =?utf8?q?=E9=AD=94=E9=81=93=E5=85=B7=E8=A1=93=E5=B8=AB?= =?utf8?q?=E3=81=A7=E3=80=81Browse=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?utf8?q?=E3=81=8C=E4=BD=BF=E3=81=88=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?utf8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/cmd6.c | 292 ++++++++++++++++++++++++++++++++-------------------------- src/dungeon.c | 4 +- src/externs.h | 2 +- 3 files changed, 167 insertions(+), 131 deletions(-) diff --git a/src/cmd6.c b/src/cmd6.c index 0bc166e08..0055aadb7 100644 --- a/src/cmd6.c +++ b/src/cmd6.c @@ -6592,11 +6592,11 @@ msg_print(" } } -static bool select_magic_eater(int mode) +static bool select_magic_eater(bool only_browse) { int ext=0; char choice; - bool flag, redraw; + bool flag, redraw, request_list; int tval = 0; int ask = TRUE, i = 0; char out_val[160]; @@ -6740,15 +6740,123 @@ static bool select_magic_eater(int mode) #else (void)strnfmt(out_val, 78, "(*=List, ESC=exit) Use which power? "); #endif - if (use_menu) screen_save(); + + /* Save the screen */ + screen_save(); - /* Get a spell from the user */ + request_list = always_show_list; - choice = (always_show_list || use_menu) ? ESCAPE:1; + /* Get a spell from the user */ while (!flag) { - if( choice==ESCAPE ) choice = ' '; - else if( !get_com(out_val, &choice, FALSE) )break; + /* Show the list */ + if (request_list || use_menu) + { + byte y, x = 0; + int ctr, chance; + int k_idx; + char dummy[80]; + int x1, y1, level; + byte col; + + strcpy(dummy, ""); + + for (y = 1; y < 20; y++) + prt("", y, x); + + y = 1; + + /* Print header(s) */ +#ifdef JP + prt(format(" %s ¼ºÎ¨ %s ¼ºÎ¨", (tval == TV_ROD ? " ¾õÂÖ " : "»ÈÍѲó¿ô"), (tval == TV_ROD ? " ¾õÂÖ " : "»ÈÍѲó¿ô")), y++, x); +#else + prt(format(" %s Fail %s Fail", (tval == TV_ROD ? " Stat " : " Charges"), (tval == TV_ROD ? " Stat " : " Charges")), y++, x); +#endif + + /* Print list */ + for (ctr = 0; ctr < EATER_EXT; ctr++) + { + if (!p_ptr->magic_num2[ctr+ext]) continue; + + k_idx = lookup_kind(tval, ctr); + + if (use_menu) + { + if (ctr == (menu_line-1)) +#ifdef JP + strcpy(dummy, "¡Õ"); +#else + strcpy(dummy, "> "); +#endif + else strcpy(dummy, " "); + + } + /* letter/number for power selection */ + else + { + char letter; + if (ctr < 26) + letter = I2A(ctr); + else + letter = '0' + ctr - 26; + sprintf(dummy, "%c)",letter); + } + x1 = ((ctr < EATER_EXT/2) ? x : x + 40); + y1 = ((ctr < EATER_EXT/2) ? y + ctr : y + ctr - EATER_EXT/2); + level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level); + chance = level * 4 / 5 + 20; + chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1); + level /= 2; + if (p_ptr->lev > level) + { + chance -= 3 * (p_ptr->lev - level); + } + chance += p_ptr->to_m_chance; + if (p_ptr->heavy_spell) chance += 20; + if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4; + else if (p_ptr->easy_spell) chance-=3; + else if (p_ptr->dec_mana) chance-=2; + chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]); + /* Stunning makes spells harder */ + if (p_ptr->stun > 50) chance += 25; + else if (p_ptr->stun) chance += 15; + + if (chance > 95) chance = 95; + + if(p_ptr->dec_mana) chance--; + if (p_ptr->heavy_spell) chance += 5; + + col = TERM_WHITE; + + if (k_idx) + { + if (tval == TV_ROD) + { + strcat(dummy, format( +#ifdef JP + " %-22.22s ½¼Å¶:%2d/%2d%3d%%", +#else + " %-22.22s (%2d/%2d) %3d%%", +#endif + k_name + k_info[k_idx].name, + p_ptr->magic_num1[ctr+ext] ? + (p_ptr->magic_num1[ctr+ext] - 1) / (EATER_ROD_CHARGE * k_info[k_idx].pval) +1 : 0, + p_ptr->magic_num2[ctr+ext], chance)); + if (p_ptr->magic_num1[ctr+ext] > k_info[k_idx].pval * (p_ptr->magic_num2[ctr+ext]-1) * EATER_ROD_CHARGE) col = TERM_RED; + } + else + { + strcat(dummy, format(" %-22.22s %2d/%2d %3d%%", k_name + k_info[k_idx].name, (s16b)(p_ptr->magic_num1[ctr+ext]/EATER_CHARGE), p_ptr->magic_num2[ctr+ext], chance)); + if (p_ptr->magic_num1[ctr+ext] < EATER_CHARGE) col = TERM_RED; + } + } + else + strcpy(dummy, ""); + c_prt(col, dummy, y1, x1); + } + } + + if(!get_com(out_val, &choice, FALSE)) break; if (use_menu && choice != ' ') { @@ -6826,131 +6934,25 @@ static bool select_magic_eater(int mode) } } } - /* Request redraw */ - if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask)) - { - /* Show the list */ - if (!redraw || use_menu) - { - byte y, x = 0; - int ctr, chance; - int k_idx; - char dummy[80]; - int x1, y1, level; - byte col; - - strcpy(dummy, ""); - - /* Show list */ - redraw = TRUE; - - /* Save the screen */ - if (!use_menu) screen_save(); - - for (y = 1; y < 20; y++) - prt("", y, x); - - y = 1; - - /* Print header(s) */ -#ifdef JP - prt(format(" %s ¼ºÎ¨ %s ¼ºÎ¨", (tval == TV_ROD ? " ¾õÂÖ " : "»ÈÍѲó¿ô"), (tval == TV_ROD ? " ¾õÂÖ " : "»ÈÍѲó¿ô")), y++, x); -#else - prt(format(" %s Fail %s Fail", (tval == TV_ROD ? " Stat " : " Charges"), (tval == TV_ROD ? " Stat " : " Charges")), y++, x); -#endif - - /* Print list */ - for (ctr = 0; ctr < EATER_EXT; ctr++) - { - if (!p_ptr->magic_num2[ctr+ext]) continue; - - k_idx = lookup_kind(tval, ctr); - - if (use_menu) - { - if (ctr == (menu_line-1)) -#ifdef JP - strcpy(dummy, "¡Õ"); -#else - strcpy(dummy, "> "); -#endif - else strcpy(dummy, " "); - - } - /* letter/number for power selection */ - else - { - char letter; - if (ctr < 26) - letter = I2A(ctr); - else - letter = '0' + ctr - 26; - sprintf(dummy, "%c)",letter); - } - x1 = ((ctr < EATER_EXT/2) ? x : x + 40); - y1 = ((ctr < EATER_EXT/2) ? y + ctr : y + ctr - EATER_EXT/2); - level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level); - chance = level * 4 / 5 + 20; - chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1); - level /= 2; - if (p_ptr->lev > level) - { - chance -= 3 * (p_ptr->lev - level); - } - chance += p_ptr->to_m_chance; - if (p_ptr->heavy_spell) chance += 20; - if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4; - else if (p_ptr->easy_spell) chance-=3; - else if (p_ptr->dec_mana) chance-=2; - chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]); - /* Stunning makes spells harder */ - if (p_ptr->stun > 50) chance += 25; - else if (p_ptr->stun) chance += 15; - - if (chance > 95) chance = 95; - if(p_ptr->dec_mana) chance--; - if (p_ptr->heavy_spell) chance += 5; - - col = TERM_WHITE; - - if (k_idx) - { - if (tval == TV_ROD) - { -strcat(dummy, format( -#ifdef JP - " %-22.22s ½¼Å¶:%2d/%2d%3d%%", -#else - " %-22.22s (%2d/%2d) %3d%%", -#endif - k_name + k_info[k_idx].name, - p_ptr->magic_num1[ctr+ext] ? - (p_ptr->magic_num1[ctr+ext] - 1) / (EATER_ROD_CHARGE * k_info[k_idx].pval) +1 : 0, - p_ptr->magic_num2[ctr+ext], chance)); - if (p_ptr->magic_num1[ctr+ext] > k_info[k_idx].pval * (p_ptr->magic_num2[ctr+ext]-1) * EATER_ROD_CHARGE) col = TERM_RED; - } - else - { - strcat(dummy, format(" %-22.22s %2d/%2d %3d%%", k_name + k_info[k_idx].name, (s16b)(p_ptr->magic_num1[ctr+ext]/EATER_CHARGE), p_ptr->magic_num2[ctr+ext], chance)); - if (p_ptr->magic_num1[ctr+ext] < EATER_CHARGE) col = TERM_RED; - } - } - else - strcpy(dummy, ""); - c_prt(col, dummy, y1, x1); - } - } + /* Request redraw */ + if (use_menu && ask) continue; + /* Request redraw */ + if (!use_menu && ((choice == ' ') || (choice == '*') || (choice == '?'))) + { /* Hide the list */ - else + if (request_list) { /* Hide list */ - redraw = FALSE; - + request_list = FALSE; + /* Restore the screen */ screen_load(); + screen_save(); } + else + request_list = TRUE; /* Redo asking */ continue; @@ -6984,7 +6986,7 @@ strcat(dummy, format( continue; } - if (mode == 0) + if (!only_browse) { /* Verify it */ if (ask) @@ -7031,12 +7033,40 @@ strcat(dummy, format( } } + /* Browse */ + else + { + int line, j; + char temp[70 * 20]; + + /* Clear lines, position cursor (really should use strlen here) */ + Term_erase(7, 23, 255); + Term_erase(7, 22, 255); + Term_erase(7, 21, 255); + Term_erase(7, 20, 255); + + roff_to_buf(k_text + k_info[lookup_kind(tval, i)].text, 62, temp); + for (j = 0, line = 21; temp[j]; j += 1 + strlen(&temp[j])) + { + prt(&temp[j], line, 10); + line++; + } + +#ifdef JP + prt("²¿¤«¥­¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£",0,0); +#else + prt("Hit any key.",0,0); +#endif + (void)inkey(); + continue; + } + /* Stop the loop */ flag = TRUE; } /* Restore the screen */ - if (redraw) screen_load(); + screen_load(); if (!flag) return -1; @@ -7046,13 +7076,17 @@ strcat(dummy, format( return ext+i; } -void do_cmd_magic_eater(void) + +/* + * Use eaten rod, wand or staff + */ +void do_cmd_magic_eater(bool only_browse) { int item, dir, chance, level, k_idx, tval, sval; bool use_charge = TRUE; /* Not when confused */ - if (p_ptr->confused) + if (!only_browse && p_ptr->confused) { #ifdef JP msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª"); @@ -7063,7 +7097,7 @@ msg_print(" return; } - item = select_magic_eater(0); + item = select_magic_eater(only_browse); if (item == -1) { energy_use = 0; diff --git a/src/dungeon.c b/src/dungeon.c index ed19b88e2..1bce3eb24 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -4340,6 +4340,8 @@ msg_print(" ) do_cmd_mind_browse(); else if (p_ptr->pclass == CLASS_SMITH) do_cmd_kaji(TRUE); + else if (p_ptr->pclass == CLASS_MAGIC_EATER) + do_cmd_magic_eater(TRUE); else do_cmd_browse(); break; } @@ -4439,7 +4441,7 @@ msg_print(" else if (p_ptr->pclass == CLASS_IMITATOR) do_cmd_mane(FALSE); else if (p_ptr->pclass == CLASS_MAGIC_EATER) - do_cmd_magic_eater(); + do_cmd_magic_eater(FALSE); else if (p_ptr->pclass == CLASS_SAMURAI) do_cmd_hissatsu(); else if (p_ptr->pclass == CLASS_BLUE_MAGE) diff --git a/src/externs.h b/src/externs.h index 8f54a4c89..ff3992ce3 100644 --- a/src/externs.h +++ b/src/externs.h @@ -683,7 +683,7 @@ extern void do_cmd_activate(void); extern void do_cmd_rerate(bool display); extern void ring_of_power(int dir); extern void do_cmd_use(void); -extern void do_cmd_magic_eater(void); +extern void do_cmd_magic_eater(bool only_browse); /* dungeon.c */ extern void leave_quest_check(void); -- 2.11.0