2 * @brief スナイパー技能の実装 / Sniping
5 * 2014 Deskull rearranged comment for Doxygen.\n
8 #include "mind/mind-sniper.h"
9 #include "action/action-limited.h"
10 #include "cmd-action/cmd-shoot.h"
11 #include "core/asking-player.h"
12 #include "core/player-redraw-types.h"
13 #include "core/player-update-types.h"
14 #include "core/stuff-handler.h"
15 #include "core/window-redrawer.h"
16 #include "game-option/text-display-options.h"
17 #include "grid/grid.h"
18 #include "inventory/inventory-slot-types.h"
19 #include "io/command-repeater.h"
20 #include "io/input-key-requester.h"
21 #include "main/sound-definitions-table.h"
22 #include "main/sound-of-music.h"
23 #include "mind/snipe-types.h"
24 #include "monster-race/race-flags-resistance.h"
25 #include "monster-race/race-flags3.h"
26 #include "monster-race/monster-race.h"
27 #include "player/player-status.h"
28 #include "system/object-type-definition.h"
29 #include "term/screen-processor.h"
30 #include "term/term-color-types.h"
31 #include "util/buffer-shaper.h"
32 #include "util/int-char-converter.h"
33 #include "view/display-messages.h"
35 #define MAX_SNIPE_POWERS 16
38 typedef struct snipe_power
45 /*! スナイパー技能の解説メッセージ */
46 static concptr const snipe_tips[MAX_SNIPE_POWERS] =
49 "精神を集中する。射撃の威力、精度が上がり、高度な射撃術が使用できるようになる。",
50 "光る矢を放つ。光に弱いモンスターに威力を発揮する。",
51 "射撃を行った後、短距離の瞬間移動を行う。",
52 "軌道上の罠をすべて無効にする低空飛行の矢を放つ。",
54 "壁を粉砕する矢を放つ。岩でできたモンスターと無生物のモンスターに威力を発揮する。",
58 "善良なモンスターに威力を発揮する矢を放つ。",
59 "邪悪なモンスターに威力を発揮する矢を放つ。",
63 "敵の急所にめがけて矢を放つ。成功すると敵を一撃死させる。失敗すると1ダメージ。",
64 "全てのモンスターに高威力を発揮する矢を放つ。反動による副次効果を受ける。",
66 "Concentrate your mind fot shooting.",
67 "Shot an allow with brightness.",
68 "Blink after shooting.",
69 "Shot an allow able to shatter traps.",
70 "Deals extra damege of fire.",
71 "Shot an allow able to shatter rocks.",
72 "Deals extra damege of ice.",
73 "An allow rushes away a target.",
74 "An allow pierces some monsters.",
75 "Deals more damage to good monsters.",
76 "Deals more damage to evil monsters.",
77 "An allow explodes when it hits a monster.",
79 "Deals extra damege of lightning.",
80 "Deals quick death or 1 damage.",
81 "Deals great damage to all monsters, and some side effects to you.",
86 static snipe_power const snipe_powers[MAX_SNIPE_POWERS] =
88 /* Level gained, cost, name */
92 { 3, 1, "シュート&アウェイ" },
102 { 32, 4, "ダブルショット" },
103 { 36, 3, "プラズマボルト" },
104 { 40, 3, "ニードルショット" },
105 { 48, 7, "セイントスターアロー" },
107 { 1, 0, "Concentration" },
108 { 2, 1, "Flush Arrow" },
109 { 3, 1, "Shoot & Away" },
110 { 5, 1, "Disarm Shot" },
111 { 8, 2, "Fire Shot" },
112 { 10, 2, "Shatter Arrow" },
113 { 13, 2, "Ice Shot" },
114 { 18, 2, "Rushing Arrow"},
115 { 22, 3, "Piercing Shot" },
116 { 25, 4, "Evil Shot"},
117 { 26, 4, "Holy Shot" },
119 { 32, 4, "Double Shot" },
120 { 36, 3, "Plasma Bolt" },
121 { 40, 3, "Needle Shot" },
122 { 48, 7, "Saint Stars Arrow" },
130 static bool snipe_concentrate(player_type *creature_ptr)
132 if ((int)creature_ptr->concent < (2 + (creature_ptr->lev + 5) / 10)) creature_ptr->concent++;
134 msg_format(_("集中した。(集中度 %d)", "You concentrate deeply. (lvl %d)"), creature_ptr->concent);
135 creature_ptr->reset_concent = FALSE;
137 creature_ptr->update |= (PU_BONUS | PU_MONSTERS);
138 creature_ptr->redraw |= (PR_STATUS);
143 * @brief スナイパーの集中度リセット
144 * @param msg TRUEならばメッセージを表示する
147 void reset_concentration(player_type *creature_ptr, bool msg)
151 msg_print(_("集中力が途切れてしまった。", "Stop concentrating."));
154 creature_ptr->concent = 0;
155 creature_ptr->reset_concent = FALSE;
157 creature_ptr->update |= (PU_BONUS | PU_MONSTERS);
158 creature_ptr->redraw |= (PR_STATUS);
162 * @brief スナイパーの集中度によるダメージボーナスを加算する
163 * @param tdam 算出中のダメージ
164 * @return 集中度修正を加えたダメージ
166 int boost_concentration_damage(player_type *creature_ptr, int tdam)
168 tdam *= (10 + creature_ptr->concent);
175 * @brief スナイパーの技能リストを表示する
178 void display_snipe_list(player_type *sniper_ptr)
183 PLAYER_LEVEL plev = sniper_ptr->lev;
187 /* Display a list of spells */
189 put_str(_("名前", "Name"), y, x + 5);
190 put_str(_("Lv MP", "Lv Mana"), y, x + 35);
192 for (i = 0; i < MAX_SNIPE_POWERS; i++)
194 /* Access the available spell */
195 spell = snipe_powers[i];
196 if (spell.min_lev > plev) continue;
197 if (spell.mana_cost > (int)sniper_ptr->concent) continue;
199 sprintf(psi_desc, " %c) %-30s%2d %4d",
200 I2A(i), spell.name, spell.min_lev, spell.mana_cost);
202 term_putstr(x, y + i + 1, -1, TERM_WHITE, psi_desc);
209 * @brief スナイパー技能を選択する
210 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
211 * @param only_browse 一覧を見るだけの場合TRUEを返す
212 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
213 * Allow user to choose a mindcrafter power.\n
215 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
216 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
217 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
219 * The "prompt" should be "cast", "recite", or "study"\n
220 * The "known" should be TRUE for cast/pray, FALSE for study\n
222 * nb: This function has a (trivial) display bug which will be obvious\n
223 * when you run it. It's probably easy to fix but I haven't tried,\n
226 static int get_snipe_power(player_type *sniper_ptr, COMMAND_CODE *sn, bool only_browse)
232 PLAYER_LEVEL plev = sniper_ptr->lev;
236 concptr p = _("射撃術", "power");
242 /* Assume cancelled */
245 /* Repeat previous command */
246 /* Get the spell, if available */
249 /* Verify the spell */
250 if ((snipe_powers[*sn].min_lev <= plev) && (snipe_powers[*sn].mana_cost <= (int)sniper_ptr->concent))
260 for (i = 0; i < MAX_SNIPE_POWERS; i++)
262 if ((snipe_powers[i].min_lev <= plev) &&
263 ((only_browse) || (snipe_powers[i].mana_cost <= (int)sniper_ptr->concent)))
269 /* Build a prompt (accept all spells) */
272 (void)strnfmt(out_val, 78,
273 _("(%^s %c-%c, '*'で一覧, ESC) どの%sについて知りますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
274 p, I2A(0), I2A(num), p);
278 (void)strnfmt(out_val, 78,
279 _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
280 p, I2A(0), I2A(num), p);
283 choice = always_show_list ? ESCAPE : 1;
286 if(choice == ESCAPE) choice = ' ';
287 else if( !get_com(out_val, &choice, FALSE) )break;
290 if ((choice == ' ') || (choice == '*') || (choice == '?'))
297 if (!only_browse) screen_save();
299 /* Display a list of spells */
301 put_str(_("名前", "Name"), y, x + 5);
302 if (only_browse) put_str(_("Lv 集中度", "Lv Pow"), y, x + 35);
304 /* Dump the spells */
305 for (i = 0; i < MAX_SNIPE_POWERS; i++)
307 term_erase(x, y + i + 1, 255);
309 /* Access the spell */
310 spell = snipe_powers[i];
311 if (spell.min_lev > plev) continue;
312 if (!only_browse && (spell.mana_cost > (int)sniper_ptr->concent)) continue;
314 /* Dump the spell --(-- */
316 sprintf(psi_desc, " %c) %-30s%2d %4d",
317 I2A(i), spell.name, spell.min_lev, spell.mana_cost);
319 sprintf(psi_desc, " %c) %-30s", I2A(i), spell.name);
320 prt(psi_desc, y + i + 1, x);
323 /* Clear the bottom line */
324 prt("", y + i + 1, x);
332 if (!only_browse) screen_load();
340 ask = isupper(choice);
343 if (ask) choice = (char)tolower(choice);
345 /* Extract request */
346 i = (islower(choice) ? A2I(choice) : -1);
348 /* Totally Illegal */
349 if ((i < 0) || (i > num) ||
350 (!only_browse &&(snipe_powers[i].mana_cost > (int)sniper_ptr->concent)))
356 /* Save the spell index */
357 spell = snipe_powers[i];
365 (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), snipe_powers[i].name);
367 /* Belay that order */
368 if (!get_check(tmp_val)) continue;
374 if (redraw && !only_browse) screen_load();
376 sniper_ptr->window |= (PW_SPELL);
377 handle_stuff(sniper_ptr);
379 /* Abort if needed */
380 if (!flag) return FALSE;
382 /* Save the choice */
393 * @brief スナイバー技能のスレイ倍率計算を行う /
394 * Calcurate magnification of snipe technics
395 * @param mult スナイバー技能のスレイ効果以前に算出している多要素の倍率(/10倍)
396 * @param m_ptr 目標となるモンスターの構造体参照ポインタ
397 * @return スレイの倍率(/10倍)
399 MULTIPLY calc_snipe_damage_with_slay(player_type *sniper_ptr, MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_type)
401 monster_race *r_ptr = &r_info[m_ptr->r_idx];
402 bool seen = is_seen(sniper_ptr, m_ptr);
407 if (r_ptr->flags3 & (RF3_HURT_LITE))
409 MULTIPLY n = 20 + sniper_ptr->concent;
410 if (seen) r_ptr->r_flags3 |= (RF3_HURT_LITE);
411 if (mult < n) mult = n;
415 if (r_ptr->flagsr & RFR_IM_FIRE)
417 if (seen) r_ptr->r_flagsr |= RFR_IM_FIRE;
421 MULTIPLY n = 15 + (sniper_ptr->concent * 3);
422 if (mult < n) mult = n;
426 if (r_ptr->flagsr & RFR_IM_COLD)
428 if (seen) r_ptr->r_flagsr |= RFR_IM_COLD;
432 MULTIPLY n = 15 + (sniper_ptr->concent * 3);
433 if (mult < n) mult = n;
437 if (r_ptr->flagsr & RFR_IM_ELEC)
439 if (seen) r_ptr->r_flagsr |= RFR_IM_ELEC;
443 MULTIPLY n = 18 + (sniper_ptr->concent * 4);
444 if (mult < n) mult = n;
448 if (r_ptr->flags3 & RF3_HURT_ROCK)
450 MULTIPLY n = 15 + (sniper_ptr->concent * 2);
451 if (seen) r_ptr->r_flags3 |= RF3_HURT_ROCK;
452 if (mult < n) mult = n;
454 else if (r_ptr->flags3 & RF3_NONLIVING)
456 MULTIPLY n = 15 + (sniper_ptr->concent * 2);
457 if (seen) r_ptr->r_flags3 |= RF3_NONLIVING;
458 if (mult < n) mult = n;
462 if (r_ptr->flags3 & RF3_GOOD)
464 MULTIPLY n = 15 + (sniper_ptr->concent * 4);
465 if (seen) r_ptr->r_flags3 |= RF3_GOOD;
466 if (mult < n) mult = n;
470 if (r_ptr->flags3 & RF3_EVIL)
472 MULTIPLY n = 12 + (sniper_ptr->concent * 3);
473 if (seen) r_ptr->r_flags3 |= RF3_EVIL;
474 if (r_ptr->flags3 & (RF3_HURT_LITE))
476 n += (sniper_ptr->concent * 3);
477 if (seen) r_ptr->r_flags3 |= (RF3_HURT_LITE);
479 if (mult < n) mult = n;
483 if (mult < 50) mult = 50;
492 * @brief スナイパー技能の発動 /
493 * do_cmd_cast calls this function if the player's class is 'snipe'.
494 * @param spell 発動する特殊技能のID
495 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
497 static bool cast_sniper_spell(player_type *sniper_ptr, int spell)
499 object_type *o_ptr = &sniper_ptr->inventory_list[INVEN_BOW];
500 SPELL_IDX snipe_type = SP_NONE;
502 if (o_ptr->tval != TV_BOW)
504 msg_print(_("弓を装備していない!", "You wield no bow!"));
511 case 0: /* Concentration */
512 if (!snipe_concentrate(sniper_ptr)) return FALSE;
513 take_turn(sniper_ptr, 100);
515 case 1: snipe_type = SP_LITE; break;
516 case 2: snipe_type = SP_AWAY; break;
517 case 3: snipe_type = SP_KILL_TRAP; break;
518 case 4: snipe_type = SP_FIRE; break;
519 case 5: snipe_type = SP_KILL_WALL; break;
520 case 6: snipe_type = SP_COLD; break;
521 case 7: snipe_type = SP_RUSH; break;
522 case 8: snipe_type = SP_PIERCE; break;
523 case 9: snipe_type = SP_EVILNESS; break;
524 case 10: snipe_type = SP_HOLYNESS; break;
525 case 11: snipe_type = SP_EXPLODE; break;
526 case 12: snipe_type = SP_DOUBLE; break;
527 case 13: snipe_type = SP_ELEC; break;
528 case 14: snipe_type = SP_NEEDLE; break;
529 case 15: snipe_type = SP_FINAL; break;
531 msg_print(_("なに?", "Zap?"));
535 do_cmd_fire(sniper_ptr, snipe_type);
537 return (sniper_ptr->is_fired);
541 * @brief スナイパー技能コマンドのメインルーチン /
544 void do_cmd_snipe(player_type *sniper_ptr)
549 if(cmd_limit_confused(sniper_ptr)) return;
550 if(cmd_limit_image(sniper_ptr)) return;
551 if(cmd_limit_stun(sniper_ptr)) return;
553 if (!get_snipe_power(sniper_ptr, &n, FALSE)) return;
556 cast = cast_sniper_spell(sniper_ptr, n);
559 sniper_ptr->redraw |= (PR_HP | PR_MANA);
560 sniper_ptr->window |= (PW_PLAYER);
561 sniper_ptr->window |= (PW_SPELL);
565 * @brief スナイパー技能コマンドの表示 /
568 void do_cmd_snipe_browse(player_type *sniper_ptr)
578 if (!get_snipe_power(sniper_ptr, &n, TRUE))
584 /* Clear lines, position cursor (really should use strlen here) */
585 term_erase(12, 22, 255);
586 term_erase(12, 21, 255);
587 term_erase(12, 20, 255);
588 term_erase(12, 19, 255);
589 term_erase(12, 18, 255);
591 shape_buffer(snipe_tips[n], 62, temp, sizeof(temp));
592 for(j = 0, line = 19; temp[j]; j += (1 + strlen(&temp[j])))
594 prt(&temp[j], line, 15);