3 /* Purpose: Mindcrafter code */
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
15 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
18 * Allow user to choose a mindcrafter power.
20 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
21 * If the user hits escape, returns FALSE, and set '*sn' to -1
22 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
24 * The "prompt" should be "cast", "recite", or "study"
25 * The "known" should be TRUE for cast/pray, FALSE for study
27 * nb: This function has a (trivial) display bug which will be obvious
28 * when you run it. It's probably easy to fix but I haven't tried,
31 static int get_hissatsu_power(int *sn)
37 int plev = p_ptr->lev;
45 cptr p = "special attack";
50 int menu_line = (use_menu ? 1 : 0);
52 /* Assume cancelled */
55 #ifdef ALLOW_REPEAT /* TNB */
57 /* Get the spell, if available */
60 /* Verify the spell */
61 if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev)
68 #endif /* ALLOW_REPEAT -- TNB */
70 /* Nothing chosen yet */
76 for (i = 0; i < 32; i++)
78 if (technic_info[TECHNIC_HISSATSU][i].slevel <= PY_MAX_LEVEL)
85 /* Build a prompt (accept all spells) */
86 (void) strnfmt(out_val, 78,
88 "(%^s %c-%c, '*'¤Ç°ìÍ÷, ESC) ¤É¤Î%s¤ò»È¤¤¤Þ¤¹¤«¡©",
90 "(%^ss %c-%c, *=List, ESC=exit) Use which %s? ",
92 p, I2A(0), "abcdefghijklmnopqrstuvwxyz012345"[num-1], p);
94 if (use_menu) screen_save();
96 /* Get a spell from the user */
98 choice= always_show_list ? ESCAPE:1 ;
101 if(choice==ESCAPE) choice = ' ';
102 else if( !get_com(out_val, &choice, FALSE) )break;
104 if (use_menu && choice != ' ')
121 if (menu_line > 32) menu_line -= 32;
122 } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
133 if (menu_line > 32) menu_line -= 32;
134 } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
145 bool reverse = FALSE;
146 if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
153 while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))))
158 if (menu_line < 2) reverse = FALSE;
163 if (menu_line > 31) reverse = TRUE;
181 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
184 if (!redraw || use_menu)
192 /* Save the screen */
193 if (!use_menu) screen_save();
195 /* Display a list of spells */
198 put_str("̾Á° Lv MP ̾Á° Lv MP ", y, x + 5);
200 put_str("name Lv SP name Lv SP ", y, x + 5);
203 /* Dump the spells */
204 for (i = 0, line = 0; i < 32; i++)
206 spell = technic_info[TECHNIC_HISSATSU][i];
208 if (spell.slevel > PY_MAX_LEVEL) continue;
210 if (!(p_ptr->spell_learned1 >> i)) break;
212 /* Access the spell */
213 if (spell.slevel > plev) continue;
214 if (!(p_ptr->spell_learned1 & (1L << i))) continue;
217 if (i == (menu_line-1))
219 strcpy(psi_desc, " ¡Õ");
221 strcpy(psi_desc, " > ");
223 else strcpy(psi_desc, " ");
230 letter = I2A(line-1);
232 letter = '0' + line - 27;
233 sprintf(psi_desc, " %c)",letter);
236 /* Dump the spell --(-- */
237 strcat(psi_desc, format(" %-18s%2d %3d",
238 do_spell(REALM_HISSATSU, i, SPELL_NAME),
239 spell.slevel, spell.smana));
240 prt(psi_desc, y + (line%17) + (line >= 17), x+(line/17)*30);
241 prt("", y + (line%17) + (line >= 17) + 1, x+(line/17)*30);
251 /* Restore the screen */
264 ask = (isupper(choice));
267 if (ask) choice = tolower(choice);
269 /* Extract request */
270 i = (islower(choice) ? A2I(choice) : -1);
274 ask = FALSE; /* Can't uppercase digits */
276 i = choice - '0' + 26;
280 /* Totally Illegal */
281 if ((i < 0) || (i >= 32) || !(p_ptr->spell_learned1 & (1 << sentaku[i])))
296 (void) strnfmt(tmp_val, 78, "%s¤ò»È¤¤¤Þ¤¹¤«¡©", do_spell(REALM_HISSATSU, j, SPELL_NAME));
298 (void)strnfmt(tmp_val, 78, "Use %s? ", do_spell(REALM_HISSATSU, j, SPELL_NAME));
302 /* Belay that order */
303 if (!get_check(tmp_val)) continue;
310 /* Restore the screen */
311 if (redraw) screen_load();
314 p_ptr->window |= (PW_SPELL);
320 /* Abort if needed */
321 if (!flag) return (FALSE);
323 /* Save the choice */
326 #ifdef ALLOW_REPEAT /* TNB */
330 #endif /* ALLOW_REPEAT -- TNB */
338 * do_cmd_cast calls this function if the player's class
341 void do_cmd_hissatsu(void)
347 /* not if confused */
351 msg_print("º®Í𤷤Ƥ¤¤Æ½¸Ãæ¤Ç¤¤Ê¤¤¡ª");
353 msg_print("You are too confused!");
358 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
360 if (flush_failure) flush();
362 msg_print("Éð´ï¤ò»ý¤¿¤Ê¤¤¤Èɬ»¦µ»¤Ï»È¤¨¤Ê¤¤¡ª");
364 msg_print("You need to wield a weapon!");
369 if (!p_ptr->spell_learned1)
372 msg_print("²¿¤âµ»¤òÃΤé¤Ê¤¤¡£");
374 msg_print("You don't know any special attacks.");
380 if (p_ptr->special_defense & KATA_MASK)
382 set_action(ACTION_NONE);
386 if (!get_hissatsu_power(&n)) return;
388 spell = technic_info[TECHNIC_HISSATSU][n];
390 /* Verify "dangerous" spells */
391 if (spell.smana > p_ptr->csp)
393 if (flush_failure) flush();
396 msg_print("£Í£Ð¤¬Â¤ê¤Þ¤»¤ó¡£");
398 msg_print("You do not have enough mana to use this power.");
407 if (!do_spell(REALM_HISSATSU, n, SPELL_CAST)) return;
413 p_ptr->csp -= spell.smana;
416 if (p_ptr->csp < 0) p_ptr->csp = 0;
419 p_ptr->redraw |= (PR_MANA);
422 p_ptr->window |= (PW_PLAYER);
423 p_ptr->window |= (PW_SPELL);
427 void do_cmd_gain_hissatsu(void)
436 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
438 set_action(ACTION_NONE);
441 if (p_ptr->blind || no_lite())
444 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡ª");
446 msg_print("You cannot see!");
455 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡ª");
457 msg_print("You are too confused!");
463 if (!(p_ptr->new_spells))
466 msg_print("¿·¤·¤¤É¬»¦µ»¤ò³Ð¤¨¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡ª");
468 msg_print("You cannot learn any new special attacks!");
475 if( p_ptr->new_spells < 10 ){
476 msg_format("¤¢¤È %d ¤Ä¤Îɬ»¦µ»¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells);
478 msg_format("¤¢¤È %d ¸Ä¤Îɬ»¦µ»¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells);
481 msg_format("You can learn %d new special attack%s.", p_ptr->new_spells,
482 (p_ptr->new_spells == 1?"":"s"));
485 item_tester_tval = TV_HISSATSU_BOOK;
489 q = "¤É¤Î½ñ¤«¤é³Ø¤Ó¤Þ¤¹¤«? ";
491 q = "Study which book? ";
495 s = "Æɤá¤ë½ñ¤¬¤Ê¤¤¡£";
497 s = "You have no books that you can read.";
500 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
502 /* Get the item (in the pack) */
505 o_ptr = &inventory[item];
508 /* Get the item (on the floor) */
511 o_ptr = &o_list[0 - item];
514 for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
516 if (p_ptr->spell_learned1 & (1L << i)) continue;
517 if (technic_info[TECHNIC_HISSATSU][i].slevel > p_ptr->lev) continue;
519 p_ptr->spell_learned1 |= (1L << i);
520 p_ptr->spell_worked1 |= (1L << i);
522 msg_format("%s¤Îµ»¤ò³Ð¤¨¤¿¡£", do_spell(REALM_HISSATSU, i, SPELL_NAME));
524 msg_format("You have learned the special attack of %s.", do_spell(REALM_HISSATSU, i, SPELL_NAME));
526 for (j = 0; j < 64; j++)
528 /* Stop at the first empty space */
529 if (p_ptr->spell_order[j] == 99) break;
531 p_ptr->spell_order[j] = i;
538 msg_print("²¿¤â³Ð¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡£");
540 msg_print("You were not able to learn any special attacks.");
547 p_ptr->update |= (PU_SPELLS);