3 * @brief スナイパー技能の実装 / Sniping
6 * 2014 Deskull rearranged comment for Doxygen.\n
12 #include "player-status.h"
13 #include "cmd-basic.h"
16 #define MAX_SNIPE_POWERS 16
18 /*! スナイパー技能情報のtypedef */
19 typedef struct snipe_power snipe_power;
29 /*! スナイパー技能の解説メッセージ */
30 static concptr const snipe_tips[MAX_SNIPE_POWERS] =
33 "精神を集中する。射撃の威力、精度が上がり、高度な射撃術が使用できるようになる。",
34 "光る矢を放つ。光に弱いモンスターに威力を発揮する。",
35 "射撃を行った後、短距離の瞬間移動を行う。",
36 "軌道上の罠をすべて無効にする低空飛行の矢を放つ。",
38 "壁を粉砕する矢を放つ。岩でできたモンスターと無生物のモンスターに威力を発揮する。",
42 "善良なモンスターに威力を発揮する矢を放つ。",
43 "邪悪なモンスターに威力を発揮する矢を放つ。",
47 "敵の急所にめがけて矢を放つ。成功すると敵を一撃死させる。失敗すると1ダメージ。",
48 "全てのモンスターに高威力を発揮する矢を放つ。反動による副次効果を受ける。",
50 "Concentrate your mind fot shooting.",
51 "Shot an allow with brightness.",
52 "Blink after shooting.",
53 "Shot an allow able to shatter traps.",
54 "Deals extra damege of fire.",
55 "Shot an allow able to shatter rocks.",
56 "Deals extra damege of ice.",
57 "An allow rushes away a target.",
58 "An allow pierces some monsters.",
59 "Deals more damage to good monsters.",
60 "Deals more damage to evil monsters.",
61 "An allow explodes when it hits a monster.",
63 "Deals extra damege of lightning.",
64 "Deals quick death or 1 damage.",
65 "Deals great damage to all monsters, and some side effects to you.",
70 static snipe_power const snipe_powers[MAX_SNIPE_POWERS] =
72 /* Level gained, cost, name */
76 { 3, 1, "シュート&アウェイ" },
88 { 40, 3, "ニードルショット" },
89 { 48, 7, "セイントスターアロー" },
91 { 1, 0, "Concentration" },
92 { 2, 1, "Flush Arrow" },
93 { 3, 1, "Shoot & Away" },
94 { 5, 1, "Disarm Shot" },
95 { 8, 2, "Fire Shot" },
96 { 10, 2, "Shatter Arrow" },
97 { 13, 2, "Ice Shot" },
98 { 18, 2, "Rushing Arrow"},
99 { 22, 3, "Piercing Shot" },
100 { 25, 4, "Evil Shot"},
101 { 26, 4, "Holy Shot" },
103 { 32, 4, "Double Shot" },
104 { 36, 3, "Plasma Bolt" },
105 { 40, 3, "Needle Shot" },
106 { 48, 7, "Saint Stars Arrow" },
114 static bool snipe_concentrate(void)
116 if ((int)p_ptr->concent < (2 + (p_ptr->lev + 5) / 10)) p_ptr->concent++;
118 msg_format(_("集中した。(集中度 %d)", "You concentrate deeply. (lvl %d)"), p_ptr->concent);
119 reset_concent = FALSE;
121 p_ptr->update |= (PU_BONUS | PU_MONSTERS);
122 p_ptr->redraw |= (PR_STATUS);
127 * @brief スナイパーの集中度リセット
128 * @param msg TRUEならばメッセージを表示する
131 void reset_concentration(bool msg)
135 msg_print(_("集中力が途切れてしまった。", "Stop concentrating."));
139 reset_concent = FALSE;
141 p_ptr->update |= (PU_BONUS | PU_MONSTERS);
142 p_ptr->redraw |= (PR_STATUS);
146 * @brief スナイパーの集中度によるダメージボーナスを加算する
147 * @param tdam 算出中のダメージ
148 * @return 集中度修正を加えたダメージ
150 int boost_concentration_damage(int tdam)
152 tdam *= (10 + p_ptr->concent);
159 * @brief スナイパーの技能リストを表示する
162 void display_snipe_list(void)
167 PLAYER_LEVEL plev = p_ptr->lev;
171 /* Display a list of spells */
173 put_str(_("名前", "Name"), y, x + 5);
174 put_str(_("Lv MP", "Lv Mana"), y, x + 35);
176 for (i = 0; i < MAX_SNIPE_POWERS; i++)
178 /* Access the available spell */
179 spell = snipe_powers[i];
180 if (spell.min_lev > plev) continue;
181 if (spell.mana_cost > (int)p_ptr->concent) continue;
183 sprintf(psi_desc, " %c) %-30s%2d %4d",
184 I2A(i), spell.name, spell.min_lev, spell.mana_cost);
186 Term_putstr(x, y + i + 1, -1, TERM_WHITE, psi_desc);
193 * @brief スナイパー技能を選択する
194 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
195 * @param only_browse 一覧を見るだけの場合TRUEを返す
196 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
197 * Allow user to choose a mindcrafter power.\n
199 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
200 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
201 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
203 * The "prompt" should be "cast", "recite", or "study"\n
204 * The "known" should be TRUE for cast/pray, FALSE for study\n
206 * nb: This function has a (trivial) display bug which will be obvious\n
207 * when you run it. It's probably easy to fix but I haven't tried,\n
210 static int get_snipe_power(COMMAND_CODE *sn, bool only_browse)
216 PLAYER_LEVEL plev = p_ptr->lev;
220 concptr p = _("射撃術", "power");
226 /* Assume cancelled */
229 /* Repeat previous command */
230 /* Get the spell, if available */
233 /* Verify the spell */
234 if ((snipe_powers[*sn].min_lev <= plev) && (snipe_powers[*sn].mana_cost <= (int)p_ptr->concent))
241 /* Nothing chosen yet */
247 for (i = 0; i < MAX_SNIPE_POWERS; i++)
249 if ((snipe_powers[i].min_lev <= plev) &&
250 ((only_browse) || (snipe_powers[i].mana_cost <= (int)p_ptr->concent)))
256 /* Build a prompt (accept all spells) */
259 (void)strnfmt(out_val, 78,
260 _("(%^s %c-%c, '*'で一覧, ESC) どの%sについて知りますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
261 p, I2A(0), I2A(num), p);
265 (void)strnfmt(out_val, 78,
266 _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
267 p, I2A(0), I2A(num), p);
270 choice = always_show_list ? ESCAPE : 1;
273 if(choice == ESCAPE) choice = ' ';
274 else if( !get_com(out_val, &choice, FALSE) )break;
277 if ((choice == ' ') || (choice == '*') || (choice == '?'))
284 if (!only_browse) screen_save();
286 /* Display a list of spells */
288 put_str(_("名前", "Name"), y, x + 5);
289 if (only_browse) put_str(_("Lv 集中度", "Lv Pow"), y, x + 35);
291 /* Dump the spells */
292 for (i = 0; i < MAX_SNIPE_POWERS; i++)
294 Term_erase(x, y + i + 1, 255);
296 /* Access the spell */
297 spell = snipe_powers[i];
298 if (spell.min_lev > plev) continue;
299 if (!only_browse && (spell.mana_cost > (int)p_ptr->concent)) continue;
301 /* Dump the spell --(-- */
303 sprintf(psi_desc, " %c) %-30s%2d %4d",
304 I2A(i), spell.name, spell.min_lev, spell.mana_cost);
306 sprintf(psi_desc, " %c) %-30s", I2A(i), spell.name);
307 prt(psi_desc, y + i + 1, x);
310 /* Clear the bottom line */
311 prt("", y + i + 1, x);
319 if (!only_browse) screen_load();
327 ask = isupper(choice);
330 if (ask) choice = (char)tolower(choice);
332 /* Extract request */
333 i = (islower(choice) ? A2I(choice) : -1);
335 /* Totally Illegal */
336 if ((i < 0) || (i > num) ||
337 (!only_browse &&(snipe_powers[i].mana_cost > (int)p_ptr->concent)))
343 /* Save the spell index */
344 spell = snipe_powers[i];
352 (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), snipe_powers[i].name);
354 /* Belay that order */
355 if (!get_check(tmp_val)) continue;
361 if (redraw && !only_browse) screen_load();
363 p_ptr->window |= (PW_SPELL);
366 /* Abort if needed */
367 if (!flag) return (FALSE);
369 /* Save the choice */
379 * @brief スナイバー技能のスレイ倍率計算を行う /
380 * Calcurate magnification of snipe technics
381 * @param mult スナイバー技能のスレイ効果以前に算出している多要素の倍率(/10倍)
382 * @param m_ptr 目標となるモンスターの構造体参照ポインタ
383 * @return スレイの倍率(/10倍)
385 MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_type)
387 monster_race *r_ptr = &r_info[m_ptr->r_idx];
388 bool seen = is_seen(m_ptr);
393 if (r_ptr->flags3 & (RF3_HURT_LITE))
395 MULTIPLY n = 20 + p_ptr->concent;
396 if (seen) r_ptr->r_flags3 |= (RF3_HURT_LITE);
397 if (mult < n) mult = n;
401 if (r_ptr->flagsr & RFR_IM_FIRE)
403 if (seen) r_ptr->r_flagsr |= RFR_IM_FIRE;
407 MULTIPLY n = 15 + (p_ptr->concent * 3);
408 if (mult < n) mult = n;
412 if (r_ptr->flagsr & RFR_IM_COLD)
414 if (seen) r_ptr->r_flagsr |= RFR_IM_COLD;
418 MULTIPLY n = 15 + (p_ptr->concent * 3);
419 if (mult < n) mult = n;
423 if (r_ptr->flagsr & RFR_IM_ELEC)
425 if (seen) r_ptr->r_flagsr |= RFR_IM_ELEC;
429 MULTIPLY n = 18 + (p_ptr->concent * 4);
430 if (mult < n) mult = n;
434 if (r_ptr->flags3 & RF3_HURT_ROCK)
436 MULTIPLY n = 15 + (p_ptr->concent * 2);
437 if (seen) r_ptr->r_flags3 |= RF3_HURT_ROCK;
438 if (mult < n) mult = n;
440 else if (r_ptr->flags3 & RF3_NONLIVING)
442 MULTIPLY n = 15 + (p_ptr->concent * 2);
443 if (seen) r_ptr->r_flags3 |= RF3_NONLIVING;
444 if (mult < n) mult = n;
448 if (r_ptr->flags3 & RF3_GOOD)
450 MULTIPLY n = 15 + (p_ptr->concent * 4);
451 if (seen) r_ptr->r_flags3 |= RF3_GOOD;
452 if (mult < n) mult = n;
456 if (r_ptr->flags3 & RF3_EVIL)
458 MULTIPLY n = 12 + (p_ptr->concent * 3);
459 if (seen) r_ptr->r_flags3 |= RF3_EVIL;
460 if (r_ptr->flags3 & (RF3_HURT_LITE))
462 n += (p_ptr->concent * 3);
463 if (seen) r_ptr->r_flags3 |= (RF3_HURT_LITE);
465 if (mult < n) mult = n;
469 if (mult < 50) mult = 50;
478 * @brief スナイパー技能の発動 /
479 * do_cmd_cast calls this function if the player's class is 'snipe'.
480 * @param spell 発動する特殊技能のID
481 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
483 static bool cast_sniper_spell(int spell)
485 object_type *o_ptr = &p_ptr->inventory_list[INVEN_BOW];
486 SPELL_IDX snipe_type = SP_NONE;
488 if (o_ptr->tval != TV_BOW)
490 msg_print(_("弓を装備していない!", "You wield no bow!"));
497 case 0: /* Concentration */
498 if (!snipe_concentrate()) return (FALSE);
499 take_turn(p_ptr, 100);
501 case 1: snipe_type = SP_LITE; break;
502 case 2: snipe_type = SP_AWAY; break;
503 case 3: snipe_type = SP_KILL_TRAP; break;
504 case 4: snipe_type = SP_FIRE; break;
505 case 5: snipe_type = SP_KILL_WALL; break;
506 case 6: snipe_type = SP_COLD; break;
507 case 7: snipe_type = SP_RUSH; break;
508 case 8: snipe_type = SP_PIERCE; break;
509 case 9: snipe_type = SP_EVILNESS; break;
510 case 10: snipe_type = SP_HOLYNESS; break;
511 case 11: snipe_type = SP_EXPLODE; break;
512 case 12: snipe_type = SP_DOUBLE; break;
513 case 13: snipe_type = SP_ELEC; break;
514 case 14: snipe_type = SP_NEEDLE; break;
515 case 15: snipe_type = SP_FINAL; break;
517 msg_print(_("なに?", "Zap?"));
521 do_cmd_fire(snipe_type);
527 * @brief スナイパー技能コマンドのメインルーチン /
530 void do_cmd_snipe(void)
535 if(cmd_limit_confused(p_ptr)) return;
536 if(cmd_limit_image(p_ptr)) return;
537 if(cmd_limit_stun(p_ptr)) return;
539 if (!get_snipe_power(&n, FALSE)) return;
542 cast = cast_sniper_spell(n);
545 p_ptr->redraw |= (PR_HP | PR_MANA);
546 p_ptr->window |= (PW_PLAYER);
547 p_ptr->window |= (PW_SPELL);
551 * @brief スナイパー技能コマンドの表示 /
554 void do_cmd_snipe_browse(void)
564 if (!get_snipe_power(&n, TRUE))
570 /* Clear lines, position cursor (really should use strlen here) */
571 Term_erase(12, 22, 255);
572 Term_erase(12, 21, 255);
573 Term_erase(12, 20, 255);
574 Term_erase(12, 19, 255);
575 Term_erase(12, 18, 255);
577 roff_to_buf(snipe_tips[n], 62, temp, sizeof(temp));
578 for(j = 0, line = 19; temp[j]; j += (1 + strlen(&temp[j])))
580 prt(&temp[j], line, 15);