void cmsg_print(byte color, cptr msg) { if (world_monster) return; if (statistics_hack) return; /* Hack: msg_print(NULL) requests a flush if needed */ if (!msg) { if (!msg_line_is_empty()) msg_line_flush(); return; } if (character_generated) { if (_msg_append && _msg_count) cmsg_append(color, msg); else cmsg_add(color, msg); } msg_line_display(color, msg); if (auto_more_state == AUTO_MORE_SKIP_ONE) auto_more_state = AUTO_MORE_PROMPT; p_ptr->window |= PW_MESSAGE; window_stuff(); if (fresh_message) /* ?? */ Term_fresh(); _msg_append = TRUE; }
/* * Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */ void handle_stuff(void) { /* Update stuff */ if (p_ptr->update) update_stuff(); /* Redraw stuff */ if (flag_used(&p_ptr->redraw)) redraw_stuff(); /* Window stuff */ if (flag_used(&p_ptr->window)) window_stuff(); }
/* * Flush the screen, make a noise */ void bell(cptr reason) { /* Mega-Hack -- Flush the output */ Term_fresh(); /* Hack -- memorize the reason if possible */ if (character_generated && reason) { message_add(reason, MSG_BELL); /* Window stuff */ p_ptr->window |= (PW_MESSAGE); /* Force window redraw */ window_stuff(); } /* Make a bell noise (if allowed) */ if (ring_bell) Term_xtra(TERM_XTRA_NOISE, 0); /* Flush the input (later!) */ flush(); }
static int get_snipe_power(int *sn, bool only_browse) { int i; int num = 0; int y = 1; int x = 20; int plev = p_ptr->lev; int ask; char choice; char out_val[160]; cptr p = "power"; snipe_power spell; bool flag, redraw; #ifdef ALLOW_REPEAT /* TNB */ repeat_push(*sn); /* Assume cancelled */ *sn = (-1); /* Repeat previous command */ /* Get the spell, if available */ if (repeat_pull(sn)) { /* Verify the spell */ if ((snipe_powers[*sn].min_lev <= plev) && (snipe_powers[*sn].mana_cost <= (int)p_ptr->concent)) { /* Success */ return (TRUE); } } #endif /* ALLOW_REPEAT -- TNB */ /* Nothing chosen yet */ flag = FALSE; /* No redraw yet */ redraw = FALSE; for (i = 0; i < MAX_SNIPE_POWERS; i++) { if ((snipe_powers[i].min_lev <= plev) && ((only_browse) || (snipe_powers[i].mana_cost <= (int)p_ptr->concent))) { num = i; } } /* Build a prompt (accept all spells) */ if (only_browse) { (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) Use which %s? ", p, I2A(0), I2A(num), p); } else { (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) Use which %s? ", p, I2A(0), I2A(num), p); } /* Get a spell from the user */ choice = always_show_list ? ESCAPE : 1; while (!flag) { if(choice == ESCAPE) choice = ' '; else if( !get_com(out_val, &choice, FALSE) )break; /* Request redraw */ if ((choice == ' ') || (choice == '*') || (choice == '?')) { /* Show the list */ if (!redraw) { char psi_desc[80]; /* Show list */ redraw = TRUE; /* Save the screen */ if (!only_browse) screen_save(); /* Display a list of spells */ prt("", y, x); put_str("Name", y, x + 5); if (only_browse) put_str("Lv Pow", y, x + 35); /* Dump the spells */ for (i = 0; i < MAX_SNIPE_POWERS; i++) { Term_erase(x, y + i + 1, 255); /* Access the spell */ spell = snipe_powers[i]; if (spell.min_lev > plev) continue; if (!only_browse && (spell.mana_cost > (int)p_ptr->concent)) continue; /* Dump the spell --(-- */ if (only_browse) sprintf(psi_desc, " %c) %-30s%2d %4d", I2A(i), spell.name, spell.min_lev, spell.mana_cost); else sprintf(psi_desc, " %c) %-30s", I2A(i), spell.name); prt(psi_desc, y + i + 1, x); } /* Clear the bottom line */ prt("", y + i + 1, x); } /* Hide the list */ else { /* Hide list */ redraw = FALSE; /* Restore the screen */ if (!only_browse) screen_load(); } /* Redo asking */ continue; } /* Note verify */ ask = isupper(choice); /* Lowercase */ if (ask) choice = tolower(choice); /* Extract request */ i = (islower(choice) ? A2I(choice) : -1); /* Totally Illegal */ if ((i < 0) || (i > num) || (!only_browse &&(snipe_powers[i].mana_cost > (int)p_ptr->concent))) { bell(); continue; } /* Save the spell index */ spell = snipe_powers[i]; /* Verify it */ if (ask) { char tmp_val[160]; /* Prompt */ (void)strnfmt(tmp_val, 78, "Use %s? ", snipe_powers[i].name); /* Belay that order */ if (!get_check(tmp_val)) continue; } /* Stop the loop */ flag = TRUE; } /* Restore the screen */ if (redraw && !only_browse) screen_load(); /* Show choices */ p_ptr->window |= (PW_SPELL); /* Window stuff */ window_stuff(); /* Abort if needed */ if (!flag) return (FALSE); /* Save the choice */ (*sn) = i; #ifdef ALLOW_REPEAT /* TNB */ repeat_push(*sn); #endif /* ALLOW_REPEAT -- TNB */ /* Success */ return (TRUE); }
/* * Allow user to choose a imitation. * * If a valid spell is chosen, saves it in '*sn' and returns TRUE * If the user hits escape, returns FALSE, and set '*sn' to -1 * If there are no legal choices, returns FALSE, and sets '*sn' to -2 * * The "prompt" should be "cast", "recite", or "study" * The "known" should be TRUE for cast/pray, FALSE for study * * nb: This function has a (trivial) display bug which will be obvious * when you run it. It's probably easy to fix but I haven't tried, * sorry. */ static int get_mane_power(int *sn, bool baigaesi) { int i = 0; int num = 0; int y = 1; int x = 18; int minfail = 0; int plev = p_ptr->lev; int chance = 0; int ask; char choice; char out_val[160]; char comment[80]; #ifdef JP cptr p = "能力"; #else cptr p = "power"; #endif monster_power spell; bool flag, redraw; /* Assume cancelled */ *sn = (-1); /* Nothing chosen yet */ flag = FALSE; /* No redraw yet */ redraw = FALSE; num = p_ptr->mane_num; /* Build a prompt (accept all spells) */ (void)strnfmt(out_val, 78, #ifdef JP "(%c-%c, '*'で一覧, ESC) どの%sをまねますか?", #else "(%c-%c, *=List, ESC=exit) Use which %s? ", #endif I2A(0), I2A(num - 1), p); /* Get a spell from the user */ choice= always_show_list ? ESCAPE:1 ; while (!flag) { if(choice==ESCAPE) choice = ' '; else if( !get_com(out_val, &choice, TRUE) )break; /* Request redraw */ if ((choice == ' ') || (choice == '*') || (choice == '?')) { /* Show the list */ if (!redraw) { char psi_desc[80]; /* Show list */ redraw = TRUE; /* Save the screen */ screen_save(); /* Display a list of spells */ prt("", y, x); #ifdef JP put_str("名前", y, x + 5); #else put_str("Name", y, x + 5); #endif #ifdef JP put_str("失率 効果", y, x + 36); #else put_str("Fail Info", y, x + 35); #endif /* Dump the spells */ for (i = 0; i < num; i++) { /* Access the spell */ spell = monster_powers[p_ptr->mane_spell[i]]; chance = spell.manefail; /* Reduce failure rate by "effective" level adjustment */ if (plev > spell.level) chance -= 3 * (plev - spell.level); /* Reduce failure rate by INT/WIS adjustment */ chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[spell.use_stat]] + adj_mag_stat[p_ptr->stat_ind[A_DEX]] - 2) / 2; if (spell.manedam) chance = chance * p_ptr->mane_dam[i] / spell.manedam; chance += p_ptr->to_m_chance; /* Extract the minimum failure rate */ minfail = adj_mag_fail[p_ptr->stat_ind[spell.use_stat]]; /* Minimum failure rate */ if (chance < minfail) chance = minfail; /* Stunning makes spells harder */ if (p_ptr->stun > 50) chance += 25; else if (p_ptr->stun) chance += 15; /* Always a 5 percent chance of working */ if (chance > 95) chance = 95; /* Get info */ mane_info(comment, p_ptr->mane_spell[i], (baigaesi ? p_ptr->mane_dam[i]*2 : p_ptr->mane_dam[i])); /* Dump the spell --(-- */ sprintf(psi_desc, " %c) %-30s %3d%%%s", I2A(i), spell.name, chance, comment); prt(psi_desc, y + i + 1, x); } /* Clear the bottom line */ prt("", y + i + 1, x); } /* Hide the list */ else { /* Hide list */ redraw = FALSE; /* Restore the screen */ screen_load(); } /* Redo asking */ continue; } /* Note verify */ ask = isupper(choice); /* Lowercase */ if (ask) choice = tolower(choice); /* Extract request */ i = (islower(choice) ? A2I(choice) : -1); /* Totally Illegal */ if ((i < 0) || (i >= num)) { bell(); continue; } /* Save the spell index */ spell = monster_powers[p_ptr->mane_spell[i]]; /* Verify it */ if (ask) { char tmp_val[160]; /* Prompt */ #ifdef JP (void) strnfmt(tmp_val, 78, "%sをまねますか?", monster_powers[p_ptr->mane_spell[i]].name); #else (void)strnfmt(tmp_val, 78, "Use %s? ", monster_powers[p_ptr->mane_spell[i]].name); #endif /* Belay that order */ if (!get_check(tmp_val)) continue; } /* Stop the loop */ flag = TRUE; } /* Restore the screen */ if (redraw) screen_load(); /* Show choices */ p_ptr->window |= (PW_SPELL); /* Window stuff */ window_stuff(); /* Abort if needed */ if (!flag) return (FALSE); /* Save the choice */ (*sn) = i; damage = (baigaesi ? p_ptr->mane_dam[i]*2 : p_ptr->mane_dam[i]); /* Success */ return (TRUE); }
/* * Destroy an item */ void do_cmd_destroy(void) { int item, amt = 1; int old_number; bool force = FALSE; object_type *o_ptr; object_type forge; object_type *q_ptr = &forge; bool is_equipped = FALSE; char o_name[MAX_NLEN]; char out_val[MAX_NLEN+40]; cptr q, s; int mode = USE_INVEN | USE_FLOOR; if (p_ptr->pclass == CLASS_RUNE_KNIGHT) mode |= USE_EQUIP; if (p_ptr->special_defense & KATA_MUSOU) { set_action(ACTION_NONE); } /* Hack -- force destruction */ if (command_arg > 0) force = TRUE; /* Get an item */ q = "Destroy which item? "; s = "You have nothing to destroy."; if (!get_item(&item, q, s, mode)) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; is_equipped = equip_is_valid_slot(item); } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Hack for Rune Knight: They can destroy worn equipment, but only if it has the Sacrifice rune. get_item() is not smart enough to handle this restriction ... */ if (is_equipped && o_ptr->rune != RUNE_SACRIFICE) { msg_print("You must first remove that item before destroying it."); return; } /* Verify unless quantity given beforehand */ if (!force && (confirm_destroy || (object_value(o_ptr) > 0))) { object_desc(o_name, o_ptr, OD_OMIT_PREFIX); /* Make a verification */ sprintf(out_val, "Really destroy %s? [y/n/Auto]", o_name); msg_print(NULL); /* HACK : Add the line to message buffer */ message_add(out_val); p_ptr->window |= (PW_MESSAGE); window_stuff(); /* Get an acceptable answer */ while (TRUE) { char i; /* Prompt */ prt(out_val, 0, 0); i = inkey(); /* Erase the prompt */ prt("", 0, 0); if (i == 'y' || i == 'Y') { break; } if (i == ESCAPE || i == 'n' || i == 'N') { /* Cancel */ return; } if (i == 'A') { /* Add an auto-destroy preference line */ if (autopick_autoregister(o_ptr)) { /* Auto-destroy it */ autopick_alter_item(item, TRUE); } /* The object is already destroyed. */ return; } } /* while (TRUE) */ } /* See how many items */ if (o_ptr->number > 1) { /* Get a quantity */ amt = get_quantity(NULL, o_ptr->number); /* Allow user abort */ if (amt <= 0) return; } /* Describe the object */ old_number = o_ptr->number; o_ptr->number = amt; object_desc(o_name, o_ptr, 0); o_ptr->number = old_number; /* Take a turn */ energy_use = 100; /* Artifacts cannot be destroyed */ if (!can_player_destroy_object(o_ptr)) { energy_use = 0; /* Message */ msg_format("You cannot destroy %s.", o_name); /* Done */ return; } object_copy(q_ptr, o_ptr); stats_on_p_destroy(o_ptr, amt); if (prace_is_(RACE_MON_JELLY)) jelly_eat_object(o_ptr); else if (prace_is_(RACE_MON_SWORD) && object_is_melee_weapon(o_ptr)) sword_absorb_object(o_ptr); else if (prace_is_(RACE_MON_RING) && object_is_jewelry(o_ptr)) ring_absorb_object(o_ptr); else msg_format("You destroy %s.", o_name); if (o_ptr->rune == RUNE_SACRIFICE) { int add_hp = is_equipped ? p_ptr->mhp : p_ptr->mhp/3; int add_sp = is_equipped ? p_ptr->msp : p_ptr->msp/3; msg_print("You feel a surge of wondrous power enter your body."); p_ptr->chp = MIN(p_ptr->mhp, p_ptr->chp + add_hp); p_ptr->chp_frac = 0; p_ptr->csp = MIN(p_ptr->msp, p_ptr->csp + add_sp); p_ptr->csp_frac = 0; p_ptr->redraw |= (PR_MANA); p_ptr->window |= (PW_PLAYER); p_ptr->window |= (PW_SPELL); p_ptr->redraw |= (PR_HP); if (is_equipped) { blast_object(o_ptr); o_ptr->curse_flags = TRC_HEAVY_CURSE; } } else if (is_equipped) blast_object(o_ptr); sound(SOUND_DESTITEM); /* Reduce the charges of rods/wands */ reduce_charges(o_ptr, amt); /* Eliminate the item (from the pack) */ if (item >= 0) { if (!is_equipped) { inven_item_increase(item, -amt); inven_item_describe(item); inven_item_optimize(item); } } /* Eliminate the item (from the floor) */ else { floor_item_increase(0 - item, -amt); floor_item_describe(0 - item); floor_item_optimize(0 - item); } if ( p_ptr->pclass == CLASS_NECROMANCER && (q_ptr->tval == TV_LIFE_BOOK || q_ptr->tval == TV_CRUSADE_BOOK) ) { int sp = 0; int osp = p_ptr->csp; switch (q_ptr->sval) { case 0: sp = 10; break; case 1: sp = 25; break; case 2: sp = 100; break; case 3: sp = 666; break; } p_ptr->csp += sp; if (p_ptr->csp >= p_ptr->msp) { p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; } if (p_ptr->csp > osp) msg_print("You feel your head clear."); p_ptr->redraw |= (PR_MANA); } if (high_level_book(q_ptr)) { bool gain_expr = FALSE; if (p_ptr->prace == RACE_ANDROID) { } else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER)) { gain_expr = TRUE; } else if (p_ptr->pclass == CLASS_PALADIN) { if (is_good_realm(p_ptr->realm1)) { if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE; } else { if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE; } } if (gain_expr && (p_ptr->exp < PY_MAX_EXP)) { s32b tester_exp = p_ptr->max_exp / 20; if (tester_exp > 10000) tester_exp = 10000; if (q_ptr->sval < 3) tester_exp /= 4; if (tester_exp<1) tester_exp = 1; msg_print("You feel more experienced."); gain_exp(tester_exp * amt); } } if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK) { virtue_add(VIRTUE_UNLIFE, 1); virtue_add(VIRTUE_VITALITY, -1); } else if ( high_level_book(q_ptr) && (q_ptr->tval == TV_DEATH_BOOK || q_ptr->tval == TV_NECROMANCY_BOOK) ) { virtue_add(VIRTUE_UNLIFE, -1); virtue_add(VIRTUE_VITALITY, 1); } if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d) virtue_add(VIRTUE_ENCHANTMENT, -1); if (object_value_real(q_ptr) > 30000) virtue_add(VIRTUE_SACRIFICE, 2); else if (object_value_real(q_ptr) > 10000) virtue_add(VIRTUE_SACRIFICE, 1); if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0) virtue_add(VIRTUE_HARMONY, 1); if (equip_is_valid_slot(item)) calc_android_exp(); }
static int get_class_power(int *sn) { int i; int num = 0; int y = 1; int x = 10; int minfail =0; int plev = p_ptr->lev; int chance; int ask; int use_mind; char choice; char out_val[160]; char comment[80]; cptr p; mind_type spell; mind_power *mind_ptr; bool flag, redraw; /* Insert if /if else statement here for classflag. */ if ((cp_ptr->flags) & CF_OFFICER) { use_mind = MIND_OFFICER; p = "commanding presence"; } else if ((cp_ptr->flags) & CF_AESTHETE) { use_mind = MIND_AESTHETE; p = "skill"; } else if ((cp_ptr->flags) & CF_EXPLORER) { use_mind = MIND_EXPLORER; p = "talent"; } else if ((cp_ptr->flags) & CF_MEDIUM) { use_mind = MIND_MEDIUM; p = "mental power"; } else if ((cp_ptr->flags) & CF_RECKONER) { use_mind = MIND_RECKONER; p = "reality alteration"; } else if ((cp_ptr->flags) & CF_TOURIST) { use_mind = MIND_TOURIST; p = "tourism dept."; } else if ((cp_ptr->flags) & CF_HUSSAR) { use_mind = MIND_HUSSAR; p = "combat techniques"; } else if ((cp_ptr->flags) & CF_NATURE) { use_mind = MIND_NATURE; p = "natural empathy"; } else if ((cp_ptr->flags) & CF_NINJA) { use_mind = MIND_NINJA; p = "ninjutsu"; } else { msg_print("You have no powers."); } mind_ptr = &mind_powers[use_mind]; /* Assume cancelled */ *sn = (-1); #ifdef ALLOW_REPEAT /* TNB */ /* Get the spell, if available */ if (repeat_pull(sn)) { /* Verify the spell */ if (mind_ptr->info[*sn].min_lev <= plev) { /* Success */ return (TRUE); } } #endif /* ALLOW_REPEAT -- TNB */ /* Nothing chosen yet */ flag = FALSE; /* No redraw yet */ redraw = FALSE; for (i = 0; i < MAX_CLASS_POWERS; i++) { if (mind_ptr->info[i].min_lev <= plev) { num++; } } /* Build a prompt (accept all spells) */ (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) Use which %s? ", p, I2A(0), I2A(num - 1), p); /* Get a spell from the user */ while (!flag && get_com(out_val, &choice)) { /* Request redraw */ if ((choice == ' ') || (choice == '*') || (choice == '?')) { /* Show the list */ if (!redraw) { char psi_desc[80]; /* Show list */ redraw = TRUE; /* Save the screen */ screen_save(); prt("", y, x); put_str("Name", y, x + 5); put_str(format("Lv MP Fail Info"), y, x + 35); /* Dump the spells */ for (i = 0; i < MAX_CLASS_POWERS; i++) { /* Access the spell */ spell = mind_ptr->info[i]; if (spell.min_lev > plev) break; chance = spell.fail; /* Reduce failure rate by "effective" level adjustment */ chance -= 3 * (plev - spell.min_lev); /* Reduce failure rate by INT/WIS adjustment */ chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[cp_ptr->spell_stat]] - 1); /* Not enough mana to cast */ if (spell.mana_cost > p_ptr->csp) { chance += 5 * (spell.mana_cost - p_ptr->csp); } /* Extract the minimum failure rate */ minfail = adj_mag_fail[p_ptr->stat_ind[cp_ptr->spell_stat]]; /* Minimum failure rate */ if (chance < minfail) chance = minfail; /* Stunning makes spells harder */ if (p_ptr->stun > 50) chance += 25; else if (p_ptr->stun) chance += 15; /* Always a 5 percent chance of working */ if (chance > 95) chance = 95; /* Get info */ mindcraft_info(comment, use_mind, i); sprintf(psi_desc, " %c) ",I2A(i)); strcat(psi_desc, format("%-30s%2d %4d %3d%%%s", spell.name, spell.min_lev, spell.mana_cost, chance, comment)); prt(psi_desc, y + i + 1, x); } /* Clear the bottom line */ prt("", y + i + 1, x); } /* Hide the list */ else { /* Hide list */ redraw = FALSE; /* Restore the screen */ screen_load(); } /* Redo asking */ continue; } /* Note verify */ ask = isupper(choice); /* Lowercase */ if (ask) choice = tolower(choice); /* Extract request */ i = (islower(choice) ? A2I(choice) : -1); /* Totally Illegal */ if ((i < 0) || (i >= num)) { bell("Illegal class power choice!"); continue; } /* Save the spell index */ spell = mind_ptr->info[i]; /* Verify it */ if (ask) { char tmp_val[160]; /* Prompt */ (void)strnfmt(tmp_val, 78, "Use %s? ", spell.name); /* Belay that order */ if (!get_check(tmp_val)) continue; } /* Stop the loop */ flag = TRUE; } /* Restore the screen */ if (redraw) screen_load(); /* Show choices */ /* Update */ p_ptr->window |= (PW_OVERHEAD); /* Window stuff */ window_stuff(); /* Abort if needed */ if (!flag) return (FALSE); /* Save the choice */ (*sn) = i; #ifdef ALLOW_REPEAT /* TNB */ repeat_push(*sn); #endif /* ALLOW_REPEAT -- TNB */ /* Success */ return (TRUE); }
/*! * @brief 使用可能な青魔法を選択する / * Allow user to choose a imitation. * @param sn 選択したモンスター攻撃ID、キャンセルの場合-1、不正な選択の場合-2を返す * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。 * @details * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n * If the user hits escape, returns FALSE, and set '*sn' to -1\n * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n *\n * The "prompt" should be "cast", "recite", or "study"\n * The "known" should be TRUE for cast/pray, FALSE for study\n *\n * nb: This function has a (trivial) display bug which will be obvious\n * when you run it. It's probably easy to fix but I haven't tried,\n * sorry.\n */ static int get_learned_power(int *sn) { int i = 0; int num = 0; int y = 1; int x = 18; int minfail = 0; int plev = p_ptr->lev; int chance = 0; int ask = TRUE, mode = 0; int spellnum[MAX_MONSPELLS]; char ch; char choice; char out_val[160]; char comment[80]; s32b f4 = 0, f5 = 0, f6 = 0; cptr p = _("魔法", "magic"); monster_power spell; bool flag, redraw; int menu_line = (use_menu ? 1 : 0); /* Assume cancelled */ *sn = (-1); /* Nothing chosen yet */ flag = FALSE; /* No redraw yet */ redraw = FALSE; #ifdef ALLOW_REPEAT /* TNB */ /* Get the spell, if available */ if (repeat_pull(sn)) { /* Success */ return (TRUE); } #endif /* ALLOW_REPEAT -- TNB */ if (use_menu) { screen_save(); while(!mode) { #ifdef JP prt(format(" %s ボルト", (menu_line == 1) ? "》" : " "), 2, 14); prt(format(" %s ボール", (menu_line == 2) ? "》" : " "), 3, 14); prt(format(" %s ブレス", (menu_line == 3) ? "》" : " "), 4, 14); prt(format(" %s 召喚", (menu_line == 4) ? "》" : " "), 5, 14); prt(format(" %s その他", (menu_line == 5) ? "》" : " "), 6, 14); prt("どの種類の魔法を使いますか?", 0, 0); #else prt(format(" %s bolt", (menu_line == 1) ? "> " : " "), 2, 14); prt(format(" %s ball", (menu_line == 2) ? "> " : " "), 3, 14); prt(format(" %s breath", (menu_line == 3) ? "> " : " "), 4, 14); prt(format(" %s sommoning", (menu_line == 4) ? "> " : " "), 5, 14); prt(format(" %s others", (menu_line == 5) ? "> " : " "), 6, 14); prt("use which type of magic? ", 0, 0); #endif choice = inkey(); switch(choice) { case ESCAPE: case 'z': case 'Z': screen_load(); return FALSE; case '2': case 'j': case 'J': menu_line++; break; case '8': case 'k': case 'K': menu_line+= 4; break; case '\r': case 'x': case 'X': mode = menu_line; break; } if (menu_line > 5) menu_line -= 5; } screen_load(); } else { sprintf(comment, _("[A]ボルト, [B]ボール, [C]ブレス, [D]召喚, [E]その他:", "[A] bolt, [B] ball, [C] breath, [D] summoning, [E] others:")); while (TRUE) { if (!get_com(comment, &ch, TRUE)) { return FALSE; } if (ch == 'A' || ch == 'a') { mode = 1; break; } if (ch == 'B' || ch == 'b') { mode = 2; break; } if (ch == 'C' || ch == 'c') { mode = 3; break; } if (ch == 'D' || ch == 'd') { mode = 4; break; } if (ch == 'E' || ch == 'e') { mode = 5; break; } } } set_rf_masks(&f4, &f5, &f6, mode); for (i = 0, num = 0; i < 32; i++) { if ((0x00000001 << i) & f4) spellnum[num++] = i; } for (; i < 64; i++) { if ((0x00000001 << (i - 32)) & f5) spellnum[num++] = i; } for (; i < 96; i++) { if ((0x00000001 << (i - 64)) & f6) spellnum[num++] = i; } for (i = 0; i < num; i++) { if (p_ptr->magic_num2[spellnum[i]]) { if (use_menu) menu_line = i+1; break; } } if (i == num) { msg_print(_("その種類の魔法は覚えていない!", "You don't know any spell of this type.")); return (FALSE); } /* Build a prompt (accept all spells) */ (void)strnfmt(out_val, 78, _("(%c-%c, '*'で一覧, ESC) どの%sを唱えますか?", "(%c-%c, *=List, ESC=exit) Use which %s? "), I2A(0), I2A(num - 1), p); if (use_menu) screen_save(); /* Get a spell from the user */ choice= (always_show_list || use_menu) ? ESCAPE:1 ; while (!flag) { if(choice==ESCAPE) choice = ' '; else if( !get_com(out_val, &choice, TRUE) )break; if (use_menu && choice != ' ') { switch(choice) { case '0': { screen_load(); return (FALSE); } case '8': case 'k': case 'K': { do { menu_line += (num-1); if (menu_line > num) menu_line -= num; } while(!p_ptr->magic_num2[spellnum[menu_line-1]]); break; } case '2': case 'j': case 'J': { do { menu_line++; if (menu_line > num) menu_line -= num; } while(!p_ptr->magic_num2[spellnum[menu_line-1]]); break; } case '6': case 'l': case 'L': { menu_line=num; while(!p_ptr->magic_num2[spellnum[menu_line-1]]) menu_line--; break; } case '4': case 'h': case 'H': { menu_line=1; while(!p_ptr->magic_num2[spellnum[menu_line-1]]) menu_line++; break; } case 'x': case 'X': case '\r': { i = menu_line - 1; ask = FALSE; break; } } } /* Request redraw */ if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask)) { /* Show the list */ if (!redraw || use_menu) { char psi_desc[80]; /* Show list */ redraw = TRUE; /* Save the screen */ if (!use_menu) screen_save(); /* Display a list of spells */ prt("", y, x); put_str(_("名前", "Name"), y, x + 5); put_str(_("MP 失率 効果", "SP Fail Info"), y, x + 33); /* Dump the spells */ for (i = 0; i < num; i++) { int need_mana; prt("", y + i + 1, x); if (!p_ptr->magic_num2[spellnum[i]]) continue; /* Access the spell */ spell = monster_powers[spellnum[i]]; chance = spell.fail; /* Reduce failure rate by "effective" level adjustment */ if (plev > spell.level) chance -= 3 * (plev - spell.level); else chance += (spell.level - plev); /* Reduce failure rate by INT/WIS adjustment */ chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[A_INT]] - 1); chance = mod_spell_chance_1(chance); need_mana = mod_need_mana(monster_powers[spellnum[i]].smana, 0, REALM_NONE); /* Not enough mana to cast */ if (need_mana > p_ptr->csp) { chance += 5 * (need_mana - p_ptr->csp); } /* Extract the minimum failure rate */ minfail = adj_mag_fail[p_ptr->stat_ind[A_INT]]; /* Minimum failure rate */ if (chance < minfail) chance = minfail; /* Stunning makes spells harder */ if (p_ptr->stun > 50) chance += 25; else if (p_ptr->stun) chance += 15; /* Always a 5 percent chance of working */ if (chance > 95) chance = 95; chance = mod_spell_chance_2(chance); /* Get info */ learned_info(comment, spellnum[i]); if (use_menu) { if (i == (menu_line-1)) strcpy(psi_desc, _(" 》", " > ")); else strcpy(psi_desc, " "); } else sprintf(psi_desc, " %c)", I2A(i)); /* Dump the spell --(-- */ strcat(psi_desc, format(" %-26s %3d %3d%%%s", spell.name, need_mana, chance, comment)); prt(psi_desc, y + i + 1, x); } /* Clear the bottom line */ if (y < 22) prt("", y + i + 1, x); } /* Hide the list */ else { /* Hide list */ redraw = FALSE; /* Restore the screen */ screen_load(); } /* Redo asking */ continue; } if (!use_menu) { /* Note verify */ ask = isupper(choice); /* Lowercase */ if (ask) choice = tolower(choice); /* Extract request */ i = (islower(choice) ? A2I(choice) : -1); } /* Totally Illegal */ if ((i < 0) || (i >= num) || !p_ptr->magic_num2[spellnum[i]]) { bell(); continue; } /* Save the spell index */ spell = monster_powers[spellnum[i]]; /* Verify it */ if (ask) { char tmp_val[160]; /* Prompt */ (void) strnfmt(tmp_val, 78, _("%sの魔法を唱えますか?", "Use %s? "), monster_powers[spellnum[i]].name); /* Belay that order */ if (!get_check(tmp_val)) continue; } /* Stop the loop */ flag = TRUE; } /* Restore the screen */ if (redraw) screen_load(); /* Show choices */ p_ptr->window |= (PW_SPELL); /* Window stuff */ window_stuff(); /* Abort if needed */ if (!flag) return (FALSE); /* Save the choice */ (*sn) = spellnum[i]; #ifdef ALLOW_REPEAT /* TNB */ repeat_push(*sn); #endif /* ALLOW_REPEAT -- TNB */ /* Success */ return (TRUE); }
static bool _choose(_choice_array_t *choices) { int key = 0, i; bool redraw = TRUE; bool done = FALSE; assert(choices->size); choices->current = 0; if (choices->mode == _CHOOSE_MODE_LEARN) { /* In this mode, the first choice is the form to learn followed by a single group of existing slots */ assert(choices->size > 1); choices->current = 1; } while (!done) { if (redraw) { _list(choices); redraw = FALSE; } { int r_idx = choices->choices[choices->current].r_idx; if (r_idx > 0) { monster_race_track(r_idx); window_stuff(); } } /* No macros. The problem is that arrow keys are implemented with macros! */ key = inkey_special(TRUE); switch (key) { case ESCAPE: done = TRUE; break; case '?': { int r_idx = choices->choices[choices->current].r_idx; if (r_idx > 0) { int x = Term->scr->cx; /* No way to query this? */ int y = Term->scr->cy; mon_display(&r_info[r_idx]); Term_gotoxy(x, y); redraw = TRUE; /* screen_save buggily misses row 0 */ } break; } case '=': _next_display_mode(); redraw = TRUE; break; case '8': case SKEY_UP: { int old_current = choices->current; choices->current--; if (choices->current < 0) choices->current = 0; if (old_current != choices->current) redraw = TRUE; break; } case '2': case SKEY_DOWN: { int old_current = choices->current; choices->current++; if (choices->current > choices->size - 1) choices->current = choices->size - 1; if (old_current != choices->current) redraw = TRUE; break; } case '\t': { int old_current = choices->current; int old_type = choices->choices[old_current].type; /* Tab to next group in the list. Wrap to first group as needed. */ for (;;) { choices->current++; if (choices->current == choices->size) /* Wrap */ choices->current = 0; if (choices->choices[choices->current].type != old_type) break; if (choices->current == old_current) break; } if (old_current != choices->current) redraw = TRUE; break; } case ' ': case '\r': case '\n': if (_confirm(choices, choices->current)) return TRUE; redraw = TRUE; break; default: for (i = 0; i < choices->size; i++) { if (choices->choices[i].key == key) { choices->current = i; if (_confirm(choices, choices->current)) return TRUE; redraw = TRUE; break; } } } } return FALSE; }
/* * Destroy an item */ void do_cmd_destroy(void) { int item, amt = 1; int old_number; bool force = FALSE; object_type *o_ptr; char o_name[MAX_NLEN]; char out_val[160]; cptr q, s; /* Hack -- force destruction */ if (command_arg > 0) force = TRUE; /* Get an item */ #ifdef JP q = "どのアイテムを壊しますか? "; s = "壊せるアイテムを持っていない。"; #else q = "Destroy which item? "; s = "You have nothing to destroy."; #endif if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Verify unless quantity given */ if (!force && (!(auto_destroy && (object_value(o_ptr) < 1)))) { object_desc(o_name, o_ptr, OD_OMIT_PREFIX); /* Make a verification */ sprintf(out_val, #ifdef JP "本当に%sを壊しますか? [y/n/Auto]", #else "Really destroy %s? [y/n/Auto]", #endif o_name); msg_print(NULL); /* HACK : Add the line to message buffer */ message_add(out_val); p_ptr->window |= (PW_MESSAGE); window_stuff(); /* Get an acceptable answer */ while (TRUE) { char i; /* Prompt */ prt(out_val, 0, 0); i = inkey(); /* Erase the prompt */ prt("", 0, 0); if (i == 'y' || i == 'Y') { break; } if (i == ESCAPE || i == 'n' || i == 'N') { /* Cancel */ return; } if (i == 'A') { /* Add an auto-destroy preference line */ if (autopick_autoregister(o_ptr)) { /* Auto-destroy it */ autopick_alter_item(item, TRUE); } /* The object is already destroyed. */ return; } } /* while (TRUE) */ } /* See how many items */ if (o_ptr->number > 1) { /* Get a quantity */ amt = get_quantity(NULL, o_ptr->number); /* Allow user abort */ if (amt <= 0) return; } /* Describe the object */ old_number = o_ptr->number; o_ptr->number = amt; object_desc(o_name, o_ptr, 0); o_ptr->number = old_number; /* Take a turn */ energy_use = 100; /* Can the player destroy the object? */ if (!can_player_destroy_object(o_ptr)) { /* Don't take a turn */ energy_use = 0; /* Message */ #ifdef JP msg_format("%sは破壊不可能だ。", o_name); #else msg_format("You cannot destroy %s.", o_name); #endif /* Done */ return; } /* Message */ #ifdef JP msg_format("%sを壊した。", o_name); #else msg_format("You destroy %s.", o_name); #endif sound(SOUND_DESTROY); if (high_level_book(o_ptr)) { bool gain_expr = FALSE; if (p_ptr->pclass == CLASS_WARRIOR) { gain_expr = TRUE; } else if (p_ptr->pclass == CLASS_PALADIN) { if (p_ptr->realm1 == REALM_LIFE) { if (o_ptr->tval != TV_LIFE_BOOK) gain_expr = TRUE; } else { if (o_ptr->tval == TV_LIFE_BOOK) gain_expr = TRUE; } } if (gain_expr && (p_ptr->exp < PY_MAX_EXP)) { s32b tester_exp = p_ptr->max_exp / 20; if (tester_exp > 10000) tester_exp = 10000; if (o_ptr->sval < 3) tester_exp /= 4; if (tester_exp < 1) tester_exp = 1; #ifdef JP msg_print("更に経験を積んだような気がする。"); #else msg_print("You feel more experienced."); #endif gain_exp(tester_exp * amt); } } /* Reduce the charges of rods/wands */ reduce_charges(o_ptr, amt); /* Eliminate the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -amt); inven_item_describe(item); inven_item_optimize(item); } /* Eliminate the item (from the floor) */ else { floor_item_increase(0 - item, -amt); floor_item_describe(0 - item); floor_item_optimize(0 - item); } }