OSDN Git Service

Merge branch 'master' of git.osdn.net:/gitroot/hengband/hengband
[hengband/hengband.git] / src / cmd-action / cmd-shoot.c
1 #include "cmd-action/cmd-shoot.h"
2 #include "combat/shoot.h"
3 #include "floor/floor-object.h"
4 #include "inventory/inventory-slot-types.h"
5 #include "mind/snipe-types.h"
6 #include "object/item-use-flags.h"
7 #include "player/attack-defense-types.h"
8 #include "player/special-defense-types.h"
9 #include "spell-kind/spells-teleport.h"
10 #include "status/action-setter.h"
11 #include "status/bad-status-setter.h"
12 #include "sv-definition/sv-bow-types.h"
13 #include "system/object-type-definition.h"
14 #include "term/screen-processor.h"
15 #include "view/display-messages.h"
16
17 /*
18  * todo Doxygenの加筆求む
19  * @brief 射撃処理のメインルーチン
20  * @param creature_ptr プレーヤーへの参照ポインタ
21  * @param snipe_type ???
22  * @return なし
23  */
24 void do_cmd_fire(player_type *creature_ptr, SPELL_IDX snipe_type)
25 {
26     OBJECT_IDX item;
27     object_type *j_ptr, *ammo_ptr;
28     if (creature_ptr->wild_mode)
29         return;
30
31     creature_ptr->is_fired = FALSE;
32     j_ptr = &creature_ptr->inventory_list[INVEN_BOW];
33     if (!j_ptr->tval) {
34         msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
35         flush();
36         return;
37     }
38
39     if (j_ptr->sval == SV_CRIMSON) {
40         msg_print(_("この武器は発動して使うもののようだ。", "It's already activated."));
41         flush();
42         return;
43     }
44
45     if (j_ptr->sval == SV_HARP) {
46         msg_print(_("この武器で射撃はできない。", "It's not for firing."));
47         flush();
48         return;
49     }
50
51     if (creature_ptr->special_defense & KATA_MUSOU)
52         set_action(creature_ptr, ACTION_NONE);
53
54     concptr q = _("どれを撃ちますか? ", "Fire which item? ");
55     concptr s = _("発射されるアイテムがありません。", "You have nothing to fire.");
56     ammo_ptr = choose_object(creature_ptr, &item, q, s, USE_INVEN | USE_FLOOR, creature_ptr->tval_ammo);
57     if (!ammo_ptr) {
58         flush();
59         return;
60     }
61
62     exe_fire(creature_ptr, item, j_ptr, snipe_type);
63     if (!creature_ptr->is_fired || creature_ptr->pclass != CLASS_SNIPER)
64         return;
65
66     if (snipe_type == SP_AWAY)
67         teleport_player(creature_ptr, 10 + (creature_ptr->concent * 2), TELEPORT_SPONTANEOUS);
68
69     if (snipe_type == SP_FINAL) {
70         msg_print(_("射撃の反動が体を襲った。", "The weapon's recoil stuns you. "));
71         (void)set_slow(creature_ptr, creature_ptr->slow + randint0(7) + 7, FALSE);
72         (void)set_stun(creature_ptr, creature_ptr->stun + randint1(25));
73     }
74 }