3 * @brief スナイパー技能の実装 / Sniping
6 * 2014 Deskull rearranged comment for Doxygen.\n
14 #include "player-status.h"
15 #include "cmd-basic.h"
17 #include "monsterrace.h"
18 #include "view-mainwindow.h"
20 #define MAX_SNIPE_POWERS 16
23 typedef struct snipe_power
30 /*! スナイパー技能の解説メッセージ */
31 static concptr const snipe_tips[MAX_SNIPE_POWERS] =
34 "精神を集中する。射撃の威力、精度が上がり、高度な射撃術が使用できるようになる。",
35 "光る矢を放つ。光に弱いモンスターに威力を発揮する。",
36 "射撃を行った後、短距離の瞬間移動を行う。",
37 "軌道上の罠をすべて無効にする低空飛行の矢を放つ。",
39 "壁を粉砕する矢を放つ。岩でできたモンスターと無生物のモンスターに威力を発揮する。",
43 "善良なモンスターに威力を発揮する矢を放つ。",
44 "邪悪なモンスターに威力を発揮する矢を放つ。",
48 "敵の急所にめがけて矢を放つ。成功すると敵を一撃死させる。失敗すると1ダメージ。",
49 "全てのモンスターに高威力を発揮する矢を放つ。反動による副次効果を受ける。",
51 "Concentrate your mind fot shooting.",
52 "Shot an allow with brightness.",
53 "Blink after shooting.",
54 "Shot an allow able to shatter traps.",
55 "Deals extra damege of fire.",
56 "Shot an allow able to shatter rocks.",
57 "Deals extra damege of ice.",
58 "An allow rushes away a target.",
59 "An allow pierces some monsters.",
60 "Deals more damage to good monsters.",
61 "Deals more damage to evil monsters.",
62 "An allow explodes when it hits a monster.",
64 "Deals extra damege of lightning.",
65 "Deals quick death or 1 damage.",
66 "Deals great damage to all monsters, and some side effects to you.",
71 static snipe_power const snipe_powers[MAX_SNIPE_POWERS] =
73 /* Level gained, cost, name */
77 { 3, 1, "シュート&アウェイ" },
89 { 40, 3, "ニードルショット" },
90 { 48, 7, "セイントスターアロー" },
92 { 1, 0, "Concentration" },
93 { 2, 1, "Flush Arrow" },
94 { 3, 1, "Shoot & Away" },
95 { 5, 1, "Disarm Shot" },
96 { 8, 2, "Fire Shot" },
97 { 10, 2, "Shatter Arrow" },
98 { 13, 2, "Ice Shot" },
99 { 18, 2, "Rushing Arrow"},
100 { 22, 3, "Piercing Shot" },
101 { 25, 4, "Evil Shot"},
102 { 26, 4, "Holy Shot" },
104 { 32, 4, "Double Shot" },
105 { 36, 3, "Plasma Bolt" },
106 { 40, 3, "Needle Shot" },
107 { 48, 7, "Saint Stars Arrow" },
115 static bool snipe_concentrate(player_type *creature_ptr)
117 if ((int)creature_ptr->concent < (2 + (creature_ptr->lev + 5) / 10)) creature_ptr->concent++;
119 msg_format(_("集中した。(集中度 %d)", "You concentrate deeply. (lvl %d)"), creature_ptr->concent);
120 creature_ptr->reset_concent = FALSE;
122 creature_ptr->update |= (PU_BONUS | PU_MONSTERS);
123 creature_ptr->redraw |= (PR_STATUS);
128 * @brief スナイパーの集中度リセット
129 * @param msg TRUEならばメッセージを表示する
132 void reset_concentration(player_type *creature_ptr, bool msg)
136 msg_print(_("集中力が途切れてしまった。", "Stop concentrating."));
139 creature_ptr->concent = 0;
140 creature_ptr->reset_concent = FALSE;
142 creature_ptr->update |= (PU_BONUS | PU_MONSTERS);
143 creature_ptr->redraw |= (PR_STATUS);
147 * @brief スナイパーの集中度によるダメージボーナスを加算する
148 * @param tdam 算出中のダメージ
149 * @return 集中度修正を加えたダメージ
151 int boost_concentration_damage(player_type *creature_ptr, int tdam)
153 tdam *= (10 + creature_ptr->concent);
160 * @brief スナイパーの技能リストを表示する
163 void display_snipe_list(player_type *sniper_ptr)
168 PLAYER_LEVEL plev = sniper_ptr->lev;
172 /* Display a list of spells */
174 put_str(_("名前", "Name"), y, x + 5);
175 put_str(_("Lv MP", "Lv Mana"), y, x + 35);
177 for (i = 0; i < MAX_SNIPE_POWERS; i++)
179 /* Access the available spell */
180 spell = snipe_powers[i];
181 if (spell.min_lev > plev) continue;
182 if (spell.mana_cost > (int)sniper_ptr->concent) continue;
184 sprintf(psi_desc, " %c) %-30s%2d %4d",
185 I2A(i), spell.name, spell.min_lev, spell.mana_cost);
187 Term_putstr(x, y + i + 1, -1, TERM_WHITE, psi_desc);
194 * @brief スナイパー技能を選択する
195 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
196 * @param only_browse 一覧を見るだけの場合TRUEを返す
197 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
198 * Allow user to choose a mindcrafter power.\n
200 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
201 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
202 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
204 * The "prompt" should be "cast", "recite", or "study"\n
205 * The "known" should be TRUE for cast/pray, FALSE for study\n
207 * nb: This function has a (trivial) display bug which will be obvious\n
208 * when you run it. It's probably easy to fix but I haven't tried,\n
211 static int get_snipe_power(player_type *sniper_ptr, COMMAND_CODE *sn, bool only_browse)
217 PLAYER_LEVEL plev = sniper_ptr->lev;
221 concptr p = _("射撃術", "power");
227 /* Assume cancelled */
230 /* Repeat previous command */
231 /* Get the spell, if available */
234 /* Verify the spell */
235 if ((snipe_powers[*sn].min_lev <= plev) && (snipe_powers[*sn].mana_cost <= (int)sniper_ptr->concent))
245 for (i = 0; i < MAX_SNIPE_POWERS; i++)
247 if ((snipe_powers[i].min_lev <= plev) &&
248 ((only_browse) || (snipe_powers[i].mana_cost <= (int)sniper_ptr->concent)))
254 /* Build a prompt (accept all spells) */
257 (void)strnfmt(out_val, 78,
258 _("(%^s %c-%c, '*'で一覧, ESC) どの%sについて知りますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
259 p, I2A(0), I2A(num), p);
263 (void)strnfmt(out_val, 78,
264 _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
265 p, I2A(0), I2A(num), p);
268 choice = always_show_list ? ESCAPE : 1;
271 if(choice == ESCAPE) choice = ' ';
272 else if( !get_com(out_val, &choice, FALSE) )break;
275 if ((choice == ' ') || (choice == '*') || (choice == '?'))
282 if (!only_browse) screen_save();
284 /* Display a list of spells */
286 put_str(_("名前", "Name"), y, x + 5);
287 if (only_browse) put_str(_("Lv 集中度", "Lv Pow"), y, x + 35);
289 /* Dump the spells */
290 for (i = 0; i < MAX_SNIPE_POWERS; i++)
292 Term_erase(x, y + i + 1, 255);
294 /* Access the spell */
295 spell = snipe_powers[i];
296 if (spell.min_lev > plev) continue;
297 if (!only_browse && (spell.mana_cost > (int)sniper_ptr->concent)) continue;
299 /* Dump the spell --(-- */
301 sprintf(psi_desc, " %c) %-30s%2d %4d",
302 I2A(i), spell.name, spell.min_lev, spell.mana_cost);
304 sprintf(psi_desc, " %c) %-30s", I2A(i), spell.name);
305 prt(psi_desc, y + i + 1, x);
308 /* Clear the bottom line */
309 prt("", y + i + 1, x);
317 if (!only_browse) screen_load();
325 ask = isupper(choice);
328 if (ask) choice = (char)tolower(choice);
330 /* Extract request */
331 i = (islower(choice) ? A2I(choice) : -1);
333 /* Totally Illegal */
334 if ((i < 0) || (i > num) ||
335 (!only_browse &&(snipe_powers[i].mana_cost > (int)sniper_ptr->concent)))
341 /* Save the spell index */
342 spell = snipe_powers[i];
350 (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), snipe_powers[i].name);
352 /* Belay that order */
353 if (!get_check(tmp_val)) continue;
359 if (redraw && !only_browse) screen_load();
361 sniper_ptr->window |= (PW_SPELL);
362 handle_stuff(sniper_ptr);
364 /* Abort if needed */
365 if (!flag) return FALSE;
367 /* Save the choice */
378 * @brief スナイバー技能のスレイ倍率計算を行う /
379 * Calcurate magnification of snipe technics
380 * @param mult スナイバー技能のスレイ効果以前に算出している多要素の倍率(/10倍)
381 * @param m_ptr 目標となるモンスターの構造体参照ポインタ
382 * @return スレイの倍率(/10倍)
384 MULTIPLY tot_dam_aux_snipe(player_type *sniper_ptr, MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_type)
386 monster_race *r_ptr = &r_info[m_ptr->r_idx];
387 bool seen = is_seen(m_ptr);
392 if (r_ptr->flags3 & (RF3_HURT_LITE))
394 MULTIPLY n = 20 + sniper_ptr->concent;
395 if (seen) r_ptr->r_flags3 |= (RF3_HURT_LITE);
396 if (mult < n) mult = n;
400 if (r_ptr->flagsr & RFR_IM_FIRE)
402 if (seen) r_ptr->r_flagsr |= RFR_IM_FIRE;
406 MULTIPLY n = 15 + (sniper_ptr->concent * 3);
407 if (mult < n) mult = n;
411 if (r_ptr->flagsr & RFR_IM_COLD)
413 if (seen) r_ptr->r_flagsr |= RFR_IM_COLD;
417 MULTIPLY n = 15 + (sniper_ptr->concent * 3);
418 if (mult < n) mult = n;
422 if (r_ptr->flagsr & RFR_IM_ELEC)
424 if (seen) r_ptr->r_flagsr |= RFR_IM_ELEC;
428 MULTIPLY n = 18 + (sniper_ptr->concent * 4);
429 if (mult < n) mult = n;
433 if (r_ptr->flags3 & RF3_HURT_ROCK)
435 MULTIPLY n = 15 + (sniper_ptr->concent * 2);
436 if (seen) r_ptr->r_flags3 |= RF3_HURT_ROCK;
437 if (mult < n) mult = n;
439 else if (r_ptr->flags3 & RF3_NONLIVING)
441 MULTIPLY n = 15 + (sniper_ptr->concent * 2);
442 if (seen) r_ptr->r_flags3 |= RF3_NONLIVING;
443 if (mult < n) mult = n;
447 if (r_ptr->flags3 & RF3_GOOD)
449 MULTIPLY n = 15 + (sniper_ptr->concent * 4);
450 if (seen) r_ptr->r_flags3 |= RF3_GOOD;
451 if (mult < n) mult = n;
455 if (r_ptr->flags3 & RF3_EVIL)
457 MULTIPLY n = 12 + (sniper_ptr->concent * 3);
458 if (seen) r_ptr->r_flags3 |= RF3_EVIL;
459 if (r_ptr->flags3 & (RF3_HURT_LITE))
461 n += (sniper_ptr->concent * 3);
462 if (seen) r_ptr->r_flags3 |= (RF3_HURT_LITE);
464 if (mult < n) mult = n;
468 if (mult < 50) mult = 50;
477 * @brief スナイパー技能の発動 /
478 * do_cmd_cast calls this function if the player's class is 'snipe'.
479 * @param spell 発動する特殊技能のID
480 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
482 static bool cast_sniper_spell(player_type *sniper_ptr, int spell)
484 object_type *o_ptr = &sniper_ptr->inventory_list[INVEN_BOW];
485 SPELL_IDX snipe_type = SP_NONE;
487 if (o_ptr->tval != TV_BOW)
489 msg_print(_("弓を装備していない!", "You wield no bow!"));
496 case 0: /* Concentration */
497 if (!snipe_concentrate(sniper_ptr)) return FALSE;
498 take_turn(sniper_ptr, 100);
500 case 1: snipe_type = SP_LITE; break;
501 case 2: snipe_type = SP_AWAY; break;
502 case 3: snipe_type = SP_KILL_TRAP; break;
503 case 4: snipe_type = SP_FIRE; break;
504 case 5: snipe_type = SP_KILL_WALL; break;
505 case 6: snipe_type = SP_COLD; break;
506 case 7: snipe_type = SP_RUSH; break;
507 case 8: snipe_type = SP_PIERCE; break;
508 case 9: snipe_type = SP_EVILNESS; break;
509 case 10: snipe_type = SP_HOLYNESS; break;
510 case 11: snipe_type = SP_EXPLODE; break;
511 case 12: snipe_type = SP_DOUBLE; break;
512 case 13: snipe_type = SP_ELEC; break;
513 case 14: snipe_type = SP_NEEDLE; break;
514 case 15: snipe_type = SP_FINAL; break;
516 msg_print(_("なに?", "Zap?"));
520 do_cmd_fire(sniper_ptr, snipe_type);
522 return (sniper_ptr->is_fired);
526 * @brief スナイパー技能コマンドのメインルーチン /
529 void do_cmd_snipe(player_type *sniper_ptr)
534 if(cmd_limit_confused(sniper_ptr)) return;
535 if(cmd_limit_image(sniper_ptr)) return;
536 if(cmd_limit_stun(sniper_ptr)) return;
538 if (!get_snipe_power(sniper_ptr, &n, FALSE)) return;
541 cast = cast_sniper_spell(sniper_ptr, n);
544 sniper_ptr->redraw |= (PR_HP | PR_MANA);
545 sniper_ptr->window |= (PW_PLAYER);
546 sniper_ptr->window |= (PW_SPELL);
550 * @brief スナイパー技能コマンドの表示 /
553 void do_cmd_snipe_browse(player_type *sniper_ptr)
563 if (!get_snipe_power(sniper_ptr, &n, TRUE))
569 /* Clear lines, position cursor (really should use strlen here) */
570 Term_erase(12, 22, 255);
571 Term_erase(12, 21, 255);
572 Term_erase(12, 20, 255);
573 Term_erase(12, 19, 255);
574 Term_erase(12, 18, 255);
576 roff_to_buf(snipe_tips[n], 62, temp, sizeof(temp));
577 for(j = 0, line = 19; temp[j]; j += (1 + strlen(&temp[j])))
579 prt(&temp[j], line, 15);